babylon.module.d.ts 5.6 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /**
  41. * Type modifier to make object properties readonly.
  42. */
  43. export type DeepImmutableObject<T> = {
  44. readonly [K in keyof T]: DeepImmutable<T[K]>;
  45. };
  46. /** @hidden */
  47. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  48. }
  49. }
  50. declare module "babylonjs/Misc/observable" {
  51. import { Nullable } from "babylonjs/types";
  52. /**
  53. * A class serves as a medium between the observable and its observers
  54. */
  55. export class EventState {
  56. /**
  57. * Create a new EventState
  58. * @param mask defines the mask associated with this state
  59. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  60. * @param target defines the original target of the state
  61. * @param currentTarget defines the current target of the state
  62. */
  63. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  64. /**
  65. * Initialize the current event state
  66. * @param mask defines the mask associated with this state
  67. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  68. * @param target defines the original target of the state
  69. * @param currentTarget defines the current target of the state
  70. * @returns the current event state
  71. */
  72. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  73. /**
  74. * An Observer can set this property to true to prevent subsequent observers of being notified
  75. */
  76. skipNextObservers: boolean;
  77. /**
  78. * Get the mask value that were used to trigger the event corresponding to this EventState object
  79. */
  80. mask: number;
  81. /**
  82. * The object that originally notified the event
  83. */
  84. target?: any;
  85. /**
  86. * The current object in the bubbling phase
  87. */
  88. currentTarget?: any;
  89. /**
  90. * This will be populated with the return value of the last function that was executed.
  91. * If it is the first function in the callback chain it will be the event data.
  92. */
  93. lastReturnValue?: any;
  94. }
  95. /**
  96. * Represent an Observer registered to a given Observable object.
  97. */
  98. export class Observer<T> {
  99. /**
  100. * Defines the callback to call when the observer is notified
  101. */
  102. callback: (eventData: T, eventState: EventState) => void;
  103. /**
  104. * Defines the mask of the observer (used to filter notifications)
  105. */
  106. mask: number;
  107. /**
  108. * Defines the current scope used to restore the JS context
  109. */
  110. scope: any;
  111. /** @hidden */
  112. _willBeUnregistered: boolean;
  113. /**
  114. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  115. */
  116. unregisterOnNextCall: boolean;
  117. /**
  118. * Creates a new observer
  119. * @param callback defines the callback to call when the observer is notified
  120. * @param mask defines the mask of the observer (used to filter notifications)
  121. * @param scope defines the current scope used to restore the JS context
  122. */
  123. constructor(
  124. /**
  125. * Defines the callback to call when the observer is notified
  126. */
  127. callback: (eventData: T, eventState: EventState) => void,
  128. /**
  129. * Defines the mask of the observer (used to filter notifications)
  130. */
  131. mask: number,
  132. /**
  133. * Defines the current scope used to restore the JS context
  134. */
  135. scope?: any);
  136. }
  137. /**
  138. * Represent a list of observers registered to multiple Observables object.
  139. */
  140. export class MultiObserver<T> {
  141. private _observers;
  142. private _observables;
  143. /**
  144. * Release associated resources
  145. */
  146. dispose(): void;
  147. /**
  148. * Raise a callback when one of the observable will notify
  149. * @param observables defines a list of observables to watch
  150. * @param callback defines the callback to call on notification
  151. * @param mask defines the mask used to filter notifications
  152. * @param scope defines the current scope used to restore the JS context
  153. * @returns the new MultiObserver
  154. */
  155. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  156. }
  157. /**
  158. * The Observable class is a simple implementation of the Observable pattern.
  159. *
  160. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  161. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  162. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  163. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  164. */
  165. export class Observable<T> {
  166. private _observers;
  167. private _eventState;
  168. private _onObserverAdded;
  169. /**
  170. * Gets the list of observers
  171. */
  172. readonly observers: Array<Observer<T>>;
  173. /**
  174. * Creates a new observable
  175. * @param onObserverAdded defines a callback to call when a new observer is added
  176. */
  177. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  178. /**
  179. * Create a new Observer with the specified callback
  180. * @param callback the callback that will be executed for that Observer
  181. * @param mask the mask used to filter observers
  182. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  183. * @param scope optional scope for the callback to be called from
  184. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  185. * @returns the new observer created for the callback
  186. */
  187. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  188. /**
  189. * Create a new Observer with the specified callback and unregisters after the next notification
  190. * @param callback the callback that will be executed for that Observer
  191. * @returns the new observer created for the callback
  192. */
  193. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  194. /**
  195. * Remove an Observer from the Observable object
  196. * @param observer the instance of the Observer to remove
  197. * @returns false if it doesn't belong to this Observable
  198. */
  199. remove(observer: Nullable<Observer<T>>): boolean;
  200. /**
  201. * Remove a callback from the Observable object
  202. * @param callback the callback to remove
  203. * @param scope optional scope. If used only the callbacks with this scope will be removed
  204. * @returns false if it doesn't belong to this Observable
  205. */
  206. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  207. private _deferUnregister;
  208. private _remove;
  209. /**
  210. * Moves the observable to the top of the observer list making it get called first when notified
  211. * @param observer the observer to move
  212. */
  213. makeObserverTopPriority(observer: Observer<T>): void;
  214. /**
  215. * Moves the observable to the bottom of the observer list making it get called last when notified
  216. * @param observer the observer to move
  217. */
  218. makeObserverBottomPriority(observer: Observer<T>): void;
  219. /**
  220. * Notify all Observers by calling their respective callback with the given data
  221. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  222. * @param eventData defines the data to send to all observers
  223. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  224. * @param target defines the original target of the state
  225. * @param currentTarget defines the current target of the state
  226. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  227. */
  228. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  229. /**
  230. * Calling this will execute each callback, expecting it to be a promise or return a value.
  231. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  232. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  233. * and it is crucial that all callbacks will be executed.
  234. * The order of the callbacks is kept, callbacks are not executed parallel.
  235. *
  236. * @param eventData The data to be sent to each callback
  237. * @param mask is used to filter observers defaults to -1
  238. * @param target defines the callback target (see EventState)
  239. * @param currentTarget defines he current object in the bubbling phase
  240. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  241. */
  242. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  243. /**
  244. * Notify a specific observer
  245. * @param observer defines the observer to notify
  246. * @param eventData defines the data to be sent to each callback
  247. * @param mask is used to filter observers defaults to -1
  248. */
  249. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  250. /**
  251. * Gets a boolean indicating if the observable has at least one observer
  252. * @returns true is the Observable has at least one Observer registered
  253. */
  254. hasObservers(): boolean;
  255. /**
  256. * Clear the list of observers
  257. */
  258. clear(): void;
  259. /**
  260. * Clone the current observable
  261. * @returns a new observable
  262. */
  263. clone(): Observable<T>;
  264. /**
  265. * Does this observable handles observer registered with a given mask
  266. * @param mask defines the mask to be tested
  267. * @return whether or not one observer registered with the given mask is handeled
  268. **/
  269. hasSpecificMask(mask?: number): boolean;
  270. }
  271. }
  272. declare module "babylonjs/Misc/domManagement" {
  273. /**
  274. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  275. * Babylon.js
  276. */
  277. export class DomManagement {
  278. /**
  279. * Checks if the window object exists
  280. * @returns true if the window object exists
  281. */
  282. static IsWindowObjectExist(): boolean;
  283. /**
  284. * Checks if the navigator object exists
  285. * @returns true if the navigator object exists
  286. */
  287. static IsNavigatorAvailable(): boolean;
  288. /**
  289. * Extracts text content from a DOM element hierarchy
  290. * @param element defines the root element
  291. * @returns a string
  292. */
  293. static GetDOMTextContent(element: HTMLElement): string;
  294. }
  295. }
  296. declare module "babylonjs/Misc/logger" {
  297. /**
  298. * Logger used througouht the application to allow configuration of
  299. * the log level required for the messages.
  300. */
  301. export class Logger {
  302. /**
  303. * No log
  304. */
  305. static readonly NoneLogLevel: number;
  306. /**
  307. * Only message logs
  308. */
  309. static readonly MessageLogLevel: number;
  310. /**
  311. * Only warning logs
  312. */
  313. static readonly WarningLogLevel: number;
  314. /**
  315. * Only error logs
  316. */
  317. static readonly ErrorLogLevel: number;
  318. /**
  319. * All logs
  320. */
  321. static readonly AllLogLevel: number;
  322. private static _LogCache;
  323. /**
  324. * Gets a value indicating the number of loading errors
  325. * @ignorenaming
  326. */
  327. static errorsCount: number;
  328. /**
  329. * Callback called when a new log is added
  330. */
  331. static OnNewCacheEntry: (entry: string) => void;
  332. private static _AddLogEntry;
  333. private static _FormatMessage;
  334. private static _LogDisabled;
  335. private static _LogEnabled;
  336. private static _WarnDisabled;
  337. private static _WarnEnabled;
  338. private static _ErrorDisabled;
  339. private static _ErrorEnabled;
  340. /**
  341. * Log a message to the console
  342. */
  343. static Log: (message: string) => void;
  344. /**
  345. * Write a warning message to the console
  346. */
  347. static Warn: (message: string) => void;
  348. /**
  349. * Write an error message to the console
  350. */
  351. static Error: (message: string) => void;
  352. /**
  353. * Gets current log cache (list of logs)
  354. */
  355. static readonly LogCache: string;
  356. /**
  357. * Clears the log cache
  358. */
  359. static ClearLogCache(): void;
  360. /**
  361. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  362. */
  363. static LogLevels: number;
  364. }
  365. }
  366. declare module "babylonjs/Misc/typeStore" {
  367. /** @hidden */
  368. export class _TypeStore {
  369. /** @hidden */
  370. static RegisteredTypes: {
  371. [key: string]: Object;
  372. };
  373. /** @hidden */
  374. static GetClass(fqdn: string): any;
  375. }
  376. }
  377. declare module "babylonjs/Misc/deepCopier" {
  378. /**
  379. * Class containing a set of static utilities functions for deep copy.
  380. */
  381. export class DeepCopier {
  382. /**
  383. * Tries to copy an object by duplicating every property
  384. * @param source defines the source object
  385. * @param destination defines the target object
  386. * @param doNotCopyList defines a list of properties to avoid
  387. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  388. */
  389. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  390. }
  391. }
  392. declare module "babylonjs/Misc/precisionDate" {
  393. /**
  394. * Class containing a set of static utilities functions for precision date
  395. */
  396. export class PrecisionDate {
  397. /**
  398. * Gets either window.performance.now() if supported or Date.now() else
  399. */
  400. static readonly Now: number;
  401. }
  402. }
  403. declare module "babylonjs/Misc/devTools" {
  404. /** @hidden */
  405. export class _DevTools {
  406. static WarnImport(name: string): string;
  407. }
  408. }
  409. declare module "babylonjs/Misc/interfaces/iWebRequest" {
  410. /**
  411. * Interface used to define the mechanism to get data from the network
  412. */
  413. export interface IWebRequest {
  414. /**
  415. * Returns client's response url
  416. */
  417. responseURL: string;
  418. /**
  419. * Returns client's status
  420. */
  421. status: number;
  422. /**
  423. * Returns client's status as a text
  424. */
  425. statusText: string;
  426. }
  427. }
  428. declare module "babylonjs/Misc/webRequest" {
  429. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  430. /**
  431. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  432. */
  433. export class WebRequest implements IWebRequest {
  434. private _xhr;
  435. /**
  436. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  437. * i.e. when loading files, where the server/service expects an Authorization header
  438. */
  439. static CustomRequestHeaders: {
  440. [key: string]: string;
  441. };
  442. /**
  443. * Add callback functions in this array to update all the requests before they get sent to the network
  444. */
  445. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  446. private _injectCustomRequestHeaders;
  447. /**
  448. * Gets or sets a function to be called when loading progress changes
  449. */
  450. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  451. /**
  452. * Returns client's state
  453. */
  454. readonly readyState: number;
  455. /**
  456. * Returns client's status
  457. */
  458. readonly status: number;
  459. /**
  460. * Returns client's status as a text
  461. */
  462. readonly statusText: string;
  463. /**
  464. * Returns client's response
  465. */
  466. readonly response: any;
  467. /**
  468. * Returns client's response url
  469. */
  470. readonly responseURL: string;
  471. /**
  472. * Returns client's response as text
  473. */
  474. readonly responseText: string;
  475. /**
  476. * Gets or sets the expected response type
  477. */
  478. responseType: XMLHttpRequestResponseType;
  479. /** @hidden */
  480. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  481. /** @hidden */
  482. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  483. /**
  484. * Cancels any network activity
  485. */
  486. abort(): void;
  487. /**
  488. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  489. * @param body defines an optional request body
  490. */
  491. send(body?: Document | BodyInit | null): void;
  492. /**
  493. * Sets the request method, request URL
  494. * @param method defines the method to use (GET, POST, etc..)
  495. * @param url defines the url to connect with
  496. */
  497. open(method: string, url: string): void;
  498. }
  499. }
  500. declare module "babylonjs/Misc/fileRequest" {
  501. import { Observable } from "babylonjs/Misc/observable";
  502. /**
  503. * File request interface
  504. */
  505. export interface IFileRequest {
  506. /**
  507. * Raised when the request is complete (success or error).
  508. */
  509. onCompleteObservable: Observable<IFileRequest>;
  510. /**
  511. * Aborts the request for a file.
  512. */
  513. abort: () => void;
  514. }
  515. }
  516. declare module "babylonjs/Maths/math.scalar" {
  517. /**
  518. * Scalar computation library
  519. */
  520. export class Scalar {
  521. /**
  522. * Two pi constants convenient for computation.
  523. */
  524. static TwoPi: number;
  525. /**
  526. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  527. * @param a number
  528. * @param b number
  529. * @param epsilon (default = 1.401298E-45)
  530. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  531. */
  532. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  533. /**
  534. * Returns a string : the upper case translation of the number i to hexadecimal.
  535. * @param i number
  536. * @returns the upper case translation of the number i to hexadecimal.
  537. */
  538. static ToHex(i: number): string;
  539. /**
  540. * Returns -1 if value is negative and +1 is value is positive.
  541. * @param value the value
  542. * @returns the value itself if it's equal to zero.
  543. */
  544. static Sign(value: number): number;
  545. /**
  546. * Returns the value itself if it's between min and max.
  547. * Returns min if the value is lower than min.
  548. * Returns max if the value is greater than max.
  549. * @param value the value to clmap
  550. * @param min the min value to clamp to (default: 0)
  551. * @param max the max value to clamp to (default: 1)
  552. * @returns the clamped value
  553. */
  554. static Clamp(value: number, min?: number, max?: number): number;
  555. /**
  556. * the log2 of value.
  557. * @param value the value to compute log2 of
  558. * @returns the log2 of value.
  559. */
  560. static Log2(value: number): number;
  561. /**
  562. * Loops the value, so that it is never larger than length and never smaller than 0.
  563. *
  564. * This is similar to the modulo operator but it works with floating point numbers.
  565. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  566. * With t = 5 and length = 2.5, the result would be 0.0.
  567. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  568. * @param value the value
  569. * @param length the length
  570. * @returns the looped value
  571. */
  572. static Repeat(value: number, length: number): number;
  573. /**
  574. * Normalize the value between 0.0 and 1.0 using min and max values
  575. * @param value value to normalize
  576. * @param min max to normalize between
  577. * @param max min to normalize between
  578. * @returns the normalized value
  579. */
  580. static Normalize(value: number, min: number, max: number): number;
  581. /**
  582. * Denormalize the value from 0.0 and 1.0 using min and max values
  583. * @param normalized value to denormalize
  584. * @param min max to denormalize between
  585. * @param max min to denormalize between
  586. * @returns the denormalized value
  587. */
  588. static Denormalize(normalized: number, min: number, max: number): number;
  589. /**
  590. * Calculates the shortest difference between two given angles given in degrees.
  591. * @param current current angle in degrees
  592. * @param target target angle in degrees
  593. * @returns the delta
  594. */
  595. static DeltaAngle(current: number, target: number): number;
  596. /**
  597. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  598. * @param tx value
  599. * @param length length
  600. * @returns The returned value will move back and forth between 0 and length
  601. */
  602. static PingPong(tx: number, length: number): number;
  603. /**
  604. * Interpolates between min and max with smoothing at the limits.
  605. *
  606. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  607. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  608. * @param from from
  609. * @param to to
  610. * @param tx value
  611. * @returns the smooth stepped value
  612. */
  613. static SmoothStep(from: number, to: number, tx: number): number;
  614. /**
  615. * Moves a value current towards target.
  616. *
  617. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  618. * Negative values of maxDelta pushes the value away from target.
  619. * @param current current value
  620. * @param target target value
  621. * @param maxDelta max distance to move
  622. * @returns resulting value
  623. */
  624. static MoveTowards(current: number, target: number, maxDelta: number): number;
  625. /**
  626. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  627. *
  628. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  629. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  630. * @param current current value
  631. * @param target target value
  632. * @param maxDelta max distance to move
  633. * @returns resulting angle
  634. */
  635. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  636. /**
  637. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  638. * @param start start value
  639. * @param end target value
  640. * @param amount amount to lerp between
  641. * @returns the lerped value
  642. */
  643. static Lerp(start: number, end: number, amount: number): number;
  644. /**
  645. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  646. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  647. * @param start start value
  648. * @param end target value
  649. * @param amount amount to lerp between
  650. * @returns the lerped value
  651. */
  652. static LerpAngle(start: number, end: number, amount: number): number;
  653. /**
  654. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  655. * @param a start value
  656. * @param b target value
  657. * @param value value between a and b
  658. * @returns the inverseLerp value
  659. */
  660. static InverseLerp(a: number, b: number, value: number): number;
  661. /**
  662. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  663. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  664. * @param value1 spline value
  665. * @param tangent1 spline value
  666. * @param value2 spline value
  667. * @param tangent2 spline value
  668. * @param amount input value
  669. * @returns hermite result
  670. */
  671. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  672. /**
  673. * Returns a random float number between and min and max values
  674. * @param min min value of random
  675. * @param max max value of random
  676. * @returns random value
  677. */
  678. static RandomRange(min: number, max: number): number;
  679. /**
  680. * This function returns percentage of a number in a given range.
  681. *
  682. * RangeToPercent(40,20,60) will return 0.5 (50%)
  683. * RangeToPercent(34,0,100) will return 0.34 (34%)
  684. * @param number to convert to percentage
  685. * @param min min range
  686. * @param max max range
  687. * @returns the percentage
  688. */
  689. static RangeToPercent(number: number, min: number, max: number): number;
  690. /**
  691. * This function returns number that corresponds to the percentage in a given range.
  692. *
  693. * PercentToRange(0.34,0,100) will return 34.
  694. * @param percent to convert to number
  695. * @param min min range
  696. * @param max max range
  697. * @returns the number
  698. */
  699. static PercentToRange(percent: number, min: number, max: number): number;
  700. /**
  701. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  702. * @param angle The angle to normalize in radian.
  703. * @return The converted angle.
  704. */
  705. static NormalizeRadians(angle: number): number;
  706. }
  707. }
  708. declare module "babylonjs/Maths/math.constants" {
  709. /**
  710. * Constant used to convert a value to gamma space
  711. * @ignorenaming
  712. */
  713. export const ToGammaSpace: number;
  714. /**
  715. * Constant used to convert a value to linear space
  716. * @ignorenaming
  717. */
  718. export const ToLinearSpace = 2.2;
  719. /**
  720. * Constant used to define the minimal number value in Babylon.js
  721. * @ignorenaming
  722. */
  723. let Epsilon: number;
  724. export { Epsilon };
  725. }
  726. declare module "babylonjs/Maths/math.viewport" {
  727. /**
  728. * Class used to represent a viewport on screen
  729. */
  730. export class Viewport {
  731. /** viewport left coordinate */
  732. x: number;
  733. /** viewport top coordinate */
  734. y: number;
  735. /**viewport width */
  736. width: number;
  737. /** viewport height */
  738. height: number;
  739. /**
  740. * Creates a Viewport object located at (x, y) and sized (width, height)
  741. * @param x defines viewport left coordinate
  742. * @param y defines viewport top coordinate
  743. * @param width defines the viewport width
  744. * @param height defines the viewport height
  745. */
  746. constructor(
  747. /** viewport left coordinate */
  748. x: number,
  749. /** viewport top coordinate */
  750. y: number,
  751. /**viewport width */
  752. width: number,
  753. /** viewport height */
  754. height: number);
  755. /**
  756. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  757. * @param renderWidth defines the rendering width
  758. * @param renderHeight defines the rendering height
  759. * @returns a new Viewport
  760. */
  761. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  762. /**
  763. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  764. * @param renderWidth defines the rendering width
  765. * @param renderHeight defines the rendering height
  766. * @param ref defines the target viewport
  767. * @returns the current viewport
  768. */
  769. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  770. /**
  771. * Returns a new Viewport copied from the current one
  772. * @returns a new Viewport
  773. */
  774. clone(): Viewport;
  775. }
  776. }
  777. declare module "babylonjs/Misc/arrayTools" {
  778. /**
  779. * Class containing a set of static utilities functions for arrays.
  780. */
  781. export class ArrayTools {
  782. /**
  783. * Returns an array of the given size filled with element built from the given constructor and the paramters
  784. * @param size the number of element to construct and put in the array
  785. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  786. * @returns a new array filled with new objects
  787. */
  788. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  789. }
  790. }
  791. declare module "babylonjs/Maths/math.like" {
  792. import { float, int, DeepImmutable } from "babylonjs/types";
  793. /**
  794. * @hidden
  795. */
  796. export interface IColor4Like {
  797. r: float;
  798. g: float;
  799. b: float;
  800. a: float;
  801. }
  802. /**
  803. * @hidden
  804. */
  805. export interface IColor3Like {
  806. r: float;
  807. g: float;
  808. b: float;
  809. }
  810. /**
  811. * @hidden
  812. */
  813. export interface IVector4Like {
  814. x: float;
  815. y: float;
  816. z: float;
  817. w: float;
  818. }
  819. /**
  820. * @hidden
  821. */
  822. export interface IVector3Like {
  823. x: float;
  824. y: float;
  825. z: float;
  826. }
  827. /**
  828. * @hidden
  829. */
  830. export interface IVector2Like {
  831. x: float;
  832. y: float;
  833. }
  834. /**
  835. * @hidden
  836. */
  837. export interface IMatrixLike {
  838. toArray(): DeepImmutable<Float32Array>;
  839. updateFlag: int;
  840. }
  841. /**
  842. * @hidden
  843. */
  844. export interface IViewportLike {
  845. x: float;
  846. y: float;
  847. width: float;
  848. height: float;
  849. }
  850. /**
  851. * @hidden
  852. */
  853. export interface IPlaneLike {
  854. normal: IVector3Like;
  855. d: float;
  856. normalize(): void;
  857. }
  858. }
  859. declare module "babylonjs/Maths/math.vector" {
  860. import { Viewport } from "babylonjs/Maths/math.viewport";
  861. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  862. import { IPlaneLike } from "babylonjs/Maths/math.like";
  863. /**
  864. * Class representing a vector containing 2 coordinates
  865. */
  866. export class Vector2 {
  867. /** defines the first coordinate */
  868. x: number;
  869. /** defines the second coordinate */
  870. y: number;
  871. /**
  872. * Creates a new Vector2 from the given x and y coordinates
  873. * @param x defines the first coordinate
  874. * @param y defines the second coordinate
  875. */
  876. constructor(
  877. /** defines the first coordinate */
  878. x?: number,
  879. /** defines the second coordinate */
  880. y?: number);
  881. /**
  882. * Gets a string with the Vector2 coordinates
  883. * @returns a string with the Vector2 coordinates
  884. */
  885. toString(): string;
  886. /**
  887. * Gets class name
  888. * @returns the string "Vector2"
  889. */
  890. getClassName(): string;
  891. /**
  892. * Gets current vector hash code
  893. * @returns the Vector2 hash code as a number
  894. */
  895. getHashCode(): number;
  896. /**
  897. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  898. * @param array defines the source array
  899. * @param index defines the offset in source array
  900. * @returns the current Vector2
  901. */
  902. toArray(array: FloatArray, index?: number): Vector2;
  903. /**
  904. * Copy the current vector to an array
  905. * @returns a new array with 2 elements: the Vector2 coordinates.
  906. */
  907. asArray(): number[];
  908. /**
  909. * Sets the Vector2 coordinates with the given Vector2 coordinates
  910. * @param source defines the source Vector2
  911. * @returns the current updated Vector2
  912. */
  913. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  914. /**
  915. * Sets the Vector2 coordinates with the given floats
  916. * @param x defines the first coordinate
  917. * @param y defines the second coordinate
  918. * @returns the current updated Vector2
  919. */
  920. copyFromFloats(x: number, y: number): Vector2;
  921. /**
  922. * Sets the Vector2 coordinates with the given floats
  923. * @param x defines the first coordinate
  924. * @param y defines the second coordinate
  925. * @returns the current updated Vector2
  926. */
  927. set(x: number, y: number): Vector2;
  928. /**
  929. * Add another vector with the current one
  930. * @param otherVector defines the other vector
  931. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  932. */
  933. add(otherVector: DeepImmutable<Vector2>): Vector2;
  934. /**
  935. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  936. * @param otherVector defines the other vector
  937. * @param result defines the target vector
  938. * @returns the unmodified current Vector2
  939. */
  940. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  941. /**
  942. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. addVector3(otherVector: Vector3): Vector2;
  953. /**
  954. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  955. * @param otherVector defines the other vector
  956. * @returns a new Vector2
  957. */
  958. subtract(otherVector: Vector2): Vector2;
  959. /**
  960. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  961. * @param otherVector defines the other vector
  962. * @param result defines the target vector
  963. * @returns the unmodified current Vector2
  964. */
  965. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  966. /**
  967. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  968. * @param otherVector defines the other vector
  969. * @returns the current updated Vector2
  970. */
  971. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  972. /**
  973. * Multiplies in place the current Vector2 coordinates by the given ones
  974. * @param otherVector defines the other vector
  975. * @returns the current updated Vector2
  976. */
  977. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  978. /**
  979. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  980. * @param otherVector defines the other vector
  981. * @returns a new Vector2
  982. */
  983. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  984. /**
  985. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  986. * @param otherVector defines the other vector
  987. * @param result defines the target vector
  988. * @returns the unmodified current Vector2
  989. */
  990. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  991. /**
  992. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  993. * @param x defines the first coordinate
  994. * @param y defines the second coordinate
  995. * @returns a new Vector2
  996. */
  997. multiplyByFloats(x: number, y: number): Vector2;
  998. /**
  999. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  1000. * @param otherVector defines the other vector
  1001. * @returns a new Vector2
  1002. */
  1003. divide(otherVector: Vector2): Vector2;
  1004. /**
  1005. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  1006. * @param otherVector defines the other vector
  1007. * @param result defines the target vector
  1008. * @returns the unmodified current Vector2
  1009. */
  1010. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  1011. /**
  1012. * Divides the current Vector2 coordinates by the given ones
  1013. * @param otherVector defines the other vector
  1014. * @returns the current updated Vector2
  1015. */
  1016. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  1017. /**
  1018. * Gets a new Vector2 with current Vector2 negated coordinates
  1019. * @returns a new Vector2
  1020. */
  1021. negate(): Vector2;
  1022. /**
  1023. * Multiply the Vector2 coordinates by scale
  1024. * @param scale defines the scaling factor
  1025. * @returns the current updated Vector2
  1026. */
  1027. scaleInPlace(scale: number): Vector2;
  1028. /**
  1029. * Returns a new Vector2 scaled by "scale" from the current Vector2
  1030. * @param scale defines the scaling factor
  1031. * @returns a new Vector2
  1032. */
  1033. scale(scale: number): Vector2;
  1034. /**
  1035. * Scale the current Vector2 values by a factor to a given Vector2
  1036. * @param scale defines the scale factor
  1037. * @param result defines the Vector2 object where to store the result
  1038. * @returns the unmodified current Vector2
  1039. */
  1040. scaleToRef(scale: number, result: Vector2): Vector2;
  1041. /**
  1042. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1043. * @param scale defines the scale factor
  1044. * @param result defines the Vector2 object where to store the result
  1045. * @returns the unmodified current Vector2
  1046. */
  1047. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1048. /**
  1049. * Gets a boolean if two vectors are equals
  1050. * @param otherVector defines the other vector
  1051. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1052. */
  1053. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1054. /**
  1055. * Gets a boolean if two vectors are equals (using an epsilon value)
  1056. * @param otherVector defines the other vector
  1057. * @param epsilon defines the minimal distance to consider equality
  1058. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1059. */
  1060. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1061. /**
  1062. * Gets a new Vector2 from current Vector2 floored values
  1063. * @returns a new Vector2
  1064. */
  1065. floor(): Vector2;
  1066. /**
  1067. * Gets a new Vector2 from current Vector2 floored values
  1068. * @returns a new Vector2
  1069. */
  1070. fract(): Vector2;
  1071. /**
  1072. * Gets the length of the vector
  1073. * @returns the vector length (float)
  1074. */
  1075. length(): number;
  1076. /**
  1077. * Gets the vector squared length
  1078. * @returns the vector squared length (float)
  1079. */
  1080. lengthSquared(): number;
  1081. /**
  1082. * Normalize the vector
  1083. * @returns the current updated Vector2
  1084. */
  1085. normalize(): Vector2;
  1086. /**
  1087. * Gets a new Vector2 copied from the Vector2
  1088. * @returns a new Vector2
  1089. */
  1090. clone(): Vector2;
  1091. /**
  1092. * Gets a new Vector2(0, 0)
  1093. * @returns a new Vector2
  1094. */
  1095. static Zero(): Vector2;
  1096. /**
  1097. * Gets a new Vector2(1, 1)
  1098. * @returns a new Vector2
  1099. */
  1100. static One(): Vector2;
  1101. /**
  1102. * Gets a new Vector2 set from the given index element of the given array
  1103. * @param array defines the data source
  1104. * @param offset defines the offset in the data source
  1105. * @returns a new Vector2
  1106. */
  1107. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1108. /**
  1109. * Sets "result" from the given index element of the given array
  1110. * @param array defines the data source
  1111. * @param offset defines the offset in the data source
  1112. * @param result defines the target vector
  1113. */
  1114. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1115. /**
  1116. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1117. * @param value1 defines 1st point of control
  1118. * @param value2 defines 2nd point of control
  1119. * @param value3 defines 3rd point of control
  1120. * @param value4 defines 4th point of control
  1121. * @param amount defines the interpolation factor
  1122. * @returns a new Vector2
  1123. */
  1124. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1125. /**
  1126. * 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".
  1127. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1128. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1129. * @param value defines the value to clamp
  1130. * @param min defines the lower limit
  1131. * @param max defines the upper limit
  1132. * @returns a new Vector2
  1133. */
  1134. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1137. * @param value1 defines the 1st control point
  1138. * @param tangent1 defines the outgoing tangent
  1139. * @param value2 defines the 2nd control point
  1140. * @param tangent2 defines the incoming tangent
  1141. * @param amount defines the interpolation factor
  1142. * @returns a new Vector2
  1143. */
  1144. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1145. /**
  1146. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1147. * @param start defines the start vector
  1148. * @param end defines the end vector
  1149. * @param amount defines the interpolation factor
  1150. * @returns a new Vector2
  1151. */
  1152. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1153. /**
  1154. * Gets the dot product of the vector "left" and the vector "right"
  1155. * @param left defines first vector
  1156. * @param right defines second vector
  1157. * @returns the dot product (float)
  1158. */
  1159. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1160. /**
  1161. * Returns a new Vector2 equal to the normalized given vector
  1162. * @param vector defines the vector to normalize
  1163. * @returns a new Vector2
  1164. */
  1165. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1166. /**
  1167. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1168. * @param left defines 1st vector
  1169. * @param right defines 2nd vector
  1170. * @returns a new Vector2
  1171. */
  1172. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1173. /**
  1174. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1175. * @param left defines 1st vector
  1176. * @param right defines 2nd vector
  1177. * @returns a new Vector2
  1178. */
  1179. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1180. /**
  1181. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1182. * @param vector defines the vector to transform
  1183. * @param transformation defines the matrix to apply
  1184. * @returns a new Vector2
  1185. */
  1186. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1187. /**
  1188. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1189. * @param vector defines the vector to transform
  1190. * @param transformation defines the matrix to apply
  1191. * @param result defines the target vector
  1192. */
  1193. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1194. /**
  1195. * Determines if a given vector is included in a triangle
  1196. * @param p defines the vector to test
  1197. * @param p0 defines 1st triangle point
  1198. * @param p1 defines 2nd triangle point
  1199. * @param p2 defines 3rd triangle point
  1200. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1201. */
  1202. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1203. /**
  1204. * Gets the distance between the vectors "value1" and "value2"
  1205. * @param value1 defines first vector
  1206. * @param value2 defines second vector
  1207. * @returns the distance between vectors
  1208. */
  1209. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1210. /**
  1211. * Returns the squared distance between the vectors "value1" and "value2"
  1212. * @param value1 defines first vector
  1213. * @param value2 defines second vector
  1214. * @returns the squared distance between vectors
  1215. */
  1216. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1217. /**
  1218. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1219. * @param value1 defines first vector
  1220. * @param value2 defines second vector
  1221. * @returns a new Vector2
  1222. */
  1223. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1224. /**
  1225. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1226. * @param p defines the middle point
  1227. * @param segA defines one point of the segment
  1228. * @param segB defines the other point of the segment
  1229. * @returns the shortest distance
  1230. */
  1231. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1232. }
  1233. /**
  1234. * Classed used to store (x,y,z) vector representation
  1235. * A Vector3 is the main object used in 3D geometry
  1236. * It can represent etiher the coordinates of a point the space, either a direction
  1237. * Reminder: js uses a left handed forward facing system
  1238. */
  1239. export class Vector3 {
  1240. /**
  1241. * Defines the first coordinates (on X axis)
  1242. */
  1243. x: number;
  1244. /**
  1245. * Defines the second coordinates (on Y axis)
  1246. */
  1247. y: number;
  1248. /**
  1249. * Defines the third coordinates (on Z axis)
  1250. */
  1251. z: number;
  1252. private static _UpReadOnly;
  1253. private static _ZeroReadOnly;
  1254. /**
  1255. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1256. * @param x defines the first coordinates (on X axis)
  1257. * @param y defines the second coordinates (on Y axis)
  1258. * @param z defines the third coordinates (on Z axis)
  1259. */
  1260. constructor(
  1261. /**
  1262. * Defines the first coordinates (on X axis)
  1263. */
  1264. x?: number,
  1265. /**
  1266. * Defines the second coordinates (on Y axis)
  1267. */
  1268. y?: number,
  1269. /**
  1270. * Defines the third coordinates (on Z axis)
  1271. */
  1272. z?: number);
  1273. /**
  1274. * Creates a string representation of the Vector3
  1275. * @returns a string with the Vector3 coordinates.
  1276. */
  1277. toString(): string;
  1278. /**
  1279. * Gets the class name
  1280. * @returns the string "Vector3"
  1281. */
  1282. getClassName(): string;
  1283. /**
  1284. * Creates the Vector3 hash code
  1285. * @returns a number which tends to be unique between Vector3 instances
  1286. */
  1287. getHashCode(): number;
  1288. /**
  1289. * Creates an array containing three elements : the coordinates of the Vector3
  1290. * @returns a new array of numbers
  1291. */
  1292. asArray(): number[];
  1293. /**
  1294. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1295. * @param array defines the destination array
  1296. * @param index defines the offset in the destination array
  1297. * @returns the current Vector3
  1298. */
  1299. toArray(array: FloatArray, index?: number): Vector3;
  1300. /**
  1301. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1302. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1303. */
  1304. toQuaternion(): Quaternion;
  1305. /**
  1306. * Adds the given vector to the current Vector3
  1307. * @param otherVector defines the second operand
  1308. * @returns the current updated Vector3
  1309. */
  1310. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1311. /**
  1312. * Adds the given coordinates to the current Vector3
  1313. * @param x defines the x coordinate of the operand
  1314. * @param y defines the y coordinate of the operand
  1315. * @param z defines the z coordinate of the operand
  1316. * @returns the current updated Vector3
  1317. */
  1318. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1319. /**
  1320. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1321. * @param otherVector defines the second operand
  1322. * @returns the resulting Vector3
  1323. */
  1324. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1325. /**
  1326. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1327. * @param otherVector defines the second operand
  1328. * @param result defines the Vector3 object where to store the result
  1329. * @returns the current Vector3
  1330. */
  1331. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1332. /**
  1333. * Subtract the given vector from the current Vector3
  1334. * @param otherVector defines the second operand
  1335. * @returns the current updated Vector3
  1336. */
  1337. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1338. /**
  1339. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1340. * @param otherVector defines the second operand
  1341. * @returns the resulting Vector3
  1342. */
  1343. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1344. /**
  1345. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1346. * @param otherVector defines the second operand
  1347. * @param result defines the Vector3 object where to store the result
  1348. * @returns the current Vector3
  1349. */
  1350. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1351. /**
  1352. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1353. * @param x defines the x coordinate of the operand
  1354. * @param y defines the y coordinate of the operand
  1355. * @param z defines the z coordinate of the operand
  1356. * @returns the resulting Vector3
  1357. */
  1358. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1359. /**
  1360. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1361. * @param x defines the x coordinate of the operand
  1362. * @param y defines the y coordinate of the operand
  1363. * @param z defines the z coordinate of the operand
  1364. * @param result defines the Vector3 object where to store the result
  1365. * @returns the current Vector3
  1366. */
  1367. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1368. /**
  1369. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1370. * @returns a new Vector3
  1371. */
  1372. negate(): Vector3;
  1373. /**
  1374. * Multiplies the Vector3 coordinates by the float "scale"
  1375. * @param scale defines the multiplier factor
  1376. * @returns the current updated Vector3
  1377. */
  1378. scaleInPlace(scale: number): Vector3;
  1379. /**
  1380. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1381. * @param scale defines the multiplier factor
  1382. * @returns a new Vector3
  1383. */
  1384. scale(scale: number): Vector3;
  1385. /**
  1386. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1387. * @param scale defines the multiplier factor
  1388. * @param result defines the Vector3 object where to store the result
  1389. * @returns the current Vector3
  1390. */
  1391. scaleToRef(scale: number, result: Vector3): Vector3;
  1392. /**
  1393. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1394. * @param scale defines the scale factor
  1395. * @param result defines the Vector3 object where to store the result
  1396. * @returns the unmodified current Vector3
  1397. */
  1398. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1399. /**
  1400. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1401. * @param otherVector defines the second operand
  1402. * @returns true if both vectors are equals
  1403. */
  1404. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1405. /**
  1406. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1407. * @param otherVector defines the second operand
  1408. * @param epsilon defines the minimal distance to define values as equals
  1409. * @returns true if both vectors are distant less than epsilon
  1410. */
  1411. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1412. /**
  1413. * Returns true if the current Vector3 coordinates equals the given floats
  1414. * @param x defines the x coordinate of the operand
  1415. * @param y defines the y coordinate of the operand
  1416. * @param z defines the z coordinate of the operand
  1417. * @returns true if both vectors are equals
  1418. */
  1419. equalsToFloats(x: number, y: number, z: number): boolean;
  1420. /**
  1421. * Multiplies the current Vector3 coordinates by the given ones
  1422. * @param otherVector defines the second operand
  1423. * @returns the current updated Vector3
  1424. */
  1425. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1426. /**
  1427. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1428. * @param otherVector defines the second operand
  1429. * @returns the new Vector3
  1430. */
  1431. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1432. /**
  1433. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1434. * @param otherVector defines the second operand
  1435. * @param result defines the Vector3 object where to store the result
  1436. * @returns the current Vector3
  1437. */
  1438. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1439. /**
  1440. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1441. * @param x defines the x coordinate of the operand
  1442. * @param y defines the y coordinate of the operand
  1443. * @param z defines the z coordinate of the operand
  1444. * @returns the new Vector3
  1445. */
  1446. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1447. /**
  1448. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1449. * @param otherVector defines the second operand
  1450. * @returns the new Vector3
  1451. */
  1452. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1453. /**
  1454. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1455. * @param otherVector defines the second operand
  1456. * @param result defines the Vector3 object where to store the result
  1457. * @returns the current Vector3
  1458. */
  1459. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1460. /**
  1461. * Divides the current Vector3 coordinates by the given ones.
  1462. * @param otherVector defines the second operand
  1463. * @returns the current updated Vector3
  1464. */
  1465. divideInPlace(otherVector: Vector3): Vector3;
  1466. /**
  1467. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1468. * @param other defines the second operand
  1469. * @returns the current updated Vector3
  1470. */
  1471. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1472. /**
  1473. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1474. * @param other defines the second operand
  1475. * @returns the current updated Vector3
  1476. */
  1477. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1478. /**
  1479. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1480. * @param x defines the x coordinate of the operand
  1481. * @param y defines the y coordinate of the operand
  1482. * @param z defines the z coordinate of the operand
  1483. * @returns the current updated Vector3
  1484. */
  1485. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1486. /**
  1487. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1488. * @param x defines the x coordinate of the operand
  1489. * @param y defines the y coordinate of the operand
  1490. * @param z defines the z coordinate of the operand
  1491. * @returns the current updated Vector3
  1492. */
  1493. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1494. /**
  1495. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1496. * Check if is non uniform within a certain amount of decimal places to account for this
  1497. * @param epsilon the amount the values can differ
  1498. * @returns if the the vector is non uniform to a certain number of decimal places
  1499. */
  1500. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1501. /**
  1502. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1503. */
  1504. readonly isNonUniform: boolean;
  1505. /**
  1506. * Gets a new Vector3 from current Vector3 floored values
  1507. * @returns a new Vector3
  1508. */
  1509. floor(): Vector3;
  1510. /**
  1511. * Gets a new Vector3 from current Vector3 floored values
  1512. * @returns a new Vector3
  1513. */
  1514. fract(): Vector3;
  1515. /**
  1516. * Gets the length of the Vector3
  1517. * @returns the length of the Vector3
  1518. */
  1519. length(): number;
  1520. /**
  1521. * Gets the squared length of the Vector3
  1522. * @returns squared length of the Vector3
  1523. */
  1524. lengthSquared(): number;
  1525. /**
  1526. * Normalize the current Vector3.
  1527. * Please note that this is an in place operation.
  1528. * @returns the current updated Vector3
  1529. */
  1530. normalize(): Vector3;
  1531. /**
  1532. * Reorders the x y z properties of the vector in place
  1533. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1534. * @returns the current updated vector
  1535. */
  1536. reorderInPlace(order: string): this;
  1537. /**
  1538. * Rotates the vector around 0,0,0 by a quaternion
  1539. * @param quaternion the rotation quaternion
  1540. * @param result vector to store the result
  1541. * @returns the resulting vector
  1542. */
  1543. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1544. /**
  1545. * Rotates a vector around a given point
  1546. * @param quaternion the rotation quaternion
  1547. * @param point the point to rotate around
  1548. * @param result vector to store the result
  1549. * @returns the resulting vector
  1550. */
  1551. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1552. /**
  1553. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  1554. * The cross product is then orthogonal to both current and "other"
  1555. * @param other defines the right operand
  1556. * @returns the cross product
  1557. */
  1558. cross(other: Vector3): Vector3;
  1559. /**
  1560. * Normalize the current Vector3 with the given input length.
  1561. * Please note that this is an in place operation.
  1562. * @param len the length of the vector
  1563. * @returns the current updated Vector3
  1564. */
  1565. normalizeFromLength(len: number): Vector3;
  1566. /**
  1567. * Normalize the current Vector3 to a new vector
  1568. * @returns the new Vector3
  1569. */
  1570. normalizeToNew(): Vector3;
  1571. /**
  1572. * Normalize the current Vector3 to the reference
  1573. * @param reference define the Vector3 to update
  1574. * @returns the updated Vector3
  1575. */
  1576. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1577. /**
  1578. * Creates a new Vector3 copied from the current Vector3
  1579. * @returns the new Vector3
  1580. */
  1581. clone(): Vector3;
  1582. /**
  1583. * Copies the given vector coordinates to the current Vector3 ones
  1584. * @param source defines the source Vector3
  1585. * @returns the current updated Vector3
  1586. */
  1587. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1588. /**
  1589. * Copies the given floats to the current Vector3 coordinates
  1590. * @param x defines the x coordinate of the operand
  1591. * @param y defines the y coordinate of the operand
  1592. * @param z defines the z coordinate of the operand
  1593. * @returns the current updated Vector3
  1594. */
  1595. copyFromFloats(x: number, y: number, z: number): Vector3;
  1596. /**
  1597. * Copies the given floats to the current Vector3 coordinates
  1598. * @param x defines the x coordinate of the operand
  1599. * @param y defines the y coordinate of the operand
  1600. * @param z defines the z coordinate of the operand
  1601. * @returns the current updated Vector3
  1602. */
  1603. set(x: number, y: number, z: number): Vector3;
  1604. /**
  1605. * Copies the given float to the current Vector3 coordinates
  1606. * @param v defines the x, y and z coordinates of the operand
  1607. * @returns the current updated Vector3
  1608. */
  1609. setAll(v: number): Vector3;
  1610. /**
  1611. * Get the clip factor between two vectors
  1612. * @param vector0 defines the first operand
  1613. * @param vector1 defines the second operand
  1614. * @param axis defines the axis to use
  1615. * @param size defines the size along the axis
  1616. * @returns the clip factor
  1617. */
  1618. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1619. /**
  1620. * Get angle between two vectors
  1621. * @param vector0 angle between vector0 and vector1
  1622. * @param vector1 angle between vector0 and vector1
  1623. * @param normal direction of the normal
  1624. * @return the angle between vector0 and vector1
  1625. */
  1626. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1627. /**
  1628. * Returns a new Vector3 set from the index "offset" of the given array
  1629. * @param array defines the source array
  1630. * @param offset defines the offset in the source array
  1631. * @returns the new Vector3
  1632. */
  1633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1634. /**
  1635. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1636. * This function is deprecated. Use FromArray instead
  1637. * @param array defines the source array
  1638. * @param offset defines the offset in the source array
  1639. * @returns the new Vector3
  1640. */
  1641. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1642. /**
  1643. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1644. * @param array defines the source array
  1645. * @param offset defines the offset in the source array
  1646. * @param result defines the Vector3 where to store the result
  1647. */
  1648. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1649. /**
  1650. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1651. * This function is deprecated. Use FromArrayToRef instead.
  1652. * @param array defines the source array
  1653. * @param offset defines the offset in the source array
  1654. * @param result defines the Vector3 where to store the result
  1655. */
  1656. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1657. /**
  1658. * Sets the given vector "result" with the given floats.
  1659. * @param x defines the x coordinate of the source
  1660. * @param y defines the y coordinate of the source
  1661. * @param z defines the z coordinate of the source
  1662. * @param result defines the Vector3 where to store the result
  1663. */
  1664. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1665. /**
  1666. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1667. * @returns a new empty Vector3
  1668. */
  1669. static Zero(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1672. * @returns a new unit Vector3
  1673. */
  1674. static One(): Vector3;
  1675. /**
  1676. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1677. * @returns a new up Vector3
  1678. */
  1679. static Up(): Vector3;
  1680. /**
  1681. * Gets a up Vector3 that must not be updated
  1682. */
  1683. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1684. /**
  1685. * Gets a zero Vector3 that must not be updated
  1686. */
  1687. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  1688. /**
  1689. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1690. * @returns a new down Vector3
  1691. */
  1692. static Down(): Vector3;
  1693. /**
  1694. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1695. * @returns a new forward Vector3
  1696. */
  1697. static Forward(): Vector3;
  1698. /**
  1699. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1700. * @returns a new forward Vector3
  1701. */
  1702. static Backward(): Vector3;
  1703. /**
  1704. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1705. * @returns a new right Vector3
  1706. */
  1707. static Right(): Vector3;
  1708. /**
  1709. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1710. * @returns a new left Vector3
  1711. */
  1712. static Left(): Vector3;
  1713. /**
  1714. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1715. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1716. * @param vector defines the Vector3 to transform
  1717. * @param transformation defines the transformation matrix
  1718. * @returns the transformed Vector3
  1719. */
  1720. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1721. /**
  1722. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1723. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1724. * @param vector defines the Vector3 to transform
  1725. * @param transformation defines the transformation matrix
  1726. * @param result defines the Vector3 where to store the result
  1727. */
  1728. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1729. /**
  1730. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1731. * This method computes tranformed coordinates only, not transformed direction vectors
  1732. * @param x define the x coordinate of the source vector
  1733. * @param y define the y coordinate of the source vector
  1734. * @param z define the z coordinate of the source vector
  1735. * @param transformation defines the transformation matrix
  1736. * @param result defines the Vector3 where to store the result
  1737. */
  1738. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1739. /**
  1740. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1741. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1742. * @param vector defines the Vector3 to transform
  1743. * @param transformation defines the transformation matrix
  1744. * @returns the new Vector3
  1745. */
  1746. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1747. /**
  1748. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1749. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1750. * @param vector defines the Vector3 to transform
  1751. * @param transformation defines the transformation matrix
  1752. * @param result defines the Vector3 where to store the result
  1753. */
  1754. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1755. /**
  1756. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1757. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1758. * @param x define the x coordinate of the source vector
  1759. * @param y define the y coordinate of the source vector
  1760. * @param z define the z coordinate of the source vector
  1761. * @param transformation defines the transformation matrix
  1762. * @param result defines the Vector3 where to store the result
  1763. */
  1764. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1765. /**
  1766. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1767. * @param value1 defines the first control point
  1768. * @param value2 defines the second control point
  1769. * @param value3 defines the third control point
  1770. * @param value4 defines the fourth control point
  1771. * @param amount defines the amount on the spline to use
  1772. * @returns the new Vector3
  1773. */
  1774. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1775. /**
  1776. * 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"
  1777. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1778. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1779. * @param value defines the current value
  1780. * @param min defines the lower range value
  1781. * @param max defines the upper range value
  1782. * @returns the new Vector3
  1783. */
  1784. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1785. /**
  1786. * 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"
  1787. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1788. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1789. * @param value defines the current value
  1790. * @param min defines the lower range value
  1791. * @param max defines the upper range value
  1792. * @param result defines the Vector3 where to store the result
  1793. */
  1794. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1795. /**
  1796. * Checks if a given vector is inside a specific range
  1797. * @param v defines the vector to test
  1798. * @param min defines the minimum range
  1799. * @param max defines the maximum range
  1800. */
  1801. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  1802. /**
  1803. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1804. * @param value1 defines the first control point
  1805. * @param tangent1 defines the first tangent vector
  1806. * @param value2 defines the second control point
  1807. * @param tangent2 defines the second tangent vector
  1808. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1809. * @returns the new Vector3
  1810. */
  1811. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1812. /**
  1813. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1814. * @param start defines the start value
  1815. * @param end defines the end value
  1816. * @param amount max defines amount between both (between 0 and 1)
  1817. * @returns the new Vector3
  1818. */
  1819. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1820. /**
  1821. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1822. * @param start defines the start value
  1823. * @param end defines the end value
  1824. * @param amount max defines amount between both (between 0 and 1)
  1825. * @param result defines the Vector3 where to store the result
  1826. */
  1827. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1828. /**
  1829. * Returns the dot product (float) between the vectors "left" and "right"
  1830. * @param left defines the left operand
  1831. * @param right defines the right operand
  1832. * @returns the dot product
  1833. */
  1834. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1835. /**
  1836. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1837. * The cross product is then orthogonal to both "left" and "right"
  1838. * @param left defines the left operand
  1839. * @param right defines the right operand
  1840. * @returns the cross product
  1841. */
  1842. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1843. /**
  1844. * Sets the given vector "result" with the cross product of "left" and "right"
  1845. * The cross product is then orthogonal to both "left" and "right"
  1846. * @param left defines the left operand
  1847. * @param right defines the right operand
  1848. * @param result defines the Vector3 where to store the result
  1849. */
  1850. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1851. /**
  1852. * Returns a new Vector3 as the normalization of the given vector
  1853. * @param vector defines the Vector3 to normalize
  1854. * @returns the new Vector3
  1855. */
  1856. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1857. /**
  1858. * Sets the given vector "result" with the normalization of the given first vector
  1859. * @param vector defines the Vector3 to normalize
  1860. * @param result defines the Vector3 where to store the result
  1861. */
  1862. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1863. /**
  1864. * Project a Vector3 onto screen space
  1865. * @param vector defines the Vector3 to project
  1866. * @param world defines the world matrix to use
  1867. * @param transform defines the transform (view x projection) matrix to use
  1868. * @param viewport defines the screen viewport to use
  1869. * @returns the new Vector3
  1870. */
  1871. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1872. /** @hidden */
  1873. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1874. /**
  1875. * Unproject from screen space to object space
  1876. * @param source defines the screen space Vector3 to use
  1877. * @param viewportWidth defines the current width of the viewport
  1878. * @param viewportHeight defines the current height of the viewport
  1879. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1880. * @param transform defines the transform (view x projection) matrix to use
  1881. * @returns the new Vector3
  1882. */
  1883. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1884. /**
  1885. * Unproject from screen space to object space
  1886. * @param source defines the screen space Vector3 to use
  1887. * @param viewportWidth defines the current width of the viewport
  1888. * @param viewportHeight defines the current height of the viewport
  1889. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1890. * @param view defines the view matrix to use
  1891. * @param projection defines the projection matrix to use
  1892. * @returns the new Vector3
  1893. */
  1894. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1895. /**
  1896. * Unproject from screen space to object space
  1897. * @param source defines the screen space Vector3 to use
  1898. * @param viewportWidth defines the current width of the viewport
  1899. * @param viewportHeight defines the current height of the viewport
  1900. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1901. * @param view defines the view matrix to use
  1902. * @param projection defines the projection matrix to use
  1903. * @param result defines the Vector3 where to store the result
  1904. */
  1905. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1906. /**
  1907. * Unproject from screen space to object space
  1908. * @param sourceX defines the screen space x coordinate to use
  1909. * @param sourceY defines the screen space y coordinate to use
  1910. * @param sourceZ defines the screen space z coordinate to use
  1911. * @param viewportWidth defines the current width of the viewport
  1912. * @param viewportHeight defines the current height of the viewport
  1913. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1914. * @param view defines the view matrix to use
  1915. * @param projection defines the projection matrix to use
  1916. * @param result defines the Vector3 where to store the result
  1917. */
  1918. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1919. /**
  1920. * Gets the minimal coordinate values between two Vector3
  1921. * @param left defines the first operand
  1922. * @param right defines the second operand
  1923. * @returns the new Vector3
  1924. */
  1925. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1926. /**
  1927. * Gets the maximal coordinate values between two Vector3
  1928. * @param left defines the first operand
  1929. * @param right defines the second operand
  1930. * @returns the new Vector3
  1931. */
  1932. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1933. /**
  1934. * Returns the distance between the vectors "value1" and "value2"
  1935. * @param value1 defines the first operand
  1936. * @param value2 defines the second operand
  1937. * @returns the distance
  1938. */
  1939. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1940. /**
  1941. * Returns the squared distance between the vectors "value1" and "value2"
  1942. * @param value1 defines the first operand
  1943. * @param value2 defines the second operand
  1944. * @returns the squared distance
  1945. */
  1946. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1947. /**
  1948. * Returns a new Vector3 located at the center between "value1" and "value2"
  1949. * @param value1 defines the first operand
  1950. * @param value2 defines the second operand
  1951. * @returns the new Vector3
  1952. */
  1953. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1954. /**
  1955. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1956. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1957. * to something in order to rotate it from its local system to the given target system
  1958. * Note: axis1, axis2 and axis3 are normalized during this operation
  1959. * @param axis1 defines the first axis
  1960. * @param axis2 defines the second axis
  1961. * @param axis3 defines the third axis
  1962. * @returns a new Vector3
  1963. */
  1964. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1965. /**
  1966. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1967. * @param axis1 defines the first axis
  1968. * @param axis2 defines the second axis
  1969. * @param axis3 defines the third axis
  1970. * @param ref defines the Vector3 where to store the result
  1971. */
  1972. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1973. }
  1974. /**
  1975. * Vector4 class created for EulerAngle class conversion to Quaternion
  1976. */
  1977. export class Vector4 {
  1978. /** x value of the vector */
  1979. x: number;
  1980. /** y value of the vector */
  1981. y: number;
  1982. /** z value of the vector */
  1983. z: number;
  1984. /** w value of the vector */
  1985. w: number;
  1986. /**
  1987. * Creates a Vector4 object from the given floats.
  1988. * @param x x value of the vector
  1989. * @param y y value of the vector
  1990. * @param z z value of the vector
  1991. * @param w w value of the vector
  1992. */
  1993. constructor(
  1994. /** x value of the vector */
  1995. x: number,
  1996. /** y value of the vector */
  1997. y: number,
  1998. /** z value of the vector */
  1999. z: number,
  2000. /** w value of the vector */
  2001. w: number);
  2002. /**
  2003. * Returns the string with the Vector4 coordinates.
  2004. * @returns a string containing all the vector values
  2005. */
  2006. toString(): string;
  2007. /**
  2008. * Returns the string "Vector4".
  2009. * @returns "Vector4"
  2010. */
  2011. getClassName(): string;
  2012. /**
  2013. * Returns the Vector4 hash code.
  2014. * @returns a unique hash code
  2015. */
  2016. getHashCode(): number;
  2017. /**
  2018. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  2019. * @returns the resulting array
  2020. */
  2021. asArray(): number[];
  2022. /**
  2023. * Populates the given array from the given index with the Vector4 coordinates.
  2024. * @param array array to populate
  2025. * @param index index of the array to start at (default: 0)
  2026. * @returns the Vector4.
  2027. */
  2028. toArray(array: FloatArray, index?: number): Vector4;
  2029. /**
  2030. * Adds the given vector to the current Vector4.
  2031. * @param otherVector the vector to add
  2032. * @returns the updated Vector4.
  2033. */
  2034. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2035. /**
  2036. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  2037. * @param otherVector the vector to add
  2038. * @returns the resulting vector
  2039. */
  2040. add(otherVector: DeepImmutable<Vector4>): Vector4;
  2041. /**
  2042. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  2043. * @param otherVector the vector to add
  2044. * @param result the vector to store the result
  2045. * @returns the current Vector4.
  2046. */
  2047. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2048. /**
  2049. * Subtract in place the given vector from the current Vector4.
  2050. * @param otherVector the vector to subtract
  2051. * @returns the updated Vector4.
  2052. */
  2053. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2054. /**
  2055. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2056. * @param otherVector the vector to add
  2057. * @returns the new vector with the result
  2058. */
  2059. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2060. /**
  2061. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2062. * @param otherVector the vector to subtract
  2063. * @param result the vector to store the result
  2064. * @returns the current Vector4.
  2065. */
  2066. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2067. /**
  2068. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2069. */
  2070. /**
  2071. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2072. * @param x value to subtract
  2073. * @param y value to subtract
  2074. * @param z value to subtract
  2075. * @param w value to subtract
  2076. * @returns new vector containing the result
  2077. */
  2078. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2079. /**
  2080. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2081. * @param x value to subtract
  2082. * @param y value to subtract
  2083. * @param z value to subtract
  2084. * @param w value to subtract
  2085. * @param result the vector to store the result in
  2086. * @returns the current Vector4.
  2087. */
  2088. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2089. /**
  2090. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2091. * @returns a new vector with the negated values
  2092. */
  2093. negate(): Vector4;
  2094. /**
  2095. * Multiplies the current Vector4 coordinates by scale (float).
  2096. * @param scale the number to scale with
  2097. * @returns the updated Vector4.
  2098. */
  2099. scaleInPlace(scale: number): Vector4;
  2100. /**
  2101. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2102. * @param scale the number to scale with
  2103. * @returns a new vector with the result
  2104. */
  2105. scale(scale: number): Vector4;
  2106. /**
  2107. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2108. * @param scale the number to scale with
  2109. * @param result a vector to store the result in
  2110. * @returns the current Vector4.
  2111. */
  2112. scaleToRef(scale: number, result: Vector4): Vector4;
  2113. /**
  2114. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2115. * @param scale defines the scale factor
  2116. * @param result defines the Vector4 object where to store the result
  2117. * @returns the unmodified current Vector4
  2118. */
  2119. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2120. /**
  2121. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2122. * @param otherVector the vector to compare against
  2123. * @returns true if they are equal
  2124. */
  2125. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2126. /**
  2127. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2128. * @param otherVector vector to compare against
  2129. * @param epsilon (Default: very small number)
  2130. * @returns true if they are equal
  2131. */
  2132. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2133. /**
  2134. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2135. * @param x x value to compare against
  2136. * @param y y value to compare against
  2137. * @param z z value to compare against
  2138. * @param w w value to compare against
  2139. * @returns true if equal
  2140. */
  2141. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2142. /**
  2143. * Multiplies in place the current Vector4 by the given one.
  2144. * @param otherVector vector to multiple with
  2145. * @returns the updated Vector4.
  2146. */
  2147. multiplyInPlace(otherVector: Vector4): Vector4;
  2148. /**
  2149. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2150. * @param otherVector vector to multiple with
  2151. * @returns resulting new vector
  2152. */
  2153. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2154. /**
  2155. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2156. * @param otherVector vector to multiple with
  2157. * @param result vector to store the result
  2158. * @returns the current Vector4.
  2159. */
  2160. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2161. /**
  2162. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2163. * @param x x value multiply with
  2164. * @param y y value multiply with
  2165. * @param z z value multiply with
  2166. * @param w w value multiply with
  2167. * @returns resulting new vector
  2168. */
  2169. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2170. /**
  2171. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2172. * @param otherVector vector to devide with
  2173. * @returns resulting new vector
  2174. */
  2175. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2176. /**
  2177. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2178. * @param otherVector vector to devide with
  2179. * @param result vector to store the result
  2180. * @returns the current Vector4.
  2181. */
  2182. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2183. /**
  2184. * Divides the current Vector3 coordinates by the given ones.
  2185. * @param otherVector vector to devide with
  2186. * @returns the updated Vector3.
  2187. */
  2188. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2189. /**
  2190. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2191. * @param other defines the second operand
  2192. * @returns the current updated Vector4
  2193. */
  2194. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2195. /**
  2196. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2197. * @param other defines the second operand
  2198. * @returns the current updated Vector4
  2199. */
  2200. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2201. /**
  2202. * Gets a new Vector4 from current Vector4 floored values
  2203. * @returns a new Vector4
  2204. */
  2205. floor(): Vector4;
  2206. /**
  2207. * Gets a new Vector4 from current Vector3 floored values
  2208. * @returns a new Vector4
  2209. */
  2210. fract(): Vector4;
  2211. /**
  2212. * Returns the Vector4 length (float).
  2213. * @returns the length
  2214. */
  2215. length(): number;
  2216. /**
  2217. * Returns the Vector4 squared length (float).
  2218. * @returns the length squared
  2219. */
  2220. lengthSquared(): number;
  2221. /**
  2222. * Normalizes in place the Vector4.
  2223. * @returns the updated Vector4.
  2224. */
  2225. normalize(): Vector4;
  2226. /**
  2227. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2228. * @returns this converted to a new vector3
  2229. */
  2230. toVector3(): Vector3;
  2231. /**
  2232. * Returns a new Vector4 copied from the current one.
  2233. * @returns the new cloned vector
  2234. */
  2235. clone(): Vector4;
  2236. /**
  2237. * Updates the current Vector4 with the given one coordinates.
  2238. * @param source the source vector to copy from
  2239. * @returns the updated Vector4.
  2240. */
  2241. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2242. /**
  2243. * Updates the current Vector4 coordinates with the given floats.
  2244. * @param x float to copy from
  2245. * @param y float to copy from
  2246. * @param z float to copy from
  2247. * @param w float to copy from
  2248. * @returns the updated Vector4.
  2249. */
  2250. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2251. /**
  2252. * Updates the current Vector4 coordinates with the given floats.
  2253. * @param x float to set from
  2254. * @param y float to set from
  2255. * @param z float to set from
  2256. * @param w float to set from
  2257. * @returns the updated Vector4.
  2258. */
  2259. set(x: number, y: number, z: number, w: number): Vector4;
  2260. /**
  2261. * Copies the given float to the current Vector3 coordinates
  2262. * @param v defines the x, y, z and w coordinates of the operand
  2263. * @returns the current updated Vector3
  2264. */
  2265. setAll(v: number): Vector4;
  2266. /**
  2267. * Returns a new Vector4 set from the starting index of the given array.
  2268. * @param array the array to pull values from
  2269. * @param offset the offset into the array to start at
  2270. * @returns the new vector
  2271. */
  2272. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2273. /**
  2274. * Updates the given vector "result" from the starting index of the given array.
  2275. * @param array the array to pull values from
  2276. * @param offset the offset into the array to start at
  2277. * @param result the vector to store the result in
  2278. */
  2279. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2280. /**
  2281. * Updates the given vector "result" from the starting index of the given Float32Array.
  2282. * @param array the array to pull values from
  2283. * @param offset the offset into the array to start at
  2284. * @param result the vector to store the result in
  2285. */
  2286. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2287. /**
  2288. * Updates the given vector "result" coordinates from the given floats.
  2289. * @param x float to set from
  2290. * @param y float to set from
  2291. * @param z float to set from
  2292. * @param w float to set from
  2293. * @param result the vector to the floats in
  2294. */
  2295. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2296. /**
  2297. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2298. * @returns the new vector
  2299. */
  2300. static Zero(): Vector4;
  2301. /**
  2302. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2303. * @returns the new vector
  2304. */
  2305. static One(): Vector4;
  2306. /**
  2307. * Returns a new normalized Vector4 from the given one.
  2308. * @param vector the vector to normalize
  2309. * @returns the vector
  2310. */
  2311. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2312. /**
  2313. * Updates the given vector "result" from the normalization of the given one.
  2314. * @param vector the vector to normalize
  2315. * @param result the vector to store the result in
  2316. */
  2317. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2318. /**
  2319. * Returns a vector with the minimum values from the left and right vectors
  2320. * @param left left vector to minimize
  2321. * @param right right vector to minimize
  2322. * @returns a new vector with the minimum of the left and right vector values
  2323. */
  2324. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2325. /**
  2326. * Returns a vector with the maximum values from the left and right vectors
  2327. * @param left left vector to maximize
  2328. * @param right right vector to maximize
  2329. * @returns a new vector with the maximum of the left and right vector values
  2330. */
  2331. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2332. /**
  2333. * Returns the distance (float) between the vectors "value1" and "value2".
  2334. * @param value1 value to calulate the distance between
  2335. * @param value2 value to calulate the distance between
  2336. * @return the distance between the two vectors
  2337. */
  2338. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2339. /**
  2340. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2341. * @param value1 value to calulate the distance between
  2342. * @param value2 value to calulate the distance between
  2343. * @return the distance between the two vectors squared
  2344. */
  2345. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2346. /**
  2347. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2348. * @param value1 value to calulate the center between
  2349. * @param value2 value to calulate the center between
  2350. * @return the center between the two vectors
  2351. */
  2352. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2353. /**
  2354. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2355. * This methods computes transformed normalized direction vectors only.
  2356. * @param vector the vector to transform
  2357. * @param transformation the transformation matrix to apply
  2358. * @returns the new vector
  2359. */
  2360. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2361. /**
  2362. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2363. * This methods computes transformed normalized direction vectors only.
  2364. * @param vector the vector to transform
  2365. * @param transformation the transformation matrix to apply
  2366. * @param result the vector to store the result in
  2367. */
  2368. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2369. /**
  2370. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2371. * This methods computes transformed normalized direction vectors only.
  2372. * @param x value to transform
  2373. * @param y value to transform
  2374. * @param z value to transform
  2375. * @param w value to transform
  2376. * @param transformation the transformation matrix to apply
  2377. * @param result the vector to store the results in
  2378. */
  2379. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2380. /**
  2381. * Creates a new Vector4 from a Vector3
  2382. * @param source defines the source data
  2383. * @param w defines the 4th component (default is 0)
  2384. * @returns a new Vector4
  2385. */
  2386. static FromVector3(source: Vector3, w?: number): Vector4;
  2387. }
  2388. /**
  2389. * Class used to store quaternion data
  2390. * @see https://en.wikipedia.org/wiki/Quaternion
  2391. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2392. */
  2393. export class Quaternion {
  2394. /** defines the first component (0 by default) */
  2395. x: number;
  2396. /** defines the second component (0 by default) */
  2397. y: number;
  2398. /** defines the third component (0 by default) */
  2399. z: number;
  2400. /** defines the fourth component (1.0 by default) */
  2401. w: number;
  2402. /**
  2403. * Creates a new Quaternion from the given floats
  2404. * @param x defines the first component (0 by default)
  2405. * @param y defines the second component (0 by default)
  2406. * @param z defines the third component (0 by default)
  2407. * @param w defines the fourth component (1.0 by default)
  2408. */
  2409. constructor(
  2410. /** defines the first component (0 by default) */
  2411. x?: number,
  2412. /** defines the second component (0 by default) */
  2413. y?: number,
  2414. /** defines the third component (0 by default) */
  2415. z?: number,
  2416. /** defines the fourth component (1.0 by default) */
  2417. w?: number);
  2418. /**
  2419. * Gets a string representation for the current quaternion
  2420. * @returns a string with the Quaternion coordinates
  2421. */
  2422. toString(): string;
  2423. /**
  2424. * Gets the class name of the quaternion
  2425. * @returns the string "Quaternion"
  2426. */
  2427. getClassName(): string;
  2428. /**
  2429. * Gets a hash code for this quaternion
  2430. * @returns the quaternion hash code
  2431. */
  2432. getHashCode(): number;
  2433. /**
  2434. * Copy the quaternion to an array
  2435. * @returns a new array populated with 4 elements from the quaternion coordinates
  2436. */
  2437. asArray(): number[];
  2438. /**
  2439. * Check if two quaternions are equals
  2440. * @param otherQuaternion defines the second operand
  2441. * @return true if the current quaternion and the given one coordinates are strictly equals
  2442. */
  2443. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2444. /**
  2445. * Clone the current quaternion
  2446. * @returns a new quaternion copied from the current one
  2447. */
  2448. clone(): Quaternion;
  2449. /**
  2450. * Copy a quaternion to the current one
  2451. * @param other defines the other quaternion
  2452. * @returns the updated current quaternion
  2453. */
  2454. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2455. /**
  2456. * Updates the current quaternion with the given float coordinates
  2457. * @param x defines the x coordinate
  2458. * @param y defines the y coordinate
  2459. * @param z defines the z coordinate
  2460. * @param w defines the w coordinate
  2461. * @returns the updated current quaternion
  2462. */
  2463. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2464. /**
  2465. * Updates the current quaternion from the given float coordinates
  2466. * @param x defines the x coordinate
  2467. * @param y defines the y coordinate
  2468. * @param z defines the z coordinate
  2469. * @param w defines the w coordinate
  2470. * @returns the updated current quaternion
  2471. */
  2472. set(x: number, y: number, z: number, w: number): Quaternion;
  2473. /**
  2474. * Adds two quaternions
  2475. * @param other defines the second operand
  2476. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2477. */
  2478. add(other: DeepImmutable<Quaternion>): Quaternion;
  2479. /**
  2480. * Add a quaternion to the current one
  2481. * @param other defines the quaternion to add
  2482. * @returns the current quaternion
  2483. */
  2484. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2485. /**
  2486. * Subtract two quaternions
  2487. * @param other defines the second operand
  2488. * @returns a new quaternion as the subtraction result of the given one from the current one
  2489. */
  2490. subtract(other: Quaternion): Quaternion;
  2491. /**
  2492. * Multiplies the current quaternion by a scale factor
  2493. * @param value defines the scale factor
  2494. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2495. */
  2496. scale(value: number): Quaternion;
  2497. /**
  2498. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2499. * @param scale defines the scale factor
  2500. * @param result defines the Quaternion object where to store the result
  2501. * @returns the unmodified current quaternion
  2502. */
  2503. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2504. /**
  2505. * Multiplies in place the current quaternion by a scale factor
  2506. * @param value defines the scale factor
  2507. * @returns the current modified quaternion
  2508. */
  2509. scaleInPlace(value: number): Quaternion;
  2510. /**
  2511. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2512. * @param scale defines the scale factor
  2513. * @param result defines the Quaternion object where to store the result
  2514. * @returns the unmodified current quaternion
  2515. */
  2516. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2517. /**
  2518. * Multiplies two quaternions
  2519. * @param q1 defines the second operand
  2520. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2521. */
  2522. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2523. /**
  2524. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2525. * @param q1 defines the second operand
  2526. * @param result defines the target quaternion
  2527. * @returns the current quaternion
  2528. */
  2529. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2530. /**
  2531. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2532. * @param q1 defines the second operand
  2533. * @returns the currentupdated quaternion
  2534. */
  2535. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2536. /**
  2537. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2538. * @param ref defines the target quaternion
  2539. * @returns the current quaternion
  2540. */
  2541. conjugateToRef(ref: Quaternion): Quaternion;
  2542. /**
  2543. * Conjugates in place (1-q) the current quaternion
  2544. * @returns the current updated quaternion
  2545. */
  2546. conjugateInPlace(): Quaternion;
  2547. /**
  2548. * Conjugates in place (1-q) the current quaternion
  2549. * @returns a new quaternion
  2550. */
  2551. conjugate(): Quaternion;
  2552. /**
  2553. * Gets length of current quaternion
  2554. * @returns the quaternion length (float)
  2555. */
  2556. length(): number;
  2557. /**
  2558. * Normalize in place the current quaternion
  2559. * @returns the current updated quaternion
  2560. */
  2561. normalize(): Quaternion;
  2562. /**
  2563. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2564. * @param order is a reserved parameter and is ignore for now
  2565. * @returns a new Vector3 containing the Euler angles
  2566. */
  2567. toEulerAngles(order?: string): Vector3;
  2568. /**
  2569. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2570. * @param result defines the vector which will be filled with the Euler angles
  2571. * @param order is a reserved parameter and is ignore for now
  2572. * @returns the current unchanged quaternion
  2573. */
  2574. toEulerAnglesToRef(result: Vector3): Quaternion;
  2575. /**
  2576. * Updates the given rotation matrix with the current quaternion values
  2577. * @param result defines the target matrix
  2578. * @returns the current unchanged quaternion
  2579. */
  2580. toRotationMatrix(result: Matrix): Quaternion;
  2581. /**
  2582. * Updates the current quaternion from the given rotation matrix values
  2583. * @param matrix defines the source matrix
  2584. * @returns the current updated quaternion
  2585. */
  2586. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2587. /**
  2588. * Creates a new quaternion from a rotation matrix
  2589. * @param matrix defines the source matrix
  2590. * @returns a new quaternion created from the given rotation matrix values
  2591. */
  2592. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2593. /**
  2594. * Updates the given quaternion with the given rotation matrix values
  2595. * @param matrix defines the source matrix
  2596. * @param result defines the target quaternion
  2597. */
  2598. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2599. /**
  2600. * Returns the dot product (float) between the quaternions "left" and "right"
  2601. * @param left defines the left operand
  2602. * @param right defines the right operand
  2603. * @returns the dot product
  2604. */
  2605. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2606. /**
  2607. * Checks if the two quaternions are close to each other
  2608. * @param quat0 defines the first quaternion to check
  2609. * @param quat1 defines the second quaternion to check
  2610. * @returns true if the two quaternions are close to each other
  2611. */
  2612. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2613. /**
  2614. * Creates an empty quaternion
  2615. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2616. */
  2617. static Zero(): Quaternion;
  2618. /**
  2619. * Inverse a given quaternion
  2620. * @param q defines the source quaternion
  2621. * @returns a new quaternion as the inverted current quaternion
  2622. */
  2623. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2624. /**
  2625. * Inverse a given quaternion
  2626. * @param q defines the source quaternion
  2627. * @param result the quaternion the result will be stored in
  2628. * @returns the result quaternion
  2629. */
  2630. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2631. /**
  2632. * Creates an identity quaternion
  2633. * @returns the identity quaternion
  2634. */
  2635. static Identity(): Quaternion;
  2636. /**
  2637. * Gets a boolean indicating if the given quaternion is identity
  2638. * @param quaternion defines the quaternion to check
  2639. * @returns true if the quaternion is identity
  2640. */
  2641. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2642. /**
  2643. * Creates a quaternion from a rotation around an axis
  2644. * @param axis defines the axis to use
  2645. * @param angle defines the angle to use
  2646. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2647. */
  2648. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2649. /**
  2650. * Creates a rotation around an axis and stores it into the given quaternion
  2651. * @param axis defines the axis to use
  2652. * @param angle defines the angle to use
  2653. * @param result defines the target quaternion
  2654. * @returns the target quaternion
  2655. */
  2656. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2657. /**
  2658. * Creates a new quaternion from data stored into an array
  2659. * @param array defines the data source
  2660. * @param offset defines the offset in the source array where the data starts
  2661. * @returns a new quaternion
  2662. */
  2663. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2664. /**
  2665. * Create a quaternion from Euler rotation angles
  2666. * @param x Pitch
  2667. * @param y Yaw
  2668. * @param z Roll
  2669. * @returns the new Quaternion
  2670. */
  2671. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2672. /**
  2673. * Updates a quaternion from Euler rotation angles
  2674. * @param x Pitch
  2675. * @param y Yaw
  2676. * @param z Roll
  2677. * @param result the quaternion to store the result
  2678. * @returns the updated quaternion
  2679. */
  2680. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2681. /**
  2682. * Create a quaternion from Euler rotation vector
  2683. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2684. * @returns the new Quaternion
  2685. */
  2686. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2687. /**
  2688. * Updates a quaternion from Euler rotation vector
  2689. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2690. * @param result the quaternion to store the result
  2691. * @returns the updated quaternion
  2692. */
  2693. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2696. * @param yaw defines the rotation around Y axis
  2697. * @param pitch defines the rotation around X axis
  2698. * @param roll defines the rotation around Z axis
  2699. * @returns the new quaternion
  2700. */
  2701. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2702. /**
  2703. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2704. * @param yaw defines the rotation around Y axis
  2705. * @param pitch defines the rotation around X axis
  2706. * @param roll defines the rotation around Z axis
  2707. * @param result defines the target quaternion
  2708. */
  2709. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2710. /**
  2711. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2712. * @param alpha defines the rotation around first axis
  2713. * @param beta defines the rotation around second axis
  2714. * @param gamma defines the rotation around third axis
  2715. * @returns the new quaternion
  2716. */
  2717. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2718. /**
  2719. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2720. * @param alpha defines the rotation around first axis
  2721. * @param beta defines the rotation around second axis
  2722. * @param gamma defines the rotation around third axis
  2723. * @param result defines the target quaternion
  2724. */
  2725. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2726. /**
  2727. * 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)
  2728. * @param axis1 defines the first axis
  2729. * @param axis2 defines the second axis
  2730. * @param axis3 defines the third axis
  2731. * @returns the new quaternion
  2732. */
  2733. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2734. /**
  2735. * 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
  2736. * @param axis1 defines the first axis
  2737. * @param axis2 defines the second axis
  2738. * @param axis3 defines the third axis
  2739. * @param ref defines the target quaternion
  2740. */
  2741. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2742. /**
  2743. * Interpolates between two quaternions
  2744. * @param left defines first quaternion
  2745. * @param right defines second quaternion
  2746. * @param amount defines the gradient to use
  2747. * @returns the new interpolated quaternion
  2748. */
  2749. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2750. /**
  2751. * Interpolates between two quaternions and stores it into a target quaternion
  2752. * @param left defines first quaternion
  2753. * @param right defines second quaternion
  2754. * @param amount defines the gradient to use
  2755. * @param result defines the target quaternion
  2756. */
  2757. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2758. /**
  2759. * Interpolate between two quaternions using Hermite interpolation
  2760. * @param value1 defines first quaternion
  2761. * @param tangent1 defines the incoming tangent
  2762. * @param value2 defines second quaternion
  2763. * @param tangent2 defines the outgoing tangent
  2764. * @param amount defines the target quaternion
  2765. * @returns the new interpolated quaternion
  2766. */
  2767. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2768. }
  2769. /**
  2770. * Class used to store matrix data (4x4)
  2771. */
  2772. export class Matrix {
  2773. private static _updateFlagSeed;
  2774. private static _identityReadOnly;
  2775. private _isIdentity;
  2776. private _isIdentityDirty;
  2777. private _isIdentity3x2;
  2778. private _isIdentity3x2Dirty;
  2779. /**
  2780. * Gets the update flag of the matrix which is an unique number for the matrix.
  2781. * It will be incremented every time the matrix data change.
  2782. * You can use it to speed the comparison between two versions of the same matrix.
  2783. */
  2784. updateFlag: number;
  2785. private readonly _m;
  2786. /**
  2787. * Gets the internal data of the matrix
  2788. */
  2789. readonly m: DeepImmutable<Float32Array>;
  2790. /** @hidden */
  2791. _markAsUpdated(): void;
  2792. /** @hidden */
  2793. private _updateIdentityStatus;
  2794. /**
  2795. * Creates an empty matrix (filled with zeros)
  2796. */
  2797. constructor();
  2798. /**
  2799. * Check if the current matrix is identity
  2800. * @returns true is the matrix is the identity matrix
  2801. */
  2802. isIdentity(): boolean;
  2803. /**
  2804. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2805. * @returns true is the matrix is the identity matrix
  2806. */
  2807. isIdentityAs3x2(): boolean;
  2808. /**
  2809. * Gets the determinant of the matrix
  2810. * @returns the matrix determinant
  2811. */
  2812. determinant(): number;
  2813. /**
  2814. * Returns the matrix as a Float32Array
  2815. * @returns the matrix underlying array
  2816. */
  2817. toArray(): DeepImmutable<Float32Array>;
  2818. /**
  2819. * Returns the matrix as a Float32Array
  2820. * @returns the matrix underlying array.
  2821. */
  2822. asArray(): DeepImmutable<Float32Array>;
  2823. /**
  2824. * Inverts the current matrix in place
  2825. * @returns the current inverted matrix
  2826. */
  2827. invert(): Matrix;
  2828. /**
  2829. * Sets all the matrix elements to zero
  2830. * @returns the current matrix
  2831. */
  2832. reset(): Matrix;
  2833. /**
  2834. * Adds the current matrix with a second one
  2835. * @param other defines the matrix to add
  2836. * @returns a new matrix as the addition of the current matrix and the given one
  2837. */
  2838. add(other: DeepImmutable<Matrix>): Matrix;
  2839. /**
  2840. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2841. * @param other defines the matrix to add
  2842. * @param result defines the target matrix
  2843. * @returns the current matrix
  2844. */
  2845. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2846. /**
  2847. * Adds in place the given matrix to the current matrix
  2848. * @param other defines the second operand
  2849. * @returns the current updated matrix
  2850. */
  2851. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2852. /**
  2853. * Sets the given matrix to the current inverted Matrix
  2854. * @param other defines the target matrix
  2855. * @returns the unmodified current matrix
  2856. */
  2857. invertToRef(other: Matrix): Matrix;
  2858. /**
  2859. * add a value at the specified position in the current Matrix
  2860. * @param index the index of the value within the matrix. between 0 and 15.
  2861. * @param value the value to be added
  2862. * @returns the current updated matrix
  2863. */
  2864. addAtIndex(index: number, value: number): Matrix;
  2865. /**
  2866. * mutiply the specified position in the current Matrix by a value
  2867. * @param index the index of the value within the matrix. between 0 and 15.
  2868. * @param value the value to be added
  2869. * @returns the current updated matrix
  2870. */
  2871. multiplyAtIndex(index: number, value: number): Matrix;
  2872. /**
  2873. * Inserts the translation vector (using 3 floats) in the current matrix
  2874. * @param x defines the 1st component of the translation
  2875. * @param y defines the 2nd component of the translation
  2876. * @param z defines the 3rd component of the translation
  2877. * @returns the current updated matrix
  2878. */
  2879. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2880. /**
  2881. * Adds the translation vector (using 3 floats) in the current matrix
  2882. * @param x defines the 1st component of the translation
  2883. * @param y defines the 2nd component of the translation
  2884. * @param z defines the 3rd component of the translation
  2885. * @returns the current updated matrix
  2886. */
  2887. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2888. /**
  2889. * Inserts the translation vector in the current matrix
  2890. * @param vector3 defines the translation to insert
  2891. * @returns the current updated matrix
  2892. */
  2893. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2894. /**
  2895. * Gets the translation value of the current matrix
  2896. * @returns a new Vector3 as the extracted translation from the matrix
  2897. */
  2898. getTranslation(): Vector3;
  2899. /**
  2900. * Fill a Vector3 with the extracted translation from the matrix
  2901. * @param result defines the Vector3 where to store the translation
  2902. * @returns the current matrix
  2903. */
  2904. getTranslationToRef(result: Vector3): Matrix;
  2905. /**
  2906. * Remove rotation and scaling part from the matrix
  2907. * @returns the updated matrix
  2908. */
  2909. removeRotationAndScaling(): Matrix;
  2910. /**
  2911. * Multiply two matrices
  2912. * @param other defines the second operand
  2913. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2914. */
  2915. multiply(other: DeepImmutable<Matrix>): Matrix;
  2916. /**
  2917. * Copy the current matrix from the given one
  2918. * @param other defines the source matrix
  2919. * @returns the current updated matrix
  2920. */
  2921. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2922. /**
  2923. * Populates the given array from the starting index with the current matrix values
  2924. * @param array defines the target array
  2925. * @param offset defines the offset in the target array where to start storing values
  2926. * @returns the current matrix
  2927. */
  2928. copyToArray(array: Float32Array, offset?: number): Matrix;
  2929. /**
  2930. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2931. * @param other defines the second operand
  2932. * @param result defines the matrix where to store the multiplication
  2933. * @returns the current matrix
  2934. */
  2935. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2936. /**
  2937. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  2938. * @param other defines the second operand
  2939. * @param result defines the array where to store the multiplication
  2940. * @param offset defines the offset in the target array where to start storing values
  2941. * @returns the current matrix
  2942. */
  2943. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  2944. /**
  2945. * Check equality between this matrix and a second one
  2946. * @param value defines the second matrix to compare
  2947. * @returns true is the current matrix and the given one values are strictly equal
  2948. */
  2949. equals(value: DeepImmutable<Matrix>): boolean;
  2950. /**
  2951. * Clone the current matrix
  2952. * @returns a new matrix from the current matrix
  2953. */
  2954. clone(): Matrix;
  2955. /**
  2956. * Returns the name of the current matrix class
  2957. * @returns the string "Matrix"
  2958. */
  2959. getClassName(): string;
  2960. /**
  2961. * Gets the hash code of the current matrix
  2962. * @returns the hash code
  2963. */
  2964. getHashCode(): number;
  2965. /**
  2966. * Decomposes the current Matrix into a translation, rotation and scaling components
  2967. * @param scale defines the scale vector3 given as a reference to update
  2968. * @param rotation defines the rotation quaternion given as a reference to update
  2969. * @param translation defines the translation vector3 given as a reference to update
  2970. * @returns true if operation was successful
  2971. */
  2972. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  2973. /**
  2974. * Gets specific row of the matrix
  2975. * @param index defines the number of the row to get
  2976. * @returns the index-th row of the current matrix as a new Vector4
  2977. */
  2978. getRow(index: number): Nullable<Vector4>;
  2979. /**
  2980. * Sets the index-th row of the current matrix to the vector4 values
  2981. * @param index defines the number of the row to set
  2982. * @param row defines the target vector4
  2983. * @returns the updated current matrix
  2984. */
  2985. setRow(index: number, row: Vector4): Matrix;
  2986. /**
  2987. * Compute the transpose of the matrix
  2988. * @returns the new transposed matrix
  2989. */
  2990. transpose(): Matrix;
  2991. /**
  2992. * Compute the transpose of the matrix and store it in a given matrix
  2993. * @param result defines the target matrix
  2994. * @returns the current matrix
  2995. */
  2996. transposeToRef(result: Matrix): Matrix;
  2997. /**
  2998. * Sets the index-th row of the current matrix with the given 4 x float values
  2999. * @param index defines the row index
  3000. * @param x defines the x component to set
  3001. * @param y defines the y component to set
  3002. * @param z defines the z component to set
  3003. * @param w defines the w component to set
  3004. * @returns the updated current matrix
  3005. */
  3006. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3007. /**
  3008. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3009. * @param scale defines the scale factor
  3010. * @returns a new matrix
  3011. */
  3012. scale(scale: number): Matrix;
  3013. /**
  3014. * Scale the current matrix values by a factor to a given result matrix
  3015. * @param scale defines the scale factor
  3016. * @param result defines the matrix to store the result
  3017. * @returns the current matrix
  3018. */
  3019. scaleToRef(scale: number, result: Matrix): Matrix;
  3020. /**
  3021. * Scale the current matrix values by a factor and add the result to a given matrix
  3022. * @param scale defines the scale factor
  3023. * @param result defines the Matrix to store the result
  3024. * @returns the current matrix
  3025. */
  3026. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3027. /**
  3028. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3029. * @param ref matrix to store the result
  3030. */
  3031. toNormalMatrix(ref: Matrix): void;
  3032. /**
  3033. * Gets only rotation part of the current matrix
  3034. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3035. */
  3036. getRotationMatrix(): Matrix;
  3037. /**
  3038. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3039. * @param result defines the target matrix to store data to
  3040. * @returns the current matrix
  3041. */
  3042. getRotationMatrixToRef(result: Matrix): Matrix;
  3043. /**
  3044. * Toggles model matrix from being right handed to left handed in place and vice versa
  3045. */
  3046. toggleModelMatrixHandInPlace(): void;
  3047. /**
  3048. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3049. */
  3050. toggleProjectionMatrixHandInPlace(): void;
  3051. /**
  3052. * Creates a matrix from an array
  3053. * @param array defines the source array
  3054. * @param offset defines an offset in the source array
  3055. * @returns a new Matrix set from the starting index of the given array
  3056. */
  3057. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3058. /**
  3059. * Copy the content of an array into a given matrix
  3060. * @param array defines the source array
  3061. * @param offset defines an offset in the source array
  3062. * @param result defines the target matrix
  3063. */
  3064. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3065. /**
  3066. * Stores an array into a matrix after having multiplied each component by a given factor
  3067. * @param array defines the source array
  3068. * @param offset defines the offset in the source array
  3069. * @param scale defines the scaling factor
  3070. * @param result defines the target matrix
  3071. */
  3072. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3073. /**
  3074. * Gets an identity matrix that must not be updated
  3075. */
  3076. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3077. /**
  3078. * Stores a list of values (16) inside a given matrix
  3079. * @param initialM11 defines 1st value of 1st row
  3080. * @param initialM12 defines 2nd value of 1st row
  3081. * @param initialM13 defines 3rd value of 1st row
  3082. * @param initialM14 defines 4th value of 1st row
  3083. * @param initialM21 defines 1st value of 2nd row
  3084. * @param initialM22 defines 2nd value of 2nd row
  3085. * @param initialM23 defines 3rd value of 2nd row
  3086. * @param initialM24 defines 4th value of 2nd row
  3087. * @param initialM31 defines 1st value of 3rd row
  3088. * @param initialM32 defines 2nd value of 3rd row
  3089. * @param initialM33 defines 3rd value of 3rd row
  3090. * @param initialM34 defines 4th value of 3rd row
  3091. * @param initialM41 defines 1st value of 4th row
  3092. * @param initialM42 defines 2nd value of 4th row
  3093. * @param initialM43 defines 3rd value of 4th row
  3094. * @param initialM44 defines 4th value of 4th row
  3095. * @param result defines the target matrix
  3096. */
  3097. 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;
  3098. /**
  3099. * Creates new matrix from a list of values (16)
  3100. * @param initialM11 defines 1st value of 1st row
  3101. * @param initialM12 defines 2nd value of 1st row
  3102. * @param initialM13 defines 3rd value of 1st row
  3103. * @param initialM14 defines 4th value of 1st row
  3104. * @param initialM21 defines 1st value of 2nd row
  3105. * @param initialM22 defines 2nd value of 2nd row
  3106. * @param initialM23 defines 3rd value of 2nd row
  3107. * @param initialM24 defines 4th value of 2nd row
  3108. * @param initialM31 defines 1st value of 3rd row
  3109. * @param initialM32 defines 2nd value of 3rd row
  3110. * @param initialM33 defines 3rd value of 3rd row
  3111. * @param initialM34 defines 4th value of 3rd row
  3112. * @param initialM41 defines 1st value of 4th row
  3113. * @param initialM42 defines 2nd value of 4th row
  3114. * @param initialM43 defines 3rd value of 4th row
  3115. * @param initialM44 defines 4th value of 4th row
  3116. * @returns the new matrix
  3117. */
  3118. 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;
  3119. /**
  3120. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3121. * @param scale defines the scale vector3
  3122. * @param rotation defines the rotation quaternion
  3123. * @param translation defines the translation vector3
  3124. * @returns a new matrix
  3125. */
  3126. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3127. /**
  3128. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3129. * @param scale defines the scale vector3
  3130. * @param rotation defines the rotation quaternion
  3131. * @param translation defines the translation vector3
  3132. * @param result defines the target matrix
  3133. */
  3134. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3135. /**
  3136. * Creates a new identity matrix
  3137. * @returns a new identity matrix
  3138. */
  3139. static Identity(): Matrix;
  3140. /**
  3141. * Creates a new identity matrix and stores the result in a given matrix
  3142. * @param result defines the target matrix
  3143. */
  3144. static IdentityToRef(result: Matrix): void;
  3145. /**
  3146. * Creates a new zero matrix
  3147. * @returns a new zero matrix
  3148. */
  3149. static Zero(): Matrix;
  3150. /**
  3151. * Creates a new rotation matrix for "angle" radians around the X axis
  3152. * @param angle defines the angle (in radians) to use
  3153. * @return the new matrix
  3154. */
  3155. static RotationX(angle: number): Matrix;
  3156. /**
  3157. * Creates a new matrix as the invert of a given matrix
  3158. * @param source defines the source matrix
  3159. * @returns the new matrix
  3160. */
  3161. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3162. /**
  3163. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3164. * @param angle defines the angle (in radians) to use
  3165. * @param result defines the target matrix
  3166. */
  3167. static RotationXToRef(angle: number, result: Matrix): void;
  3168. /**
  3169. * Creates a new rotation matrix for "angle" radians around the Y axis
  3170. * @param angle defines the angle (in radians) to use
  3171. * @return the new matrix
  3172. */
  3173. static RotationY(angle: number): Matrix;
  3174. /**
  3175. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3176. * @param angle defines the angle (in radians) to use
  3177. * @param result defines the target matrix
  3178. */
  3179. static RotationYToRef(angle: number, result: Matrix): void;
  3180. /**
  3181. * Creates a new rotation matrix for "angle" radians around the Z axis
  3182. * @param angle defines the angle (in radians) to use
  3183. * @return the new matrix
  3184. */
  3185. static RotationZ(angle: number): Matrix;
  3186. /**
  3187. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3188. * @param angle defines the angle (in radians) to use
  3189. * @param result defines the target matrix
  3190. */
  3191. static RotationZToRef(angle: number, result: Matrix): void;
  3192. /**
  3193. * Creates a new rotation matrix for "angle" radians around the given axis
  3194. * @param axis defines the axis to use
  3195. * @param angle defines the angle (in radians) to use
  3196. * @return the new matrix
  3197. */
  3198. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3199. /**
  3200. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3201. * @param axis defines the axis to use
  3202. * @param angle defines the angle (in radians) to use
  3203. * @param result defines the target matrix
  3204. */
  3205. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3206. /**
  3207. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3208. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3209. * @param from defines the vector to align
  3210. * @param to defines the vector to align to
  3211. * @param result defines the target matrix
  3212. */
  3213. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3214. /**
  3215. * Creates a rotation matrix
  3216. * @param yaw defines the yaw angle in radians (Y axis)
  3217. * @param pitch defines the pitch angle in radians (X axis)
  3218. * @param roll defines the roll angle in radians (X axis)
  3219. * @returns the new rotation matrix
  3220. */
  3221. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3222. /**
  3223. * Creates a rotation matrix and stores it in a given matrix
  3224. * @param yaw defines the yaw angle in radians (Y axis)
  3225. * @param pitch defines the pitch angle in radians (X axis)
  3226. * @param roll defines the roll angle in radians (X axis)
  3227. * @param result defines the target matrix
  3228. */
  3229. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3230. /**
  3231. * Creates a scaling matrix
  3232. * @param x defines the scale factor on X axis
  3233. * @param y defines the scale factor on Y axis
  3234. * @param z defines the scale factor on Z axis
  3235. * @returns the new matrix
  3236. */
  3237. static Scaling(x: number, y: number, z: number): Matrix;
  3238. /**
  3239. * Creates a scaling matrix and stores it in a given matrix
  3240. * @param x defines the scale factor on X axis
  3241. * @param y defines the scale factor on Y axis
  3242. * @param z defines the scale factor on Z axis
  3243. * @param result defines the target matrix
  3244. */
  3245. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3246. /**
  3247. * Creates a translation matrix
  3248. * @param x defines the translation on X axis
  3249. * @param y defines the translation on Y axis
  3250. * @param z defines the translationon Z axis
  3251. * @returns the new matrix
  3252. */
  3253. static Translation(x: number, y: number, z: number): Matrix;
  3254. /**
  3255. * Creates a translation matrix and stores it in a given matrix
  3256. * @param x defines the translation on X axis
  3257. * @param y defines the translation on Y axis
  3258. * @param z defines the translationon Z axis
  3259. * @param result defines the target matrix
  3260. */
  3261. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3262. /**
  3263. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3264. * @param startValue defines the start value
  3265. * @param endValue defines the end value
  3266. * @param gradient defines the gradient factor
  3267. * @returns the new matrix
  3268. */
  3269. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3270. /**
  3271. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3272. * @param startValue defines the start value
  3273. * @param endValue defines the end value
  3274. * @param gradient defines the gradient factor
  3275. * @param result defines the Matrix object where to store data
  3276. */
  3277. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3278. /**
  3279. * Builds a new matrix whose values are computed by:
  3280. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3281. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3282. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3283. * @param startValue defines the first matrix
  3284. * @param endValue defines the second matrix
  3285. * @param gradient defines the gradient between the two matrices
  3286. * @returns the new matrix
  3287. */
  3288. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3289. /**
  3290. * Update a matrix to values which are computed by:
  3291. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3292. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3293. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3294. * @param startValue defines the first matrix
  3295. * @param endValue defines the second matrix
  3296. * @param gradient defines the gradient between the two matrices
  3297. * @param result defines the target matrix
  3298. */
  3299. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3300. /**
  3301. * 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"
  3302. * This function works in left handed mode
  3303. * @param eye defines the final position of the entity
  3304. * @param target defines where the entity should look at
  3305. * @param up defines the up vector for the entity
  3306. * @returns the new matrix
  3307. */
  3308. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3309. /**
  3310. * 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".
  3311. * This function works in left handed mode
  3312. * @param eye defines the final position of the entity
  3313. * @param target defines where the entity should look at
  3314. * @param up defines the up vector for the entity
  3315. * @param result defines the target matrix
  3316. */
  3317. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3318. /**
  3319. * 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"
  3320. * This function works in right handed mode
  3321. * @param eye defines the final position of the entity
  3322. * @param target defines where the entity should look at
  3323. * @param up defines the up vector for the entity
  3324. * @returns the new matrix
  3325. */
  3326. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3327. /**
  3328. * 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".
  3329. * This function works in right handed mode
  3330. * @param eye defines the final position of the entity
  3331. * @param target defines where the entity should look at
  3332. * @param up defines the up vector for the entity
  3333. * @param result defines the target matrix
  3334. */
  3335. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3336. /**
  3337. * Create a left-handed orthographic projection matrix
  3338. * @param width defines the viewport width
  3339. * @param height defines the viewport height
  3340. * @param znear defines the near clip plane
  3341. * @param zfar defines the far clip plane
  3342. * @returns a new matrix as a left-handed orthographic projection matrix
  3343. */
  3344. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3345. /**
  3346. * Store a left-handed orthographic projection to a given matrix
  3347. * @param width defines the viewport width
  3348. * @param height defines the viewport height
  3349. * @param znear defines the near clip plane
  3350. * @param zfar defines the far clip plane
  3351. * @param result defines the target matrix
  3352. */
  3353. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3354. /**
  3355. * Create a left-handed orthographic projection matrix
  3356. * @param left defines the viewport left coordinate
  3357. * @param right defines the viewport right coordinate
  3358. * @param bottom defines the viewport bottom coordinate
  3359. * @param top defines the viewport top coordinate
  3360. * @param znear defines the near clip plane
  3361. * @param zfar defines the far clip plane
  3362. * @returns a new matrix as a left-handed orthographic projection matrix
  3363. */
  3364. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3365. /**
  3366. * Stores a left-handed orthographic projection into a given matrix
  3367. * @param left defines the viewport left coordinate
  3368. * @param right defines the viewport right coordinate
  3369. * @param bottom defines the viewport bottom coordinate
  3370. * @param top defines the viewport top coordinate
  3371. * @param znear defines the near clip plane
  3372. * @param zfar defines the far clip plane
  3373. * @param result defines the target matrix
  3374. */
  3375. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3376. /**
  3377. * Creates a right-handed orthographic projection matrix
  3378. * @param left defines the viewport left coordinate
  3379. * @param right defines the viewport right coordinate
  3380. * @param bottom defines the viewport bottom coordinate
  3381. * @param top defines the viewport top coordinate
  3382. * @param znear defines the near clip plane
  3383. * @param zfar defines the far clip plane
  3384. * @returns a new matrix as a right-handed orthographic projection matrix
  3385. */
  3386. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3387. /**
  3388. * Stores a right-handed orthographic projection into a given matrix
  3389. * @param left defines the viewport left coordinate
  3390. * @param right defines the viewport right coordinate
  3391. * @param bottom defines the viewport bottom coordinate
  3392. * @param top defines the viewport top coordinate
  3393. * @param znear defines the near clip plane
  3394. * @param zfar defines the far clip plane
  3395. * @param result defines the target matrix
  3396. */
  3397. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3398. /**
  3399. * Creates a left-handed perspective projection matrix
  3400. * @param width defines the viewport width
  3401. * @param height defines the viewport height
  3402. * @param znear defines the near clip plane
  3403. * @param zfar defines the far clip plane
  3404. * @returns a new matrix as a left-handed perspective projection matrix
  3405. */
  3406. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3407. /**
  3408. * Creates a left-handed perspective projection matrix
  3409. * @param fov defines the horizontal field of view
  3410. * @param aspect defines the aspect ratio
  3411. * @param znear defines the near clip plane
  3412. * @param zfar defines the far clip plane
  3413. * @returns a new matrix as a left-handed perspective projection matrix
  3414. */
  3415. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3416. /**
  3417. * Stores a left-handed perspective projection into a given matrix
  3418. * @param fov defines the horizontal field of view
  3419. * @param aspect defines the aspect ratio
  3420. * @param znear defines the near clip plane
  3421. * @param zfar defines the far clip plane
  3422. * @param result defines the target matrix
  3423. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3424. */
  3425. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3426. /**
  3427. * Creates a right-handed perspective projection matrix
  3428. * @param fov defines the horizontal field of view
  3429. * @param aspect defines the aspect ratio
  3430. * @param znear defines the near clip plane
  3431. * @param zfar defines the far clip plane
  3432. * @returns a new matrix as a right-handed perspective projection matrix
  3433. */
  3434. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3435. /**
  3436. * Stores a right-handed perspective projection into a given matrix
  3437. * @param fov defines the horizontal field of view
  3438. * @param aspect defines the aspect ratio
  3439. * @param znear defines the near clip plane
  3440. * @param zfar defines the far clip plane
  3441. * @param result defines the target matrix
  3442. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3443. */
  3444. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3445. /**
  3446. * Stores a perspective projection for WebVR info a given matrix
  3447. * @param fov defines the field of view
  3448. * @param znear defines the near clip plane
  3449. * @param zfar defines the far clip plane
  3450. * @param result defines the target matrix
  3451. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3452. */
  3453. static PerspectiveFovWebVRToRef(fov: {
  3454. upDegrees: number;
  3455. downDegrees: number;
  3456. leftDegrees: number;
  3457. rightDegrees: number;
  3458. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3459. /**
  3460. * Computes a complete transformation matrix
  3461. * @param viewport defines the viewport to use
  3462. * @param world defines the world matrix
  3463. * @param view defines the view matrix
  3464. * @param projection defines the projection matrix
  3465. * @param zmin defines the near clip plane
  3466. * @param zmax defines the far clip plane
  3467. * @returns the transformation matrix
  3468. */
  3469. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3470. /**
  3471. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3472. * @param matrix defines the matrix to use
  3473. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3474. */
  3475. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3476. /**
  3477. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3478. * @param matrix defines the matrix to use
  3479. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3480. */
  3481. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3482. /**
  3483. * Compute the transpose of a given matrix
  3484. * @param matrix defines the matrix to transpose
  3485. * @returns the new matrix
  3486. */
  3487. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3488. /**
  3489. * Compute the transpose of a matrix and store it in a target matrix
  3490. * @param matrix defines the matrix to transpose
  3491. * @param result defines the target matrix
  3492. */
  3493. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3494. /**
  3495. * Computes a reflection matrix from a plane
  3496. * @param plane defines the reflection plane
  3497. * @returns a new matrix
  3498. */
  3499. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  3500. /**
  3501. * Computes a reflection matrix from a plane
  3502. * @param plane defines the reflection plane
  3503. * @param result defines the target matrix
  3504. */
  3505. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  3506. /**
  3507. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3508. * @param xaxis defines the value of the 1st axis
  3509. * @param yaxis defines the value of the 2nd axis
  3510. * @param zaxis defines the value of the 3rd axis
  3511. * @param result defines the target matrix
  3512. */
  3513. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3514. /**
  3515. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3516. * @param quat defines the quaternion to use
  3517. * @param result defines the target matrix
  3518. */
  3519. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3520. }
  3521. /**
  3522. * @hidden
  3523. */
  3524. export class TmpVectors {
  3525. static Vector2: Vector2[];
  3526. static Vector3: Vector3[];
  3527. static Vector4: Vector4[];
  3528. static Quaternion: Quaternion[];
  3529. static Matrix: Matrix[];
  3530. }
  3531. }
  3532. declare module "babylonjs/Maths/math.color" {
  3533. import { DeepImmutable, FloatArray } from "babylonjs/types";
  3534. /**
  3535. * Class used to hold a RBG color
  3536. */
  3537. export class Color3 {
  3538. /**
  3539. * Defines the red component (between 0 and 1, default is 0)
  3540. */
  3541. r: number;
  3542. /**
  3543. * Defines the green component (between 0 and 1, default is 0)
  3544. */
  3545. g: number;
  3546. /**
  3547. * Defines the blue component (between 0 and 1, default is 0)
  3548. */
  3549. b: number;
  3550. /**
  3551. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  3552. * @param r defines the red component (between 0 and 1, default is 0)
  3553. * @param g defines the green component (between 0 and 1, default is 0)
  3554. * @param b defines the blue component (between 0 and 1, default is 0)
  3555. */
  3556. constructor(
  3557. /**
  3558. * Defines the red component (between 0 and 1, default is 0)
  3559. */
  3560. r?: number,
  3561. /**
  3562. * Defines the green component (between 0 and 1, default is 0)
  3563. */
  3564. g?: number,
  3565. /**
  3566. * Defines the blue component (between 0 and 1, default is 0)
  3567. */
  3568. b?: number);
  3569. /**
  3570. * Creates a string with the Color3 current values
  3571. * @returns the string representation of the Color3 object
  3572. */
  3573. toString(): string;
  3574. /**
  3575. * Returns the string "Color3"
  3576. * @returns "Color3"
  3577. */
  3578. getClassName(): string;
  3579. /**
  3580. * Compute the Color3 hash code
  3581. * @returns an unique number that can be used to hash Color3 objects
  3582. */
  3583. getHashCode(): number;
  3584. /**
  3585. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  3586. * @param array defines the array where to store the r,g,b components
  3587. * @param index defines an optional index in the target array to define where to start storing values
  3588. * @returns the current Color3 object
  3589. */
  3590. toArray(array: FloatArray, index?: number): Color3;
  3591. /**
  3592. * Returns a new Color4 object from the current Color3 and the given alpha
  3593. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  3594. * @returns a new Color4 object
  3595. */
  3596. toColor4(alpha?: number): Color4;
  3597. /**
  3598. * Returns a new array populated with 3 numeric elements : red, green and blue values
  3599. * @returns the new array
  3600. */
  3601. asArray(): number[];
  3602. /**
  3603. * Returns the luminance value
  3604. * @returns a float value
  3605. */
  3606. toLuminance(): number;
  3607. /**
  3608. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  3609. * @param otherColor defines the second operand
  3610. * @returns the new Color3 object
  3611. */
  3612. multiply(otherColor: DeepImmutable<Color3>): Color3;
  3613. /**
  3614. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  3615. * @param otherColor defines the second operand
  3616. * @param result defines the Color3 object where to store the result
  3617. * @returns the current Color3
  3618. */
  3619. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3620. /**
  3621. * Determines equality between Color3 objects
  3622. * @param otherColor defines the second operand
  3623. * @returns true if the rgb values are equal to the given ones
  3624. */
  3625. equals(otherColor: DeepImmutable<Color3>): boolean;
  3626. /**
  3627. * Determines equality between the current Color3 object and a set of r,b,g values
  3628. * @param r defines the red component to check
  3629. * @param g defines the green component to check
  3630. * @param b defines the blue component to check
  3631. * @returns true if the rgb values are equal to the given ones
  3632. */
  3633. equalsFloats(r: number, g: number, b: number): boolean;
  3634. /**
  3635. * Multiplies in place each rgb value by scale
  3636. * @param scale defines the scaling factor
  3637. * @returns the updated Color3
  3638. */
  3639. scale(scale: number): Color3;
  3640. /**
  3641. * Multiplies the rgb values by scale and stores the result into "result"
  3642. * @param scale defines the scaling factor
  3643. * @param result defines the Color3 object where to store the result
  3644. * @returns the unmodified current Color3
  3645. */
  3646. scaleToRef(scale: number, result: Color3): Color3;
  3647. /**
  3648. * Scale the current Color3 values by a factor and add the result to a given Color3
  3649. * @param scale defines the scale factor
  3650. * @param result defines color to store the result into
  3651. * @returns the unmodified current Color3
  3652. */
  3653. scaleAndAddToRef(scale: number, result: Color3): Color3;
  3654. /**
  3655. * Clamps the rgb values by the min and max values and stores the result into "result"
  3656. * @param min defines minimum clamping value (default is 0)
  3657. * @param max defines maximum clamping value (default is 1)
  3658. * @param result defines color to store the result into
  3659. * @returns the original Color3
  3660. */
  3661. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  3662. /**
  3663. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  3664. * @param otherColor defines the second operand
  3665. * @returns the new Color3
  3666. */
  3667. add(otherColor: DeepImmutable<Color3>): Color3;
  3668. /**
  3669. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  3670. * @param otherColor defines the second operand
  3671. * @param result defines Color3 object to store the result into
  3672. * @returns the unmodified current Color3
  3673. */
  3674. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3675. /**
  3676. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  3677. * @param otherColor defines the second operand
  3678. * @returns the new Color3
  3679. */
  3680. subtract(otherColor: DeepImmutable<Color3>): Color3;
  3681. /**
  3682. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  3683. * @param otherColor defines the second operand
  3684. * @param result defines Color3 object to store the result into
  3685. * @returns the unmodified current Color3
  3686. */
  3687. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  3688. /**
  3689. * Copy the current object
  3690. * @returns a new Color3 copied the current one
  3691. */
  3692. clone(): Color3;
  3693. /**
  3694. * Copies the rgb values from the source in the current Color3
  3695. * @param source defines the source Color3 object
  3696. * @returns the updated Color3 object
  3697. */
  3698. copyFrom(source: DeepImmutable<Color3>): Color3;
  3699. /**
  3700. * Updates the Color3 rgb values from the given floats
  3701. * @param r defines the red component to read from
  3702. * @param g defines the green component to read from
  3703. * @param b defines the blue component to read from
  3704. * @returns the current Color3 object
  3705. */
  3706. copyFromFloats(r: number, g: number, b: number): Color3;
  3707. /**
  3708. * Updates the Color3 rgb values from the given floats
  3709. * @param r defines the red component to read from
  3710. * @param g defines the green component to read from
  3711. * @param b defines the blue component to read from
  3712. * @returns the current Color3 object
  3713. */
  3714. set(r: number, g: number, b: number): Color3;
  3715. /**
  3716. * Compute the Color3 hexadecimal code as a string
  3717. * @returns a string containing the hexadecimal representation of the Color3 object
  3718. */
  3719. toHexString(): string;
  3720. /**
  3721. * Computes a new Color3 converted from the current one to linear space
  3722. * @returns a new Color3 object
  3723. */
  3724. toLinearSpace(): Color3;
  3725. /**
  3726. * Converts current color in rgb space to HSV values
  3727. * @returns a new color3 representing the HSV values
  3728. */
  3729. toHSV(): Color3;
  3730. /**
  3731. * Converts current color in rgb space to HSV values
  3732. * @param result defines the Color3 where to store the HSV values
  3733. */
  3734. toHSVToRef(result: Color3): void;
  3735. /**
  3736. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  3737. * @param convertedColor defines the Color3 object where to store the linear space version
  3738. * @returns the unmodified Color3
  3739. */
  3740. toLinearSpaceToRef(convertedColor: Color3): Color3;
  3741. /**
  3742. * Computes a new Color3 converted from the current one to gamma space
  3743. * @returns a new Color3 object
  3744. */
  3745. toGammaSpace(): Color3;
  3746. /**
  3747. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  3748. * @param convertedColor defines the Color3 object where to store the gamma space version
  3749. * @returns the unmodified Color3
  3750. */
  3751. toGammaSpaceToRef(convertedColor: Color3): Color3;
  3752. private static _BlackReadOnly;
  3753. /**
  3754. * Convert Hue, saturation and value to a Color3 (RGB)
  3755. * @param hue defines the hue
  3756. * @param saturation defines the saturation
  3757. * @param value defines the value
  3758. * @param result defines the Color3 where to store the RGB values
  3759. */
  3760. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  3761. /**
  3762. * Creates a new Color3 from the string containing valid hexadecimal values
  3763. * @param hex defines a string containing valid hexadecimal values
  3764. * @returns a new Color3 object
  3765. */
  3766. static FromHexString(hex: string): Color3;
  3767. /**
  3768. * Creates a new Color3 from the starting index of the given array
  3769. * @param array defines the source array
  3770. * @param offset defines an offset in the source array
  3771. * @returns a new Color3 object
  3772. */
  3773. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  3774. /**
  3775. * Creates a new Color3 from integer values (< 256)
  3776. * @param r defines the red component to read from (value between 0 and 255)
  3777. * @param g defines the green component to read from (value between 0 and 255)
  3778. * @param b defines the blue component to read from (value between 0 and 255)
  3779. * @returns a new Color3 object
  3780. */
  3781. static FromInts(r: number, g: number, b: number): Color3;
  3782. /**
  3783. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3784. * @param start defines the start Color3 value
  3785. * @param end defines the end Color3 value
  3786. * @param amount defines the gradient value between start and end
  3787. * @returns a new Color3 object
  3788. */
  3789. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  3790. /**
  3791. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  3792. * @param left defines the start value
  3793. * @param right defines the end value
  3794. * @param amount defines the gradient factor
  3795. * @param result defines the Color3 object where to store the result
  3796. */
  3797. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  3798. /**
  3799. * Returns a Color3 value containing a red color
  3800. * @returns a new Color3 object
  3801. */
  3802. static Red(): Color3;
  3803. /**
  3804. * Returns a Color3 value containing a green color
  3805. * @returns a new Color3 object
  3806. */
  3807. static Green(): Color3;
  3808. /**
  3809. * Returns a Color3 value containing a blue color
  3810. * @returns a new Color3 object
  3811. */
  3812. static Blue(): Color3;
  3813. /**
  3814. * Returns a Color3 value containing a black color
  3815. * @returns a new Color3 object
  3816. */
  3817. static Black(): Color3;
  3818. /**
  3819. * Gets a Color3 value containing a black color that must not be updated
  3820. */
  3821. static readonly BlackReadOnly: DeepImmutable<Color3>;
  3822. /**
  3823. * Returns a Color3 value containing a white color
  3824. * @returns a new Color3 object
  3825. */
  3826. static White(): Color3;
  3827. /**
  3828. * Returns a Color3 value containing a purple color
  3829. * @returns a new Color3 object
  3830. */
  3831. static Purple(): Color3;
  3832. /**
  3833. * Returns a Color3 value containing a magenta color
  3834. * @returns a new Color3 object
  3835. */
  3836. static Magenta(): Color3;
  3837. /**
  3838. * Returns a Color3 value containing a yellow color
  3839. * @returns a new Color3 object
  3840. */
  3841. static Yellow(): Color3;
  3842. /**
  3843. * Returns a Color3 value containing a gray color
  3844. * @returns a new Color3 object
  3845. */
  3846. static Gray(): Color3;
  3847. /**
  3848. * Returns a Color3 value containing a teal color
  3849. * @returns a new Color3 object
  3850. */
  3851. static Teal(): Color3;
  3852. /**
  3853. * Returns a Color3 value containing a random color
  3854. * @returns a new Color3 object
  3855. */
  3856. static Random(): Color3;
  3857. }
  3858. /**
  3859. * Class used to hold a RBGA color
  3860. */
  3861. export class Color4 {
  3862. /**
  3863. * Defines the red component (between 0 and 1, default is 0)
  3864. */
  3865. r: number;
  3866. /**
  3867. * Defines the green component (between 0 and 1, default is 0)
  3868. */
  3869. g: number;
  3870. /**
  3871. * Defines the blue component (between 0 and 1, default is 0)
  3872. */
  3873. b: number;
  3874. /**
  3875. * Defines the alpha component (between 0 and 1, default is 1)
  3876. */
  3877. a: number;
  3878. /**
  3879. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  3880. * @param r defines the red component (between 0 and 1, default is 0)
  3881. * @param g defines the green component (between 0 and 1, default is 0)
  3882. * @param b defines the blue component (between 0 and 1, default is 0)
  3883. * @param a defines the alpha component (between 0 and 1, default is 1)
  3884. */
  3885. constructor(
  3886. /**
  3887. * Defines the red component (between 0 and 1, default is 0)
  3888. */
  3889. r?: number,
  3890. /**
  3891. * Defines the green component (between 0 and 1, default is 0)
  3892. */
  3893. g?: number,
  3894. /**
  3895. * Defines the blue component (between 0 and 1, default is 0)
  3896. */
  3897. b?: number,
  3898. /**
  3899. * Defines the alpha component (between 0 and 1, default is 1)
  3900. */
  3901. a?: number);
  3902. /**
  3903. * Adds in place the given Color4 values to the current Color4 object
  3904. * @param right defines the second operand
  3905. * @returns the current updated Color4 object
  3906. */
  3907. addInPlace(right: DeepImmutable<Color4>): Color4;
  3908. /**
  3909. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  3910. * @returns the new array
  3911. */
  3912. asArray(): number[];
  3913. /**
  3914. * Stores from the starting index in the given array the Color4 successive values
  3915. * @param array defines the array where to store the r,g,b components
  3916. * @param index defines an optional index in the target array to define where to start storing values
  3917. * @returns the current Color4 object
  3918. */
  3919. toArray(array: number[], index?: number): Color4;
  3920. /**
  3921. * Determines equality between Color4 objects
  3922. * @param otherColor defines the second operand
  3923. * @returns true if the rgba values are equal to the given ones
  3924. */
  3925. equals(otherColor: DeepImmutable<Color4>): boolean;
  3926. /**
  3927. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  3928. * @param right defines the second operand
  3929. * @returns a new Color4 object
  3930. */
  3931. add(right: DeepImmutable<Color4>): Color4;
  3932. /**
  3933. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  3934. * @param right defines the second operand
  3935. * @returns a new Color4 object
  3936. */
  3937. subtract(right: DeepImmutable<Color4>): Color4;
  3938. /**
  3939. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  3940. * @param right defines the second operand
  3941. * @param result defines the Color4 object where to store the result
  3942. * @returns the current Color4 object
  3943. */
  3944. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  3945. /**
  3946. * Creates a new Color4 with the current Color4 values multiplied by scale
  3947. * @param scale defines the scaling factor to apply
  3948. * @returns a new Color4 object
  3949. */
  3950. scale(scale: number): Color4;
  3951. /**
  3952. * Multiplies the current Color4 values by scale and stores the result in "result"
  3953. * @param scale defines the scaling factor to apply
  3954. * @param result defines the Color4 object where to store the result
  3955. * @returns the current unmodified Color4
  3956. */
  3957. scaleToRef(scale: number, result: Color4): Color4;
  3958. /**
  3959. * Scale the current Color4 values by a factor and add the result to a given Color4
  3960. * @param scale defines the scale factor
  3961. * @param result defines the Color4 object where to store the result
  3962. * @returns the unmodified current Color4
  3963. */
  3964. scaleAndAddToRef(scale: number, result: Color4): Color4;
  3965. /**
  3966. * Clamps the rgb values by the min and max values and stores the result into "result"
  3967. * @param min defines minimum clamping value (default is 0)
  3968. * @param max defines maximum clamping value (default is 1)
  3969. * @param result defines color to store the result into.
  3970. * @returns the cuurent Color4
  3971. */
  3972. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  3973. /**
  3974. * Multipy an Color4 value by another and return a new Color4 object
  3975. * @param color defines the Color4 value to multiply by
  3976. * @returns a new Color4 object
  3977. */
  3978. multiply(color: Color4): Color4;
  3979. /**
  3980. * Multipy a Color4 value by another and push the result in a reference value
  3981. * @param color defines the Color4 value to multiply by
  3982. * @param result defines the Color4 to fill the result in
  3983. * @returns the result Color4
  3984. */
  3985. multiplyToRef(color: Color4, result: Color4): Color4;
  3986. /**
  3987. * Creates a string with the Color4 current values
  3988. * @returns the string representation of the Color4 object
  3989. */
  3990. toString(): string;
  3991. /**
  3992. * Returns the string "Color4"
  3993. * @returns "Color4"
  3994. */
  3995. getClassName(): string;
  3996. /**
  3997. * Compute the Color4 hash code
  3998. * @returns an unique number that can be used to hash Color4 objects
  3999. */
  4000. getHashCode(): number;
  4001. /**
  4002. * Creates a new Color4 copied from the current one
  4003. * @returns a new Color4 object
  4004. */
  4005. clone(): Color4;
  4006. /**
  4007. * Copies the given Color4 values into the current one
  4008. * @param source defines the source Color4 object
  4009. * @returns the current updated Color4 object
  4010. */
  4011. copyFrom(source: Color4): Color4;
  4012. /**
  4013. * Copies the given float values into the current one
  4014. * @param r defines the red component to read from
  4015. * @param g defines the green component to read from
  4016. * @param b defines the blue component to read from
  4017. * @param a defines the alpha component to read from
  4018. * @returns the current updated Color4 object
  4019. */
  4020. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  4021. /**
  4022. * Copies the given float values into the current one
  4023. * @param r defines the red component to read from
  4024. * @param g defines the green component to read from
  4025. * @param b defines the blue component to read from
  4026. * @param a defines the alpha component to read from
  4027. * @returns the current updated Color4 object
  4028. */
  4029. set(r: number, g: number, b: number, a: number): Color4;
  4030. /**
  4031. * Compute the Color4 hexadecimal code as a string
  4032. * @returns a string containing the hexadecimal representation of the Color4 object
  4033. */
  4034. toHexString(): string;
  4035. /**
  4036. * Computes a new Color4 converted from the current one to linear space
  4037. * @returns a new Color4 object
  4038. */
  4039. toLinearSpace(): Color4;
  4040. /**
  4041. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  4042. * @param convertedColor defines the Color4 object where to store the linear space version
  4043. * @returns the unmodified Color4
  4044. */
  4045. toLinearSpaceToRef(convertedColor: Color4): Color4;
  4046. /**
  4047. * Computes a new Color4 converted from the current one to gamma space
  4048. * @returns a new Color4 object
  4049. */
  4050. toGammaSpace(): Color4;
  4051. /**
  4052. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  4053. * @param convertedColor defines the Color4 object where to store the gamma space version
  4054. * @returns the unmodified Color4
  4055. */
  4056. toGammaSpaceToRef(convertedColor: Color4): Color4;
  4057. /**
  4058. * Creates a new Color4 from the string containing valid hexadecimal values
  4059. * @param hex defines a string containing valid hexadecimal values
  4060. * @returns a new Color4 object
  4061. */
  4062. static FromHexString(hex: string): Color4;
  4063. /**
  4064. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4065. * @param left defines the start value
  4066. * @param right defines the end value
  4067. * @param amount defines the gradient factor
  4068. * @returns a new Color4 object
  4069. */
  4070. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  4071. /**
  4072. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  4073. * @param left defines the start value
  4074. * @param right defines the end value
  4075. * @param amount defines the gradient factor
  4076. * @param result defines the Color4 object where to store data
  4077. */
  4078. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  4079. /**
  4080. * Creates a new Color4 from a Color3 and an alpha value
  4081. * @param color3 defines the source Color3 to read from
  4082. * @param alpha defines the alpha component (1.0 by default)
  4083. * @returns a new Color4 object
  4084. */
  4085. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  4086. /**
  4087. * Creates a new Color4 from the starting index element of the given array
  4088. * @param array defines the source array to read from
  4089. * @param offset defines the offset in the source array
  4090. * @returns a new Color4 object
  4091. */
  4092. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  4093. /**
  4094. * Creates a new Color3 from integer values (< 256)
  4095. * @param r defines the red component to read from (value between 0 and 255)
  4096. * @param g defines the green component to read from (value between 0 and 255)
  4097. * @param b defines the blue component to read from (value between 0 and 255)
  4098. * @param a defines the alpha component to read from (value between 0 and 255)
  4099. * @returns a new Color3 object
  4100. */
  4101. static FromInts(r: number, g: number, b: number, a: number): Color4;
  4102. /**
  4103. * Check the content of a given array and convert it to an array containing RGBA data
  4104. * If the original array was already containing count * 4 values then it is returned directly
  4105. * @param colors defines the array to check
  4106. * @param count defines the number of RGBA data to expect
  4107. * @returns an array containing count * 4 values (RGBA)
  4108. */
  4109. static CheckColors4(colors: number[], count: number): number[];
  4110. }
  4111. /**
  4112. * @hidden
  4113. */
  4114. export class TmpColors {
  4115. static Color3: Color3[];
  4116. static Color4: Color4[];
  4117. }
  4118. }
  4119. declare module "babylonjs/Maths/sphericalPolynomial" {
  4120. import { Vector3 } from "babylonjs/Maths/math.vector";
  4121. import { Color3 } from "babylonjs/Maths/math.color";
  4122. /**
  4123. * Class representing spherical harmonics coefficients to the 3rd degree
  4124. */
  4125. export class SphericalHarmonics {
  4126. /**
  4127. * Defines whether or not the harmonics have been prescaled for rendering.
  4128. */
  4129. preScaled: boolean;
  4130. /**
  4131. * The l0,0 coefficients of the spherical harmonics
  4132. */
  4133. l00: Vector3;
  4134. /**
  4135. * The l1,-1 coefficients of the spherical harmonics
  4136. */
  4137. l1_1: Vector3;
  4138. /**
  4139. * The l1,0 coefficients of the spherical harmonics
  4140. */
  4141. l10: Vector3;
  4142. /**
  4143. * The l1,1 coefficients of the spherical harmonics
  4144. */
  4145. l11: Vector3;
  4146. /**
  4147. * The l2,-2 coefficients of the spherical harmonics
  4148. */
  4149. l2_2: Vector3;
  4150. /**
  4151. * The l2,-1 coefficients of the spherical harmonics
  4152. */
  4153. l2_1: Vector3;
  4154. /**
  4155. * The l2,0 coefficients of the spherical harmonics
  4156. */
  4157. l20: Vector3;
  4158. /**
  4159. * The l2,1 coefficients of the spherical harmonics
  4160. */
  4161. l21: Vector3;
  4162. /**
  4163. * The l2,2 coefficients of the spherical harmonics
  4164. */
  4165. l22: Vector3;
  4166. /**
  4167. * Adds a light to the spherical harmonics
  4168. * @param direction the direction of the light
  4169. * @param color the color of the light
  4170. * @param deltaSolidAngle the delta solid angle of the light
  4171. */
  4172. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  4173. /**
  4174. * Scales the spherical harmonics by the given amount
  4175. * @param scale the amount to scale
  4176. */
  4177. scaleInPlace(scale: number): void;
  4178. /**
  4179. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  4180. *
  4181. * ```
  4182. * E_lm = A_l * L_lm
  4183. * ```
  4184. *
  4185. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  4186. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  4187. * the scaling factors are given in equation 9.
  4188. */
  4189. convertIncidentRadianceToIrradiance(): void;
  4190. /**
  4191. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  4192. *
  4193. * ```
  4194. * L = (1/pi) * E * rho
  4195. * ```
  4196. *
  4197. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  4198. */
  4199. convertIrradianceToLambertianRadiance(): void;
  4200. /**
  4201. * Integrates the reconstruction coefficients directly in to the SH preventing further
  4202. * required operations at run time.
  4203. *
  4204. * This is simply done by scaling back the SH with Ylm constants parameter.
  4205. * The trigonometric part being applied by the shader at run time.
  4206. */
  4207. preScaleForRendering(): void;
  4208. /**
  4209. * Constructs a spherical harmonics from an array.
  4210. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  4211. * @returns the spherical harmonics
  4212. */
  4213. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  4214. /**
  4215. * Gets the spherical harmonics from polynomial
  4216. * @param polynomial the spherical polynomial
  4217. * @returns the spherical harmonics
  4218. */
  4219. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  4220. }
  4221. /**
  4222. * Class representing spherical polynomial coefficients to the 3rd degree
  4223. */
  4224. export class SphericalPolynomial {
  4225. private _harmonics;
  4226. /**
  4227. * The spherical harmonics used to create the polynomials.
  4228. */
  4229. readonly preScaledHarmonics: SphericalHarmonics;
  4230. /**
  4231. * The x coefficients of the spherical polynomial
  4232. */
  4233. x: Vector3;
  4234. /**
  4235. * The y coefficients of the spherical polynomial
  4236. */
  4237. y: Vector3;
  4238. /**
  4239. * The z coefficients of the spherical polynomial
  4240. */
  4241. z: Vector3;
  4242. /**
  4243. * The xx coefficients of the spherical polynomial
  4244. */
  4245. xx: Vector3;
  4246. /**
  4247. * The yy coefficients of the spherical polynomial
  4248. */
  4249. yy: Vector3;
  4250. /**
  4251. * The zz coefficients of the spherical polynomial
  4252. */
  4253. zz: Vector3;
  4254. /**
  4255. * The xy coefficients of the spherical polynomial
  4256. */
  4257. xy: Vector3;
  4258. /**
  4259. * The yz coefficients of the spherical polynomial
  4260. */
  4261. yz: Vector3;
  4262. /**
  4263. * The zx coefficients of the spherical polynomial
  4264. */
  4265. zx: Vector3;
  4266. /**
  4267. * Adds an ambient color to the spherical polynomial
  4268. * @param color the color to add
  4269. */
  4270. addAmbient(color: Color3): void;
  4271. /**
  4272. * Scales the spherical polynomial by the given amount
  4273. * @param scale the amount to scale
  4274. */
  4275. scaleInPlace(scale: number): void;
  4276. /**
  4277. * Gets the spherical polynomial from harmonics
  4278. * @param harmonics the spherical harmonics
  4279. * @returns the spherical polynomial
  4280. */
  4281. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  4282. /**
  4283. * Constructs a spherical polynomial from an array.
  4284. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  4285. * @returns the spherical polynomial
  4286. */
  4287. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  4288. }
  4289. }
  4290. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  4291. /**
  4292. * Define options used to create a render target texture
  4293. */
  4294. export class RenderTargetCreationOptions {
  4295. /**
  4296. * Specifies is mipmaps must be generated
  4297. */
  4298. generateMipMaps?: boolean;
  4299. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  4300. generateDepthBuffer?: boolean;
  4301. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  4302. generateStencilBuffer?: boolean;
  4303. /** Defines texture type (int by default) */
  4304. type?: number;
  4305. /** Defines sampling mode (trilinear by default) */
  4306. samplingMode?: number;
  4307. /** Defines format (RGBA by default) */
  4308. format?: number;
  4309. }
  4310. }
  4311. declare module "babylonjs/Instrumentation/timeToken" {
  4312. import { Nullable } from "babylonjs/types";
  4313. /**
  4314. * @hidden
  4315. **/
  4316. export class _TimeToken {
  4317. _startTimeQuery: Nullable<WebGLQuery>;
  4318. _endTimeQuery: Nullable<WebGLQuery>;
  4319. _timeElapsedQuery: Nullable<WebGLQuery>;
  4320. _timeElapsedQueryEnded: boolean;
  4321. }
  4322. }
  4323. declare module "babylonjs/Engines/constants" {
  4324. /** Defines the cross module used constants to avoid circular dependncies */
  4325. export class Constants {
  4326. /** Defines that alpha blending is disabled */
  4327. static readonly ALPHA_DISABLE: number;
  4328. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4329. static readonly ALPHA_ADD: number;
  4330. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4331. static readonly ALPHA_COMBINE: number;
  4332. /** Defines that alpha blending to DEST - SRC * DEST */
  4333. static readonly ALPHA_SUBTRACT: number;
  4334. /** Defines that alpha blending to SRC * DEST */
  4335. static readonly ALPHA_MULTIPLY: number;
  4336. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4337. static readonly ALPHA_MAXIMIZED: number;
  4338. /** Defines that alpha blending to SRC + DEST */
  4339. static readonly ALPHA_ONEONE: number;
  4340. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4341. static readonly ALPHA_PREMULTIPLIED: number;
  4342. /**
  4343. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4344. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4345. */
  4346. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4347. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4348. static readonly ALPHA_INTERPOLATE: number;
  4349. /**
  4350. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4351. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4352. */
  4353. static readonly ALPHA_SCREENMODE: number;
  4354. /**
  4355. * Defines that alpha blending to SRC + DST
  4356. * Alpha will be set to SRC ALPHA + DST ALPHA
  4357. */
  4358. static readonly ALPHA_ONEONE_ONEONE: number;
  4359. /**
  4360. * Defines that alpha blending to SRC * DST ALPHA + DST
  4361. * Alpha will be set to 0
  4362. */
  4363. static readonly ALPHA_ALPHATOCOLOR: number;
  4364. /**
  4365. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  4366. */
  4367. static readonly ALPHA_REVERSEONEMINUS: number;
  4368. /**
  4369. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  4370. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  4371. */
  4372. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  4373. /**
  4374. * Defines that alpha blending to SRC + DST
  4375. * Alpha will be set to SRC ALPHA
  4376. */
  4377. static readonly ALPHA_ONEONE_ONEZERO: number;
  4378. /** Defines that alpha blending equation a SUM */
  4379. static readonly ALPHA_EQUATION_ADD: number;
  4380. /** Defines that alpha blending equation a SUBSTRACTION */
  4381. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  4382. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  4383. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  4384. /** Defines that alpha blending equation a MAX operation */
  4385. static readonly ALPHA_EQUATION_MAX: number;
  4386. /** Defines that alpha blending equation a MIN operation */
  4387. static readonly ALPHA_EQUATION_MIN: number;
  4388. /**
  4389. * Defines that alpha blending equation a DARKEN operation:
  4390. * It takes the min of the src and sums the alpha channels.
  4391. */
  4392. static readonly ALPHA_EQUATION_DARKEN: number;
  4393. /** Defines that the ressource is not delayed*/
  4394. static readonly DELAYLOADSTATE_NONE: number;
  4395. /** Defines that the ressource was successfully delay loaded */
  4396. static readonly DELAYLOADSTATE_LOADED: number;
  4397. /** Defines that the ressource is currently delay loading */
  4398. static readonly DELAYLOADSTATE_LOADING: number;
  4399. /** Defines that the ressource is delayed and has not started loading */
  4400. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4401. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4402. static readonly NEVER: number;
  4403. /** 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 */
  4404. static readonly ALWAYS: number;
  4405. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4406. static readonly LESS: number;
  4407. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4408. static readonly EQUAL: number;
  4409. /** 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 */
  4410. static readonly LEQUAL: number;
  4411. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4412. static readonly GREATER: number;
  4413. /** 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 */
  4414. static readonly GEQUAL: number;
  4415. /** 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 */
  4416. static readonly NOTEQUAL: number;
  4417. /** Passed to stencilOperation to specify that stencil value must be kept */
  4418. static readonly KEEP: number;
  4419. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4420. static readonly REPLACE: number;
  4421. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4422. static readonly INCR: number;
  4423. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4424. static readonly DECR: number;
  4425. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4426. static readonly INVERT: number;
  4427. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4428. static readonly INCR_WRAP: number;
  4429. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4430. static readonly DECR_WRAP: number;
  4431. /** Texture is not repeating outside of 0..1 UVs */
  4432. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4433. /** Texture is repeating outside of 0..1 UVs */
  4434. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4435. /** Texture is repeating and mirrored */
  4436. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4437. /** ALPHA */
  4438. static readonly TEXTUREFORMAT_ALPHA: number;
  4439. /** LUMINANCE */
  4440. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4441. /** LUMINANCE_ALPHA */
  4442. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4443. /** RGB */
  4444. static readonly TEXTUREFORMAT_RGB: number;
  4445. /** RGBA */
  4446. static readonly TEXTUREFORMAT_RGBA: number;
  4447. /** RED */
  4448. static readonly TEXTUREFORMAT_RED: number;
  4449. /** RED (2nd reference) */
  4450. static readonly TEXTUREFORMAT_R: number;
  4451. /** RG */
  4452. static readonly TEXTUREFORMAT_RG: number;
  4453. /** RED_INTEGER */
  4454. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4455. /** RED_INTEGER (2nd reference) */
  4456. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4457. /** RG_INTEGER */
  4458. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4459. /** RGB_INTEGER */
  4460. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4461. /** RGBA_INTEGER */
  4462. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4463. /** UNSIGNED_BYTE */
  4464. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4465. /** UNSIGNED_BYTE (2nd reference) */
  4466. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4467. /** FLOAT */
  4468. static readonly TEXTURETYPE_FLOAT: number;
  4469. /** HALF_FLOAT */
  4470. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4471. /** BYTE */
  4472. static readonly TEXTURETYPE_BYTE: number;
  4473. /** SHORT */
  4474. static readonly TEXTURETYPE_SHORT: number;
  4475. /** UNSIGNED_SHORT */
  4476. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4477. /** INT */
  4478. static readonly TEXTURETYPE_INT: number;
  4479. /** UNSIGNED_INT */
  4480. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4481. /** UNSIGNED_SHORT_4_4_4_4 */
  4482. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4483. /** UNSIGNED_SHORT_5_5_5_1 */
  4484. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4485. /** UNSIGNED_SHORT_5_6_5 */
  4486. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4487. /** UNSIGNED_INT_2_10_10_10_REV */
  4488. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4489. /** UNSIGNED_INT_24_8 */
  4490. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4491. /** UNSIGNED_INT_10F_11F_11F_REV */
  4492. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4493. /** UNSIGNED_INT_5_9_9_9_REV */
  4494. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4495. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4496. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4497. /** nearest is mag = nearest and min = nearest and mip = linear */
  4498. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4499. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4500. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4501. /** Trilinear is mag = linear and min = linear and mip = linear */
  4502. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4503. /** nearest is mag = nearest and min = nearest and mip = linear */
  4504. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4505. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4506. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4507. /** Trilinear is mag = linear and min = linear and mip = linear */
  4508. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4509. /** mag = nearest and min = nearest and mip = nearest */
  4510. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4511. /** mag = nearest and min = linear and mip = nearest */
  4512. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4513. /** mag = nearest and min = linear and mip = linear */
  4514. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4515. /** mag = nearest and min = linear and mip = none */
  4516. static readonly TEXTURE_NEAREST_LINEAR: number;
  4517. /** mag = nearest and min = nearest and mip = none */
  4518. static readonly TEXTURE_NEAREST_NEAREST: number;
  4519. /** mag = linear and min = nearest and mip = nearest */
  4520. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4521. /** mag = linear and min = nearest and mip = linear */
  4522. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4523. /** mag = linear and min = linear and mip = none */
  4524. static readonly TEXTURE_LINEAR_LINEAR: number;
  4525. /** mag = linear and min = nearest and mip = none */
  4526. static readonly TEXTURE_LINEAR_NEAREST: number;
  4527. /** Explicit coordinates mode */
  4528. static readonly TEXTURE_EXPLICIT_MODE: number;
  4529. /** Spherical coordinates mode */
  4530. static readonly TEXTURE_SPHERICAL_MODE: number;
  4531. /** Planar coordinates mode */
  4532. static readonly TEXTURE_PLANAR_MODE: number;
  4533. /** Cubic coordinates mode */
  4534. static readonly TEXTURE_CUBIC_MODE: number;
  4535. /** Projection coordinates mode */
  4536. static readonly TEXTURE_PROJECTION_MODE: number;
  4537. /** Skybox coordinates mode */
  4538. static readonly TEXTURE_SKYBOX_MODE: number;
  4539. /** Inverse Cubic coordinates mode */
  4540. static readonly TEXTURE_INVCUBIC_MODE: number;
  4541. /** Equirectangular coordinates mode */
  4542. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4543. /** Equirectangular Fixed coordinates mode */
  4544. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4545. /** Equirectangular Fixed Mirrored coordinates mode */
  4546. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4547. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4548. static readonly SCALEMODE_FLOOR: number;
  4549. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4550. static readonly SCALEMODE_NEAREST: number;
  4551. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4552. static readonly SCALEMODE_CEILING: number;
  4553. /**
  4554. * The dirty texture flag value
  4555. */
  4556. static readonly MATERIAL_TextureDirtyFlag: number;
  4557. /**
  4558. * The dirty light flag value
  4559. */
  4560. static readonly MATERIAL_LightDirtyFlag: number;
  4561. /**
  4562. * The dirty fresnel flag value
  4563. */
  4564. static readonly MATERIAL_FresnelDirtyFlag: number;
  4565. /**
  4566. * The dirty attribute flag value
  4567. */
  4568. static readonly MATERIAL_AttributesDirtyFlag: number;
  4569. /**
  4570. * The dirty misc flag value
  4571. */
  4572. static readonly MATERIAL_MiscDirtyFlag: number;
  4573. /**
  4574. * The all dirty flag value
  4575. */
  4576. static readonly MATERIAL_AllDirtyFlag: number;
  4577. /**
  4578. * Returns the triangle fill mode
  4579. */
  4580. static readonly MATERIAL_TriangleFillMode: number;
  4581. /**
  4582. * Returns the wireframe mode
  4583. */
  4584. static readonly MATERIAL_WireFrameFillMode: number;
  4585. /**
  4586. * Returns the point fill mode
  4587. */
  4588. static readonly MATERIAL_PointFillMode: number;
  4589. /**
  4590. * Returns the point list draw mode
  4591. */
  4592. static readonly MATERIAL_PointListDrawMode: number;
  4593. /**
  4594. * Returns the line list draw mode
  4595. */
  4596. static readonly MATERIAL_LineListDrawMode: number;
  4597. /**
  4598. * Returns the line loop draw mode
  4599. */
  4600. static readonly MATERIAL_LineLoopDrawMode: number;
  4601. /**
  4602. * Returns the line strip draw mode
  4603. */
  4604. static readonly MATERIAL_LineStripDrawMode: number;
  4605. /**
  4606. * Returns the triangle strip draw mode
  4607. */
  4608. static readonly MATERIAL_TriangleStripDrawMode: number;
  4609. /**
  4610. * Returns the triangle fan draw mode
  4611. */
  4612. static readonly MATERIAL_TriangleFanDrawMode: number;
  4613. /**
  4614. * Stores the clock-wise side orientation
  4615. */
  4616. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4617. /**
  4618. * Stores the counter clock-wise side orientation
  4619. */
  4620. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4621. /**
  4622. * Nothing
  4623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4624. */
  4625. static readonly ACTION_NothingTrigger: number;
  4626. /**
  4627. * On pick
  4628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4629. */
  4630. static readonly ACTION_OnPickTrigger: number;
  4631. /**
  4632. * On left pick
  4633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4634. */
  4635. static readonly ACTION_OnLeftPickTrigger: number;
  4636. /**
  4637. * On right pick
  4638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4639. */
  4640. static readonly ACTION_OnRightPickTrigger: number;
  4641. /**
  4642. * On center pick
  4643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4644. */
  4645. static readonly ACTION_OnCenterPickTrigger: number;
  4646. /**
  4647. * On pick down
  4648. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4649. */
  4650. static readonly ACTION_OnPickDownTrigger: number;
  4651. /**
  4652. * On double pick
  4653. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4654. */
  4655. static readonly ACTION_OnDoublePickTrigger: number;
  4656. /**
  4657. * On pick up
  4658. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4659. */
  4660. static readonly ACTION_OnPickUpTrigger: number;
  4661. /**
  4662. * On pick out.
  4663. * This trigger will only be raised if you also declared a OnPickDown
  4664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4665. */
  4666. static readonly ACTION_OnPickOutTrigger: number;
  4667. /**
  4668. * On long press
  4669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4670. */
  4671. static readonly ACTION_OnLongPressTrigger: number;
  4672. /**
  4673. * On pointer over
  4674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4675. */
  4676. static readonly ACTION_OnPointerOverTrigger: number;
  4677. /**
  4678. * On pointer out
  4679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4680. */
  4681. static readonly ACTION_OnPointerOutTrigger: number;
  4682. /**
  4683. * On every frame
  4684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4685. */
  4686. static readonly ACTION_OnEveryFrameTrigger: number;
  4687. /**
  4688. * On intersection enter
  4689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4690. */
  4691. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4692. /**
  4693. * On intersection exit
  4694. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4695. */
  4696. static readonly ACTION_OnIntersectionExitTrigger: number;
  4697. /**
  4698. * On key down
  4699. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4700. */
  4701. static readonly ACTION_OnKeyDownTrigger: number;
  4702. /**
  4703. * On key up
  4704. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4705. */
  4706. static readonly ACTION_OnKeyUpTrigger: number;
  4707. /**
  4708. * Billboard mode will only apply to Y axis
  4709. */
  4710. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4711. /**
  4712. * Billboard mode will apply to all axes
  4713. */
  4714. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4715. /**
  4716. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4717. */
  4718. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4719. /**
  4720. * Gets or sets base Assets URL
  4721. */
  4722. static PARTICLES_BaseAssetsUrl: string;
  4723. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4724. * Test order :
  4725. * Is the bounding sphere outside the frustum ?
  4726. * If not, are the bounding box vertices outside the frustum ?
  4727. * It not, then the cullable object is in the frustum.
  4728. */
  4729. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4730. /** Culling strategy : Bounding Sphere Only.
  4731. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4732. * It's also less accurate than the standard because some not visible objects can still be selected.
  4733. * Test : is the bounding sphere outside the frustum ?
  4734. * If not, then the cullable object is in the frustum.
  4735. */
  4736. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4737. /** Culling strategy : Optimistic Inclusion.
  4738. * This in an inclusion test first, then the standard exclusion test.
  4739. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4740. * 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.
  4741. * Anyway, it's as accurate as the standard strategy.
  4742. * Test :
  4743. * Is the cullable object bounding sphere center in the frustum ?
  4744. * If not, apply the default culling strategy.
  4745. */
  4746. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4747. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4748. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4749. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4750. * 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.
  4751. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4752. * Test :
  4753. * Is the cullable object bounding sphere center in the frustum ?
  4754. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4755. */
  4756. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4757. /**
  4758. * No logging while loading
  4759. */
  4760. static readonly SCENELOADER_NO_LOGGING: number;
  4761. /**
  4762. * Minimal logging while loading
  4763. */
  4764. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4765. /**
  4766. * Summary logging while loading
  4767. */
  4768. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4769. /**
  4770. * Detailled logging while loading
  4771. */
  4772. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4773. }
  4774. }
  4775. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  4776. import { Nullable } from "babylonjs/types";
  4777. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  4778. /**
  4779. * This represents the required contract to create a new type of texture loader.
  4780. */
  4781. export interface IInternalTextureLoader {
  4782. /**
  4783. * Defines wether the loader supports cascade loading the different faces.
  4784. */
  4785. supportCascades: boolean;
  4786. /**
  4787. * This returns if the loader support the current file information.
  4788. * @param extension defines the file extension of the file being loaded
  4789. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4790. * @param fallback defines the fallback internal texture if any
  4791. * @param isBase64 defines whether the texture is encoded as a base64
  4792. * @param isBuffer defines whether the texture data are stored as a buffer
  4793. * @returns true if the loader can load the specified file
  4794. */
  4795. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  4796. /**
  4797. * Transform the url before loading if required.
  4798. * @param rootUrl the url of the texture
  4799. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4800. * @returns the transformed texture
  4801. */
  4802. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  4803. /**
  4804. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  4805. * @param rootUrl the url of the texture
  4806. * @param textureFormatInUse defines the current compressed format in use iun the engine
  4807. * @returns the fallback texture
  4808. */
  4809. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  4810. /**
  4811. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  4812. * @param data contains the texture data
  4813. * @param texture defines the BabylonJS internal texture
  4814. * @param createPolynomials will be true if polynomials have been requested
  4815. * @param onLoad defines the callback to trigger once the texture is ready
  4816. * @param onError defines the callback to trigger in case of error
  4817. */
  4818. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  4819. /**
  4820. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  4821. * @param data contains the texture data
  4822. * @param texture defines the BabylonJS internal texture
  4823. * @param callback defines the method to call once ready to upload
  4824. */
  4825. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  4826. }
  4827. }
  4828. declare module "babylonjs/Engines/IPipelineContext" {
  4829. /**
  4830. * Class used to store and describe the pipeline context associated with an effect
  4831. */
  4832. export interface IPipelineContext {
  4833. /**
  4834. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  4835. */
  4836. isAsync: boolean;
  4837. /**
  4838. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  4839. */
  4840. isReady: boolean;
  4841. /** @hidden */
  4842. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  4843. }
  4844. }
  4845. declare module "babylonjs/Meshes/dataBuffer" {
  4846. /**
  4847. * Class used to store gfx data (like WebGLBuffer)
  4848. */
  4849. export class DataBuffer {
  4850. /**
  4851. * Gets or sets the number of objects referencing this buffer
  4852. */
  4853. references: number;
  4854. /** Gets or sets the size of the underlying buffer */
  4855. capacity: number;
  4856. /**
  4857. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  4858. */
  4859. is32Bits: boolean;
  4860. /**
  4861. * Gets the underlying buffer
  4862. */
  4863. readonly underlyingResource: any;
  4864. }
  4865. }
  4866. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  4867. /** @hidden */
  4868. export interface IShaderProcessor {
  4869. attributeProcessor?: (attribute: string) => string;
  4870. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  4871. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  4872. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  4873. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  4874. lineProcessor?: (line: string, isFragment: boolean) => string;
  4875. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4876. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  4877. }
  4878. }
  4879. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  4880. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  4881. /** @hidden */
  4882. export interface ProcessingOptions {
  4883. defines: string[];
  4884. indexParameters: any;
  4885. isFragment: boolean;
  4886. shouldUseHighPrecisionShader: boolean;
  4887. supportsUniformBuffers: boolean;
  4888. shadersRepository: string;
  4889. includesShadersStore: {
  4890. [key: string]: string;
  4891. };
  4892. processor?: IShaderProcessor;
  4893. version: string;
  4894. platformName: string;
  4895. lookForClosingBracketForUniformBuffer?: boolean;
  4896. }
  4897. }
  4898. declare module "babylonjs/Misc/stringTools" {
  4899. /**
  4900. * Helper to manipulate strings
  4901. */
  4902. export class StringTools {
  4903. /**
  4904. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  4905. * @param str Source string
  4906. * @param suffix Suffix to search for in the source string
  4907. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4908. */
  4909. static EndsWith(str: string, suffix: string): boolean;
  4910. /**
  4911. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  4912. * @param str Source string
  4913. * @param suffix Suffix to search for in the source string
  4914. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  4915. */
  4916. static StartsWith(str: string, suffix: string): boolean;
  4917. }
  4918. }
  4919. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  4920. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4921. /** @hidden */
  4922. export class ShaderCodeNode {
  4923. line: string;
  4924. children: ShaderCodeNode[];
  4925. additionalDefineKey?: string;
  4926. additionalDefineValue?: string;
  4927. isValid(preprocessors: {
  4928. [key: string]: string;
  4929. }): boolean;
  4930. process(preprocessors: {
  4931. [key: string]: string;
  4932. }, options: ProcessingOptions): string;
  4933. }
  4934. }
  4935. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  4936. /** @hidden */
  4937. export class ShaderCodeCursor {
  4938. private _lines;
  4939. lineIndex: number;
  4940. readonly currentLine: string;
  4941. readonly canRead: boolean;
  4942. lines: string[];
  4943. }
  4944. }
  4945. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  4946. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4947. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  4948. /** @hidden */
  4949. export class ShaderCodeConditionNode extends ShaderCodeNode {
  4950. process(preprocessors: {
  4951. [key: string]: string;
  4952. }, options: ProcessingOptions): string;
  4953. }
  4954. }
  4955. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  4956. /** @hidden */
  4957. export class ShaderDefineExpression {
  4958. isTrue(preprocessors: {
  4959. [key: string]: string;
  4960. }): boolean;
  4961. }
  4962. }
  4963. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  4964. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  4965. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4966. /** @hidden */
  4967. export class ShaderCodeTestNode extends ShaderCodeNode {
  4968. testExpression: ShaderDefineExpression;
  4969. isValid(preprocessors: {
  4970. [key: string]: string;
  4971. }): boolean;
  4972. }
  4973. }
  4974. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  4975. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4976. /** @hidden */
  4977. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  4978. define: string;
  4979. not: boolean;
  4980. constructor(define: string, not?: boolean);
  4981. isTrue(preprocessors: {
  4982. [key: string]: string;
  4983. }): boolean;
  4984. }
  4985. }
  4986. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  4987. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4988. /** @hidden */
  4989. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  4990. leftOperand: ShaderDefineExpression;
  4991. rightOperand: ShaderDefineExpression;
  4992. isTrue(preprocessors: {
  4993. [key: string]: string;
  4994. }): boolean;
  4995. }
  4996. }
  4997. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  4998. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  4999. /** @hidden */
  5000. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  5001. leftOperand: ShaderDefineExpression;
  5002. rightOperand: ShaderDefineExpression;
  5003. isTrue(preprocessors: {
  5004. [key: string]: string;
  5005. }): boolean;
  5006. }
  5007. }
  5008. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  5009. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  5010. /** @hidden */
  5011. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  5012. define: string;
  5013. operand: string;
  5014. testValue: string;
  5015. constructor(define: string, operand: string, testValue: string);
  5016. isTrue(preprocessors: {
  5017. [key: string]: string;
  5018. }): boolean;
  5019. }
  5020. }
  5021. declare module "babylonjs/Misc/loadFileError" {
  5022. import { WebRequest } from "babylonjs/Misc/webRequest";
  5023. /**
  5024. * @ignore
  5025. * Application error to support additional information when loading a file
  5026. */
  5027. export class LoadFileError extends Error {
  5028. /** defines the optional web request */
  5029. request?: WebRequest | undefined;
  5030. private static _setPrototypeOf;
  5031. /**
  5032. * Creates a new LoadFileError
  5033. * @param message defines the message of the error
  5034. * @param request defines the optional web request
  5035. */
  5036. constructor(message: string,
  5037. /** defines the optional web request */
  5038. request?: WebRequest | undefined);
  5039. }
  5040. }
  5041. declare module "babylonjs/Offline/IOfflineProvider" {
  5042. /**
  5043. * Class used to enable access to offline support
  5044. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  5045. */
  5046. export interface IOfflineProvider {
  5047. /**
  5048. * Gets a boolean indicating if scene must be saved in the database
  5049. */
  5050. enableSceneOffline: boolean;
  5051. /**
  5052. * Gets a boolean indicating if textures must be saved in the database
  5053. */
  5054. enableTexturesOffline: boolean;
  5055. /**
  5056. * Open the offline support and make it available
  5057. * @param successCallback defines the callback to call on success
  5058. * @param errorCallback defines the callback to call on error
  5059. */
  5060. open(successCallback: () => void, errorCallback: () => void): void;
  5061. /**
  5062. * Loads an image from the offline support
  5063. * @param url defines the url to load from
  5064. * @param image defines the target DOM image
  5065. */
  5066. loadImage(url: string, image: HTMLImageElement): void;
  5067. /**
  5068. * Loads a file from offline support
  5069. * @param url defines the URL to load from
  5070. * @param sceneLoaded defines a callback to call on success
  5071. * @param progressCallBack defines a callback to call when progress changed
  5072. * @param errorCallback defines a callback to call on error
  5073. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  5074. */
  5075. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  5076. }
  5077. }
  5078. declare module "babylonjs/Misc/filesInputStore" {
  5079. /**
  5080. * Class used to help managing file picking and drag'n'drop
  5081. * File Storage
  5082. */
  5083. export class FilesInputStore {
  5084. /**
  5085. * List of files ready to be loaded
  5086. */
  5087. static FilesToLoad: {
  5088. [key: string]: File;
  5089. };
  5090. }
  5091. }
  5092. declare module "babylonjs/Misc/retryStrategy" {
  5093. import { WebRequest } from "babylonjs/Misc/webRequest";
  5094. /**
  5095. * Class used to define a retry strategy when error happens while loading assets
  5096. */
  5097. export class RetryStrategy {
  5098. /**
  5099. * Function used to defines an exponential back off strategy
  5100. * @param maxRetries defines the maximum number of retries (3 by default)
  5101. * @param baseInterval defines the interval between retries
  5102. * @returns the strategy function to use
  5103. */
  5104. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  5105. }
  5106. }
  5107. declare module "babylonjs/Misc/fileTools" {
  5108. import { WebRequest } from "babylonjs/Misc/webRequest";
  5109. import { Nullable } from "babylonjs/types";
  5110. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  5111. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  5112. /**
  5113. * @hidden
  5114. */
  5115. export class FileTools {
  5116. /**
  5117. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  5118. */
  5119. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  5120. /**
  5121. * Gets or sets the base URL to use to load assets
  5122. */
  5123. static BaseUrl: string;
  5124. /**
  5125. * Default behaviour for cors in the application.
  5126. * It can be a string if the expected behavior is identical in the entire app.
  5127. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  5128. */
  5129. static CorsBehavior: string | ((url: string | string[]) => string);
  5130. /**
  5131. * Gets or sets a function used to pre-process url before using them to load assets
  5132. */
  5133. static PreprocessUrl: (url: string) => string;
  5134. /**
  5135. * Removes unwanted characters from an url
  5136. * @param url defines the url to clean
  5137. * @returns the cleaned url
  5138. */
  5139. private static _CleanUrl;
  5140. /**
  5141. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  5142. * @param url define the url we are trying
  5143. * @param element define the dom element where to configure the cors policy
  5144. */
  5145. static SetCorsBehavior(url: string | string[], element: {
  5146. crossOrigin: string | null;
  5147. }): void;
  5148. /**
  5149. * Loads an image as an HTMLImageElement.
  5150. * @param input url string, ArrayBuffer, or Blob to load
  5151. * @param onLoad callback called when the image successfully loads
  5152. * @param onError callback called when the image fails to load
  5153. * @param offlineProvider offline provider for caching
  5154. * @returns the HTMLImageElement of the loaded image
  5155. */
  5156. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  5157. /**
  5158. * Loads a file
  5159. * @param fileToLoad defines the file to load
  5160. * @param callback defines the callback to call when data is loaded
  5161. * @param progressCallBack defines the callback to call during loading process
  5162. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  5163. * @returns a file request object
  5164. */
  5165. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  5166. /**
  5167. * Loads a file
  5168. * @param url url string, ArrayBuffer, or Blob to load
  5169. * @param onSuccess callback called when the file successfully loads
  5170. * @param onProgress callback called while file is loading (if the server supports this mode)
  5171. * @param offlineProvider defines the offline provider for caching
  5172. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  5173. * @param onError callback called when the file fails to load
  5174. * @returns a file request object
  5175. */
  5176. 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;
  5177. /**
  5178. * Checks if the loaded document was accessed via `file:`-Protocol.
  5179. * @returns boolean
  5180. */
  5181. static IsFileURL(): boolean;
  5182. }
  5183. }
  5184. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  5185. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  5186. /** @hidden */
  5187. export class ShaderProcessor {
  5188. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  5189. private static _ProcessPrecision;
  5190. private static _ExtractOperation;
  5191. private static _BuildSubExpression;
  5192. private static _BuildExpression;
  5193. private static _MoveCursorWithinIf;
  5194. private static _MoveCursor;
  5195. private static _EvaluatePreProcessors;
  5196. private static _PreparePreProcessors;
  5197. private static _ProcessShaderConversion;
  5198. private static _ProcessIncludes;
  5199. }
  5200. }
  5201. declare module "babylonjs/Materials/iEffectFallbacks" {
  5202. import { Effect } from "babylonjs/Materials/effect";
  5203. /**
  5204. * Interface used to define common properties for effect fallbacks
  5205. */
  5206. export interface IEffectFallbacks {
  5207. /**
  5208. * Removes the defines that should be removed when falling back.
  5209. * @param currentDefines defines the current define statements for the shader.
  5210. * @param effect defines the current effect we try to compile
  5211. * @returns The resulting defines with defines of the current rank removed.
  5212. */
  5213. reduce(currentDefines: string, effect: Effect): string;
  5214. /**
  5215. * Removes the fallback from the bound mesh.
  5216. */
  5217. unBindMesh(): void;
  5218. /**
  5219. * Checks to see if more fallbacks are still availible.
  5220. */
  5221. hasMoreFallbacks: boolean;
  5222. }
  5223. }
  5224. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5225. /**
  5226. * Class used to evalaute queries containing `and` and `or` operators
  5227. */
  5228. export class AndOrNotEvaluator {
  5229. /**
  5230. * Evaluate a query
  5231. * @param query defines the query to evaluate
  5232. * @param evaluateCallback defines the callback used to filter result
  5233. * @returns true if the query matches
  5234. */
  5235. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5236. private static _HandleParenthesisContent;
  5237. private static _SimplifyNegation;
  5238. }
  5239. }
  5240. declare module "babylonjs/Misc/tags" {
  5241. /**
  5242. * Class used to store custom tags
  5243. */
  5244. export class Tags {
  5245. /**
  5246. * Adds support for tags on the given object
  5247. * @param obj defines the object to use
  5248. */
  5249. static EnableFor(obj: any): void;
  5250. /**
  5251. * Removes tags support
  5252. * @param obj defines the object to use
  5253. */
  5254. static DisableFor(obj: any): void;
  5255. /**
  5256. * Gets a boolean indicating if the given object has tags
  5257. * @param obj defines the object to use
  5258. * @returns a boolean
  5259. */
  5260. static HasTags(obj: any): boolean;
  5261. /**
  5262. * Gets the tags available on a given object
  5263. * @param obj defines the object to use
  5264. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5265. * @returns the tags
  5266. */
  5267. static GetTags(obj: any, asString?: boolean): any;
  5268. /**
  5269. * Adds tags to an object
  5270. * @param obj defines the object to use
  5271. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5272. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5273. */
  5274. static AddTagsTo(obj: any, tagsString: string): void;
  5275. /**
  5276. * @hidden
  5277. */
  5278. static _AddTagTo(obj: any, tag: string): void;
  5279. /**
  5280. * Removes specific tags from a specific object
  5281. * @param obj defines the object to use
  5282. * @param tagsString defines the tags to remove
  5283. */
  5284. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5285. /**
  5286. * @hidden
  5287. */
  5288. static _RemoveTagFrom(obj: any, tag: string): void;
  5289. /**
  5290. * Defines if tags hosted on an object match a given query
  5291. * @param obj defines the object to use
  5292. * @param tagsQuery defines the tag query
  5293. * @returns a boolean
  5294. */
  5295. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5296. }
  5297. }
  5298. declare module "babylonjs/Maths/math.path" {
  5299. import { DeepImmutable, Nullable } from "babylonjs/types";
  5300. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  5301. /**
  5302. * Defines potential orientation for back face culling
  5303. */
  5304. export enum Orientation {
  5305. /**
  5306. * Clockwise
  5307. */
  5308. CW = 0,
  5309. /** Counter clockwise */
  5310. CCW = 1
  5311. }
  5312. /** Class used to represent a Bezier curve */
  5313. export class BezierCurve {
  5314. /**
  5315. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  5316. * @param t defines the time
  5317. * @param x1 defines the left coordinate on X axis
  5318. * @param y1 defines the left coordinate on Y axis
  5319. * @param x2 defines the right coordinate on X axis
  5320. * @param y2 defines the right coordinate on Y axis
  5321. * @returns the interpolated value
  5322. */
  5323. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  5324. }
  5325. /**
  5326. * Defines angle representation
  5327. */
  5328. export class Angle {
  5329. private _radians;
  5330. /**
  5331. * Creates an Angle object of "radians" radians (float).
  5332. * @param radians the angle in radians
  5333. */
  5334. constructor(radians: number);
  5335. /**
  5336. * Get value in degrees
  5337. * @returns the Angle value in degrees (float)
  5338. */
  5339. degrees(): number;
  5340. /**
  5341. * Get value in radians
  5342. * @returns the Angle value in radians (float)
  5343. */
  5344. radians(): number;
  5345. /**
  5346. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  5347. * @param a defines first vector
  5348. * @param b defines second vector
  5349. * @returns a new Angle
  5350. */
  5351. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  5352. /**
  5353. * Gets a new Angle object from the given float in radians
  5354. * @param radians defines the angle value in radians
  5355. * @returns a new Angle
  5356. */
  5357. static FromRadians(radians: number): Angle;
  5358. /**
  5359. * Gets a new Angle object from the given float in degrees
  5360. * @param degrees defines the angle value in degrees
  5361. * @returns a new Angle
  5362. */
  5363. static FromDegrees(degrees: number): Angle;
  5364. }
  5365. /**
  5366. * This represents an arc in a 2d space.
  5367. */
  5368. export class Arc2 {
  5369. /** Defines the start point of the arc */
  5370. startPoint: Vector2;
  5371. /** Defines the mid point of the arc */
  5372. midPoint: Vector2;
  5373. /** Defines the end point of the arc */
  5374. endPoint: Vector2;
  5375. /**
  5376. * Defines the center point of the arc.
  5377. */
  5378. centerPoint: Vector2;
  5379. /**
  5380. * Defines the radius of the arc.
  5381. */
  5382. radius: number;
  5383. /**
  5384. * Defines the angle of the arc (from mid point to end point).
  5385. */
  5386. angle: Angle;
  5387. /**
  5388. * Defines the start angle of the arc (from start point to middle point).
  5389. */
  5390. startAngle: Angle;
  5391. /**
  5392. * Defines the orientation of the arc (clock wise/counter clock wise).
  5393. */
  5394. orientation: Orientation;
  5395. /**
  5396. * Creates an Arc object from the three given points : start, middle and end.
  5397. * @param startPoint Defines the start point of the arc
  5398. * @param midPoint Defines the midlle point of the arc
  5399. * @param endPoint Defines the end point of the arc
  5400. */
  5401. constructor(
  5402. /** Defines the start point of the arc */
  5403. startPoint: Vector2,
  5404. /** Defines the mid point of the arc */
  5405. midPoint: Vector2,
  5406. /** Defines the end point of the arc */
  5407. endPoint: Vector2);
  5408. }
  5409. /**
  5410. * Represents a 2D path made up of multiple 2D points
  5411. */
  5412. export class Path2 {
  5413. private _points;
  5414. private _length;
  5415. /**
  5416. * If the path start and end point are the same
  5417. */
  5418. closed: boolean;
  5419. /**
  5420. * Creates a Path2 object from the starting 2D coordinates x and y.
  5421. * @param x the starting points x value
  5422. * @param y the starting points y value
  5423. */
  5424. constructor(x: number, y: number);
  5425. /**
  5426. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5427. * @param x the added points x value
  5428. * @param y the added points y value
  5429. * @returns the updated Path2.
  5430. */
  5431. addLineTo(x: number, y: number): Path2;
  5432. /**
  5433. * 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.
  5434. * @param midX middle point x value
  5435. * @param midY middle point y value
  5436. * @param endX end point x value
  5437. * @param endY end point y value
  5438. * @param numberOfSegments (default: 36)
  5439. * @returns the updated Path2.
  5440. */
  5441. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5442. /**
  5443. * Closes the Path2.
  5444. * @returns the Path2.
  5445. */
  5446. close(): Path2;
  5447. /**
  5448. * Gets the sum of the distance between each sequential point in the path
  5449. * @returns the Path2 total length (float).
  5450. */
  5451. length(): number;
  5452. /**
  5453. * Gets the points which construct the path
  5454. * @returns the Path2 internal array of points.
  5455. */
  5456. getPoints(): Vector2[];
  5457. /**
  5458. * Retreives the point at the distance aways from the starting point
  5459. * @param normalizedLengthPosition the length along the path to retreive the point from
  5460. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5461. */
  5462. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5463. /**
  5464. * Creates a new path starting from an x and y position
  5465. * @param x starting x value
  5466. * @param y starting y value
  5467. * @returns a new Path2 starting at the coordinates (x, y).
  5468. */
  5469. static StartingAt(x: number, y: number): Path2;
  5470. }
  5471. /**
  5472. * Represents a 3D path made up of multiple 3D points
  5473. */
  5474. export class Path3D {
  5475. /**
  5476. * an array of Vector3, the curve axis of the Path3D
  5477. */
  5478. path: Vector3[];
  5479. private _curve;
  5480. private _distances;
  5481. private _tangents;
  5482. private _normals;
  5483. private _binormals;
  5484. private _raw;
  5485. /**
  5486. * new Path3D(path, normal, raw)
  5487. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5488. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5489. * @param path an array of Vector3, the curve axis of the Path3D
  5490. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5491. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5492. */
  5493. constructor(
  5494. /**
  5495. * an array of Vector3, the curve axis of the Path3D
  5496. */
  5497. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  5498. /**
  5499. * Returns the Path3D array of successive Vector3 designing its curve.
  5500. * @returns the Path3D array of successive Vector3 designing its curve.
  5501. */
  5502. getCurve(): Vector3[];
  5503. /**
  5504. * Returns an array populated with tangent vectors on each Path3D curve point.
  5505. * @returns an array populated with tangent vectors on each Path3D curve point.
  5506. */
  5507. getTangents(): Vector3[];
  5508. /**
  5509. * Returns an array populated with normal vectors on each Path3D curve point.
  5510. * @returns an array populated with normal vectors on each Path3D curve point.
  5511. */
  5512. getNormals(): Vector3[];
  5513. /**
  5514. * Returns an array populated with binormal vectors on each Path3D curve point.
  5515. * @returns an array populated with binormal vectors on each Path3D curve point.
  5516. */
  5517. getBinormals(): Vector3[];
  5518. /**
  5519. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5520. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5521. */
  5522. getDistances(): number[];
  5523. /**
  5524. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5525. * @param path path which all values are copied into the curves points
  5526. * @param firstNormal which should be projected onto the curve
  5527. * @returns the same object updated.
  5528. */
  5529. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  5530. private _compute;
  5531. private _getFirstNonNullVector;
  5532. private _getLastNonNullVector;
  5533. private _normalVector;
  5534. }
  5535. /**
  5536. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5537. * A Curve3 is designed from a series of successive Vector3.
  5538. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5539. */
  5540. export class Curve3 {
  5541. private _points;
  5542. private _length;
  5543. /**
  5544. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5545. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5546. * @param v1 (Vector3) the control point
  5547. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5548. * @param nbPoints (integer) the wanted number of points in the curve
  5549. * @returns the created Curve3
  5550. */
  5551. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5552. /**
  5553. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5554. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5555. * @param v1 (Vector3) the first control point
  5556. * @param v2 (Vector3) the second control point
  5557. * @param v3 (Vector3) the end point of the Cubic Bezier
  5558. * @param nbPoints (integer) the wanted number of points in the curve
  5559. * @returns the created Curve3
  5560. */
  5561. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5562. /**
  5563. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5564. * @param p1 (Vector3) the origin point of the Hermite Spline
  5565. * @param t1 (Vector3) the tangent vector at the origin point
  5566. * @param p2 (Vector3) the end point of the Hermite Spline
  5567. * @param t2 (Vector3) the tangent vector at the end point
  5568. * @param nbPoints (integer) the wanted number of points in the curve
  5569. * @returns the created Curve3
  5570. */
  5571. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5572. /**
  5573. * Returns a Curve3 object along a CatmullRom Spline curve :
  5574. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5575. * @param nbPoints (integer) the wanted number of points between each curve control points
  5576. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5577. * @returns the created Curve3
  5578. */
  5579. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5580. /**
  5581. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5582. * A Curve3 is designed from a series of successive Vector3.
  5583. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5584. * @param points points which make up the curve
  5585. */
  5586. constructor(points: Vector3[]);
  5587. /**
  5588. * @returns the Curve3 stored array of successive Vector3
  5589. */
  5590. getPoints(): Vector3[];
  5591. /**
  5592. * @returns the computed length (float) of the curve.
  5593. */
  5594. length(): number;
  5595. /**
  5596. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5597. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5598. * curveA and curveB keep unchanged.
  5599. * @param curve the curve to continue from this curve
  5600. * @returns the newly constructed curve
  5601. */
  5602. continue(curve: DeepImmutable<Curve3>): Curve3;
  5603. private _computeLength;
  5604. }
  5605. }
  5606. declare module "babylonjs/Animations/easing" {
  5607. /**
  5608. * This represents the main contract an easing function should follow.
  5609. * Easing functions are used throughout the animation system.
  5610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5611. */
  5612. export interface IEasingFunction {
  5613. /**
  5614. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5615. * of the easing function.
  5616. * The link below provides some of the most common examples of easing functions.
  5617. * @see https://easings.net/
  5618. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5619. * @returns the corresponding value on the curve defined by the easing function
  5620. */
  5621. ease(gradient: number): number;
  5622. }
  5623. /**
  5624. * Base class used for every default easing function.
  5625. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5626. */
  5627. export class EasingFunction implements IEasingFunction {
  5628. /**
  5629. * Interpolation follows the mathematical formula associated with the easing function.
  5630. */
  5631. static readonly EASINGMODE_EASEIN: number;
  5632. /**
  5633. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5634. */
  5635. static readonly EASINGMODE_EASEOUT: number;
  5636. /**
  5637. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5638. */
  5639. static readonly EASINGMODE_EASEINOUT: number;
  5640. private _easingMode;
  5641. /**
  5642. * Sets the easing mode of the current function.
  5643. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5644. */
  5645. setEasingMode(easingMode: number): void;
  5646. /**
  5647. * Gets the current easing mode.
  5648. * @returns the easing mode
  5649. */
  5650. getEasingMode(): number;
  5651. /**
  5652. * @hidden
  5653. */
  5654. easeInCore(gradient: number): number;
  5655. /**
  5656. * Given an input gradient between 0 and 1, this returns the corresponding value
  5657. * of the easing function.
  5658. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5659. * @returns the corresponding value on the curve defined by the easing function
  5660. */
  5661. ease(gradient: number): number;
  5662. }
  5663. /**
  5664. * Easing function with a circle shape (see link below).
  5665. * @see https://easings.net/#easeInCirc
  5666. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5667. */
  5668. export class CircleEase extends EasingFunction implements IEasingFunction {
  5669. /** @hidden */
  5670. easeInCore(gradient: number): number;
  5671. }
  5672. /**
  5673. * Easing function with a ease back shape (see link below).
  5674. * @see https://easings.net/#easeInBack
  5675. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5676. */
  5677. export class BackEase extends EasingFunction implements IEasingFunction {
  5678. /** Defines the amplitude of the function */
  5679. amplitude: number;
  5680. /**
  5681. * Instantiates a back ease easing
  5682. * @see https://easings.net/#easeInBack
  5683. * @param amplitude Defines the amplitude of the function
  5684. */
  5685. constructor(
  5686. /** Defines the amplitude of the function */
  5687. amplitude?: number);
  5688. /** @hidden */
  5689. easeInCore(gradient: number): number;
  5690. }
  5691. /**
  5692. * Easing function with a bouncing shape (see link below).
  5693. * @see https://easings.net/#easeInBounce
  5694. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5695. */
  5696. export class BounceEase extends EasingFunction implements IEasingFunction {
  5697. /** Defines the number of bounces */
  5698. bounces: number;
  5699. /** Defines the amplitude of the bounce */
  5700. bounciness: number;
  5701. /**
  5702. * Instantiates a bounce easing
  5703. * @see https://easings.net/#easeInBounce
  5704. * @param bounces Defines the number of bounces
  5705. * @param bounciness Defines the amplitude of the bounce
  5706. */
  5707. constructor(
  5708. /** Defines the number of bounces */
  5709. bounces?: number,
  5710. /** Defines the amplitude of the bounce */
  5711. bounciness?: number);
  5712. /** @hidden */
  5713. easeInCore(gradient: number): number;
  5714. }
  5715. /**
  5716. * Easing function with a power of 3 shape (see link below).
  5717. * @see https://easings.net/#easeInCubic
  5718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5719. */
  5720. export class CubicEase extends EasingFunction implements IEasingFunction {
  5721. /** @hidden */
  5722. easeInCore(gradient: number): number;
  5723. }
  5724. /**
  5725. * Easing function with an elastic shape (see link below).
  5726. * @see https://easings.net/#easeInElastic
  5727. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5728. */
  5729. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5730. /** Defines the number of oscillations*/
  5731. oscillations: number;
  5732. /** Defines the amplitude of the oscillations*/
  5733. springiness: number;
  5734. /**
  5735. * Instantiates an elastic easing function
  5736. * @see https://easings.net/#easeInElastic
  5737. * @param oscillations Defines the number of oscillations
  5738. * @param springiness Defines the amplitude of the oscillations
  5739. */
  5740. constructor(
  5741. /** Defines the number of oscillations*/
  5742. oscillations?: number,
  5743. /** Defines the amplitude of the oscillations*/
  5744. springiness?: number);
  5745. /** @hidden */
  5746. easeInCore(gradient: number): number;
  5747. }
  5748. /**
  5749. * Easing function with an exponential shape (see link below).
  5750. * @see https://easings.net/#easeInExpo
  5751. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5752. */
  5753. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5754. /** Defines the exponent of the function */
  5755. exponent: number;
  5756. /**
  5757. * Instantiates an exponential easing function
  5758. * @see https://easings.net/#easeInExpo
  5759. * @param exponent Defines the exponent of the function
  5760. */
  5761. constructor(
  5762. /** Defines the exponent of the function */
  5763. exponent?: number);
  5764. /** @hidden */
  5765. easeInCore(gradient: number): number;
  5766. }
  5767. /**
  5768. * Easing function with a power shape (see link below).
  5769. * @see https://easings.net/#easeInQuad
  5770. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5771. */
  5772. export class PowerEase extends EasingFunction implements IEasingFunction {
  5773. /** Defines the power of the function */
  5774. power: number;
  5775. /**
  5776. * Instantiates an power base easing function
  5777. * @see https://easings.net/#easeInQuad
  5778. * @param power Defines the power of the function
  5779. */
  5780. constructor(
  5781. /** Defines the power of the function */
  5782. power?: number);
  5783. /** @hidden */
  5784. easeInCore(gradient: number): number;
  5785. }
  5786. /**
  5787. * Easing function with a power of 2 shape (see link below).
  5788. * @see https://easings.net/#easeInQuad
  5789. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5790. */
  5791. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5792. /** @hidden */
  5793. easeInCore(gradient: number): number;
  5794. }
  5795. /**
  5796. * Easing function with a power of 4 shape (see link below).
  5797. * @see https://easings.net/#easeInQuart
  5798. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5799. */
  5800. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5801. /** @hidden */
  5802. easeInCore(gradient: number): number;
  5803. }
  5804. /**
  5805. * Easing function with a power of 5 shape (see link below).
  5806. * @see https://easings.net/#easeInQuint
  5807. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5808. */
  5809. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5810. /** @hidden */
  5811. easeInCore(gradient: number): number;
  5812. }
  5813. /**
  5814. * Easing function with a sin shape (see link below).
  5815. * @see https://easings.net/#easeInSine
  5816. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5817. */
  5818. export class SineEase extends EasingFunction implements IEasingFunction {
  5819. /** @hidden */
  5820. easeInCore(gradient: number): number;
  5821. }
  5822. /**
  5823. * Easing function with a bezier shape (see link below).
  5824. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5825. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  5826. */
  5827. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5828. /** Defines the x component of the start tangent in the bezier curve */
  5829. x1: number;
  5830. /** Defines the y component of the start tangent in the bezier curve */
  5831. y1: number;
  5832. /** Defines the x component of the end tangent in the bezier curve */
  5833. x2: number;
  5834. /** Defines the y component of the end tangent in the bezier curve */
  5835. y2: number;
  5836. /**
  5837. * Instantiates a bezier function
  5838. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5839. * @param x1 Defines the x component of the start tangent in the bezier curve
  5840. * @param y1 Defines the y component of the start tangent in the bezier curve
  5841. * @param x2 Defines the x component of the end tangent in the bezier curve
  5842. * @param y2 Defines the y component of the end tangent in the bezier curve
  5843. */
  5844. constructor(
  5845. /** Defines the x component of the start tangent in the bezier curve */
  5846. x1?: number,
  5847. /** Defines the y component of the start tangent in the bezier curve */
  5848. y1?: number,
  5849. /** Defines the x component of the end tangent in the bezier curve */
  5850. x2?: number,
  5851. /** Defines the y component of the end tangent in the bezier curve */
  5852. y2?: number);
  5853. /** @hidden */
  5854. easeInCore(gradient: number): number;
  5855. }
  5856. }
  5857. declare module "babylonjs/Animations/animationKey" {
  5858. /**
  5859. * Defines an interface which represents an animation key frame
  5860. */
  5861. export interface IAnimationKey {
  5862. /**
  5863. * Frame of the key frame
  5864. */
  5865. frame: number;
  5866. /**
  5867. * Value at the specifies key frame
  5868. */
  5869. value: any;
  5870. /**
  5871. * The input tangent for the cubic hermite spline
  5872. */
  5873. inTangent?: any;
  5874. /**
  5875. * The output tangent for the cubic hermite spline
  5876. */
  5877. outTangent?: any;
  5878. /**
  5879. * The animation interpolation type
  5880. */
  5881. interpolation?: AnimationKeyInterpolation;
  5882. }
  5883. /**
  5884. * Enum for the animation key frame interpolation type
  5885. */
  5886. export enum AnimationKeyInterpolation {
  5887. /**
  5888. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  5889. */
  5890. STEP = 1
  5891. }
  5892. }
  5893. declare module "babylonjs/Animations/animationRange" {
  5894. /**
  5895. * Represents the range of an animation
  5896. */
  5897. export class AnimationRange {
  5898. /**The name of the animation range**/
  5899. name: string;
  5900. /**The starting frame of the animation */
  5901. from: number;
  5902. /**The ending frame of the animation*/
  5903. to: number;
  5904. /**
  5905. * Initializes the range of an animation
  5906. * @param name The name of the animation range
  5907. * @param from The starting frame of the animation
  5908. * @param to The ending frame of the animation
  5909. */
  5910. constructor(
  5911. /**The name of the animation range**/
  5912. name: string,
  5913. /**The starting frame of the animation */
  5914. from: number,
  5915. /**The ending frame of the animation*/
  5916. to: number);
  5917. /**
  5918. * Makes a copy of the animation range
  5919. * @returns A copy of the animation range
  5920. */
  5921. clone(): AnimationRange;
  5922. }
  5923. }
  5924. declare module "babylonjs/Animations/animationEvent" {
  5925. /**
  5926. * Composed of a frame, and an action function
  5927. */
  5928. export class AnimationEvent {
  5929. /** The frame for which the event is triggered **/
  5930. frame: number;
  5931. /** The event to perform when triggered **/
  5932. action: (currentFrame: number) => void;
  5933. /** Specifies if the event should be triggered only once**/
  5934. onlyOnce?: boolean | undefined;
  5935. /**
  5936. * Specifies if the animation event is done
  5937. */
  5938. isDone: boolean;
  5939. /**
  5940. * Initializes the animation event
  5941. * @param frame The frame for which the event is triggered
  5942. * @param action The event to perform when triggered
  5943. * @param onlyOnce Specifies if the event should be triggered only once
  5944. */
  5945. constructor(
  5946. /** The frame for which the event is triggered **/
  5947. frame: number,
  5948. /** The event to perform when triggered **/
  5949. action: (currentFrame: number) => void,
  5950. /** Specifies if the event should be triggered only once**/
  5951. onlyOnce?: boolean | undefined);
  5952. /** @hidden */
  5953. _clone(): AnimationEvent;
  5954. }
  5955. }
  5956. declare module "babylonjs/Behaviors/behavior" {
  5957. import { Nullable } from "babylonjs/types";
  5958. /**
  5959. * Interface used to define a behavior
  5960. */
  5961. export interface Behavior<T> {
  5962. /** gets or sets behavior's name */
  5963. name: string;
  5964. /**
  5965. * Function called when the behavior needs to be initialized (after attaching it to a target)
  5966. */
  5967. init(): void;
  5968. /**
  5969. * Called when the behavior is attached to a target
  5970. * @param target defines the target where the behavior is attached to
  5971. */
  5972. attach(target: T): void;
  5973. /**
  5974. * Called when the behavior is detached from its target
  5975. */
  5976. detach(): void;
  5977. }
  5978. /**
  5979. * Interface implemented by classes supporting behaviors
  5980. */
  5981. export interface IBehaviorAware<T> {
  5982. /**
  5983. * Attach a behavior
  5984. * @param behavior defines the behavior to attach
  5985. * @returns the current host
  5986. */
  5987. addBehavior(behavior: Behavior<T>): T;
  5988. /**
  5989. * Remove a behavior from the current object
  5990. * @param behavior defines the behavior to detach
  5991. * @returns the current host
  5992. */
  5993. removeBehavior(behavior: Behavior<T>): T;
  5994. /**
  5995. * Gets a behavior using its name to search
  5996. * @param name defines the name to search
  5997. * @returns the behavior or null if not found
  5998. */
  5999. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6000. }
  6001. }
  6002. declare module "babylonjs/Misc/smartArray" {
  6003. /**
  6004. * Defines an array and its length.
  6005. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6006. */
  6007. export interface ISmartArrayLike<T> {
  6008. /**
  6009. * The data of the array.
  6010. */
  6011. data: Array<T>;
  6012. /**
  6013. * The active length of the array.
  6014. */
  6015. length: number;
  6016. }
  6017. /**
  6018. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6019. */
  6020. export class SmartArray<T> implements ISmartArrayLike<T> {
  6021. /**
  6022. * The full set of data from the array.
  6023. */
  6024. data: Array<T>;
  6025. /**
  6026. * The active length of the array.
  6027. */
  6028. length: number;
  6029. protected _id: number;
  6030. /**
  6031. * Instantiates a Smart Array.
  6032. * @param capacity defines the default capacity of the array.
  6033. */
  6034. constructor(capacity: number);
  6035. /**
  6036. * Pushes a value at the end of the active data.
  6037. * @param value defines the object to push in the array.
  6038. */
  6039. push(value: T): void;
  6040. /**
  6041. * Iterates over the active data and apply the lambda to them.
  6042. * @param func defines the action to apply on each value.
  6043. */
  6044. forEach(func: (content: T) => void): void;
  6045. /**
  6046. * Sorts the full sets of data.
  6047. * @param compareFn defines the comparison function to apply.
  6048. */
  6049. sort(compareFn: (a: T, b: T) => number): void;
  6050. /**
  6051. * Resets the active data to an empty array.
  6052. */
  6053. reset(): void;
  6054. /**
  6055. * Releases all the data from the array as well as the array.
  6056. */
  6057. dispose(): void;
  6058. /**
  6059. * Concats the active data with a given array.
  6060. * @param array defines the data to concatenate with.
  6061. */
  6062. concat(array: any): void;
  6063. /**
  6064. * Returns the position of a value in the active data.
  6065. * @param value defines the value to find the index for
  6066. * @returns the index if found in the active data otherwise -1
  6067. */
  6068. indexOf(value: T): number;
  6069. /**
  6070. * Returns whether an element is part of the active data.
  6071. * @param value defines the value to look for
  6072. * @returns true if found in the active data otherwise false
  6073. */
  6074. contains(value: T): boolean;
  6075. private static _GlobalId;
  6076. }
  6077. /**
  6078. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6079. * The data in this array can only be present once
  6080. */
  6081. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6082. private _duplicateId;
  6083. /**
  6084. * Pushes a value at the end of the active data.
  6085. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6086. * @param value defines the object to push in the array.
  6087. */
  6088. push(value: T): void;
  6089. /**
  6090. * Pushes a value at the end of the active data.
  6091. * If the data is already present, it won t be added again
  6092. * @param value defines the object to push in the array.
  6093. * @returns true if added false if it was already present
  6094. */
  6095. pushNoDuplicate(value: T): boolean;
  6096. /**
  6097. * Resets the active data to an empty array.
  6098. */
  6099. reset(): void;
  6100. /**
  6101. * Concats the active data with a given array.
  6102. * This ensures no dupplicate will be present in the result.
  6103. * @param array defines the data to concatenate with.
  6104. */
  6105. concatWithNoDuplicate(array: any): void;
  6106. }
  6107. }
  6108. declare module "babylonjs/Cameras/cameraInputsManager" {
  6109. import { Nullable } from "babylonjs/types";
  6110. import { Camera } from "babylonjs/Cameras/camera";
  6111. /**
  6112. * @ignore
  6113. * This is a list of all the different input types that are available in the application.
  6114. * Fo instance: ArcRotateCameraGamepadInput...
  6115. */
  6116. export var CameraInputTypes: {};
  6117. /**
  6118. * This is the contract to implement in order to create a new input class.
  6119. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6120. */
  6121. export interface ICameraInput<TCamera extends Camera> {
  6122. /**
  6123. * Defines the camera the input is attached to.
  6124. */
  6125. camera: Nullable<TCamera>;
  6126. /**
  6127. * Gets the class name of the current intput.
  6128. * @returns the class name
  6129. */
  6130. getClassName(): string;
  6131. /**
  6132. * Get the friendly name associated with the input class.
  6133. * @returns the input friendly name
  6134. */
  6135. getSimpleName(): string;
  6136. /**
  6137. * Attach the input controls to a specific dom element to get the input from.
  6138. * @param element Defines the element the controls should be listened from
  6139. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6140. */
  6141. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6142. /**
  6143. * Detach the current controls from the specified dom element.
  6144. * @param element Defines the element to stop listening the inputs from
  6145. */
  6146. detachControl(element: Nullable<HTMLElement>): void;
  6147. /**
  6148. * Update the current camera state depending on the inputs that have been used this frame.
  6149. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6150. */
  6151. checkInputs?: () => void;
  6152. }
  6153. /**
  6154. * Represents a map of input types to input instance or input index to input instance.
  6155. */
  6156. export interface CameraInputsMap<TCamera extends Camera> {
  6157. /**
  6158. * Accessor to the input by input type.
  6159. */
  6160. [name: string]: ICameraInput<TCamera>;
  6161. /**
  6162. * Accessor to the input by input index.
  6163. */
  6164. [idx: number]: ICameraInput<TCamera>;
  6165. }
  6166. /**
  6167. * This represents the input manager used within a camera.
  6168. * It helps dealing with all the different kind of input attached to a camera.
  6169. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6170. */
  6171. export class CameraInputsManager<TCamera extends Camera> {
  6172. /**
  6173. * Defines the list of inputs attahed to the camera.
  6174. */
  6175. attached: CameraInputsMap<TCamera>;
  6176. /**
  6177. * Defines the dom element the camera is collecting inputs from.
  6178. * This is null if the controls have not been attached.
  6179. */
  6180. attachedElement: Nullable<HTMLElement>;
  6181. /**
  6182. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6183. */
  6184. noPreventDefault: boolean;
  6185. /**
  6186. * Defined the camera the input manager belongs to.
  6187. */
  6188. camera: TCamera;
  6189. /**
  6190. * Update the current camera state depending on the inputs that have been used this frame.
  6191. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6192. */
  6193. checkInputs: () => void;
  6194. /**
  6195. * Instantiate a new Camera Input Manager.
  6196. * @param camera Defines the camera the input manager blongs to
  6197. */
  6198. constructor(camera: TCamera);
  6199. /**
  6200. * Add an input method to a camera
  6201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  6202. * @param input camera input method
  6203. */
  6204. add(input: ICameraInput<TCamera>): void;
  6205. /**
  6206. * Remove a specific input method from a camera
  6207. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6208. * @param inputToRemove camera input method
  6209. */
  6210. remove(inputToRemove: ICameraInput<TCamera>): void;
  6211. /**
  6212. * Remove a specific input type from a camera
  6213. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6214. * @param inputType the type of the input to remove
  6215. */
  6216. removeByType(inputType: string): void;
  6217. private _addCheckInputs;
  6218. /**
  6219. * Attach the input controls to the currently attached dom element to listen the events from.
  6220. * @param input Defines the input to attach
  6221. */
  6222. attachInput(input: ICameraInput<TCamera>): void;
  6223. /**
  6224. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6225. * @param element Defines the dom element to collect the events from
  6226. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6227. */
  6228. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6229. /**
  6230. * Detach the current manager inputs controls from a specific dom element.
  6231. * @param element Defines the dom element to collect the events from
  6232. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6233. */
  6234. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6235. /**
  6236. * Rebuild the dynamic inputCheck function from the current list of
  6237. * defined inputs in the manager.
  6238. */
  6239. rebuildInputCheck(): void;
  6240. /**
  6241. * Remove all attached input methods from a camera
  6242. */
  6243. clear(): void;
  6244. /**
  6245. * Serialize the current input manager attached to a camera.
  6246. * This ensures than once parsed,
  6247. * the input associated to the camera will be identical to the current ones
  6248. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6249. */
  6250. serialize(serializedCamera: any): void;
  6251. /**
  6252. * Parses an input manager serialized JSON to restore the previous list of inputs
  6253. * and states associated to a camera.
  6254. * @param parsedCamera Defines the JSON to parse
  6255. */
  6256. parse(parsedCamera: any): void;
  6257. }
  6258. }
  6259. declare module "babylonjs/Meshes/buffer" {
  6260. import { Nullable, DataArray } from "babylonjs/types";
  6261. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6262. /**
  6263. * Class used to store data that will be store in GPU memory
  6264. */
  6265. export class Buffer {
  6266. private _engine;
  6267. private _buffer;
  6268. /** @hidden */
  6269. _data: Nullable<DataArray>;
  6270. private _updatable;
  6271. private _instanced;
  6272. /**
  6273. * Gets the byte stride.
  6274. */
  6275. readonly byteStride: number;
  6276. /**
  6277. * Constructor
  6278. * @param engine the engine
  6279. * @param data the data to use for this buffer
  6280. * @param updatable whether the data is updatable
  6281. * @param stride the stride (optional)
  6282. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6283. * @param instanced whether the buffer is instanced (optional)
  6284. * @param useBytes set to true if the stride in in bytes (optional)
  6285. */
  6286. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  6287. /**
  6288. * Create a new VertexBuffer based on the current buffer
  6289. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6290. * @param offset defines offset in the buffer (0 by default)
  6291. * @param size defines the size in floats of attributes (position is 3 for instance)
  6292. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6293. * @param instanced defines if the vertex buffer contains indexed data
  6294. * @param useBytes defines if the offset and stride are in bytes
  6295. * @returns the new vertex buffer
  6296. */
  6297. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  6298. /**
  6299. * Gets a boolean indicating if the Buffer is updatable?
  6300. * @returns true if the buffer is updatable
  6301. */
  6302. isUpdatable(): boolean;
  6303. /**
  6304. * Gets current buffer's data
  6305. * @returns a DataArray or null
  6306. */
  6307. getData(): Nullable<DataArray>;
  6308. /**
  6309. * Gets underlying native buffer
  6310. * @returns underlying native buffer
  6311. */
  6312. getBuffer(): Nullable<DataBuffer>;
  6313. /**
  6314. * Gets the stride in float32 units (i.e. byte stride / 4).
  6315. * May not be an integer if the byte stride is not divisible by 4.
  6316. * DEPRECATED. Use byteStride instead.
  6317. * @returns the stride in float32 units
  6318. */
  6319. getStrideSize(): number;
  6320. /**
  6321. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6322. * @param data defines the data to store
  6323. */
  6324. create(data?: Nullable<DataArray>): void;
  6325. /** @hidden */
  6326. _rebuild(): void;
  6327. /**
  6328. * Update current buffer data
  6329. * @param data defines the data to store
  6330. */
  6331. update(data: DataArray): void;
  6332. /**
  6333. * Updates the data directly.
  6334. * @param data the new data
  6335. * @param offset the new offset
  6336. * @param vertexCount the vertex count (optional)
  6337. * @param useBytes set to true if the offset is in bytes
  6338. */
  6339. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6340. /**
  6341. * Release all resources
  6342. */
  6343. dispose(): void;
  6344. }
  6345. /**
  6346. * Specialized buffer used to store vertex data
  6347. */
  6348. export class VertexBuffer {
  6349. /** @hidden */
  6350. _buffer: Buffer;
  6351. private _kind;
  6352. private _size;
  6353. private _ownsBuffer;
  6354. private _instanced;
  6355. private _instanceDivisor;
  6356. /**
  6357. * The byte type.
  6358. */
  6359. static readonly BYTE: number;
  6360. /**
  6361. * The unsigned byte type.
  6362. */
  6363. static readonly UNSIGNED_BYTE: number;
  6364. /**
  6365. * The short type.
  6366. */
  6367. static readonly SHORT: number;
  6368. /**
  6369. * The unsigned short type.
  6370. */
  6371. static readonly UNSIGNED_SHORT: number;
  6372. /**
  6373. * The integer type.
  6374. */
  6375. static readonly INT: number;
  6376. /**
  6377. * The unsigned integer type.
  6378. */
  6379. static readonly UNSIGNED_INT: number;
  6380. /**
  6381. * The float type.
  6382. */
  6383. static readonly FLOAT: number;
  6384. /**
  6385. * Gets or sets the instance divisor when in instanced mode
  6386. */
  6387. instanceDivisor: number;
  6388. /**
  6389. * Gets the byte stride.
  6390. */
  6391. readonly byteStride: number;
  6392. /**
  6393. * Gets the byte offset.
  6394. */
  6395. readonly byteOffset: number;
  6396. /**
  6397. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6398. */
  6399. readonly normalized: boolean;
  6400. /**
  6401. * Gets the data type of each component in the array.
  6402. */
  6403. readonly type: number;
  6404. /**
  6405. * Constructor
  6406. * @param engine the engine
  6407. * @param data the data to use for this vertex buffer
  6408. * @param kind the vertex buffer kind
  6409. * @param updatable whether the data is updatable
  6410. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6411. * @param stride the stride (optional)
  6412. * @param instanced whether the buffer is instanced (optional)
  6413. * @param offset the offset of the data (optional)
  6414. * @param size the number of components (optional)
  6415. * @param type the type of the component (optional)
  6416. * @param normalized whether the data contains normalized data (optional)
  6417. * @param useBytes set to true if stride and offset are in bytes (optional)
  6418. */
  6419. 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);
  6420. /** @hidden */
  6421. _rebuild(): void;
  6422. /**
  6423. * Returns the kind of the VertexBuffer (string)
  6424. * @returns a string
  6425. */
  6426. getKind(): string;
  6427. /**
  6428. * Gets a boolean indicating if the VertexBuffer is updatable?
  6429. * @returns true if the buffer is updatable
  6430. */
  6431. isUpdatable(): boolean;
  6432. /**
  6433. * Gets current buffer's data
  6434. * @returns a DataArray or null
  6435. */
  6436. getData(): Nullable<DataArray>;
  6437. /**
  6438. * Gets underlying native buffer
  6439. * @returns underlying native buffer
  6440. */
  6441. getBuffer(): Nullable<DataBuffer>;
  6442. /**
  6443. * Gets the stride in float32 units (i.e. byte stride / 4).
  6444. * May not be an integer if the byte stride is not divisible by 4.
  6445. * DEPRECATED. Use byteStride instead.
  6446. * @returns the stride in float32 units
  6447. */
  6448. getStrideSize(): number;
  6449. /**
  6450. * Returns the offset as a multiple of the type byte length.
  6451. * DEPRECATED. Use byteOffset instead.
  6452. * @returns the offset in bytes
  6453. */
  6454. getOffset(): number;
  6455. /**
  6456. * Returns the number of components per vertex attribute (integer)
  6457. * @returns the size in float
  6458. */
  6459. getSize(): number;
  6460. /**
  6461. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6462. * @returns true if this buffer is instanced
  6463. */
  6464. getIsInstanced(): boolean;
  6465. /**
  6466. * Returns the instancing divisor, zero for non-instanced (integer).
  6467. * @returns a number
  6468. */
  6469. getInstanceDivisor(): number;
  6470. /**
  6471. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6472. * @param data defines the data to store
  6473. */
  6474. create(data?: DataArray): void;
  6475. /**
  6476. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6477. * This function will create a new buffer if the current one is not updatable
  6478. * @param data defines the data to store
  6479. */
  6480. update(data: DataArray): void;
  6481. /**
  6482. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6483. * Returns the directly updated WebGLBuffer.
  6484. * @param data the new data
  6485. * @param offset the new offset
  6486. * @param useBytes set to true if the offset is in bytes
  6487. */
  6488. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6489. /**
  6490. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6491. */
  6492. dispose(): void;
  6493. /**
  6494. * Enumerates each value of this vertex buffer as numbers.
  6495. * @param count the number of values to enumerate
  6496. * @param callback the callback function called for each value
  6497. */
  6498. forEach(count: number, callback: (value: number, index: number) => void): void;
  6499. /**
  6500. * Positions
  6501. */
  6502. static readonly PositionKind: string;
  6503. /**
  6504. * Normals
  6505. */
  6506. static readonly NormalKind: string;
  6507. /**
  6508. * Tangents
  6509. */
  6510. static readonly TangentKind: string;
  6511. /**
  6512. * Texture coordinates
  6513. */
  6514. static readonly UVKind: string;
  6515. /**
  6516. * Texture coordinates 2
  6517. */
  6518. static readonly UV2Kind: string;
  6519. /**
  6520. * Texture coordinates 3
  6521. */
  6522. static readonly UV3Kind: string;
  6523. /**
  6524. * Texture coordinates 4
  6525. */
  6526. static readonly UV4Kind: string;
  6527. /**
  6528. * Texture coordinates 5
  6529. */
  6530. static readonly UV5Kind: string;
  6531. /**
  6532. * Texture coordinates 6
  6533. */
  6534. static readonly UV6Kind: string;
  6535. /**
  6536. * Colors
  6537. */
  6538. static readonly ColorKind: string;
  6539. /**
  6540. * Matrix indices (for bones)
  6541. */
  6542. static readonly MatricesIndicesKind: string;
  6543. /**
  6544. * Matrix weights (for bones)
  6545. */
  6546. static readonly MatricesWeightsKind: string;
  6547. /**
  6548. * Additional matrix indices (for bones)
  6549. */
  6550. static readonly MatricesIndicesExtraKind: string;
  6551. /**
  6552. * Additional matrix weights (for bones)
  6553. */
  6554. static readonly MatricesWeightsExtraKind: string;
  6555. /**
  6556. * Deduces the stride given a kind.
  6557. * @param kind The kind string to deduce
  6558. * @returns The deduced stride
  6559. */
  6560. static DeduceStride(kind: string): number;
  6561. /**
  6562. * Gets the byte length of the given type.
  6563. * @param type the type
  6564. * @returns the number of bytes
  6565. */
  6566. static GetTypeByteLength(type: number): number;
  6567. /**
  6568. * Enumerates each value of the given parameters as numbers.
  6569. * @param data the data to enumerate
  6570. * @param byteOffset the byte offset of the data
  6571. * @param byteStride the byte stride of the data
  6572. * @param componentCount the number of components per element
  6573. * @param componentType the type of the component
  6574. * @param count the number of values to enumerate
  6575. * @param normalized whether the data is normalized
  6576. * @param callback the callback function called for each value
  6577. */
  6578. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6579. private static _GetFloatValue;
  6580. }
  6581. }
  6582. declare module "babylonjs/Collisions/intersectionInfo" {
  6583. import { Nullable } from "babylonjs/types";
  6584. /**
  6585. * @hidden
  6586. */
  6587. export class IntersectionInfo {
  6588. bu: Nullable<number>;
  6589. bv: Nullable<number>;
  6590. distance: number;
  6591. faceId: number;
  6592. subMeshId: number;
  6593. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6594. }
  6595. }
  6596. declare module "babylonjs/Maths/math.plane" {
  6597. import { DeepImmutable } from "babylonjs/types";
  6598. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  6599. /**
  6600. * Represens a plane by the equation ax + by + cz + d = 0
  6601. */
  6602. export class Plane {
  6603. private static _TmpMatrix;
  6604. /**
  6605. * Normal of the plane (a,b,c)
  6606. */
  6607. normal: Vector3;
  6608. /**
  6609. * d component of the plane
  6610. */
  6611. d: number;
  6612. /**
  6613. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  6614. * @param a a component of the plane
  6615. * @param b b component of the plane
  6616. * @param c c component of the plane
  6617. * @param d d component of the plane
  6618. */
  6619. constructor(a: number, b: number, c: number, d: number);
  6620. /**
  6621. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  6622. */
  6623. asArray(): number[];
  6624. /**
  6625. * @returns a new plane copied from the current Plane.
  6626. */
  6627. clone(): Plane;
  6628. /**
  6629. * @returns the string "Plane".
  6630. */
  6631. getClassName(): string;
  6632. /**
  6633. * @returns the Plane hash code.
  6634. */
  6635. getHashCode(): number;
  6636. /**
  6637. * Normalize the current Plane in place.
  6638. * @returns the updated Plane.
  6639. */
  6640. normalize(): Plane;
  6641. /**
  6642. * Applies a transformation the plane and returns the result
  6643. * @param transformation the transformation matrix to be applied to the plane
  6644. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  6645. */
  6646. transform(transformation: DeepImmutable<Matrix>): Plane;
  6647. /**
  6648. * Calcualtte the dot product between the point and the plane normal
  6649. * @param point point to calculate the dot product with
  6650. * @returns the dot product (float) of the point coordinates and the plane normal.
  6651. */
  6652. dotCoordinate(point: DeepImmutable<Vector3>): number;
  6653. /**
  6654. * Updates the current Plane from the plane defined by the three given points.
  6655. * @param point1 one of the points used to contruct the plane
  6656. * @param point2 one of the points used to contruct the plane
  6657. * @param point3 one of the points used to contruct the plane
  6658. * @returns the updated Plane.
  6659. */
  6660. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6661. /**
  6662. * Checks if the plane is facing a given direction
  6663. * @param direction the direction to check if the plane is facing
  6664. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  6665. * @returns True is the vector "direction" is the same side than the plane normal.
  6666. */
  6667. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  6668. /**
  6669. * Calculates the distance to a point
  6670. * @param point point to calculate distance to
  6671. * @returns the signed distance (float) from the given point to the Plane.
  6672. */
  6673. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  6674. /**
  6675. * Creates a plane from an array
  6676. * @param array the array to create a plane from
  6677. * @returns a new Plane from the given array.
  6678. */
  6679. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  6680. /**
  6681. * Creates a plane from three points
  6682. * @param point1 point used to create the plane
  6683. * @param point2 point used to create the plane
  6684. * @param point3 point used to create the plane
  6685. * @returns a new Plane defined by the three given points.
  6686. */
  6687. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  6688. /**
  6689. * Creates a plane from an origin point and a normal
  6690. * @param origin origin of the plane to be constructed
  6691. * @param normal normal of the plane to be constructed
  6692. * @returns a new Plane the normal vector to this plane at the given origin point.
  6693. * Note : the vector "normal" is updated because normalized.
  6694. */
  6695. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  6696. /**
  6697. * Calculates the distance from a plane and a point
  6698. * @param origin origin of the plane to be constructed
  6699. * @param normal normal of the plane to be constructed
  6700. * @param point point to calculate distance to
  6701. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  6702. */
  6703. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  6704. }
  6705. }
  6706. declare module "babylonjs/Culling/boundingSphere" {
  6707. import { DeepImmutable } from "babylonjs/types";
  6708. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6709. import { Plane } from "babylonjs/Maths/math.plane";
  6710. /**
  6711. * Class used to store bounding sphere information
  6712. */
  6713. export class BoundingSphere {
  6714. /**
  6715. * Gets the center of the bounding sphere in local space
  6716. */
  6717. readonly center: Vector3;
  6718. /**
  6719. * Radius of the bounding sphere in local space
  6720. */
  6721. radius: number;
  6722. /**
  6723. * Gets the center of the bounding sphere in world space
  6724. */
  6725. readonly centerWorld: Vector3;
  6726. /**
  6727. * Radius of the bounding sphere in world space
  6728. */
  6729. radiusWorld: number;
  6730. /**
  6731. * Gets the minimum vector in local space
  6732. */
  6733. readonly minimum: Vector3;
  6734. /**
  6735. * Gets the maximum vector in local space
  6736. */
  6737. readonly maximum: Vector3;
  6738. private _worldMatrix;
  6739. private static readonly TmpVector3;
  6740. /**
  6741. * Creates a new bounding sphere
  6742. * @param min defines the minimum vector (in local space)
  6743. * @param max defines the maximum vector (in local space)
  6744. * @param worldMatrix defines the new world matrix
  6745. */
  6746. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6747. /**
  6748. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6749. * @param min defines the new minimum vector (in local space)
  6750. * @param max defines the new maximum vector (in local space)
  6751. * @param worldMatrix defines the new world matrix
  6752. */
  6753. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6754. /**
  6755. * Scale the current bounding sphere by applying a scale factor
  6756. * @param factor defines the scale factor to apply
  6757. * @returns the current bounding box
  6758. */
  6759. scale(factor: number): BoundingSphere;
  6760. /**
  6761. * Gets the world matrix of the bounding box
  6762. * @returns a matrix
  6763. */
  6764. getWorldMatrix(): DeepImmutable<Matrix>;
  6765. /** @hidden */
  6766. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6767. /**
  6768. * Tests if the bounding sphere is intersecting the frustum planes
  6769. * @param frustumPlanes defines the frustum planes to test
  6770. * @returns true if there is an intersection
  6771. */
  6772. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6773. /**
  6774. * Tests if the bounding sphere center is in between the frustum planes.
  6775. * Used for optimistic fast inclusion.
  6776. * @param frustumPlanes defines the frustum planes to test
  6777. * @returns true if the sphere center is in between the frustum planes
  6778. */
  6779. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6780. /**
  6781. * Tests if a point is inside the bounding sphere
  6782. * @param point defines the point to test
  6783. * @returns true if the point is inside the bounding sphere
  6784. */
  6785. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6786. /**
  6787. * Checks if two sphere intersct
  6788. * @param sphere0 sphere 0
  6789. * @param sphere1 sphere 1
  6790. * @returns true if the speres intersect
  6791. */
  6792. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6793. }
  6794. }
  6795. declare module "babylonjs/Culling/boundingBox" {
  6796. import { DeepImmutable } from "babylonjs/types";
  6797. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6798. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6799. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6800. import { Plane } from "babylonjs/Maths/math.plane";
  6801. /**
  6802. * Class used to store bounding box information
  6803. */
  6804. export class BoundingBox implements ICullable {
  6805. /**
  6806. * Gets the 8 vectors representing the bounding box in local space
  6807. */
  6808. readonly vectors: Vector3[];
  6809. /**
  6810. * Gets the center of the bounding box in local space
  6811. */
  6812. readonly center: Vector3;
  6813. /**
  6814. * Gets the center of the bounding box in world space
  6815. */
  6816. readonly centerWorld: Vector3;
  6817. /**
  6818. * Gets the extend size in local space
  6819. */
  6820. readonly extendSize: Vector3;
  6821. /**
  6822. * Gets the extend size in world space
  6823. */
  6824. readonly extendSizeWorld: Vector3;
  6825. /**
  6826. * Gets the OBB (object bounding box) directions
  6827. */
  6828. readonly directions: Vector3[];
  6829. /**
  6830. * Gets the 8 vectors representing the bounding box in world space
  6831. */
  6832. readonly vectorsWorld: Vector3[];
  6833. /**
  6834. * Gets the minimum vector in world space
  6835. */
  6836. readonly minimumWorld: Vector3;
  6837. /**
  6838. * Gets the maximum vector in world space
  6839. */
  6840. readonly maximumWorld: Vector3;
  6841. /**
  6842. * Gets the minimum vector in local space
  6843. */
  6844. readonly minimum: Vector3;
  6845. /**
  6846. * Gets the maximum vector in local space
  6847. */
  6848. readonly maximum: Vector3;
  6849. private _worldMatrix;
  6850. private static readonly TmpVector3;
  6851. /**
  6852. * @hidden
  6853. */
  6854. _tag: number;
  6855. /**
  6856. * Creates a new bounding box
  6857. * @param min defines the minimum vector (in local space)
  6858. * @param max defines the maximum vector (in local space)
  6859. * @param worldMatrix defines the new world matrix
  6860. */
  6861. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6862. /**
  6863. * Recreates the entire bounding box from scratch as if we call the constructor in place
  6864. * @param min defines the new minimum vector (in local space)
  6865. * @param max defines the new maximum vector (in local space)
  6866. * @param worldMatrix defines the new world matrix
  6867. */
  6868. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6869. /**
  6870. * Scale the current bounding box by applying a scale factor
  6871. * @param factor defines the scale factor to apply
  6872. * @returns the current bounding box
  6873. */
  6874. scale(factor: number): BoundingBox;
  6875. /**
  6876. * Gets the world matrix of the bounding box
  6877. * @returns a matrix
  6878. */
  6879. getWorldMatrix(): DeepImmutable<Matrix>;
  6880. /** @hidden */
  6881. _update(world: DeepImmutable<Matrix>): void;
  6882. /**
  6883. * Tests if the bounding box is intersecting the frustum planes
  6884. * @param frustumPlanes defines the frustum planes to test
  6885. * @returns true if there is an intersection
  6886. */
  6887. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6888. /**
  6889. * Tests if the bounding box is entirely inside the frustum planes
  6890. * @param frustumPlanes defines the frustum planes to test
  6891. * @returns true if there is an inclusion
  6892. */
  6893. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6894. /**
  6895. * Tests if a point is inside the bounding box
  6896. * @param point defines the point to test
  6897. * @returns true if the point is inside the bounding box
  6898. */
  6899. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6900. /**
  6901. * Tests if the bounding box intersects with a bounding sphere
  6902. * @param sphere defines the sphere to test
  6903. * @returns true if there is an intersection
  6904. */
  6905. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  6906. /**
  6907. * Tests if the bounding box intersects with a box defined by a min and max vectors
  6908. * @param min defines the min vector to use
  6909. * @param max defines the max vector to use
  6910. * @returns true if there is an intersection
  6911. */
  6912. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  6913. /**
  6914. * Tests if two bounding boxes are intersections
  6915. * @param box0 defines the first box to test
  6916. * @param box1 defines the second box to test
  6917. * @returns true if there is an intersection
  6918. */
  6919. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  6920. /**
  6921. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  6922. * @param minPoint defines the minimum vector of the bounding box
  6923. * @param maxPoint defines the maximum vector of the bounding box
  6924. * @param sphereCenter defines the sphere center
  6925. * @param sphereRadius defines the sphere radius
  6926. * @returns true if there is an intersection
  6927. */
  6928. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  6929. /**
  6930. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  6931. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6932. * @param frustumPlanes defines the frustum planes to test
  6933. * @return true if there is an inclusion
  6934. */
  6935. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6936. /**
  6937. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  6938. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  6939. * @param frustumPlanes defines the frustum planes to test
  6940. * @return true if there is an intersection
  6941. */
  6942. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6943. }
  6944. }
  6945. declare module "babylonjs/Collisions/collider" {
  6946. import { Nullable, IndicesArray } from "babylonjs/types";
  6947. import { Vector3 } from "babylonjs/Maths/math.vector";
  6948. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  6949. import { Plane } from "babylonjs/Maths/math.plane";
  6950. /** @hidden */
  6951. export class Collider {
  6952. /** Define if a collision was found */
  6953. collisionFound: boolean;
  6954. /**
  6955. * Define last intersection point in local space
  6956. */
  6957. intersectionPoint: Vector3;
  6958. /**
  6959. * Define last collided mesh
  6960. */
  6961. collidedMesh: Nullable<AbstractMesh>;
  6962. private _collisionPoint;
  6963. private _planeIntersectionPoint;
  6964. private _tempVector;
  6965. private _tempVector2;
  6966. private _tempVector3;
  6967. private _tempVector4;
  6968. private _edge;
  6969. private _baseToVertex;
  6970. private _destinationPoint;
  6971. private _slidePlaneNormal;
  6972. private _displacementVector;
  6973. /** @hidden */
  6974. _radius: Vector3;
  6975. /** @hidden */
  6976. _retry: number;
  6977. private _velocity;
  6978. private _basePoint;
  6979. private _epsilon;
  6980. /** @hidden */
  6981. _velocityWorldLength: number;
  6982. /** @hidden */
  6983. _basePointWorld: Vector3;
  6984. private _velocityWorld;
  6985. private _normalizedVelocity;
  6986. /** @hidden */
  6987. _initialVelocity: Vector3;
  6988. /** @hidden */
  6989. _initialPosition: Vector3;
  6990. private _nearestDistance;
  6991. private _collisionMask;
  6992. collisionMask: number;
  6993. /**
  6994. * Gets the plane normal used to compute the sliding response (in local space)
  6995. */
  6996. readonly slidePlaneNormal: Vector3;
  6997. /** @hidden */
  6998. _initialize(source: Vector3, dir: Vector3, e: number): void;
  6999. /** @hidden */
  7000. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7001. /** @hidden */
  7002. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7003. /** @hidden */
  7004. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7005. /** @hidden */
  7006. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7007. /** @hidden */
  7008. _getResponse(pos: Vector3, vel: Vector3): void;
  7009. }
  7010. }
  7011. declare module "babylonjs/Culling/boundingInfo" {
  7012. import { DeepImmutable } from "babylonjs/types";
  7013. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7014. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7015. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7016. import { Plane } from "babylonjs/Maths/math.plane";
  7017. import { Collider } from "babylonjs/Collisions/collider";
  7018. /**
  7019. * Interface for cullable objects
  7020. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7021. */
  7022. export interface ICullable {
  7023. /**
  7024. * Checks if the object or part of the object is in the frustum
  7025. * @param frustumPlanes Camera near/planes
  7026. * @returns true if the object is in frustum otherwise false
  7027. */
  7028. isInFrustum(frustumPlanes: Plane[]): boolean;
  7029. /**
  7030. * Checks if a cullable object (mesh...) is in the camera frustum
  7031. * Unlike isInFrustum this cheks the full bounding box
  7032. * @param frustumPlanes Camera near/planes
  7033. * @returns true if the object is in frustum otherwise false
  7034. */
  7035. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7036. }
  7037. /**
  7038. * Info for a bounding data of a mesh
  7039. */
  7040. export class BoundingInfo implements ICullable {
  7041. /**
  7042. * Bounding box for the mesh
  7043. */
  7044. readonly boundingBox: BoundingBox;
  7045. /**
  7046. * Bounding sphere for the mesh
  7047. */
  7048. readonly boundingSphere: BoundingSphere;
  7049. private _isLocked;
  7050. private static readonly TmpVector3;
  7051. /**
  7052. * Constructs bounding info
  7053. * @param minimum min vector of the bounding box/sphere
  7054. * @param maximum max vector of the bounding box/sphere
  7055. * @param worldMatrix defines the new world matrix
  7056. */
  7057. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7058. /**
  7059. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7060. * @param min defines the new minimum vector (in local space)
  7061. * @param max defines the new maximum vector (in local space)
  7062. * @param worldMatrix defines the new world matrix
  7063. */
  7064. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7065. /**
  7066. * min vector of the bounding box/sphere
  7067. */
  7068. readonly minimum: Vector3;
  7069. /**
  7070. * max vector of the bounding box/sphere
  7071. */
  7072. readonly maximum: Vector3;
  7073. /**
  7074. * If the info is locked and won't be updated to avoid perf overhead
  7075. */
  7076. isLocked: boolean;
  7077. /**
  7078. * Updates the bounding sphere and box
  7079. * @param world world matrix to be used to update
  7080. */
  7081. update(world: DeepImmutable<Matrix>): void;
  7082. /**
  7083. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7084. * @param center New center of the bounding info
  7085. * @param extend New extend of the bounding info
  7086. * @returns the current bounding info
  7087. */
  7088. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7089. /**
  7090. * Scale the current bounding info by applying a scale factor
  7091. * @param factor defines the scale factor to apply
  7092. * @returns the current bounding info
  7093. */
  7094. scale(factor: number): BoundingInfo;
  7095. /**
  7096. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7097. * @param frustumPlanes defines the frustum to test
  7098. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7099. * @returns true if the bounding info is in the frustum planes
  7100. */
  7101. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7102. /**
  7103. * Gets the world distance between the min and max points of the bounding box
  7104. */
  7105. readonly diagonalLength: number;
  7106. /**
  7107. * Checks if a cullable object (mesh...) is in the camera frustum
  7108. * Unlike isInFrustum this cheks the full bounding box
  7109. * @param frustumPlanes Camera near/planes
  7110. * @returns true if the object is in frustum otherwise false
  7111. */
  7112. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7113. /** @hidden */
  7114. _checkCollision(collider: Collider): boolean;
  7115. /**
  7116. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7117. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7118. * @param point the point to check intersection with
  7119. * @returns if the point intersects
  7120. */
  7121. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7122. /**
  7123. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7124. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7125. * @param boundingInfo the bounding info to check intersection with
  7126. * @param precise if the intersection should be done using OBB
  7127. * @returns if the bounding info intersects
  7128. */
  7129. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7130. }
  7131. }
  7132. declare module "babylonjs/Maths/math.functions" {
  7133. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7134. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7135. /**
  7136. * Extracts minimum and maximum values from a list of indexed positions
  7137. * @param positions defines the positions to use
  7138. * @param indices defines the indices to the positions
  7139. * @param indexStart defines the start index
  7140. * @param indexCount defines the end index
  7141. * @param bias defines bias value to add to the result
  7142. * @return minimum and maximum values
  7143. */
  7144. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7145. minimum: Vector3;
  7146. maximum: Vector3;
  7147. };
  7148. /**
  7149. * Extracts minimum and maximum values from a list of positions
  7150. * @param positions defines the positions to use
  7151. * @param start defines the start index in the positions array
  7152. * @param count defines the number of positions to handle
  7153. * @param bias defines bias value to add to the result
  7154. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7155. * @return minimum and maximum values
  7156. */
  7157. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7158. minimum: Vector3;
  7159. maximum: Vector3;
  7160. };
  7161. }
  7162. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7163. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7164. /** @hidden */
  7165. export class WebGLDataBuffer extends DataBuffer {
  7166. private _buffer;
  7167. constructor(resource: WebGLBuffer);
  7168. readonly underlyingResource: any;
  7169. }
  7170. }
  7171. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7172. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7173. import { Nullable } from "babylonjs/types";
  7174. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7175. /** @hidden */
  7176. export class WebGLPipelineContext implements IPipelineContext {
  7177. engine: ThinEngine;
  7178. program: Nullable<WebGLProgram>;
  7179. context?: WebGLRenderingContext;
  7180. vertexShader?: WebGLShader;
  7181. fragmentShader?: WebGLShader;
  7182. isParallelCompiled: boolean;
  7183. onCompiled?: () => void;
  7184. transformFeedback?: WebGLTransformFeedback | null;
  7185. readonly isAsync: boolean;
  7186. readonly isReady: boolean;
  7187. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7188. }
  7189. }
  7190. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7191. import { FloatArray, Nullable } from "babylonjs/types";
  7192. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7193. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7194. module "babylonjs/Engines/thinEngine" {
  7195. interface ThinEngine {
  7196. /**
  7197. * Create an uniform buffer
  7198. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7199. * @param elements defines the content of the uniform buffer
  7200. * @returns the webGL uniform buffer
  7201. */
  7202. createUniformBuffer(elements: FloatArray): DataBuffer;
  7203. /**
  7204. * Create a dynamic uniform buffer
  7205. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7206. * @param elements defines the content of the uniform buffer
  7207. * @returns the webGL uniform buffer
  7208. */
  7209. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7210. /**
  7211. * Update an existing uniform buffer
  7212. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7213. * @param uniformBuffer defines the target uniform buffer
  7214. * @param elements defines the content to update
  7215. * @param offset defines the offset in the uniform buffer where update should start
  7216. * @param count defines the size of the data to update
  7217. */
  7218. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7219. /**
  7220. * Bind an uniform buffer to the current webGL context
  7221. * @param buffer defines the buffer to bind
  7222. */
  7223. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7224. /**
  7225. * Bind a buffer to the current webGL context at a given location
  7226. * @param buffer defines the buffer to bind
  7227. * @param location defines the index where to bind the buffer
  7228. */
  7229. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7230. /**
  7231. * Bind a specific block at a given index in a specific shader program
  7232. * @param pipelineContext defines the pipeline context to use
  7233. * @param blockName defines the block name
  7234. * @param index defines the index where to bind the block
  7235. */
  7236. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7237. }
  7238. }
  7239. }
  7240. declare module "babylonjs/Materials/uniformBuffer" {
  7241. import { Nullable, FloatArray } from "babylonjs/types";
  7242. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7243. import { Engine } from "babylonjs/Engines/engine";
  7244. import { Effect } from "babylonjs/Materials/effect";
  7245. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7246. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7247. import { Color3 } from "babylonjs/Maths/math.color";
  7248. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7249. /**
  7250. * Uniform buffer objects.
  7251. *
  7252. * Handles blocks of uniform on the GPU.
  7253. *
  7254. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7255. *
  7256. * For more information, please refer to :
  7257. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7258. */
  7259. export class UniformBuffer {
  7260. private _engine;
  7261. private _buffer;
  7262. private _data;
  7263. private _bufferData;
  7264. private _dynamic?;
  7265. private _uniformLocations;
  7266. private _uniformSizes;
  7267. private _uniformLocationPointer;
  7268. private _needSync;
  7269. private _noUBO;
  7270. private _currentEffect;
  7271. private static _MAX_UNIFORM_SIZE;
  7272. private static _tempBuffer;
  7273. /**
  7274. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7275. * This is dynamic to allow compat with webgl 1 and 2.
  7276. * You will need to pass the name of the uniform as well as the value.
  7277. */
  7278. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7279. /**
  7280. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7281. * This is dynamic to allow compat with webgl 1 and 2.
  7282. * You will need to pass the name of the uniform as well as the value.
  7283. */
  7284. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7285. /**
  7286. * Lambda to Update a single float in a uniform buffer.
  7287. * This is dynamic to allow compat with webgl 1 and 2.
  7288. * You will need to pass the name of the uniform as well as the value.
  7289. */
  7290. updateFloat: (name: string, x: number) => void;
  7291. /**
  7292. * Lambda to Update a vec2 of float in a uniform buffer.
  7293. * This is dynamic to allow compat with webgl 1 and 2.
  7294. * You will need to pass the name of the uniform as well as the value.
  7295. */
  7296. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7297. /**
  7298. * Lambda to Update a vec3 of float in a uniform buffer.
  7299. * This is dynamic to allow compat with webgl 1 and 2.
  7300. * You will need to pass the name of the uniform as well as the value.
  7301. */
  7302. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7303. /**
  7304. * Lambda to Update a vec4 of float in a uniform buffer.
  7305. * This is dynamic to allow compat with webgl 1 and 2.
  7306. * You will need to pass the name of the uniform as well as the value.
  7307. */
  7308. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7309. /**
  7310. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7311. * This is dynamic to allow compat with webgl 1 and 2.
  7312. * You will need to pass the name of the uniform as well as the value.
  7313. */
  7314. updateMatrix: (name: string, mat: Matrix) => void;
  7315. /**
  7316. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7317. * This is dynamic to allow compat with webgl 1 and 2.
  7318. * You will need to pass the name of the uniform as well as the value.
  7319. */
  7320. updateVector3: (name: string, vector: Vector3) => void;
  7321. /**
  7322. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7323. * This is dynamic to allow compat with webgl 1 and 2.
  7324. * You will need to pass the name of the uniform as well as the value.
  7325. */
  7326. updateVector4: (name: string, vector: Vector4) => void;
  7327. /**
  7328. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7329. * This is dynamic to allow compat with webgl 1 and 2.
  7330. * You will need to pass the name of the uniform as well as the value.
  7331. */
  7332. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7333. /**
  7334. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7335. * This is dynamic to allow compat with webgl 1 and 2.
  7336. * You will need to pass the name of the uniform as well as the value.
  7337. */
  7338. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7339. /**
  7340. * Instantiates a new Uniform buffer objects.
  7341. *
  7342. * Handles blocks of uniform on the GPU.
  7343. *
  7344. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7345. *
  7346. * For more information, please refer to :
  7347. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7348. * @param engine Define the engine the buffer is associated with
  7349. * @param data Define the data contained in the buffer
  7350. * @param dynamic Define if the buffer is updatable
  7351. */
  7352. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7353. /**
  7354. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7355. * or just falling back on setUniformXXX calls.
  7356. */
  7357. readonly useUbo: boolean;
  7358. /**
  7359. * Indicates if the WebGL underlying uniform buffer is in sync
  7360. * with the javascript cache data.
  7361. */
  7362. readonly isSync: boolean;
  7363. /**
  7364. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7365. * Also, a dynamic UniformBuffer will disable cache verification and always
  7366. * update the underlying WebGL uniform buffer to the GPU.
  7367. * @returns if Dynamic, otherwise false
  7368. */
  7369. isDynamic(): boolean;
  7370. /**
  7371. * The data cache on JS side.
  7372. * @returns the underlying data as a float array
  7373. */
  7374. getData(): Float32Array;
  7375. /**
  7376. * The underlying WebGL Uniform buffer.
  7377. * @returns the webgl buffer
  7378. */
  7379. getBuffer(): Nullable<DataBuffer>;
  7380. /**
  7381. * std140 layout specifies how to align data within an UBO structure.
  7382. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7383. * for specs.
  7384. */
  7385. private _fillAlignment;
  7386. /**
  7387. * Adds an uniform in the buffer.
  7388. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7389. * for the layout to be correct !
  7390. * @param name Name of the uniform, as used in the uniform block in the shader.
  7391. * @param size Data size, or data directly.
  7392. */
  7393. addUniform(name: string, size: number | number[]): void;
  7394. /**
  7395. * Adds a Matrix 4x4 to the uniform buffer.
  7396. * @param name Name of the uniform, as used in the uniform block in the shader.
  7397. * @param mat A 4x4 matrix.
  7398. */
  7399. addMatrix(name: string, mat: Matrix): void;
  7400. /**
  7401. * Adds a vec2 to the uniform buffer.
  7402. * @param name Name of the uniform, as used in the uniform block in the shader.
  7403. * @param x Define the x component value of the vec2
  7404. * @param y Define the y component value of the vec2
  7405. */
  7406. addFloat2(name: string, x: number, y: number): void;
  7407. /**
  7408. * Adds a vec3 to the uniform buffer.
  7409. * @param name Name of the uniform, as used in the uniform block in the shader.
  7410. * @param x Define the x component value of the vec3
  7411. * @param y Define the y component value of the vec3
  7412. * @param z Define the z component value of the vec3
  7413. */
  7414. addFloat3(name: string, x: number, y: number, z: number): void;
  7415. /**
  7416. * Adds a vec3 to the uniform buffer.
  7417. * @param name Name of the uniform, as used in the uniform block in the shader.
  7418. * @param color Define the vec3 from a Color
  7419. */
  7420. addColor3(name: string, color: Color3): void;
  7421. /**
  7422. * Adds a vec4 to the uniform buffer.
  7423. * @param name Name of the uniform, as used in the uniform block in the shader.
  7424. * @param color Define the rgb components from a Color
  7425. * @param alpha Define the a component of the vec4
  7426. */
  7427. addColor4(name: string, color: Color3, alpha: number): void;
  7428. /**
  7429. * Adds a vec3 to the uniform buffer.
  7430. * @param name Name of the uniform, as used in the uniform block in the shader.
  7431. * @param vector Define the vec3 components from a Vector
  7432. */
  7433. addVector3(name: string, vector: Vector3): void;
  7434. /**
  7435. * Adds a Matrix 3x3 to the uniform buffer.
  7436. * @param name Name of the uniform, as used in the uniform block in the shader.
  7437. */
  7438. addMatrix3x3(name: string): void;
  7439. /**
  7440. * Adds a Matrix 2x2 to the uniform buffer.
  7441. * @param name Name of the uniform, as used in the uniform block in the shader.
  7442. */
  7443. addMatrix2x2(name: string): void;
  7444. /**
  7445. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7446. */
  7447. create(): void;
  7448. /** @hidden */
  7449. _rebuild(): void;
  7450. /**
  7451. * Updates the WebGL Uniform Buffer on the GPU.
  7452. * If the `dynamic` flag is set to true, no cache comparison is done.
  7453. * Otherwise, the buffer will be updated only if the cache differs.
  7454. */
  7455. update(): void;
  7456. /**
  7457. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7458. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7459. * @param data Define the flattened data
  7460. * @param size Define the size of the data.
  7461. */
  7462. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7463. private _valueCache;
  7464. private _cacheMatrix;
  7465. private _updateMatrix3x3ForUniform;
  7466. private _updateMatrix3x3ForEffect;
  7467. private _updateMatrix2x2ForEffect;
  7468. private _updateMatrix2x2ForUniform;
  7469. private _updateFloatForEffect;
  7470. private _updateFloatForUniform;
  7471. private _updateFloat2ForEffect;
  7472. private _updateFloat2ForUniform;
  7473. private _updateFloat3ForEffect;
  7474. private _updateFloat3ForUniform;
  7475. private _updateFloat4ForEffect;
  7476. private _updateFloat4ForUniform;
  7477. private _updateMatrixForEffect;
  7478. private _updateMatrixForUniform;
  7479. private _updateVector3ForEffect;
  7480. private _updateVector3ForUniform;
  7481. private _updateVector4ForEffect;
  7482. private _updateVector4ForUniform;
  7483. private _updateColor3ForEffect;
  7484. private _updateColor3ForUniform;
  7485. private _updateColor4ForEffect;
  7486. private _updateColor4ForUniform;
  7487. /**
  7488. * Sets a sampler uniform on the effect.
  7489. * @param name Define the name of the sampler.
  7490. * @param texture Define the texture to set in the sampler
  7491. */
  7492. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7493. /**
  7494. * Directly updates the value of the uniform in the cache AND on the GPU.
  7495. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7496. * @param data Define the flattened data
  7497. */
  7498. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7499. /**
  7500. * Binds this uniform buffer to an effect.
  7501. * @param effect Define the effect to bind the buffer to
  7502. * @param name Name of the uniform block in the shader.
  7503. */
  7504. bindToEffect(effect: Effect, name: string): void;
  7505. /**
  7506. * Disposes the uniform buffer.
  7507. */
  7508. dispose(): void;
  7509. }
  7510. }
  7511. declare module "babylonjs/Misc/iInspectable" {
  7512. /**
  7513. * Enum that determines the text-wrapping mode to use.
  7514. */
  7515. export enum InspectableType {
  7516. /**
  7517. * Checkbox for booleans
  7518. */
  7519. Checkbox = 0,
  7520. /**
  7521. * Sliders for numbers
  7522. */
  7523. Slider = 1,
  7524. /**
  7525. * Vector3
  7526. */
  7527. Vector3 = 2,
  7528. /**
  7529. * Quaternions
  7530. */
  7531. Quaternion = 3,
  7532. /**
  7533. * Color3
  7534. */
  7535. Color3 = 4,
  7536. /**
  7537. * String
  7538. */
  7539. String = 5
  7540. }
  7541. /**
  7542. * Interface used to define custom inspectable properties.
  7543. * This interface is used by the inspector to display custom property grids
  7544. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7545. */
  7546. export interface IInspectable {
  7547. /**
  7548. * Gets the label to display
  7549. */
  7550. label: string;
  7551. /**
  7552. * Gets the name of the property to edit
  7553. */
  7554. propertyName: string;
  7555. /**
  7556. * Gets the type of the editor to use
  7557. */
  7558. type: InspectableType;
  7559. /**
  7560. * Gets the minimum value of the property when using in "slider" mode
  7561. */
  7562. min?: number;
  7563. /**
  7564. * Gets the maximum value of the property when using in "slider" mode
  7565. */
  7566. max?: number;
  7567. /**
  7568. * Gets the setp to use when using in "slider" mode
  7569. */
  7570. step?: number;
  7571. }
  7572. }
  7573. declare module "babylonjs/Misc/timingTools" {
  7574. /**
  7575. * Class used to provide helper for timing
  7576. */
  7577. export class TimingTools {
  7578. /**
  7579. * Polyfill for setImmediate
  7580. * @param action defines the action to execute after the current execution block
  7581. */
  7582. static SetImmediate(action: () => void): void;
  7583. }
  7584. }
  7585. declare module "babylonjs/Misc/instantiationTools" {
  7586. /**
  7587. * Class used to enable instatition of objects by class name
  7588. */
  7589. export class InstantiationTools {
  7590. /**
  7591. * Use this object to register external classes like custom textures or material
  7592. * to allow the laoders to instantiate them
  7593. */
  7594. static RegisteredExternalClasses: {
  7595. [key: string]: Object;
  7596. };
  7597. /**
  7598. * Tries to instantiate a new object from a given class name
  7599. * @param className defines the class name to instantiate
  7600. * @returns the new object or null if the system was not able to do the instantiation
  7601. */
  7602. static Instantiate(className: string): any;
  7603. }
  7604. }
  7605. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7606. /**
  7607. * Define options used to create a depth texture
  7608. */
  7609. export class DepthTextureCreationOptions {
  7610. /** Specifies whether or not a stencil should be allocated in the texture */
  7611. generateStencil?: boolean;
  7612. /** Specifies whether or not bilinear filtering is enable on the texture */
  7613. bilinearFiltering?: boolean;
  7614. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7615. comparisonFunction?: number;
  7616. /** Specifies if the created texture is a cube texture */
  7617. isCube?: boolean;
  7618. }
  7619. }
  7620. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7621. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7622. import { Nullable } from "babylonjs/types";
  7623. import { Scene } from "babylonjs/scene";
  7624. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  7625. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7626. module "babylonjs/Engines/thinEngine" {
  7627. interface ThinEngine {
  7628. /**
  7629. * Creates a depth stencil cube texture.
  7630. * This is only available in WebGL 2.
  7631. * @param size The size of face edge in the cube texture.
  7632. * @param options The options defining the cube texture.
  7633. * @returns The cube texture
  7634. */
  7635. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7636. /**
  7637. * Creates a cube texture
  7638. * @param rootUrl defines the url where the files to load is located
  7639. * @param scene defines the current scene
  7640. * @param files defines the list of files to load (1 per face)
  7641. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7642. * @param onLoad defines an optional callback raised when the texture is loaded
  7643. * @param onError defines an optional callback raised if there is an issue to load the texture
  7644. * @param format defines the format of the data
  7645. * @param forcedExtension defines the extension to use to pick the right loader
  7646. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7647. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7648. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7649. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7650. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  7651. * @returns the cube texture as an InternalTexture
  7652. */
  7653. 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;
  7654. /**
  7655. * Creates a cube texture
  7656. * @param rootUrl defines the url where the files to load is located
  7657. * @param scene defines the current scene
  7658. * @param files defines the list of files to load (1 per face)
  7659. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7660. * @param onLoad defines an optional callback raised when the texture is loaded
  7661. * @param onError defines an optional callback raised if there is an issue to load the texture
  7662. * @param format defines the format of the data
  7663. * @param forcedExtension defines the extension to use to pick the right loader
  7664. * @returns the cube texture as an InternalTexture
  7665. */
  7666. 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;
  7667. /**
  7668. * Creates a cube texture
  7669. * @param rootUrl defines the url where the files to load is located
  7670. * @param scene defines the current scene
  7671. * @param files defines the list of files to load (1 per face)
  7672. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7673. * @param onLoad defines an optional callback raised when the texture is loaded
  7674. * @param onError defines an optional callback raised if there is an issue to load the texture
  7675. * @param format defines the format of the data
  7676. * @param forcedExtension defines the extension to use to pick the right loader
  7677. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7678. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7679. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7680. * @returns the cube texture as an InternalTexture
  7681. */
  7682. 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;
  7683. /** @hidden */
  7684. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7685. /** @hidden */
  7686. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7687. /** @hidden */
  7688. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7689. /** @hidden */
  7690. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7691. }
  7692. }
  7693. }
  7694. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7695. import { Nullable } from "babylonjs/types";
  7696. import { Scene } from "babylonjs/scene";
  7697. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7698. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7699. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7700. /**
  7701. * Class for creating a cube texture
  7702. */
  7703. export class CubeTexture extends BaseTexture {
  7704. private _delayedOnLoad;
  7705. /**
  7706. * The url of the texture
  7707. */
  7708. url: string;
  7709. /**
  7710. * Gets or sets the center of the bounding box associated with the cube texture.
  7711. * It must define where the camera used to render the texture was set
  7712. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7713. */
  7714. boundingBoxPosition: Vector3;
  7715. private _boundingBoxSize;
  7716. /**
  7717. * Gets or sets the size of the bounding box associated with the cube texture
  7718. * When defined, the cubemap will switch to local mode
  7719. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7720. * @example https://www.babylonjs-playground.com/#RNASML
  7721. */
  7722. /**
  7723. * Returns the bounding box size
  7724. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7725. */
  7726. boundingBoxSize: Vector3;
  7727. protected _rotationY: number;
  7728. /**
  7729. * Sets texture matrix rotation angle around Y axis in radians.
  7730. */
  7731. /**
  7732. * Gets texture matrix rotation angle around Y axis radians.
  7733. */
  7734. rotationY: number;
  7735. /**
  7736. * Are mip maps generated for this texture or not.
  7737. */
  7738. readonly noMipmap: boolean;
  7739. private _noMipmap;
  7740. private _files;
  7741. protected _forcedExtension: Nullable<string>;
  7742. private _extensions;
  7743. private _textureMatrix;
  7744. private _format;
  7745. private _createPolynomials;
  7746. /** @hidden */
  7747. _prefiltered: boolean;
  7748. /**
  7749. * Creates a cube texture from an array of image urls
  7750. * @param files defines an array of image urls
  7751. * @param scene defines the hosting scene
  7752. * @param noMipmap specifies if mip maps are not used
  7753. * @returns a cube texture
  7754. */
  7755. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  7756. /**
  7757. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  7758. * @param url defines the url of the prefiltered texture
  7759. * @param scene defines the scene the texture is attached to
  7760. * @param forcedExtension defines the extension of the file if different from the url
  7761. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7762. * @return the prefiltered texture
  7763. */
  7764. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  7765. /**
  7766. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  7767. * as prefiltered data.
  7768. * @param rootUrl defines the url of the texture or the root name of the six images
  7769. * @param scene defines the scene the texture is attached to
  7770. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  7771. * @param noMipmap defines if mipmaps should be created or not
  7772. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  7773. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  7774. * @param onError defines a callback triggered in case of error during load
  7775. * @param format defines the internal format to use for the texture once loaded
  7776. * @param prefiltered defines whether or not the texture is created from prefiltered data
  7777. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  7778. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  7779. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7780. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7781. * @return the cube texture
  7782. */
  7783. 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);
  7784. /**
  7785. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  7786. */
  7787. readonly isPrefiltered: boolean;
  7788. /**
  7789. * Get the current class name of the texture useful for serialization or dynamic coding.
  7790. * @returns "CubeTexture"
  7791. */
  7792. getClassName(): string;
  7793. /**
  7794. * Update the url (and optional buffer) of this texture if url was null during construction.
  7795. * @param url the url of the texture
  7796. * @param forcedExtension defines the extension to use
  7797. * @param onLoad callback called when the texture is loaded (defaults to null)
  7798. */
  7799. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  7800. /**
  7801. * Delays loading of the cube texture
  7802. * @param forcedExtension defines the extension to use
  7803. */
  7804. delayLoad(forcedExtension?: string): void;
  7805. /**
  7806. * Returns the reflection texture matrix
  7807. * @returns the reflection texture matrix
  7808. */
  7809. getReflectionTextureMatrix(): Matrix;
  7810. /**
  7811. * Sets the reflection texture matrix
  7812. * @param value Reflection texture matrix
  7813. */
  7814. setReflectionTextureMatrix(value: Matrix): void;
  7815. /**
  7816. * Parses text to create a cube texture
  7817. * @param parsedTexture define the serialized text to read from
  7818. * @param scene defines the hosting scene
  7819. * @param rootUrl defines the root url of the cube texture
  7820. * @returns a cube texture
  7821. */
  7822. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  7823. /**
  7824. * Makes a clone, or deep copy, of the cube texture
  7825. * @returns a new cube texture
  7826. */
  7827. clone(): CubeTexture;
  7828. }
  7829. }
  7830. declare module "babylonjs/Materials/materialDefines" {
  7831. /**
  7832. * Manages the defines for the Material
  7833. */
  7834. export class MaterialDefines {
  7835. /** @hidden */
  7836. protected _keys: string[];
  7837. private _isDirty;
  7838. /** @hidden */
  7839. _renderId: number;
  7840. /** @hidden */
  7841. _areLightsDirty: boolean;
  7842. /** @hidden */
  7843. _areLightsDisposed: boolean;
  7844. /** @hidden */
  7845. _areAttributesDirty: boolean;
  7846. /** @hidden */
  7847. _areTexturesDirty: boolean;
  7848. /** @hidden */
  7849. _areFresnelDirty: boolean;
  7850. /** @hidden */
  7851. _areMiscDirty: boolean;
  7852. /** @hidden */
  7853. _areImageProcessingDirty: boolean;
  7854. /** @hidden */
  7855. _normals: boolean;
  7856. /** @hidden */
  7857. _uvs: boolean;
  7858. /** @hidden */
  7859. _needNormals: boolean;
  7860. /** @hidden */
  7861. _needUVs: boolean;
  7862. [id: string]: any;
  7863. /**
  7864. * Specifies if the material needs to be re-calculated
  7865. */
  7866. readonly isDirty: boolean;
  7867. /**
  7868. * Marks the material to indicate that it has been re-calculated
  7869. */
  7870. markAsProcessed(): void;
  7871. /**
  7872. * Marks the material to indicate that it needs to be re-calculated
  7873. */
  7874. markAsUnprocessed(): void;
  7875. /**
  7876. * Marks the material to indicate all of its defines need to be re-calculated
  7877. */
  7878. markAllAsDirty(): void;
  7879. /**
  7880. * Marks the material to indicate that image processing needs to be re-calculated
  7881. */
  7882. markAsImageProcessingDirty(): void;
  7883. /**
  7884. * Marks the material to indicate the lights need to be re-calculated
  7885. * @param disposed Defines whether the light is dirty due to dispose or not
  7886. */
  7887. markAsLightDirty(disposed?: boolean): void;
  7888. /**
  7889. * Marks the attribute state as changed
  7890. */
  7891. markAsAttributesDirty(): void;
  7892. /**
  7893. * Marks the texture state as changed
  7894. */
  7895. markAsTexturesDirty(): void;
  7896. /**
  7897. * Marks the fresnel state as changed
  7898. */
  7899. markAsFresnelDirty(): void;
  7900. /**
  7901. * Marks the misc state as changed
  7902. */
  7903. markAsMiscDirty(): void;
  7904. /**
  7905. * Rebuilds the material defines
  7906. */
  7907. rebuild(): void;
  7908. /**
  7909. * Specifies if two material defines are equal
  7910. * @param other - A material define instance to compare to
  7911. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  7912. */
  7913. isEqual(other: MaterialDefines): boolean;
  7914. /**
  7915. * Clones this instance's defines to another instance
  7916. * @param other - material defines to clone values to
  7917. */
  7918. cloneTo(other: MaterialDefines): void;
  7919. /**
  7920. * Resets the material define values
  7921. */
  7922. reset(): void;
  7923. /**
  7924. * Converts the material define values to a string
  7925. * @returns - String of material define information
  7926. */
  7927. toString(): string;
  7928. }
  7929. }
  7930. declare module "babylonjs/Materials/colorCurves" {
  7931. import { Effect } from "babylonjs/Materials/effect";
  7932. /**
  7933. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  7934. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  7935. * 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;
  7936. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  7937. */
  7938. export class ColorCurves {
  7939. private _dirty;
  7940. private _tempColor;
  7941. private _globalCurve;
  7942. private _highlightsCurve;
  7943. private _midtonesCurve;
  7944. private _shadowsCurve;
  7945. private _positiveCurve;
  7946. private _negativeCurve;
  7947. private _globalHue;
  7948. private _globalDensity;
  7949. private _globalSaturation;
  7950. private _globalExposure;
  7951. /**
  7952. * Gets the global Hue value.
  7953. * 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).
  7954. */
  7955. /**
  7956. * Sets the global Hue value.
  7957. * 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).
  7958. */
  7959. globalHue: number;
  7960. /**
  7961. * Gets the global Density value.
  7962. * 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.
  7963. * Values less than zero provide a filter of opposite hue.
  7964. */
  7965. /**
  7966. * Sets the global Density value.
  7967. * 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.
  7968. * Values less than zero provide a filter of opposite hue.
  7969. */
  7970. globalDensity: number;
  7971. /**
  7972. * Gets the global Saturation value.
  7973. * 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.
  7974. */
  7975. /**
  7976. * Sets the global Saturation value.
  7977. * 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.
  7978. */
  7979. globalSaturation: number;
  7980. /**
  7981. * Gets the global Exposure value.
  7982. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7983. */
  7984. /**
  7985. * Sets the global Exposure value.
  7986. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  7987. */
  7988. globalExposure: number;
  7989. private _highlightsHue;
  7990. private _highlightsDensity;
  7991. private _highlightsSaturation;
  7992. private _highlightsExposure;
  7993. /**
  7994. * Gets the highlights Hue value.
  7995. * 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).
  7996. */
  7997. /**
  7998. * Sets the highlights Hue value.
  7999. * 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).
  8000. */
  8001. highlightsHue: number;
  8002. /**
  8003. * Gets the highlights Density value.
  8004. * 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.
  8005. * Values less than zero provide a filter of opposite hue.
  8006. */
  8007. /**
  8008. * Sets the highlights Density value.
  8009. * 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.
  8010. * Values less than zero provide a filter of opposite hue.
  8011. */
  8012. highlightsDensity: number;
  8013. /**
  8014. * Gets the highlights Saturation value.
  8015. * 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.
  8016. */
  8017. /**
  8018. * Sets the highlights Saturation value.
  8019. * 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.
  8020. */
  8021. highlightsSaturation: number;
  8022. /**
  8023. * Gets the highlights Exposure value.
  8024. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8025. */
  8026. /**
  8027. * Sets the highlights Exposure value.
  8028. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8029. */
  8030. highlightsExposure: number;
  8031. private _midtonesHue;
  8032. private _midtonesDensity;
  8033. private _midtonesSaturation;
  8034. private _midtonesExposure;
  8035. /**
  8036. * Gets the midtones Hue value.
  8037. * 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).
  8038. */
  8039. /**
  8040. * Sets the midtones Hue value.
  8041. * 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).
  8042. */
  8043. midtonesHue: number;
  8044. /**
  8045. * Gets the midtones Density value.
  8046. * 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.
  8047. * Values less than zero provide a filter of opposite hue.
  8048. */
  8049. /**
  8050. * Sets the midtones Density value.
  8051. * 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.
  8052. * Values less than zero provide a filter of opposite hue.
  8053. */
  8054. midtonesDensity: number;
  8055. /**
  8056. * Gets the midtones Saturation value.
  8057. * 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.
  8058. */
  8059. /**
  8060. * Sets the midtones Saturation value.
  8061. * 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.
  8062. */
  8063. midtonesSaturation: number;
  8064. /**
  8065. * Gets the midtones Exposure value.
  8066. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8067. */
  8068. /**
  8069. * Sets the midtones Exposure value.
  8070. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8071. */
  8072. midtonesExposure: number;
  8073. private _shadowsHue;
  8074. private _shadowsDensity;
  8075. private _shadowsSaturation;
  8076. private _shadowsExposure;
  8077. /**
  8078. * Gets the shadows Hue value.
  8079. * 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).
  8080. */
  8081. /**
  8082. * Sets the shadows Hue value.
  8083. * 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).
  8084. */
  8085. shadowsHue: number;
  8086. /**
  8087. * Gets the shadows Density value.
  8088. * 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.
  8089. * Values less than zero provide a filter of opposite hue.
  8090. */
  8091. /**
  8092. * Sets the shadows Density value.
  8093. * 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.
  8094. * Values less than zero provide a filter of opposite hue.
  8095. */
  8096. shadowsDensity: number;
  8097. /**
  8098. * Gets the shadows Saturation value.
  8099. * 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.
  8100. */
  8101. /**
  8102. * Sets the shadows Saturation value.
  8103. * 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.
  8104. */
  8105. shadowsSaturation: number;
  8106. /**
  8107. * Gets the shadows Exposure value.
  8108. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8109. */
  8110. /**
  8111. * Sets the shadows Exposure value.
  8112. * This is an adjustment value in the range [-100,+100], where the default value of 0.0 makes no adjustment, positive values increase exposure and negative values decrease exposure.
  8113. */
  8114. shadowsExposure: number;
  8115. /**
  8116. * Returns the class name
  8117. * @returns The class name
  8118. */
  8119. getClassName(): string;
  8120. /**
  8121. * Binds the color curves to the shader.
  8122. * @param colorCurves The color curve to bind
  8123. * @param effect The effect to bind to
  8124. * @param positiveUniform The positive uniform shader parameter
  8125. * @param neutralUniform The neutral uniform shader parameter
  8126. * @param negativeUniform The negative uniform shader parameter
  8127. */
  8128. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8129. /**
  8130. * Prepare the list of uniforms associated with the ColorCurves effects.
  8131. * @param uniformsList The list of uniforms used in the effect
  8132. */
  8133. static PrepareUniforms(uniformsList: string[]): void;
  8134. /**
  8135. * Returns color grading data based on a hue, density, saturation and exposure value.
  8136. * @param filterHue The hue of the color filter.
  8137. * @param filterDensity The density of the color filter.
  8138. * @param saturation The saturation.
  8139. * @param exposure The exposure.
  8140. * @param result The result data container.
  8141. */
  8142. private getColorGradingDataToRef;
  8143. /**
  8144. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8145. * @param value The input slider value in range [-100,100].
  8146. * @returns Adjusted value.
  8147. */
  8148. private static applyColorGradingSliderNonlinear;
  8149. /**
  8150. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8151. * @param hue The hue (H) input.
  8152. * @param saturation The saturation (S) input.
  8153. * @param brightness The brightness (B) input.
  8154. * @result An RGBA color represented as Vector4.
  8155. */
  8156. private static fromHSBToRef;
  8157. /**
  8158. * Returns a value clamped between min and max
  8159. * @param value The value to clamp
  8160. * @param min The minimum of value
  8161. * @param max The maximum of value
  8162. * @returns The clamped value.
  8163. */
  8164. private static clamp;
  8165. /**
  8166. * Clones the current color curve instance.
  8167. * @return The cloned curves
  8168. */
  8169. clone(): ColorCurves;
  8170. /**
  8171. * Serializes the current color curve instance to a json representation.
  8172. * @return a JSON representation
  8173. */
  8174. serialize(): any;
  8175. /**
  8176. * Parses the color curve from a json representation.
  8177. * @param source the JSON source to parse
  8178. * @return The parsed curves
  8179. */
  8180. static Parse(source: any): ColorCurves;
  8181. }
  8182. }
  8183. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8184. import { Observable } from "babylonjs/Misc/observable";
  8185. import { Nullable } from "babylonjs/types";
  8186. import { Color4 } from "babylonjs/Maths/math.color";
  8187. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8188. import { Effect } from "babylonjs/Materials/effect";
  8189. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8190. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8191. /**
  8192. * Interface to follow in your material defines to integrate easily the
  8193. * Image proccessing functions.
  8194. * @hidden
  8195. */
  8196. export interface IImageProcessingConfigurationDefines {
  8197. IMAGEPROCESSING: boolean;
  8198. VIGNETTE: boolean;
  8199. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8200. VIGNETTEBLENDMODEOPAQUE: boolean;
  8201. TONEMAPPING: boolean;
  8202. TONEMAPPING_ACES: boolean;
  8203. CONTRAST: boolean;
  8204. EXPOSURE: boolean;
  8205. COLORCURVES: boolean;
  8206. COLORGRADING: boolean;
  8207. COLORGRADING3D: boolean;
  8208. SAMPLER3DGREENDEPTH: boolean;
  8209. SAMPLER3DBGRMAP: boolean;
  8210. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8211. }
  8212. /**
  8213. * @hidden
  8214. */
  8215. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8216. IMAGEPROCESSING: boolean;
  8217. VIGNETTE: boolean;
  8218. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8219. VIGNETTEBLENDMODEOPAQUE: boolean;
  8220. TONEMAPPING: boolean;
  8221. TONEMAPPING_ACES: boolean;
  8222. CONTRAST: boolean;
  8223. COLORCURVES: boolean;
  8224. COLORGRADING: boolean;
  8225. COLORGRADING3D: boolean;
  8226. SAMPLER3DGREENDEPTH: boolean;
  8227. SAMPLER3DBGRMAP: boolean;
  8228. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8229. EXPOSURE: boolean;
  8230. constructor();
  8231. }
  8232. /**
  8233. * This groups together the common properties used for image processing either in direct forward pass
  8234. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8235. * or not.
  8236. */
  8237. export class ImageProcessingConfiguration {
  8238. /**
  8239. * Default tone mapping applied in BabylonJS.
  8240. */
  8241. static readonly TONEMAPPING_STANDARD: number;
  8242. /**
  8243. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8244. * to other engines rendering to increase portability.
  8245. */
  8246. static readonly TONEMAPPING_ACES: number;
  8247. /**
  8248. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8249. */
  8250. colorCurves: Nullable<ColorCurves>;
  8251. private _colorCurvesEnabled;
  8252. /**
  8253. * Gets wether the color curves effect is enabled.
  8254. */
  8255. /**
  8256. * Sets wether the color curves effect is enabled.
  8257. */
  8258. colorCurvesEnabled: boolean;
  8259. private _colorGradingTexture;
  8260. /**
  8261. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8262. */
  8263. /**
  8264. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8265. */
  8266. colorGradingTexture: Nullable<BaseTexture>;
  8267. private _colorGradingEnabled;
  8268. /**
  8269. * Gets wether the color grading effect is enabled.
  8270. */
  8271. /**
  8272. * Sets wether the color grading effect is enabled.
  8273. */
  8274. colorGradingEnabled: boolean;
  8275. private _colorGradingWithGreenDepth;
  8276. /**
  8277. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8278. */
  8279. /**
  8280. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8281. */
  8282. colorGradingWithGreenDepth: boolean;
  8283. private _colorGradingBGR;
  8284. /**
  8285. * Gets wether the color grading texture contains BGR values.
  8286. */
  8287. /**
  8288. * Sets wether the color grading texture contains BGR values.
  8289. */
  8290. colorGradingBGR: boolean;
  8291. /** @hidden */
  8292. _exposure: number;
  8293. /**
  8294. * Gets the Exposure used in the effect.
  8295. */
  8296. /**
  8297. * Sets the Exposure used in the effect.
  8298. */
  8299. exposure: number;
  8300. private _toneMappingEnabled;
  8301. /**
  8302. * Gets wether the tone mapping effect is enabled.
  8303. */
  8304. /**
  8305. * Sets wether the tone mapping effect is enabled.
  8306. */
  8307. toneMappingEnabled: boolean;
  8308. private _toneMappingType;
  8309. /**
  8310. * Gets the type of tone mapping effect.
  8311. */
  8312. /**
  8313. * Sets the type of tone mapping effect used in BabylonJS.
  8314. */
  8315. toneMappingType: number;
  8316. protected _contrast: number;
  8317. /**
  8318. * Gets the contrast used in the effect.
  8319. */
  8320. /**
  8321. * Sets the contrast used in the effect.
  8322. */
  8323. contrast: number;
  8324. /**
  8325. * Vignette stretch size.
  8326. */
  8327. vignetteStretch: number;
  8328. /**
  8329. * Vignette centre X Offset.
  8330. */
  8331. vignetteCentreX: number;
  8332. /**
  8333. * Vignette centre Y Offset.
  8334. */
  8335. vignetteCentreY: number;
  8336. /**
  8337. * Vignette weight or intensity of the vignette effect.
  8338. */
  8339. vignetteWeight: number;
  8340. /**
  8341. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8342. * if vignetteEnabled is set to true.
  8343. */
  8344. vignetteColor: Color4;
  8345. /**
  8346. * Camera field of view used by the Vignette effect.
  8347. */
  8348. vignetteCameraFov: number;
  8349. private _vignetteBlendMode;
  8350. /**
  8351. * Gets the vignette blend mode allowing different kind of effect.
  8352. */
  8353. /**
  8354. * Sets the vignette blend mode allowing different kind of effect.
  8355. */
  8356. vignetteBlendMode: number;
  8357. private _vignetteEnabled;
  8358. /**
  8359. * Gets wether the vignette effect is enabled.
  8360. */
  8361. /**
  8362. * Sets wether the vignette effect is enabled.
  8363. */
  8364. vignetteEnabled: boolean;
  8365. private _applyByPostProcess;
  8366. /**
  8367. * Gets wether the image processing is applied through a post process or not.
  8368. */
  8369. /**
  8370. * Sets wether the image processing is applied through a post process or not.
  8371. */
  8372. applyByPostProcess: boolean;
  8373. private _isEnabled;
  8374. /**
  8375. * Gets wether the image processing is enabled or not.
  8376. */
  8377. /**
  8378. * Sets wether the image processing is enabled or not.
  8379. */
  8380. isEnabled: boolean;
  8381. /**
  8382. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8383. */
  8384. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8385. /**
  8386. * Method called each time the image processing information changes requires to recompile the effect.
  8387. */
  8388. protected _updateParameters(): void;
  8389. /**
  8390. * Gets the current class name.
  8391. * @return "ImageProcessingConfiguration"
  8392. */
  8393. getClassName(): string;
  8394. /**
  8395. * Prepare the list of uniforms associated with the Image Processing effects.
  8396. * @param uniforms The list of uniforms used in the effect
  8397. * @param defines the list of defines currently in use
  8398. */
  8399. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8400. /**
  8401. * Prepare the list of samplers associated with the Image Processing effects.
  8402. * @param samplersList The list of uniforms used in the effect
  8403. * @param defines the list of defines currently in use
  8404. */
  8405. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8406. /**
  8407. * Prepare the list of defines associated to the shader.
  8408. * @param defines the list of defines to complete
  8409. * @param forPostProcess Define if we are currently in post process mode or not
  8410. */
  8411. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8412. /**
  8413. * Returns true if all the image processing information are ready.
  8414. * @returns True if ready, otherwise, false
  8415. */
  8416. isReady(): boolean;
  8417. /**
  8418. * Binds the image processing to the shader.
  8419. * @param effect The effect to bind to
  8420. * @param aspectRatio Define the current aspect ratio of the effect
  8421. */
  8422. bind(effect: Effect, aspectRatio?: number): void;
  8423. /**
  8424. * Clones the current image processing instance.
  8425. * @return The cloned image processing
  8426. */
  8427. clone(): ImageProcessingConfiguration;
  8428. /**
  8429. * Serializes the current image processing instance to a json representation.
  8430. * @return a JSON representation
  8431. */
  8432. serialize(): any;
  8433. /**
  8434. * Parses the image processing from a json representation.
  8435. * @param source the JSON source to parse
  8436. * @return The parsed image processing
  8437. */
  8438. static Parse(source: any): ImageProcessingConfiguration;
  8439. private static _VIGNETTEMODE_MULTIPLY;
  8440. private static _VIGNETTEMODE_OPAQUE;
  8441. /**
  8442. * Used to apply the vignette as a mix with the pixel color.
  8443. */
  8444. static readonly VIGNETTEMODE_MULTIPLY: number;
  8445. /**
  8446. * Used to apply the vignette as a replacement of the pixel color.
  8447. */
  8448. static readonly VIGNETTEMODE_OPAQUE: number;
  8449. }
  8450. }
  8451. declare module "babylonjs/Shaders/postprocess.vertex" {
  8452. /** @hidden */
  8453. export var postprocessVertexShader: {
  8454. name: string;
  8455. shader: string;
  8456. };
  8457. }
  8458. declare module "babylonjs/Maths/math.axis" {
  8459. import { Vector3 } from "babylonjs/Maths/math.vector";
  8460. /** Defines supported spaces */
  8461. export enum Space {
  8462. /** Local (object) space */
  8463. LOCAL = 0,
  8464. /** World space */
  8465. WORLD = 1,
  8466. /** Bone space */
  8467. BONE = 2
  8468. }
  8469. /** Defines the 3 main axes */
  8470. export class Axis {
  8471. /** X axis */
  8472. static X: Vector3;
  8473. /** Y axis */
  8474. static Y: Vector3;
  8475. /** Z axis */
  8476. static Z: Vector3;
  8477. }
  8478. }
  8479. declare module "babylonjs/Cameras/targetCamera" {
  8480. import { Nullable } from "babylonjs/types";
  8481. import { Camera } from "babylonjs/Cameras/camera";
  8482. import { Scene } from "babylonjs/scene";
  8483. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  8484. /**
  8485. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8486. * This is the base of the follow, arc rotate cameras and Free camera
  8487. * @see http://doc.babylonjs.com/features/cameras
  8488. */
  8489. export class TargetCamera extends Camera {
  8490. private static _RigCamTransformMatrix;
  8491. private static _TargetTransformMatrix;
  8492. private static _TargetFocalPoint;
  8493. /**
  8494. * Define the current direction the camera is moving to
  8495. */
  8496. cameraDirection: Vector3;
  8497. /**
  8498. * Define the current rotation the camera is rotating to
  8499. */
  8500. cameraRotation: Vector2;
  8501. /**
  8502. * When set, the up vector of the camera will be updated by the rotation of the camera
  8503. */
  8504. updateUpVectorFromRotation: boolean;
  8505. private _tmpQuaternion;
  8506. /**
  8507. * Define the current rotation of the camera
  8508. */
  8509. rotation: Vector3;
  8510. /**
  8511. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8512. */
  8513. rotationQuaternion: Quaternion;
  8514. /**
  8515. * Define the current speed of the camera
  8516. */
  8517. speed: number;
  8518. /**
  8519. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8520. * around all axis.
  8521. */
  8522. noRotationConstraint: boolean;
  8523. /**
  8524. * Define the current target of the camera as an object or a position.
  8525. */
  8526. lockedTarget: any;
  8527. /** @hidden */
  8528. _currentTarget: Vector3;
  8529. /** @hidden */
  8530. _initialFocalDistance: number;
  8531. /** @hidden */
  8532. _viewMatrix: Matrix;
  8533. /** @hidden */
  8534. _camMatrix: Matrix;
  8535. /** @hidden */
  8536. _cameraTransformMatrix: Matrix;
  8537. /** @hidden */
  8538. _cameraRotationMatrix: Matrix;
  8539. /** @hidden */
  8540. _referencePoint: Vector3;
  8541. /** @hidden */
  8542. _transformedReferencePoint: Vector3;
  8543. protected _globalCurrentTarget: Vector3;
  8544. protected _globalCurrentUpVector: Vector3;
  8545. /** @hidden */
  8546. _reset: () => void;
  8547. private _defaultUp;
  8548. /**
  8549. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  8550. * This is the base of the follow, arc rotate cameras and Free camera
  8551. * @see http://doc.babylonjs.com/features/cameras
  8552. * @param name Defines the name of the camera in the scene
  8553. * @param position Defines the start position of the camera in the scene
  8554. * @param scene Defines the scene the camera belongs to
  8555. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8556. */
  8557. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8558. /**
  8559. * Gets the position in front of the camera at a given distance.
  8560. * @param distance The distance from the camera we want the position to be
  8561. * @returns the position
  8562. */
  8563. getFrontPosition(distance: number): Vector3;
  8564. /** @hidden */
  8565. _getLockedTargetPosition(): Nullable<Vector3>;
  8566. private _storedPosition;
  8567. private _storedRotation;
  8568. private _storedRotationQuaternion;
  8569. /**
  8570. * Store current camera state of the camera (fov, position, rotation, etc..)
  8571. * @returns the camera
  8572. */
  8573. storeState(): Camera;
  8574. /**
  8575. * Restored camera state. You must call storeState() first
  8576. * @returns whether it was successful or not
  8577. * @hidden
  8578. */
  8579. _restoreStateValues(): boolean;
  8580. /** @hidden */
  8581. _initCache(): void;
  8582. /** @hidden */
  8583. _updateCache(ignoreParentClass?: boolean): void;
  8584. /** @hidden */
  8585. _isSynchronizedViewMatrix(): boolean;
  8586. /** @hidden */
  8587. _computeLocalCameraSpeed(): number;
  8588. /**
  8589. * Defines the target the camera should look at.
  8590. * @param target Defines the new target as a Vector or a mesh
  8591. */
  8592. setTarget(target: Vector3): void;
  8593. /**
  8594. * Return the current target position of the camera. This value is expressed in local space.
  8595. * @returns the target position
  8596. */
  8597. getTarget(): Vector3;
  8598. /** @hidden */
  8599. _decideIfNeedsToMove(): boolean;
  8600. /** @hidden */
  8601. _updatePosition(): void;
  8602. /** @hidden */
  8603. _checkInputs(): void;
  8604. protected _updateCameraRotationMatrix(): void;
  8605. /**
  8606. * 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)
  8607. * @returns the current camera
  8608. */
  8609. private _rotateUpVectorWithCameraRotationMatrix;
  8610. private _cachedRotationZ;
  8611. private _cachedQuaternionRotationZ;
  8612. /** @hidden */
  8613. _getViewMatrix(): Matrix;
  8614. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8615. /**
  8616. * @hidden
  8617. */
  8618. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8619. /**
  8620. * @hidden
  8621. */
  8622. _updateRigCameras(): void;
  8623. private _getRigCamPositionAndTarget;
  8624. /**
  8625. * Gets the current object class name.
  8626. * @return the class name
  8627. */
  8628. getClassName(): string;
  8629. }
  8630. }
  8631. declare module "babylonjs/Events/keyboardEvents" {
  8632. /**
  8633. * Gather the list of keyboard event types as constants.
  8634. */
  8635. export class KeyboardEventTypes {
  8636. /**
  8637. * The keydown event is fired when a key becomes active (pressed).
  8638. */
  8639. static readonly KEYDOWN: number;
  8640. /**
  8641. * The keyup event is fired when a key has been released.
  8642. */
  8643. static readonly KEYUP: number;
  8644. }
  8645. /**
  8646. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8647. */
  8648. export class KeyboardInfo {
  8649. /**
  8650. * Defines the type of event (KeyboardEventTypes)
  8651. */
  8652. type: number;
  8653. /**
  8654. * Defines the related dom event
  8655. */
  8656. event: KeyboardEvent;
  8657. /**
  8658. * Instantiates a new keyboard info.
  8659. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8660. * @param type Defines the type of event (KeyboardEventTypes)
  8661. * @param event Defines the related dom event
  8662. */
  8663. constructor(
  8664. /**
  8665. * Defines the type of event (KeyboardEventTypes)
  8666. */
  8667. type: number,
  8668. /**
  8669. * Defines the related dom event
  8670. */
  8671. event: KeyboardEvent);
  8672. }
  8673. /**
  8674. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8675. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8676. */
  8677. export class KeyboardInfoPre extends KeyboardInfo {
  8678. /**
  8679. * Defines the type of event (KeyboardEventTypes)
  8680. */
  8681. type: number;
  8682. /**
  8683. * Defines the related dom event
  8684. */
  8685. event: KeyboardEvent;
  8686. /**
  8687. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8688. */
  8689. skipOnPointerObservable: boolean;
  8690. /**
  8691. * Instantiates a new keyboard pre info.
  8692. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8693. * @param type Defines the type of event (KeyboardEventTypes)
  8694. * @param event Defines the related dom event
  8695. */
  8696. constructor(
  8697. /**
  8698. * Defines the type of event (KeyboardEventTypes)
  8699. */
  8700. type: number,
  8701. /**
  8702. * Defines the related dom event
  8703. */
  8704. event: KeyboardEvent);
  8705. }
  8706. }
  8707. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8708. import { Nullable } from "babylonjs/types";
  8709. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8710. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8711. /**
  8712. * Manage the keyboard inputs to control the movement of a free camera.
  8713. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8714. */
  8715. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8716. /**
  8717. * Defines the camera the input is attached to.
  8718. */
  8719. camera: FreeCamera;
  8720. /**
  8721. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8722. */
  8723. keysUp: number[];
  8724. /**
  8725. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8726. */
  8727. keysDown: number[];
  8728. /**
  8729. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8730. */
  8731. keysLeft: number[];
  8732. /**
  8733. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8734. */
  8735. keysRight: number[];
  8736. private _keys;
  8737. private _onCanvasBlurObserver;
  8738. private _onKeyboardObserver;
  8739. private _engine;
  8740. private _scene;
  8741. /**
  8742. * Attach the input controls to a specific dom element to get the input from.
  8743. * @param element Defines the element the controls should be listened from
  8744. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8745. */
  8746. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8747. /**
  8748. * Detach the current controls from the specified dom element.
  8749. * @param element Defines the element to stop listening the inputs from
  8750. */
  8751. detachControl(element: Nullable<HTMLElement>): void;
  8752. /**
  8753. * Update the current camera state depending on the inputs that have been used this frame.
  8754. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8755. */
  8756. checkInputs(): void;
  8757. /**
  8758. * Gets the class name of the current intput.
  8759. * @returns the class name
  8760. */
  8761. getClassName(): string;
  8762. /** @hidden */
  8763. _onLostFocus(): void;
  8764. /**
  8765. * Get the friendly name associated with the input class.
  8766. * @returns the input friendly name
  8767. */
  8768. getSimpleName(): string;
  8769. }
  8770. }
  8771. declare module "babylonjs/Lights/shadowLight" {
  8772. import { Camera } from "babylonjs/Cameras/camera";
  8773. import { Scene } from "babylonjs/scene";
  8774. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  8775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8776. import { Light } from "babylonjs/Lights/light";
  8777. /**
  8778. * Interface describing all the common properties and methods a shadow light needs to implement.
  8779. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8780. * as well as binding the different shadow properties to the effects.
  8781. */
  8782. export interface IShadowLight extends Light {
  8783. /**
  8784. * The light id in the scene (used in scene.findLighById for instance)
  8785. */
  8786. id: string;
  8787. /**
  8788. * The position the shdow will be casted from.
  8789. */
  8790. position: Vector3;
  8791. /**
  8792. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8793. */
  8794. direction: Vector3;
  8795. /**
  8796. * The transformed position. Position of the light in world space taking parenting in account.
  8797. */
  8798. transformedPosition: Vector3;
  8799. /**
  8800. * The transformed direction. Direction of the light in world space taking parenting in account.
  8801. */
  8802. transformedDirection: Vector3;
  8803. /**
  8804. * The friendly name of the light in the scene.
  8805. */
  8806. name: string;
  8807. /**
  8808. * Defines the shadow projection clipping minimum z value.
  8809. */
  8810. shadowMinZ: number;
  8811. /**
  8812. * Defines the shadow projection clipping maximum z value.
  8813. */
  8814. shadowMaxZ: number;
  8815. /**
  8816. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8817. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8818. */
  8819. computeTransformedInformation(): boolean;
  8820. /**
  8821. * Gets the scene the light belongs to.
  8822. * @returns The scene
  8823. */
  8824. getScene(): Scene;
  8825. /**
  8826. * Callback defining a custom Projection Matrix Builder.
  8827. * This can be used to override the default projection matrix computation.
  8828. */
  8829. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8830. /**
  8831. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  8832. * @param matrix The materix to updated with the projection information
  8833. * @param viewMatrix The transform matrix of the light
  8834. * @param renderList The list of mesh to render in the map
  8835. * @returns The current light
  8836. */
  8837. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  8838. /**
  8839. * Gets the current depth scale used in ESM.
  8840. * @returns The scale
  8841. */
  8842. getDepthScale(): number;
  8843. /**
  8844. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8845. * @returns true if a cube texture needs to be use
  8846. */
  8847. needCube(): boolean;
  8848. /**
  8849. * Detects if the projection matrix requires to be recomputed this frame.
  8850. * @returns true if it requires to be recomputed otherwise, false.
  8851. */
  8852. needProjectionMatrixCompute(): boolean;
  8853. /**
  8854. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8855. */
  8856. forceProjectionMatrixCompute(): void;
  8857. /**
  8858. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8859. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8860. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8861. */
  8862. getShadowDirection(faceIndex?: number): Vector3;
  8863. /**
  8864. * Gets the minZ used for shadow according to both the scene and the light.
  8865. * @param activeCamera The camera we are returning the min for
  8866. * @returns the depth min z
  8867. */
  8868. getDepthMinZ(activeCamera: Camera): number;
  8869. /**
  8870. * Gets the maxZ used for shadow according to both the scene and the light.
  8871. * @param activeCamera The camera we are returning the max for
  8872. * @returns the depth max z
  8873. */
  8874. getDepthMaxZ(activeCamera: Camera): number;
  8875. }
  8876. /**
  8877. * Base implementation IShadowLight
  8878. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  8879. */
  8880. export abstract class ShadowLight extends Light implements IShadowLight {
  8881. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  8882. protected _position: Vector3;
  8883. protected _setPosition(value: Vector3): void;
  8884. /**
  8885. * Sets the position the shadow will be casted from. Also use as the light position for both
  8886. * point and spot lights.
  8887. */
  8888. /**
  8889. * Sets the position the shadow will be casted from. Also use as the light position for both
  8890. * point and spot lights.
  8891. */
  8892. position: Vector3;
  8893. protected _direction: Vector3;
  8894. protected _setDirection(value: Vector3): void;
  8895. /**
  8896. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  8897. * Also use as the light direction on spot and directional lights.
  8898. */
  8899. /**
  8900. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  8901. * Also use as the light direction on spot and directional lights.
  8902. */
  8903. direction: Vector3;
  8904. private _shadowMinZ;
  8905. /**
  8906. * Gets the shadow projection clipping minimum z value.
  8907. */
  8908. /**
  8909. * Sets the shadow projection clipping minimum z value.
  8910. */
  8911. shadowMinZ: number;
  8912. private _shadowMaxZ;
  8913. /**
  8914. * Sets the shadow projection clipping maximum z value.
  8915. */
  8916. /**
  8917. * Gets the shadow projection clipping maximum z value.
  8918. */
  8919. shadowMaxZ: number;
  8920. /**
  8921. * Callback defining a custom Projection Matrix Builder.
  8922. * This can be used to override the default projection matrix computation.
  8923. */
  8924. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  8925. /**
  8926. * The transformed position. Position of the light in world space taking parenting in account.
  8927. */
  8928. transformedPosition: Vector3;
  8929. /**
  8930. * The transformed direction. Direction of the light in world space taking parenting in account.
  8931. */
  8932. transformedDirection: Vector3;
  8933. private _needProjectionMatrixCompute;
  8934. /**
  8935. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  8936. * @returns true if the information has been computed, false if it does not need to (no parenting)
  8937. */
  8938. computeTransformedInformation(): boolean;
  8939. /**
  8940. * Return the depth scale used for the shadow map.
  8941. * @returns the depth scale.
  8942. */
  8943. getDepthScale(): number;
  8944. /**
  8945. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  8946. * @param faceIndex The index of the face we are computed the direction to generate shadow
  8947. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  8948. */
  8949. getShadowDirection(faceIndex?: number): Vector3;
  8950. /**
  8951. * Returns the ShadowLight absolute position in the World.
  8952. * @returns the position vector in world space
  8953. */
  8954. getAbsolutePosition(): Vector3;
  8955. /**
  8956. * Sets the ShadowLight direction toward the passed target.
  8957. * @param target The point to target in local space
  8958. * @returns the updated ShadowLight direction
  8959. */
  8960. setDirectionToTarget(target: Vector3): Vector3;
  8961. /**
  8962. * Returns the light rotation in euler definition.
  8963. * @returns the x y z rotation in local space.
  8964. */
  8965. getRotation(): Vector3;
  8966. /**
  8967. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  8968. * @returns true if a cube texture needs to be use
  8969. */
  8970. needCube(): boolean;
  8971. /**
  8972. * Detects if the projection matrix requires to be recomputed this frame.
  8973. * @returns true if it requires to be recomputed otherwise, false.
  8974. */
  8975. needProjectionMatrixCompute(): boolean;
  8976. /**
  8977. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  8978. */
  8979. forceProjectionMatrixCompute(): void;
  8980. /** @hidden */
  8981. _initCache(): void;
  8982. /** @hidden */
  8983. _isSynchronized(): boolean;
  8984. /**
  8985. * Computes the world matrix of the node
  8986. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  8987. * @returns the world matrix
  8988. */
  8989. computeWorldMatrix(force?: boolean): Matrix;
  8990. /**
  8991. * Gets the minZ used for shadow according to both the scene and the light.
  8992. * @param activeCamera The camera we are returning the min for
  8993. * @returns the depth min z
  8994. */
  8995. getDepthMinZ(activeCamera: Camera): number;
  8996. /**
  8997. * Gets the maxZ used for shadow according to both the scene and the light.
  8998. * @param activeCamera The camera we are returning the max for
  8999. * @returns the depth max z
  9000. */
  9001. getDepthMaxZ(activeCamera: Camera): number;
  9002. /**
  9003. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9004. * @param matrix The materix to updated with the projection information
  9005. * @param viewMatrix The transform matrix of the light
  9006. * @param renderList The list of mesh to render in the map
  9007. * @returns The current light
  9008. */
  9009. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9010. }
  9011. }
  9012. declare module "babylonjs/Materials/effectFallbacks" {
  9013. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9014. import { Effect } from "babylonjs/Materials/effect";
  9015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9016. /**
  9017. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9018. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9019. */
  9020. export class EffectFallbacks implements IEffectFallbacks {
  9021. private _defines;
  9022. private _currentRank;
  9023. private _maxRank;
  9024. private _mesh;
  9025. /**
  9026. * Removes the fallback from the bound mesh.
  9027. */
  9028. unBindMesh(): void;
  9029. /**
  9030. * Adds a fallback on the specified property.
  9031. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9032. * @param define The name of the define in the shader
  9033. */
  9034. addFallback(rank: number, define: string): void;
  9035. /**
  9036. * Sets the mesh to use CPU skinning when needing to fallback.
  9037. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9038. * @param mesh The mesh to use the fallbacks.
  9039. */
  9040. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9041. /**
  9042. * Checks to see if more fallbacks are still availible.
  9043. */
  9044. readonly hasMoreFallbacks: boolean;
  9045. /**
  9046. * Removes the defines that should be removed when falling back.
  9047. * @param currentDefines defines the current define statements for the shader.
  9048. * @param effect defines the current effect we try to compile
  9049. * @returns The resulting defines with defines of the current rank removed.
  9050. */
  9051. reduce(currentDefines: string, effect: Effect): string;
  9052. }
  9053. }
  9054. declare module "babylonjs/Materials/materialHelper" {
  9055. import { Nullable } from "babylonjs/types";
  9056. import { Scene } from "babylonjs/scene";
  9057. import { Engine } from "babylonjs/Engines/engine";
  9058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9059. import { Light } from "babylonjs/Lights/light";
  9060. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9061. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  9062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9063. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9064. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  9065. /**
  9066. * "Static Class" containing the most commonly used helper while dealing with material for
  9067. * rendering purpose.
  9068. *
  9069. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9070. *
  9071. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9072. */
  9073. export class MaterialHelper {
  9074. /**
  9075. * Bind the current view position to an effect.
  9076. * @param effect The effect to be bound
  9077. * @param scene The scene the eyes position is used from
  9078. */
  9079. static BindEyePosition(effect: Effect, scene: Scene): void;
  9080. /**
  9081. * Helps preparing the defines values about the UVs in used in the effect.
  9082. * UVs are shared as much as we can accross channels in the shaders.
  9083. * @param texture The texture we are preparing the UVs for
  9084. * @param defines The defines to update
  9085. * @param key The channel key "diffuse", "specular"... used in the shader
  9086. */
  9087. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9088. /**
  9089. * Binds a texture matrix value to its corrsponding uniform
  9090. * @param texture The texture to bind the matrix for
  9091. * @param uniformBuffer The uniform buffer receivin the data
  9092. * @param key The channel key "diffuse", "specular"... used in the shader
  9093. */
  9094. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9095. /**
  9096. * Gets the current status of the fog (should it be enabled?)
  9097. * @param mesh defines the mesh to evaluate for fog support
  9098. * @param scene defines the hosting scene
  9099. * @returns true if fog must be enabled
  9100. */
  9101. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  9102. /**
  9103. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9104. * @param mesh defines the current mesh
  9105. * @param scene defines the current scene
  9106. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9107. * @param pointsCloud defines if point cloud rendering has to be turned on
  9108. * @param fogEnabled defines if fog has to be turned on
  9109. * @param alphaTest defines if alpha testing has to be turned on
  9110. * @param defines defines the current list of defines
  9111. */
  9112. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9113. /**
  9114. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9115. * @param scene defines the current scene
  9116. * @param engine defines the current engine
  9117. * @param defines specifies the list of active defines
  9118. * @param useInstances defines if instances have to be turned on
  9119. * @param useClipPlane defines if clip plane have to be turned on
  9120. */
  9121. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9122. /**
  9123. * Prepares the defines for bones
  9124. * @param mesh The mesh containing the geometry data we will draw
  9125. * @param defines The defines to update
  9126. */
  9127. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  9128. /**
  9129. * Prepares the defines for morph targets
  9130. * @param mesh The mesh containing the geometry data we will draw
  9131. * @param defines The defines to update
  9132. */
  9133. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  9134. /**
  9135. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9136. * @param mesh The mesh containing the geometry data we will draw
  9137. * @param defines The defines to update
  9138. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9139. * @param useBones Precise whether bones should be used or not (override mesh info)
  9140. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9141. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9142. * @returns false if defines are considered not dirty and have not been checked
  9143. */
  9144. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9145. /**
  9146. * Prepares the defines related to multiview
  9147. * @param scene The scene we are intending to draw
  9148. * @param defines The defines to update
  9149. */
  9150. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9151. /**
  9152. * Prepares the defines related to the light information passed in parameter
  9153. * @param scene The scene we are intending to draw
  9154. * @param mesh The mesh the effect is compiling for
  9155. * @param light The light the effect is compiling for
  9156. * @param lightIndex The index of the light
  9157. * @param defines The defines to update
  9158. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9159. * @param state Defines the current state regarding what is needed (normals, etc...)
  9160. */
  9161. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  9162. needNormals: boolean;
  9163. needRebuild: boolean;
  9164. shadowEnabled: boolean;
  9165. specularEnabled: boolean;
  9166. lightmapMode: boolean;
  9167. }): void;
  9168. /**
  9169. * Prepares the defines related to the light information passed in parameter
  9170. * @param scene The scene we are intending to draw
  9171. * @param mesh The mesh the effect is compiling for
  9172. * @param defines The defines to update
  9173. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9174. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9175. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9176. * @returns true if normals will be required for the rest of the effect
  9177. */
  9178. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9179. /**
  9180. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  9181. * @param lightIndex defines the light index
  9182. * @param uniformsList The uniform list
  9183. * @param samplersList The sampler list
  9184. * @param projectedLightTexture defines if projected texture must be used
  9185. * @param uniformBuffersList defines an optional list of uniform buffers
  9186. */
  9187. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  9188. /**
  9189. * Prepares the uniforms and samplers list to be used in the effect
  9190. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9191. * @param samplersList The sampler list
  9192. * @param defines The defines helping in the list generation
  9193. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9194. */
  9195. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9196. /**
  9197. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9198. * @param defines The defines to update while falling back
  9199. * @param fallbacks The authorized effect fallbacks
  9200. * @param maxSimultaneousLights The maximum number of lights allowed
  9201. * @param rank the current rank of the Effect
  9202. * @returns The newly affected rank
  9203. */
  9204. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9205. private static _TmpMorphInfluencers;
  9206. /**
  9207. * Prepares the list of attributes required for morph targets according to the effect defines.
  9208. * @param attribs The current list of supported attribs
  9209. * @param mesh The mesh to prepare the morph targets attributes for
  9210. * @param influencers The number of influencers
  9211. */
  9212. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  9213. /**
  9214. * Prepares the list of attributes required for morph targets according to the effect defines.
  9215. * @param attribs The current list of supported attribs
  9216. * @param mesh The mesh to prepare the morph targets attributes for
  9217. * @param defines The current Defines of the effect
  9218. */
  9219. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9220. /**
  9221. * Prepares the list of attributes required for bones according to the effect defines.
  9222. * @param attribs The current list of supported attribs
  9223. * @param mesh The mesh to prepare the bones attributes for
  9224. * @param defines The current Defines of the effect
  9225. * @param fallbacks The current efffect fallback strategy
  9226. */
  9227. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9228. /**
  9229. * Check and prepare the list of attributes required for instances according to the effect defines.
  9230. * @param attribs The current list of supported attribs
  9231. * @param defines The current MaterialDefines of the effect
  9232. */
  9233. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  9234. /**
  9235. * Add the list of attributes required for instances to the attribs array.
  9236. * @param attribs The current list of supported attribs
  9237. */
  9238. static PushAttributesForInstances(attribs: string[]): void;
  9239. /**
  9240. * Binds the light shadow information to the effect for the given mesh.
  9241. * @param light The light containing the generator
  9242. * @param scene The scene the lights belongs to
  9243. * @param mesh The mesh we are binding the information to render
  9244. * @param lightIndex The light index in the effect used to render the mesh
  9245. * @param effect The effect we are binding the data to
  9246. */
  9247. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9248. /**
  9249. * Binds the light information to the effect.
  9250. * @param light The light containing the generator
  9251. * @param effect The effect we are binding the data to
  9252. * @param lightIndex The light index in the effect used to render
  9253. */
  9254. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9255. /**
  9256. * Binds the lights information from the scene to the effect for the given mesh.
  9257. * @param light Light to bind
  9258. * @param lightIndex Light index
  9259. * @param scene The scene where the light belongs to
  9260. * @param mesh The mesh we are binding the information to render
  9261. * @param effect The effect we are binding the data to
  9262. * @param useSpecular Defines if specular is supported
  9263. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9264. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9265. */
  9266. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9267. /**
  9268. * Binds the lights information from the scene to the effect for the given mesh.
  9269. * @param scene The scene the lights belongs to
  9270. * @param mesh The mesh we are binding the information to render
  9271. * @param effect The effect we are binding the data to
  9272. * @param defines The generated defines for the effect
  9273. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9274. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9275. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  9276. */
  9277. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  9278. private static _tempFogColor;
  9279. /**
  9280. * Binds the fog information from the scene to the effect for the given mesh.
  9281. * @param scene The scene the lights belongs to
  9282. * @param mesh The mesh we are binding the information to render
  9283. * @param effect The effect we are binding the data to
  9284. * @param linearSpace Defines if the fog effect is applied in linear space
  9285. */
  9286. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9287. /**
  9288. * Binds the bones information from the mesh to the effect.
  9289. * @param mesh The mesh we are binding the information to render
  9290. * @param effect The effect we are binding the data to
  9291. */
  9292. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9293. /**
  9294. * Binds the morph targets information from the mesh to the effect.
  9295. * @param abstractMesh The mesh we are binding the information to render
  9296. * @param effect The effect we are binding the data to
  9297. */
  9298. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9299. /**
  9300. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9301. * @param defines The generated defines used in the effect
  9302. * @param effect The effect we are binding the data to
  9303. * @param scene The scene we are willing to render with logarithmic scale for
  9304. */
  9305. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9306. /**
  9307. * Binds the clip plane information from the scene to the effect.
  9308. * @param scene The scene the clip plane information are extracted from
  9309. * @param effect The effect we are binding the data to
  9310. */
  9311. static BindClipPlane(effect: Effect, scene: Scene): void;
  9312. }
  9313. }
  9314. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9315. /** @hidden */
  9316. export var packingFunctions: {
  9317. name: string;
  9318. shader: string;
  9319. };
  9320. }
  9321. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9322. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9323. /** @hidden */
  9324. export var shadowMapPixelShader: {
  9325. name: string;
  9326. shader: string;
  9327. };
  9328. }
  9329. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9330. /** @hidden */
  9331. export var bonesDeclaration: {
  9332. name: string;
  9333. shader: string;
  9334. };
  9335. }
  9336. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9337. /** @hidden */
  9338. export var morphTargetsVertexGlobalDeclaration: {
  9339. name: string;
  9340. shader: string;
  9341. };
  9342. }
  9343. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9344. /** @hidden */
  9345. export var morphTargetsVertexDeclaration: {
  9346. name: string;
  9347. shader: string;
  9348. };
  9349. }
  9350. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9351. /** @hidden */
  9352. export var instancesDeclaration: {
  9353. name: string;
  9354. shader: string;
  9355. };
  9356. }
  9357. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9358. /** @hidden */
  9359. export var helperFunctions: {
  9360. name: string;
  9361. shader: string;
  9362. };
  9363. }
  9364. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9365. /** @hidden */
  9366. export var morphTargetsVertex: {
  9367. name: string;
  9368. shader: string;
  9369. };
  9370. }
  9371. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9372. /** @hidden */
  9373. export var instancesVertex: {
  9374. name: string;
  9375. shader: string;
  9376. };
  9377. }
  9378. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9379. /** @hidden */
  9380. export var bonesVertex: {
  9381. name: string;
  9382. shader: string;
  9383. };
  9384. }
  9385. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9386. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9387. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9388. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9389. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9392. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9393. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9394. /** @hidden */
  9395. export var shadowMapVertexShader: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9401. /** @hidden */
  9402. export var depthBoxBlurPixelShader: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9408. import { Nullable } from "babylonjs/types";
  9409. import { Scene } from "babylonjs/scene";
  9410. import { Matrix } from "babylonjs/Maths/math.vector";
  9411. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9412. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9413. import { Mesh } from "babylonjs/Meshes/mesh";
  9414. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9415. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9416. import { Effect } from "babylonjs/Materials/effect";
  9417. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9418. import "babylonjs/Shaders/shadowMap.fragment";
  9419. import "babylonjs/Shaders/shadowMap.vertex";
  9420. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9421. import { Observable } from "babylonjs/Misc/observable";
  9422. /**
  9423. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9424. */
  9425. export interface ICustomShaderOptions {
  9426. /**
  9427. * Gets or sets the custom shader name to use
  9428. */
  9429. shaderName: string;
  9430. /**
  9431. * The list of attribute names used in the shader
  9432. */
  9433. attributes?: string[];
  9434. /**
  9435. * The list of unifrom names used in the shader
  9436. */
  9437. uniforms?: string[];
  9438. /**
  9439. * The list of sampler names used in the shader
  9440. */
  9441. samplers?: string[];
  9442. /**
  9443. * The list of defines used in the shader
  9444. */
  9445. defines?: string[];
  9446. }
  9447. /**
  9448. * Interface to implement to create a shadow generator compatible with BJS.
  9449. */
  9450. export interface IShadowGenerator {
  9451. /**
  9452. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9453. * @returns The render target texture if present otherwise, null
  9454. */
  9455. getShadowMap(): Nullable<RenderTargetTexture>;
  9456. /**
  9457. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9458. * @returns The render target texture if the shadow map is present otherwise, null
  9459. */
  9460. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9461. /**
  9462. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9463. * @param subMesh The submesh we want to render in the shadow map
  9464. * @param useInstances Defines wether will draw in the map using instances
  9465. * @returns true if ready otherwise, false
  9466. */
  9467. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9468. /**
  9469. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9470. * @param defines Defines of the material we want to update
  9471. * @param lightIndex Index of the light in the enabled light list of the material
  9472. */
  9473. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9474. /**
  9475. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9476. * defined in the generator but impacting the effect).
  9477. * It implies the unifroms available on the materials are the standard BJS ones.
  9478. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9479. * @param effect The effect we are binfing the information for
  9480. */
  9481. bindShadowLight(lightIndex: string, effect: Effect): void;
  9482. /**
  9483. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9484. * (eq to shadow prjection matrix * light transform matrix)
  9485. * @returns The transform matrix used to create the shadow map
  9486. */
  9487. getTransformMatrix(): Matrix;
  9488. /**
  9489. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9490. * Cube and 2D textures for instance.
  9491. */
  9492. recreateShadowMap(): void;
  9493. /**
  9494. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9495. * @param onCompiled Callback triggered at the and of the effects compilation
  9496. * @param options Sets of optional options forcing the compilation with different modes
  9497. */
  9498. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9499. useInstances: boolean;
  9500. }>): void;
  9501. /**
  9502. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9503. * @param options Sets of optional options forcing the compilation with different modes
  9504. * @returns A promise that resolves when the compilation completes
  9505. */
  9506. forceCompilationAsync(options?: Partial<{
  9507. useInstances: boolean;
  9508. }>): Promise<void>;
  9509. /**
  9510. * Serializes the shadow generator setup to a json object.
  9511. * @returns The serialized JSON object
  9512. */
  9513. serialize(): any;
  9514. /**
  9515. * Disposes the Shadow map and related Textures and effects.
  9516. */
  9517. dispose(): void;
  9518. }
  9519. /**
  9520. * Default implementation IShadowGenerator.
  9521. * This is the main object responsible of generating shadows in the framework.
  9522. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9523. */
  9524. export class ShadowGenerator implements IShadowGenerator {
  9525. /**
  9526. * Shadow generator mode None: no filtering applied.
  9527. */
  9528. static readonly FILTER_NONE: number;
  9529. /**
  9530. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9531. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9532. */
  9533. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9534. /**
  9535. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9536. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9537. */
  9538. static readonly FILTER_POISSONSAMPLING: number;
  9539. /**
  9540. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9541. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9542. */
  9543. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9544. /**
  9545. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9546. * edge artifacts on steep falloff.
  9547. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9548. */
  9549. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9550. /**
  9551. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9552. * edge artifacts on steep falloff.
  9553. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9554. */
  9555. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9556. /**
  9557. * Shadow generator mode PCF: Percentage Closer Filtering
  9558. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9559. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9560. */
  9561. static readonly FILTER_PCF: number;
  9562. /**
  9563. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9564. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9565. * Contact Hardening
  9566. */
  9567. static readonly FILTER_PCSS: number;
  9568. /**
  9569. * Reserved for PCF and PCSS
  9570. * Highest Quality.
  9571. *
  9572. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9573. *
  9574. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9575. */
  9576. static readonly QUALITY_HIGH: number;
  9577. /**
  9578. * Reserved for PCF and PCSS
  9579. * Good tradeoff for quality/perf cross devices
  9580. *
  9581. * Execute PCF on a 3*3 kernel.
  9582. *
  9583. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9584. */
  9585. static readonly QUALITY_MEDIUM: number;
  9586. /**
  9587. * Reserved for PCF and PCSS
  9588. * The lowest quality but the fastest.
  9589. *
  9590. * Execute PCF on a 1*1 kernel.
  9591. *
  9592. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9593. */
  9594. static readonly QUALITY_LOW: number;
  9595. /** Gets or sets the custom shader name to use */
  9596. customShaderOptions: ICustomShaderOptions;
  9597. /**
  9598. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9599. */
  9600. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9601. /**
  9602. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  9603. */
  9604. onAfterShadowMapRenderObservable: Observable<Effect>;
  9605. /**
  9606. * Observable triggered before a mesh is rendered in the shadow map.
  9607. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9608. */
  9609. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9610. /**
  9611. * Observable triggered after a mesh is rendered in the shadow map.
  9612. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  9613. */
  9614. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  9615. private _bias;
  9616. /**
  9617. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9618. */
  9619. /**
  9620. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9621. */
  9622. bias: number;
  9623. private _normalBias;
  9624. /**
  9625. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9626. */
  9627. /**
  9628. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9629. */
  9630. normalBias: number;
  9631. private _blurBoxOffset;
  9632. /**
  9633. * Gets the blur box offset: offset applied during the blur pass.
  9634. * Only useful if useKernelBlur = false
  9635. */
  9636. /**
  9637. * Sets the blur box offset: offset applied during the blur pass.
  9638. * Only useful if useKernelBlur = false
  9639. */
  9640. blurBoxOffset: number;
  9641. private _blurScale;
  9642. /**
  9643. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9644. * 2 means half of the size.
  9645. */
  9646. /**
  9647. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9648. * 2 means half of the size.
  9649. */
  9650. blurScale: number;
  9651. private _blurKernel;
  9652. /**
  9653. * Gets the blur kernel: kernel size of the blur pass.
  9654. * Only useful if useKernelBlur = true
  9655. */
  9656. /**
  9657. * Sets the blur kernel: kernel size of the blur pass.
  9658. * Only useful if useKernelBlur = true
  9659. */
  9660. blurKernel: number;
  9661. private _useKernelBlur;
  9662. /**
  9663. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9664. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9665. */
  9666. /**
  9667. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9668. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9669. */
  9670. useKernelBlur: boolean;
  9671. private _depthScale;
  9672. /**
  9673. * Gets the depth scale used in ESM mode.
  9674. */
  9675. /**
  9676. * Sets the depth scale used in ESM mode.
  9677. * This can override the scale stored on the light.
  9678. */
  9679. depthScale: number;
  9680. private _filter;
  9681. /**
  9682. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9683. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9684. */
  9685. /**
  9686. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9687. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9688. */
  9689. filter: number;
  9690. /**
  9691. * Gets if the current filter is set to Poisson Sampling.
  9692. */
  9693. /**
  9694. * Sets the current filter to Poisson Sampling.
  9695. */
  9696. usePoissonSampling: boolean;
  9697. /**
  9698. * Gets if the current filter is set to ESM.
  9699. */
  9700. /**
  9701. * Sets the current filter is to ESM.
  9702. */
  9703. useExponentialShadowMap: boolean;
  9704. /**
  9705. * Gets if the current filter is set to filtered ESM.
  9706. */
  9707. /**
  9708. * Gets if the current filter is set to filtered ESM.
  9709. */
  9710. useBlurExponentialShadowMap: boolean;
  9711. /**
  9712. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9713. * exponential to prevent steep falloff artifacts).
  9714. */
  9715. /**
  9716. * Sets the current filter to "close ESM" (using the inverse of the
  9717. * exponential to prevent steep falloff artifacts).
  9718. */
  9719. useCloseExponentialShadowMap: boolean;
  9720. /**
  9721. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9722. * exponential to prevent steep falloff artifacts).
  9723. */
  9724. /**
  9725. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9726. * exponential to prevent steep falloff artifacts).
  9727. */
  9728. useBlurCloseExponentialShadowMap: boolean;
  9729. /**
  9730. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9731. */
  9732. /**
  9733. * Sets the current filter to "PCF" (percentage closer filtering).
  9734. */
  9735. usePercentageCloserFiltering: boolean;
  9736. private _filteringQuality;
  9737. /**
  9738. * Gets the PCF or PCSS Quality.
  9739. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9740. */
  9741. /**
  9742. * Sets the PCF or PCSS Quality.
  9743. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9744. */
  9745. filteringQuality: number;
  9746. /**
  9747. * Gets if the current filter is set to "PCSS" (contact hardening).
  9748. */
  9749. /**
  9750. * Sets the current filter to "PCSS" (contact hardening).
  9751. */
  9752. useContactHardeningShadow: boolean;
  9753. private _contactHardeningLightSizeUVRatio;
  9754. /**
  9755. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9756. * Using a ratio helps keeping shape stability independently of the map size.
  9757. *
  9758. * It does not account for the light projection as it was having too much
  9759. * instability during the light setup or during light position changes.
  9760. *
  9761. * Only valid if useContactHardeningShadow is true.
  9762. */
  9763. /**
  9764. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9765. * Using a ratio helps keeping shape stability independently of the map size.
  9766. *
  9767. * It does not account for the light projection as it was having too much
  9768. * instability during the light setup or during light position changes.
  9769. *
  9770. * Only valid if useContactHardeningShadow is true.
  9771. */
  9772. contactHardeningLightSizeUVRatio: number;
  9773. private _darkness;
  9774. /** Gets or sets the actual darkness of a shadow */
  9775. darkness: number;
  9776. /**
  9777. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9778. * 0 means strongest and 1 would means no shadow.
  9779. * @returns the darkness.
  9780. */
  9781. getDarkness(): number;
  9782. /**
  9783. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9784. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9785. * @returns the shadow generator allowing fluent coding.
  9786. */
  9787. setDarkness(darkness: number): ShadowGenerator;
  9788. private _transparencyShadow;
  9789. /** Gets or sets the ability to have transparent shadow */
  9790. transparencyShadow: boolean;
  9791. /**
  9792. * Sets the ability to have transparent shadow (boolean).
  9793. * @param transparent True if transparent else False
  9794. * @returns the shadow generator allowing fluent coding
  9795. */
  9796. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9797. private _shadowMap;
  9798. private _shadowMap2;
  9799. /**
  9800. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9801. * @returns The render target texture if present otherwise, null
  9802. */
  9803. getShadowMap(): Nullable<RenderTargetTexture>;
  9804. /**
  9805. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9806. * @returns The render target texture if the shadow map is present otherwise, null
  9807. */
  9808. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9809. /**
  9810. * Gets the class name of that object
  9811. * @returns "ShadowGenerator"
  9812. */
  9813. getClassName(): string;
  9814. /**
  9815. * Helper function to add a mesh and its descendants to the list of shadow casters.
  9816. * @param mesh Mesh to add
  9817. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  9818. * @returns the Shadow Generator itself
  9819. */
  9820. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9821. /**
  9822. * Helper function to remove a mesh and its descendants from the list of shadow casters
  9823. * @param mesh Mesh to remove
  9824. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  9825. * @returns the Shadow Generator itself
  9826. */
  9827. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  9828. /**
  9829. * Controls the extent to which the shadows fade out at the edge of the frustum
  9830. * Used only by directionals and spots
  9831. */
  9832. frustumEdgeFalloff: number;
  9833. private _light;
  9834. /**
  9835. * Returns the associated light object.
  9836. * @returns the light generating the shadow
  9837. */
  9838. getLight(): IShadowLight;
  9839. /**
  9840. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  9841. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  9842. * It might on the other hand introduce peter panning.
  9843. */
  9844. forceBackFacesOnly: boolean;
  9845. private _scene;
  9846. private _lightDirection;
  9847. private _effect;
  9848. private _viewMatrix;
  9849. private _projectionMatrix;
  9850. private _transformMatrix;
  9851. private _cachedPosition;
  9852. private _cachedDirection;
  9853. private _cachedDefines;
  9854. private _currentRenderID;
  9855. private _boxBlurPostprocess;
  9856. private _kernelBlurXPostprocess;
  9857. private _kernelBlurYPostprocess;
  9858. private _blurPostProcesses;
  9859. private _mapSize;
  9860. private _currentFaceIndex;
  9861. private _currentFaceIndexCache;
  9862. private _textureType;
  9863. private _defaultTextureMatrix;
  9864. private _storedUniqueId;
  9865. /** @hidden */
  9866. static _SceneComponentInitialization: (scene: Scene) => void;
  9867. /**
  9868. * Creates a ShadowGenerator object.
  9869. * A ShadowGenerator is the required tool to use the shadows.
  9870. * Each light casting shadows needs to use its own ShadowGenerator.
  9871. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  9872. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  9873. * @param light The light object generating the shadows.
  9874. * @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.
  9875. */
  9876. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  9877. private _initializeGenerator;
  9878. private _initializeShadowMap;
  9879. private _initializeBlurRTTAndPostProcesses;
  9880. private _renderForShadowMap;
  9881. private _renderSubMeshForShadowMap;
  9882. private _applyFilterValues;
  9883. /**
  9884. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9885. * @param onCompiled Callback triggered at the and of the effects compilation
  9886. * @param options Sets of optional options forcing the compilation with different modes
  9887. */
  9888. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9889. useInstances: boolean;
  9890. }>): void;
  9891. /**
  9892. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9893. * @param options Sets of optional options forcing the compilation with different modes
  9894. * @returns A promise that resolves when the compilation completes
  9895. */
  9896. forceCompilationAsync(options?: Partial<{
  9897. useInstances: boolean;
  9898. }>): Promise<void>;
  9899. /**
  9900. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9901. * @param subMesh The submesh we want to render in the shadow map
  9902. * @param useInstances Defines wether will draw in the map using instances
  9903. * @returns true if ready otherwise, false
  9904. */
  9905. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9906. /**
  9907. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9908. * @param defines Defines of the material we want to update
  9909. * @param lightIndex Index of the light in the enabled light list of the material
  9910. */
  9911. prepareDefines(defines: any, lightIndex: number): void;
  9912. /**
  9913. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9914. * defined in the generator but impacting the effect).
  9915. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9916. * @param effect The effect we are binfing the information for
  9917. */
  9918. bindShadowLight(lightIndex: string, effect: Effect): void;
  9919. /**
  9920. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9921. * (eq to shadow prjection matrix * light transform matrix)
  9922. * @returns The transform matrix used to create the shadow map
  9923. */
  9924. getTransformMatrix(): Matrix;
  9925. /**
  9926. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9927. * Cube and 2D textures for instance.
  9928. */
  9929. recreateShadowMap(): void;
  9930. private _disposeBlurPostProcesses;
  9931. private _disposeRTTandPostProcesses;
  9932. /**
  9933. * Disposes the ShadowGenerator.
  9934. * Returns nothing.
  9935. */
  9936. dispose(): void;
  9937. /**
  9938. * Serializes the shadow generator setup to a json object.
  9939. * @returns The serialized JSON object
  9940. */
  9941. serialize(): any;
  9942. /**
  9943. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  9944. * @param parsedShadowGenerator The JSON object to parse
  9945. * @param scene The scene to create the shadow map for
  9946. * @returns The parsed shadow generator
  9947. */
  9948. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  9949. }
  9950. }
  9951. declare module "babylonjs/Lights/light" {
  9952. import { Nullable } from "babylonjs/types";
  9953. import { Scene } from "babylonjs/scene";
  9954. import { Vector3 } from "babylonjs/Maths/math.vector";
  9955. import { Color3 } from "babylonjs/Maths/math.color";
  9956. import { Node } from "babylonjs/node";
  9957. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9958. import { Effect } from "babylonjs/Materials/effect";
  9959. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9960. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  9961. /**
  9962. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  9963. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  9964. * 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.
  9965. */
  9966. export abstract class Light extends Node {
  9967. /**
  9968. * Falloff Default: light is falling off following the material specification:
  9969. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  9970. */
  9971. static readonly FALLOFF_DEFAULT: number;
  9972. /**
  9973. * Falloff Physical: light is falling off following the inverse squared distance law.
  9974. */
  9975. static readonly FALLOFF_PHYSICAL: number;
  9976. /**
  9977. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  9978. * to enhance interoperability with other engines.
  9979. */
  9980. static readonly FALLOFF_GLTF: number;
  9981. /**
  9982. * Falloff Standard: light is falling off like in the standard material
  9983. * to enhance interoperability with other materials.
  9984. */
  9985. static readonly FALLOFF_STANDARD: number;
  9986. /**
  9987. * If every light affecting the material is in this lightmapMode,
  9988. * material.lightmapTexture adds or multiplies
  9989. * (depends on material.useLightmapAsShadowmap)
  9990. * after every other light calculations.
  9991. */
  9992. static readonly LIGHTMAP_DEFAULT: number;
  9993. /**
  9994. * material.lightmapTexture as only diffuse lighting from this light
  9995. * adds only specular lighting from this light
  9996. * adds dynamic shadows
  9997. */
  9998. static readonly LIGHTMAP_SPECULAR: number;
  9999. /**
  10000. * material.lightmapTexture as only lighting
  10001. * no light calculation from this light
  10002. * only adds dynamic shadows from this light
  10003. */
  10004. static readonly LIGHTMAP_SHADOWSONLY: number;
  10005. /**
  10006. * Each light type uses the default quantity according to its type:
  10007. * point/spot lights use luminous intensity
  10008. * directional lights use illuminance
  10009. */
  10010. static readonly INTENSITYMODE_AUTOMATIC: number;
  10011. /**
  10012. * lumen (lm)
  10013. */
  10014. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10015. /**
  10016. * candela (lm/sr)
  10017. */
  10018. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10019. /**
  10020. * lux (lm/m^2)
  10021. */
  10022. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10023. /**
  10024. * nit (cd/m^2)
  10025. */
  10026. static readonly INTENSITYMODE_LUMINANCE: number;
  10027. /**
  10028. * Light type const id of the point light.
  10029. */
  10030. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10031. /**
  10032. * Light type const id of the directional light.
  10033. */
  10034. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10035. /**
  10036. * Light type const id of the spot light.
  10037. */
  10038. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10039. /**
  10040. * Light type const id of the hemispheric light.
  10041. */
  10042. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10043. /**
  10044. * Diffuse gives the basic color to an object.
  10045. */
  10046. diffuse: Color3;
  10047. /**
  10048. * Specular produces a highlight color on an object.
  10049. * Note: This is note affecting PBR materials.
  10050. */
  10051. specular: Color3;
  10052. /**
  10053. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10054. * falling off base on range or angle.
  10055. * This can be set to any values in Light.FALLOFF_x.
  10056. *
  10057. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10058. * other types of materials.
  10059. */
  10060. falloffType: number;
  10061. /**
  10062. * Strength of the light.
  10063. * Note: By default it is define in the framework own unit.
  10064. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10065. */
  10066. intensity: number;
  10067. private _range;
  10068. protected _inverseSquaredRange: number;
  10069. /**
  10070. * Defines how far from the source the light is impacting in scene units.
  10071. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10072. */
  10073. /**
  10074. * Defines how far from the source the light is impacting in scene units.
  10075. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10076. */
  10077. range: number;
  10078. /**
  10079. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10080. * of light.
  10081. */
  10082. private _photometricScale;
  10083. private _intensityMode;
  10084. /**
  10085. * Gets the photometric scale used to interpret the intensity.
  10086. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10087. */
  10088. /**
  10089. * Sets the photometric scale used to interpret the intensity.
  10090. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10091. */
  10092. intensityMode: number;
  10093. private _radius;
  10094. /**
  10095. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10096. */
  10097. /**
  10098. * sets the light radius used by PBR Materials to simulate soft area lights.
  10099. */
  10100. radius: number;
  10101. private _renderPriority;
  10102. /**
  10103. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10104. * exceeding the number allowed of the materials.
  10105. */
  10106. renderPriority: number;
  10107. private _shadowEnabled;
  10108. /**
  10109. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10110. * the current shadow generator.
  10111. */
  10112. /**
  10113. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10114. * the current shadow generator.
  10115. */
  10116. shadowEnabled: boolean;
  10117. private _includedOnlyMeshes;
  10118. /**
  10119. * Gets the only meshes impacted by this light.
  10120. */
  10121. /**
  10122. * Sets the only meshes impacted by this light.
  10123. */
  10124. includedOnlyMeshes: AbstractMesh[];
  10125. private _excludedMeshes;
  10126. /**
  10127. * Gets the meshes not impacted by this light.
  10128. */
  10129. /**
  10130. * Sets the meshes not impacted by this light.
  10131. */
  10132. excludedMeshes: AbstractMesh[];
  10133. private _excludeWithLayerMask;
  10134. /**
  10135. * Gets the layer id use to find what meshes are not impacted by the light.
  10136. * Inactive if 0
  10137. */
  10138. /**
  10139. * Sets the layer id use to find what meshes are not impacted by the light.
  10140. * Inactive if 0
  10141. */
  10142. excludeWithLayerMask: number;
  10143. private _includeOnlyWithLayerMask;
  10144. /**
  10145. * Gets the layer id use to find what meshes are impacted by the light.
  10146. * Inactive if 0
  10147. */
  10148. /**
  10149. * Sets the layer id use to find what meshes are impacted by the light.
  10150. * Inactive if 0
  10151. */
  10152. includeOnlyWithLayerMask: number;
  10153. private _lightmapMode;
  10154. /**
  10155. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10156. */
  10157. /**
  10158. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10159. */
  10160. lightmapMode: number;
  10161. /**
  10162. * Shadow generator associted to the light.
  10163. * @hidden Internal use only.
  10164. */
  10165. _shadowGenerator: Nullable<IShadowGenerator>;
  10166. /**
  10167. * @hidden Internal use only.
  10168. */
  10169. _excludedMeshesIds: string[];
  10170. /**
  10171. * @hidden Internal use only.
  10172. */
  10173. _includedOnlyMeshesIds: string[];
  10174. /**
  10175. * The current light unifom buffer.
  10176. * @hidden Internal use only.
  10177. */
  10178. _uniformBuffer: UniformBuffer;
  10179. /**
  10180. * Creates a Light object in the scene.
  10181. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10182. * @param name The firendly name of the light
  10183. * @param scene The scene the light belongs too
  10184. */
  10185. constructor(name: string, scene: Scene);
  10186. protected abstract _buildUniformLayout(): void;
  10187. /**
  10188. * Sets the passed Effect "effect" with the Light information.
  10189. * @param effect The effect to update
  10190. * @param lightIndex The index of the light in the effect to update
  10191. * @returns The light
  10192. */
  10193. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10194. /**
  10195. * Sets the passed Effect "effect" with the Light information.
  10196. * @param effect The effect to update
  10197. * @param lightDataUniformName The uniform used to store light data (position or direction)
  10198. * @returns The light
  10199. */
  10200. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  10201. /**
  10202. * Returns the string "Light".
  10203. * @returns the class name
  10204. */
  10205. getClassName(): string;
  10206. /** @hidden */
  10207. readonly _isLight: boolean;
  10208. /**
  10209. * Converts the light information to a readable string for debug purpose.
  10210. * @param fullDetails Supports for multiple levels of logging within scene loading
  10211. * @returns the human readable light info
  10212. */
  10213. toString(fullDetails?: boolean): string;
  10214. /** @hidden */
  10215. protected _syncParentEnabledState(): void;
  10216. /**
  10217. * Set the enabled state of this node.
  10218. * @param value - the new enabled state
  10219. */
  10220. setEnabled(value: boolean): void;
  10221. /**
  10222. * Returns the Light associated shadow generator if any.
  10223. * @return the associated shadow generator.
  10224. */
  10225. getShadowGenerator(): Nullable<IShadowGenerator>;
  10226. /**
  10227. * Returns a Vector3, the absolute light position in the World.
  10228. * @returns the world space position of the light
  10229. */
  10230. getAbsolutePosition(): Vector3;
  10231. /**
  10232. * Specifies if the light will affect the passed mesh.
  10233. * @param mesh The mesh to test against the light
  10234. * @return true the mesh is affected otherwise, false.
  10235. */
  10236. canAffectMesh(mesh: AbstractMesh): boolean;
  10237. /**
  10238. * Sort function to order lights for rendering.
  10239. * @param a First Light object to compare to second.
  10240. * @param b Second Light object to compare first.
  10241. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10242. */
  10243. static CompareLightsPriority(a: Light, b: Light): number;
  10244. /**
  10245. * Releases resources associated with this node.
  10246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10248. */
  10249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10250. /**
  10251. * Returns the light type ID (integer).
  10252. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10253. */
  10254. getTypeID(): number;
  10255. /**
  10256. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10257. * @returns the scaled intensity in intensity mode unit
  10258. */
  10259. getScaledIntensity(): number;
  10260. /**
  10261. * Returns a new Light object, named "name", from the current one.
  10262. * @param name The name of the cloned light
  10263. * @returns the new created light
  10264. */
  10265. clone(name: string): Nullable<Light>;
  10266. /**
  10267. * Serializes the current light into a Serialization object.
  10268. * @returns the serialized object.
  10269. */
  10270. serialize(): any;
  10271. /**
  10272. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10273. * This new light is named "name" and added to the passed scene.
  10274. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10275. * @param name The friendly name of the light
  10276. * @param scene The scene the new light will belong to
  10277. * @returns the constructor function
  10278. */
  10279. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10280. /**
  10281. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10282. * @param parsedLight The JSON representation of the light
  10283. * @param scene The scene to create the parsed light in
  10284. * @returns the created light after parsing
  10285. */
  10286. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10287. private _hookArrayForExcluded;
  10288. private _hookArrayForIncludedOnly;
  10289. private _resyncMeshes;
  10290. /**
  10291. * Forces the meshes to update their light related information in their rendering used effects
  10292. * @hidden Internal Use Only
  10293. */
  10294. _markMeshesAsLightDirty(): void;
  10295. /**
  10296. * Recomputes the cached photometric scale if needed.
  10297. */
  10298. private _computePhotometricScale;
  10299. /**
  10300. * Returns the Photometric Scale according to the light type and intensity mode.
  10301. */
  10302. private _getPhotometricScale;
  10303. /**
  10304. * Reorder the light in the scene according to their defined priority.
  10305. * @hidden Internal Use Only
  10306. */
  10307. _reorderLightsInScene(): void;
  10308. /**
  10309. * Prepares the list of defines specific to the light type.
  10310. * @param defines the list of defines
  10311. * @param lightIndex defines the index of the light for the effect
  10312. */
  10313. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10314. }
  10315. }
  10316. declare module "babylonjs/Actions/action" {
  10317. import { Observable } from "babylonjs/Misc/observable";
  10318. import { Condition } from "babylonjs/Actions/condition";
  10319. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10320. import { ActionManager } from "babylonjs/Actions/actionManager";
  10321. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10322. /**
  10323. * Interface used to define Action
  10324. */
  10325. export interface IAction {
  10326. /**
  10327. * Trigger for the action
  10328. */
  10329. trigger: number;
  10330. /** Options of the trigger */
  10331. triggerOptions: any;
  10332. /**
  10333. * Gets the trigger parameters
  10334. * @returns the trigger parameters
  10335. */
  10336. getTriggerParameter(): any;
  10337. /**
  10338. * Internal only - executes current action event
  10339. * @hidden
  10340. */
  10341. _executeCurrent(evt?: ActionEvent): void;
  10342. /**
  10343. * Serialize placeholder for child classes
  10344. * @param parent of child
  10345. * @returns the serialized object
  10346. */
  10347. serialize(parent: any): any;
  10348. /**
  10349. * Internal only
  10350. * @hidden
  10351. */
  10352. _prepare(): void;
  10353. /**
  10354. * Internal only - manager for action
  10355. * @hidden
  10356. */
  10357. _actionManager: AbstractActionManager;
  10358. /**
  10359. * Adds action to chain of actions, may be a DoNothingAction
  10360. * @param action defines the next action to execute
  10361. * @returns The action passed in
  10362. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10363. */
  10364. then(action: IAction): IAction;
  10365. }
  10366. /**
  10367. * The action to be carried out following a trigger
  10368. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10369. */
  10370. export class Action implements IAction {
  10371. /** the trigger, with or without parameters, for the action */
  10372. triggerOptions: any;
  10373. /**
  10374. * Trigger for the action
  10375. */
  10376. trigger: number;
  10377. /**
  10378. * Internal only - manager for action
  10379. * @hidden
  10380. */
  10381. _actionManager: ActionManager;
  10382. private _nextActiveAction;
  10383. private _child;
  10384. private _condition?;
  10385. private _triggerParameter;
  10386. /**
  10387. * An event triggered prior to action being executed.
  10388. */
  10389. onBeforeExecuteObservable: Observable<Action>;
  10390. /**
  10391. * Creates a new Action
  10392. * @param triggerOptions the trigger, with or without parameters, for the action
  10393. * @param condition an optional determinant of action
  10394. */
  10395. constructor(
  10396. /** the trigger, with or without parameters, for the action */
  10397. triggerOptions: any, condition?: Condition);
  10398. /**
  10399. * Internal only
  10400. * @hidden
  10401. */
  10402. _prepare(): void;
  10403. /**
  10404. * Gets the trigger parameters
  10405. * @returns the trigger parameters
  10406. */
  10407. getTriggerParameter(): any;
  10408. /**
  10409. * Internal only - executes current action event
  10410. * @hidden
  10411. */
  10412. _executeCurrent(evt?: ActionEvent): void;
  10413. /**
  10414. * Execute placeholder for child classes
  10415. * @param evt optional action event
  10416. */
  10417. execute(evt?: ActionEvent): void;
  10418. /**
  10419. * Skips to next active action
  10420. */
  10421. skipToNextActiveAction(): void;
  10422. /**
  10423. * Adds action to chain of actions, may be a DoNothingAction
  10424. * @param action defines the next action to execute
  10425. * @returns The action passed in
  10426. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10427. */
  10428. then(action: Action): Action;
  10429. /**
  10430. * Internal only
  10431. * @hidden
  10432. */
  10433. _getProperty(propertyPath: string): string;
  10434. /**
  10435. * Internal only
  10436. * @hidden
  10437. */
  10438. _getEffectiveTarget(target: any, propertyPath: string): any;
  10439. /**
  10440. * Serialize placeholder for child classes
  10441. * @param parent of child
  10442. * @returns the serialized object
  10443. */
  10444. serialize(parent: any): any;
  10445. /**
  10446. * Internal only called by serialize
  10447. * @hidden
  10448. */
  10449. protected _serialize(serializedAction: any, parent?: any): any;
  10450. /**
  10451. * Internal only
  10452. * @hidden
  10453. */
  10454. static _SerializeValueAsString: (value: any) => string;
  10455. /**
  10456. * Internal only
  10457. * @hidden
  10458. */
  10459. static _GetTargetProperty: (target: import("babylonjs/node").Node | import("babylonjs/scene").Scene) => {
  10460. name: string;
  10461. targetType: string;
  10462. value: string;
  10463. };
  10464. }
  10465. }
  10466. declare module "babylonjs/Actions/condition" {
  10467. import { ActionManager } from "babylonjs/Actions/actionManager";
  10468. /**
  10469. * A Condition applied to an Action
  10470. */
  10471. export class Condition {
  10472. /**
  10473. * Internal only - manager for action
  10474. * @hidden
  10475. */
  10476. _actionManager: ActionManager;
  10477. /**
  10478. * Internal only
  10479. * @hidden
  10480. */
  10481. _evaluationId: number;
  10482. /**
  10483. * Internal only
  10484. * @hidden
  10485. */
  10486. _currentResult: boolean;
  10487. /**
  10488. * Creates a new Condition
  10489. * @param actionManager the manager of the action the condition is applied to
  10490. */
  10491. constructor(actionManager: ActionManager);
  10492. /**
  10493. * Check if the current condition is valid
  10494. * @returns a boolean
  10495. */
  10496. isValid(): boolean;
  10497. /**
  10498. * Internal only
  10499. * @hidden
  10500. */
  10501. _getProperty(propertyPath: string): string;
  10502. /**
  10503. * Internal only
  10504. * @hidden
  10505. */
  10506. _getEffectiveTarget(target: any, propertyPath: string): any;
  10507. /**
  10508. * Serialize placeholder for child classes
  10509. * @returns the serialized object
  10510. */
  10511. serialize(): any;
  10512. /**
  10513. * Internal only
  10514. * @hidden
  10515. */
  10516. protected _serialize(serializedCondition: any): any;
  10517. }
  10518. /**
  10519. * Defines specific conditional operators as extensions of Condition
  10520. */
  10521. export class ValueCondition extends Condition {
  10522. /** path to specify the property of the target the conditional operator uses */
  10523. propertyPath: string;
  10524. /** the value compared by the conditional operator against the current value of the property */
  10525. value: any;
  10526. /** the conditional operator, default ValueCondition.IsEqual */
  10527. operator: number;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. private static _IsEqual;
  10533. /**
  10534. * Internal only
  10535. * @hidden
  10536. */
  10537. private static _IsDifferent;
  10538. /**
  10539. * Internal only
  10540. * @hidden
  10541. */
  10542. private static _IsGreater;
  10543. /**
  10544. * Internal only
  10545. * @hidden
  10546. */
  10547. private static _IsLesser;
  10548. /**
  10549. * returns the number for IsEqual
  10550. */
  10551. static readonly IsEqual: number;
  10552. /**
  10553. * Returns the number for IsDifferent
  10554. */
  10555. static readonly IsDifferent: number;
  10556. /**
  10557. * Returns the number for IsGreater
  10558. */
  10559. static readonly IsGreater: number;
  10560. /**
  10561. * Returns the number for IsLesser
  10562. */
  10563. static readonly IsLesser: number;
  10564. /**
  10565. * Internal only The action manager for the condition
  10566. * @hidden
  10567. */
  10568. _actionManager: ActionManager;
  10569. /**
  10570. * Internal only
  10571. * @hidden
  10572. */
  10573. private _target;
  10574. /**
  10575. * Internal only
  10576. * @hidden
  10577. */
  10578. private _effectiveTarget;
  10579. /**
  10580. * Internal only
  10581. * @hidden
  10582. */
  10583. private _property;
  10584. /**
  10585. * Creates a new ValueCondition
  10586. * @param actionManager manager for the action the condition applies to
  10587. * @param target for the action
  10588. * @param propertyPath path to specify the property of the target the conditional operator uses
  10589. * @param value the value compared by the conditional operator against the current value of the property
  10590. * @param operator the conditional operator, default ValueCondition.IsEqual
  10591. */
  10592. constructor(actionManager: ActionManager, target: any,
  10593. /** path to specify the property of the target the conditional operator uses */
  10594. propertyPath: string,
  10595. /** the value compared by the conditional operator against the current value of the property */
  10596. value: any,
  10597. /** the conditional operator, default ValueCondition.IsEqual */
  10598. operator?: number);
  10599. /**
  10600. * Compares the given value with the property value for the specified conditional operator
  10601. * @returns the result of the comparison
  10602. */
  10603. isValid(): boolean;
  10604. /**
  10605. * Serialize the ValueCondition into a JSON compatible object
  10606. * @returns serialization object
  10607. */
  10608. serialize(): any;
  10609. /**
  10610. * Gets the name of the conditional operator for the ValueCondition
  10611. * @param operator the conditional operator
  10612. * @returns the name
  10613. */
  10614. static GetOperatorName(operator: number): string;
  10615. }
  10616. /**
  10617. * Defines a predicate condition as an extension of Condition
  10618. */
  10619. export class PredicateCondition extends Condition {
  10620. /** defines the predicate function used to validate the condition */
  10621. predicate: () => boolean;
  10622. /**
  10623. * Internal only - manager for action
  10624. * @hidden
  10625. */
  10626. _actionManager: ActionManager;
  10627. /**
  10628. * Creates a new PredicateCondition
  10629. * @param actionManager manager for the action the condition applies to
  10630. * @param predicate defines the predicate function used to validate the condition
  10631. */
  10632. constructor(actionManager: ActionManager,
  10633. /** defines the predicate function used to validate the condition */
  10634. predicate: () => boolean);
  10635. /**
  10636. * @returns the validity of the predicate condition
  10637. */
  10638. isValid(): boolean;
  10639. }
  10640. /**
  10641. * Defines a state condition as an extension of Condition
  10642. */
  10643. export class StateCondition extends Condition {
  10644. /** Value to compare with target state */
  10645. value: string;
  10646. /**
  10647. * Internal only - manager for action
  10648. * @hidden
  10649. */
  10650. _actionManager: ActionManager;
  10651. /**
  10652. * Internal only
  10653. * @hidden
  10654. */
  10655. private _target;
  10656. /**
  10657. * Creates a new StateCondition
  10658. * @param actionManager manager for the action the condition applies to
  10659. * @param target of the condition
  10660. * @param value to compare with target state
  10661. */
  10662. constructor(actionManager: ActionManager, target: any,
  10663. /** Value to compare with target state */
  10664. value: string);
  10665. /**
  10666. * Gets a boolean indicating if the current condition is met
  10667. * @returns the validity of the state
  10668. */
  10669. isValid(): boolean;
  10670. /**
  10671. * Serialize the StateCondition into a JSON compatible object
  10672. * @returns serialization object
  10673. */
  10674. serialize(): any;
  10675. }
  10676. }
  10677. declare module "babylonjs/Actions/directActions" {
  10678. import { Action } from "babylonjs/Actions/action";
  10679. import { Condition } from "babylonjs/Actions/condition";
  10680. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10681. /**
  10682. * This defines an action responsible to toggle a boolean once triggered.
  10683. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10684. */
  10685. export class SwitchBooleanAction extends Action {
  10686. /**
  10687. * The path to the boolean property in the target object
  10688. */
  10689. propertyPath: string;
  10690. private _target;
  10691. private _effectiveTarget;
  10692. private _property;
  10693. /**
  10694. * Instantiate the action
  10695. * @param triggerOptions defines the trigger options
  10696. * @param target defines the object containing the boolean
  10697. * @param propertyPath defines the path to the boolean property in the target object
  10698. * @param condition defines the trigger related conditions
  10699. */
  10700. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10701. /** @hidden */
  10702. _prepare(): void;
  10703. /**
  10704. * Execute the action toggle the boolean value.
  10705. */
  10706. execute(): void;
  10707. /**
  10708. * Serializes the actions and its related information.
  10709. * @param parent defines the object to serialize in
  10710. * @returns the serialized object
  10711. */
  10712. serialize(parent: any): any;
  10713. }
  10714. /**
  10715. * This defines an action responsible to set a the state field of the target
  10716. * to a desired value once triggered.
  10717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10718. */
  10719. export class SetStateAction extends Action {
  10720. /**
  10721. * The value to store in the state field.
  10722. */
  10723. value: string;
  10724. private _target;
  10725. /**
  10726. * Instantiate the action
  10727. * @param triggerOptions defines the trigger options
  10728. * @param target defines the object containing the state property
  10729. * @param value defines the value to store in the state field
  10730. * @param condition defines the trigger related conditions
  10731. */
  10732. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10733. /**
  10734. * Execute the action and store the value on the target state property.
  10735. */
  10736. execute(): void;
  10737. /**
  10738. * Serializes the actions and its related information.
  10739. * @param parent defines the object to serialize in
  10740. * @returns the serialized object
  10741. */
  10742. serialize(parent: any): any;
  10743. }
  10744. /**
  10745. * This defines an action responsible to set a property of the target
  10746. * to a desired value once triggered.
  10747. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10748. */
  10749. export class SetValueAction extends Action {
  10750. /**
  10751. * The path of the property to set in the target.
  10752. */
  10753. propertyPath: string;
  10754. /**
  10755. * The value to set in the property
  10756. */
  10757. value: any;
  10758. private _target;
  10759. private _effectiveTarget;
  10760. private _property;
  10761. /**
  10762. * Instantiate the action
  10763. * @param triggerOptions defines the trigger options
  10764. * @param target defines the object containing the property
  10765. * @param propertyPath defines the path of the property to set in the target
  10766. * @param value defines the value to set in the property
  10767. * @param condition defines the trigger related conditions
  10768. */
  10769. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10770. /** @hidden */
  10771. _prepare(): void;
  10772. /**
  10773. * Execute the action and set the targetted property to the desired value.
  10774. */
  10775. execute(): void;
  10776. /**
  10777. * Serializes the actions and its related information.
  10778. * @param parent defines the object to serialize in
  10779. * @returns the serialized object
  10780. */
  10781. serialize(parent: any): any;
  10782. }
  10783. /**
  10784. * This defines an action responsible to increment the target value
  10785. * to a desired value once triggered.
  10786. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10787. */
  10788. export class IncrementValueAction extends Action {
  10789. /**
  10790. * The path of the property to increment in the target.
  10791. */
  10792. propertyPath: string;
  10793. /**
  10794. * The value we should increment the property by.
  10795. */
  10796. value: any;
  10797. private _target;
  10798. private _effectiveTarget;
  10799. private _property;
  10800. /**
  10801. * Instantiate the action
  10802. * @param triggerOptions defines the trigger options
  10803. * @param target defines the object containing the property
  10804. * @param propertyPath defines the path of the property to increment in the target
  10805. * @param value defines the value value we should increment the property by
  10806. * @param condition defines the trigger related conditions
  10807. */
  10808. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10809. /** @hidden */
  10810. _prepare(): void;
  10811. /**
  10812. * Execute the action and increment the target of the value amount.
  10813. */
  10814. execute(): void;
  10815. /**
  10816. * Serializes the actions and its related information.
  10817. * @param parent defines the object to serialize in
  10818. * @returns the serialized object
  10819. */
  10820. serialize(parent: any): any;
  10821. }
  10822. /**
  10823. * This defines an action responsible to start an animation once triggered.
  10824. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10825. */
  10826. export class PlayAnimationAction extends Action {
  10827. /**
  10828. * Where the animation should start (animation frame)
  10829. */
  10830. from: number;
  10831. /**
  10832. * Where the animation should stop (animation frame)
  10833. */
  10834. to: number;
  10835. /**
  10836. * Define if the animation should loop or stop after the first play.
  10837. */
  10838. loop?: boolean;
  10839. private _target;
  10840. /**
  10841. * Instantiate the action
  10842. * @param triggerOptions defines the trigger options
  10843. * @param target defines the target animation or animation name
  10844. * @param from defines from where the animation should start (animation frame)
  10845. * @param end defines where the animation should stop (animation frame)
  10846. * @param loop defines if the animation should loop or stop after the first play
  10847. * @param condition defines the trigger related conditions
  10848. */
  10849. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10850. /** @hidden */
  10851. _prepare(): void;
  10852. /**
  10853. * Execute the action and play the animation.
  10854. */
  10855. execute(): void;
  10856. /**
  10857. * Serializes the actions and its related information.
  10858. * @param parent defines the object to serialize in
  10859. * @returns the serialized object
  10860. */
  10861. serialize(parent: any): any;
  10862. }
  10863. /**
  10864. * This defines an action responsible to stop an animation once triggered.
  10865. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10866. */
  10867. export class StopAnimationAction extends Action {
  10868. private _target;
  10869. /**
  10870. * Instantiate the action
  10871. * @param triggerOptions defines the trigger options
  10872. * @param target defines the target animation or animation name
  10873. * @param condition defines the trigger related conditions
  10874. */
  10875. constructor(triggerOptions: any, target: any, condition?: Condition);
  10876. /** @hidden */
  10877. _prepare(): void;
  10878. /**
  10879. * Execute the action and stop the animation.
  10880. */
  10881. execute(): void;
  10882. /**
  10883. * Serializes the actions and its related information.
  10884. * @param parent defines the object to serialize in
  10885. * @returns the serialized object
  10886. */
  10887. serialize(parent: any): any;
  10888. }
  10889. /**
  10890. * This defines an action responsible that does nothing once triggered.
  10891. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10892. */
  10893. export class DoNothingAction extends Action {
  10894. /**
  10895. * Instantiate the action
  10896. * @param triggerOptions defines the trigger options
  10897. * @param condition defines the trigger related conditions
  10898. */
  10899. constructor(triggerOptions?: any, condition?: Condition);
  10900. /**
  10901. * Execute the action and do nothing.
  10902. */
  10903. execute(): void;
  10904. /**
  10905. * Serializes the actions and its related information.
  10906. * @param parent defines the object to serialize in
  10907. * @returns the serialized object
  10908. */
  10909. serialize(parent: any): any;
  10910. }
  10911. /**
  10912. * This defines an action responsible to trigger several actions once triggered.
  10913. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10914. */
  10915. export class CombineAction extends Action {
  10916. /**
  10917. * The list of aggregated animations to run.
  10918. */
  10919. children: Action[];
  10920. /**
  10921. * Instantiate the action
  10922. * @param triggerOptions defines the trigger options
  10923. * @param children defines the list of aggregated animations to run
  10924. * @param condition defines the trigger related conditions
  10925. */
  10926. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10927. /** @hidden */
  10928. _prepare(): void;
  10929. /**
  10930. * Execute the action and executes all the aggregated actions.
  10931. */
  10932. execute(evt: ActionEvent): void;
  10933. /**
  10934. * Serializes the actions and its related information.
  10935. * @param parent defines the object to serialize in
  10936. * @returns the serialized object
  10937. */
  10938. serialize(parent: any): any;
  10939. }
  10940. /**
  10941. * This defines an action responsible to run code (external event) once triggered.
  10942. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10943. */
  10944. export class ExecuteCodeAction extends Action {
  10945. /**
  10946. * The callback function to run.
  10947. */
  10948. func: (evt: ActionEvent) => void;
  10949. /**
  10950. * Instantiate the action
  10951. * @param triggerOptions defines the trigger options
  10952. * @param func defines the callback function to run
  10953. * @param condition defines the trigger related conditions
  10954. */
  10955. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10956. /**
  10957. * Execute the action and run the attached code.
  10958. */
  10959. execute(evt: ActionEvent): void;
  10960. }
  10961. /**
  10962. * This defines an action responsible to set the parent property of the target once triggered.
  10963. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10964. */
  10965. export class SetParentAction extends Action {
  10966. private _parent;
  10967. private _target;
  10968. /**
  10969. * Instantiate the action
  10970. * @param triggerOptions defines the trigger options
  10971. * @param target defines the target containing the parent property
  10972. * @param parent defines from where the animation should start (animation frame)
  10973. * @param condition defines the trigger related conditions
  10974. */
  10975. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10976. /** @hidden */
  10977. _prepare(): void;
  10978. /**
  10979. * Execute the action and set the parent property.
  10980. */
  10981. execute(): void;
  10982. /**
  10983. * Serializes the actions and its related information.
  10984. * @param parent defines the object to serialize in
  10985. * @returns the serialized object
  10986. */
  10987. serialize(parent: any): any;
  10988. }
  10989. }
  10990. declare module "babylonjs/Actions/actionManager" {
  10991. import { Nullable } from "babylonjs/types";
  10992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10993. import { Scene } from "babylonjs/scene";
  10994. import { IAction } from "babylonjs/Actions/action";
  10995. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10996. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10997. /**
  10998. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10999. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11000. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11001. */
  11002. export class ActionManager extends AbstractActionManager {
  11003. /**
  11004. * Nothing
  11005. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11006. */
  11007. static readonly NothingTrigger: number;
  11008. /**
  11009. * On pick
  11010. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11011. */
  11012. static readonly OnPickTrigger: number;
  11013. /**
  11014. * On left pick
  11015. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11016. */
  11017. static readonly OnLeftPickTrigger: number;
  11018. /**
  11019. * On right pick
  11020. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11021. */
  11022. static readonly OnRightPickTrigger: number;
  11023. /**
  11024. * On center pick
  11025. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11026. */
  11027. static readonly OnCenterPickTrigger: number;
  11028. /**
  11029. * On pick down
  11030. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11031. */
  11032. static readonly OnPickDownTrigger: number;
  11033. /**
  11034. * On double pick
  11035. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11036. */
  11037. static readonly OnDoublePickTrigger: number;
  11038. /**
  11039. * On pick up
  11040. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11041. */
  11042. static readonly OnPickUpTrigger: number;
  11043. /**
  11044. * On pick out.
  11045. * This trigger will only be raised if you also declared a OnPickDown
  11046. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11047. */
  11048. static readonly OnPickOutTrigger: number;
  11049. /**
  11050. * On long press
  11051. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11052. */
  11053. static readonly OnLongPressTrigger: number;
  11054. /**
  11055. * On pointer over
  11056. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11057. */
  11058. static readonly OnPointerOverTrigger: number;
  11059. /**
  11060. * On pointer out
  11061. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11062. */
  11063. static readonly OnPointerOutTrigger: number;
  11064. /**
  11065. * On every frame
  11066. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11067. */
  11068. static readonly OnEveryFrameTrigger: number;
  11069. /**
  11070. * On intersection enter
  11071. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11072. */
  11073. static readonly OnIntersectionEnterTrigger: number;
  11074. /**
  11075. * On intersection exit
  11076. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11077. */
  11078. static readonly OnIntersectionExitTrigger: number;
  11079. /**
  11080. * On key down
  11081. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11082. */
  11083. static readonly OnKeyDownTrigger: number;
  11084. /**
  11085. * On key up
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11087. */
  11088. static readonly OnKeyUpTrigger: number;
  11089. private _scene;
  11090. /**
  11091. * Creates a new action manager
  11092. * @param scene defines the hosting scene
  11093. */
  11094. constructor(scene: Scene);
  11095. /**
  11096. * Releases all associated resources
  11097. */
  11098. dispose(): void;
  11099. /**
  11100. * Gets hosting scene
  11101. * @returns the hosting scene
  11102. */
  11103. getScene(): Scene;
  11104. /**
  11105. * Does this action manager handles actions of any of the given triggers
  11106. * @param triggers defines the triggers to be tested
  11107. * @return a boolean indicating whether one (or more) of the triggers is handled
  11108. */
  11109. hasSpecificTriggers(triggers: number[]): boolean;
  11110. /**
  11111. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11112. * speed.
  11113. * @param triggerA defines the trigger to be tested
  11114. * @param triggerB defines the trigger to be tested
  11115. * @return a boolean indicating whether one (or more) of the triggers is handled
  11116. */
  11117. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11118. /**
  11119. * Does this action manager handles actions of a given trigger
  11120. * @param trigger defines the trigger to be tested
  11121. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11122. * @return whether the trigger is handled
  11123. */
  11124. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11125. /**
  11126. * Does this action manager has pointer triggers
  11127. */
  11128. readonly hasPointerTriggers: boolean;
  11129. /**
  11130. * Does this action manager has pick triggers
  11131. */
  11132. readonly hasPickTriggers: boolean;
  11133. /**
  11134. * Registers an action to this action manager
  11135. * @param action defines the action to be registered
  11136. * @return the action amended (prepared) after registration
  11137. */
  11138. registerAction(action: IAction): Nullable<IAction>;
  11139. /**
  11140. * Unregisters an action to this action manager
  11141. * @param action defines the action to be unregistered
  11142. * @return a boolean indicating whether the action has been unregistered
  11143. */
  11144. unregisterAction(action: IAction): Boolean;
  11145. /**
  11146. * Process a specific trigger
  11147. * @param trigger defines the trigger to process
  11148. * @param evt defines the event details to be processed
  11149. */
  11150. processTrigger(trigger: number, evt?: IActionEvent): void;
  11151. /** @hidden */
  11152. _getEffectiveTarget(target: any, propertyPath: string): any;
  11153. /** @hidden */
  11154. _getProperty(propertyPath: string): string;
  11155. /**
  11156. * Serialize this manager to a JSON object
  11157. * @param name defines the property name to store this manager
  11158. * @returns a JSON representation of this manager
  11159. */
  11160. serialize(name: string): any;
  11161. /**
  11162. * Creates a new ActionManager from a JSON data
  11163. * @param parsedActions defines the JSON data to read from
  11164. * @param object defines the hosting mesh
  11165. * @param scene defines the hosting scene
  11166. */
  11167. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11168. /**
  11169. * Get a trigger name by index
  11170. * @param trigger defines the trigger index
  11171. * @returns a trigger name
  11172. */
  11173. static GetTriggerName(trigger: number): string;
  11174. }
  11175. }
  11176. declare module "babylonjs/Culling/ray" {
  11177. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11178. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  11179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11180. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11181. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11182. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11183. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11184. import { Plane } from "babylonjs/Maths/math.plane";
  11185. /**
  11186. * Class representing a ray with position and direction
  11187. */
  11188. export class Ray {
  11189. /** origin point */
  11190. origin: Vector3;
  11191. /** direction */
  11192. direction: Vector3;
  11193. /** length of the ray */
  11194. length: number;
  11195. private static readonly TmpVector3;
  11196. private _tmpRay;
  11197. /**
  11198. * Creates a new ray
  11199. * @param origin origin point
  11200. * @param direction direction
  11201. * @param length length of the ray
  11202. */
  11203. constructor(
  11204. /** origin point */
  11205. origin: Vector3,
  11206. /** direction */
  11207. direction: Vector3,
  11208. /** length of the ray */
  11209. length?: number);
  11210. /**
  11211. * Checks if the ray intersects a box
  11212. * @param minimum bound of the box
  11213. * @param maximum bound of the box
  11214. * @param intersectionTreshold extra extend to be added to the box in all direction
  11215. * @returns if the box was hit
  11216. */
  11217. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11218. /**
  11219. * Checks if the ray intersects a box
  11220. * @param box the bounding box to check
  11221. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11222. * @returns if the box was hit
  11223. */
  11224. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11225. /**
  11226. * If the ray hits a sphere
  11227. * @param sphere the bounding sphere to check
  11228. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11229. * @returns true if it hits the sphere
  11230. */
  11231. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11232. /**
  11233. * If the ray hits a triange
  11234. * @param vertex0 triangle vertex
  11235. * @param vertex1 triangle vertex
  11236. * @param vertex2 triangle vertex
  11237. * @returns intersection information if hit
  11238. */
  11239. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11240. /**
  11241. * Checks if ray intersects a plane
  11242. * @param plane the plane to check
  11243. * @returns the distance away it was hit
  11244. */
  11245. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11246. /**
  11247. * Calculate the intercept of a ray on a given axis
  11248. * @param axis to check 'x' | 'y' | 'z'
  11249. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  11250. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  11251. */
  11252. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  11253. /**
  11254. * Checks if ray intersects a mesh
  11255. * @param mesh the mesh to check
  11256. * @param fastCheck if only the bounding box should checked
  11257. * @returns picking info of the intersecton
  11258. */
  11259. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11260. /**
  11261. * Checks if ray intersects a mesh
  11262. * @param meshes the meshes to check
  11263. * @param fastCheck if only the bounding box should checked
  11264. * @param results array to store result in
  11265. * @returns Array of picking infos
  11266. */
  11267. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11268. private _comparePickingInfo;
  11269. private static smallnum;
  11270. private static rayl;
  11271. /**
  11272. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11273. * @param sega the first point of the segment to test the intersection against
  11274. * @param segb the second point of the segment to test the intersection against
  11275. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11276. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11277. */
  11278. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11279. /**
  11280. * Update the ray from viewport position
  11281. * @param x position
  11282. * @param y y position
  11283. * @param viewportWidth viewport width
  11284. * @param viewportHeight viewport height
  11285. * @param world world matrix
  11286. * @param view view matrix
  11287. * @param projection projection matrix
  11288. * @returns this ray updated
  11289. */
  11290. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11291. /**
  11292. * Creates a ray with origin and direction of 0,0,0
  11293. * @returns the new ray
  11294. */
  11295. static Zero(): Ray;
  11296. /**
  11297. * Creates a new ray from screen space and viewport
  11298. * @param x position
  11299. * @param y y position
  11300. * @param viewportWidth viewport width
  11301. * @param viewportHeight viewport height
  11302. * @param world world matrix
  11303. * @param view view matrix
  11304. * @param projection projection matrix
  11305. * @returns new ray
  11306. */
  11307. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11308. /**
  11309. * 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
  11310. * transformed to the given world matrix.
  11311. * @param origin The origin point
  11312. * @param end The end point
  11313. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11314. * @returns the new ray
  11315. */
  11316. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11317. /**
  11318. * Transforms a ray by a matrix
  11319. * @param ray ray to transform
  11320. * @param matrix matrix to apply
  11321. * @returns the resulting new ray
  11322. */
  11323. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11324. /**
  11325. * Transforms a ray by a matrix
  11326. * @param ray ray to transform
  11327. * @param matrix matrix to apply
  11328. * @param result ray to store result in
  11329. */
  11330. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11331. /**
  11332. * Unproject a ray from screen space to object space
  11333. * @param sourceX defines the screen space x coordinate to use
  11334. * @param sourceY defines the screen space y coordinate to use
  11335. * @param viewportWidth defines the current width of the viewport
  11336. * @param viewportHeight defines the current height of the viewport
  11337. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11338. * @param view defines the view matrix to use
  11339. * @param projection defines the projection matrix to use
  11340. */
  11341. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11342. }
  11343. /**
  11344. * Type used to define predicate used to select faces when a mesh intersection is detected
  11345. */
  11346. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11347. module "babylonjs/scene" {
  11348. interface Scene {
  11349. /** @hidden */
  11350. _tempPickingRay: Nullable<Ray>;
  11351. /** @hidden */
  11352. _cachedRayForTransform: Ray;
  11353. /** @hidden */
  11354. _pickWithRayInverseMatrix: Matrix;
  11355. /** @hidden */
  11356. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11357. /** @hidden */
  11358. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11359. }
  11360. }
  11361. }
  11362. declare module "babylonjs/sceneComponent" {
  11363. import { Scene } from "babylonjs/scene";
  11364. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11365. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11366. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11367. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11368. import { Nullable } from "babylonjs/types";
  11369. import { Camera } from "babylonjs/Cameras/camera";
  11370. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11371. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11372. import { AbstractScene } from "babylonjs/abstractScene";
  11373. /**
  11374. * Groups all the scene component constants in one place to ease maintenance.
  11375. * @hidden
  11376. */
  11377. export class SceneComponentConstants {
  11378. static readonly NAME_EFFECTLAYER: string;
  11379. static readonly NAME_LAYER: string;
  11380. static readonly NAME_LENSFLARESYSTEM: string;
  11381. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11382. static readonly NAME_PARTICLESYSTEM: string;
  11383. static readonly NAME_GAMEPAD: string;
  11384. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11385. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11386. static readonly NAME_DEPTHRENDERER: string;
  11387. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11388. static readonly NAME_SPRITE: string;
  11389. static readonly NAME_OUTLINERENDERER: string;
  11390. static readonly NAME_PROCEDURALTEXTURE: string;
  11391. static readonly NAME_SHADOWGENERATOR: string;
  11392. static readonly NAME_OCTREE: string;
  11393. static readonly NAME_PHYSICSENGINE: string;
  11394. static readonly NAME_AUDIO: string;
  11395. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11396. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11397. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11398. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11399. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11400. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11401. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11402. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11403. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11404. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11405. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11406. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11407. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11408. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11409. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11410. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11411. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11412. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11413. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11414. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11415. static readonly STEP_AFTERRENDER_AUDIO: number;
  11416. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11417. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11418. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11419. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11420. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11421. static readonly STEP_POINTERMOVE_SPRITE: number;
  11422. static readonly STEP_POINTERDOWN_SPRITE: number;
  11423. static readonly STEP_POINTERUP_SPRITE: number;
  11424. }
  11425. /**
  11426. * This represents a scene component.
  11427. *
  11428. * This is used to decouple the dependency the scene is having on the different workloads like
  11429. * layers, post processes...
  11430. */
  11431. export interface ISceneComponent {
  11432. /**
  11433. * The name of the component. Each component must have a unique name.
  11434. */
  11435. name: string;
  11436. /**
  11437. * The scene the component belongs to.
  11438. */
  11439. scene: Scene;
  11440. /**
  11441. * Register the component to one instance of a scene.
  11442. */
  11443. register(): void;
  11444. /**
  11445. * Rebuilds the elements related to this component in case of
  11446. * context lost for instance.
  11447. */
  11448. rebuild(): void;
  11449. /**
  11450. * Disposes the component and the associated ressources.
  11451. */
  11452. dispose(): void;
  11453. }
  11454. /**
  11455. * This represents a SERIALIZABLE scene component.
  11456. *
  11457. * This extends Scene Component to add Serialization methods on top.
  11458. */
  11459. export interface ISceneSerializableComponent extends ISceneComponent {
  11460. /**
  11461. * Adds all the elements from the container to the scene
  11462. * @param container the container holding the elements
  11463. */
  11464. addFromContainer(container: AbstractScene): void;
  11465. /**
  11466. * Removes all the elements in the container from the scene
  11467. * @param container contains the elements to remove
  11468. * @param dispose if the removed element should be disposed (default: false)
  11469. */
  11470. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11471. /**
  11472. * Serializes the component data to the specified json object
  11473. * @param serializationObject The object to serialize to
  11474. */
  11475. serialize(serializationObject: any): void;
  11476. }
  11477. /**
  11478. * Strong typing of a Mesh related stage step action
  11479. */
  11480. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11481. /**
  11482. * Strong typing of a Evaluate Sub Mesh related stage step action
  11483. */
  11484. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11485. /**
  11486. * Strong typing of a Active Mesh related stage step action
  11487. */
  11488. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11489. /**
  11490. * Strong typing of a Camera related stage step action
  11491. */
  11492. export type CameraStageAction = (camera: Camera) => void;
  11493. /**
  11494. * Strong typing of a Camera Frame buffer related stage step action
  11495. */
  11496. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11497. /**
  11498. * Strong typing of a Render Target related stage step action
  11499. */
  11500. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11501. /**
  11502. * Strong typing of a RenderingGroup related stage step action
  11503. */
  11504. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11505. /**
  11506. * Strong typing of a Mesh Render related stage step action
  11507. */
  11508. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11509. /**
  11510. * Strong typing of a simple stage step action
  11511. */
  11512. export type SimpleStageAction = () => void;
  11513. /**
  11514. * Strong typing of a render target action.
  11515. */
  11516. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11517. /**
  11518. * Strong typing of a pointer move action.
  11519. */
  11520. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11521. /**
  11522. * Strong typing of a pointer up/down action.
  11523. */
  11524. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11525. /**
  11526. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11527. * @hidden
  11528. */
  11529. export class Stage<T extends Function> extends Array<{
  11530. index: number;
  11531. component: ISceneComponent;
  11532. action: T;
  11533. }> {
  11534. /**
  11535. * Hide ctor from the rest of the world.
  11536. * @param items The items to add.
  11537. */
  11538. private constructor();
  11539. /**
  11540. * Creates a new Stage.
  11541. * @returns A new instance of a Stage
  11542. */
  11543. static Create<T extends Function>(): Stage<T>;
  11544. /**
  11545. * Registers a step in an ordered way in the targeted stage.
  11546. * @param index Defines the position to register the step in
  11547. * @param component Defines the component attached to the step
  11548. * @param action Defines the action to launch during the step
  11549. */
  11550. registerStep(index: number, component: ISceneComponent, action: T): void;
  11551. /**
  11552. * Clears all the steps from the stage.
  11553. */
  11554. clear(): void;
  11555. }
  11556. }
  11557. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11558. import { Nullable } from "babylonjs/types";
  11559. import { Observable } from "babylonjs/Misc/observable";
  11560. import { Scene } from "babylonjs/scene";
  11561. import { Sprite } from "babylonjs/Sprites/sprite";
  11562. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11563. import { Ray } from "babylonjs/Culling/ray";
  11564. import { Camera } from "babylonjs/Cameras/camera";
  11565. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11566. import { ISceneComponent } from "babylonjs/sceneComponent";
  11567. module "babylonjs/scene" {
  11568. interface Scene {
  11569. /** @hidden */
  11570. _pointerOverSprite: Nullable<Sprite>;
  11571. /** @hidden */
  11572. _pickedDownSprite: Nullable<Sprite>;
  11573. /** @hidden */
  11574. _tempSpritePickingRay: Nullable<Ray>;
  11575. /**
  11576. * All of the sprite managers added to this scene
  11577. * @see http://doc.babylonjs.com/babylon101/sprites
  11578. */
  11579. spriteManagers: Array<ISpriteManager>;
  11580. /**
  11581. * An event triggered when sprites rendering is about to start
  11582. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11583. */
  11584. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11585. /**
  11586. * An event triggered when sprites rendering is done
  11587. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11588. */
  11589. onAfterSpritesRenderingObservable: Observable<Scene>;
  11590. /** @hidden */
  11591. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11592. /** Launch a ray to try to pick a sprite in the scene
  11593. * @param x position on screen
  11594. * @param y position on screen
  11595. * @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
  11596. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11597. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11598. * @returns a PickingInfo
  11599. */
  11600. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11601. /** Use the given ray to pick a sprite in the scene
  11602. * @param ray The ray (in world space) to use to pick meshes
  11603. * @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
  11604. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11605. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11606. * @returns a PickingInfo
  11607. */
  11608. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11609. /** @hidden */
  11610. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11611. /** Launch a ray to try to pick sprites in the scene
  11612. * @param x position on screen
  11613. * @param y position on screen
  11614. * @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
  11615. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11616. * @returns a PickingInfo array
  11617. */
  11618. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11619. /** Use the given ray to pick sprites in the scene
  11620. * @param ray The ray (in world space) to use to pick meshes
  11621. * @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
  11622. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11623. * @returns a PickingInfo array
  11624. */
  11625. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11626. /**
  11627. * Force the sprite under the pointer
  11628. * @param sprite defines the sprite to use
  11629. */
  11630. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11631. /**
  11632. * Gets the sprite under the pointer
  11633. * @returns a Sprite or null if no sprite is under the pointer
  11634. */
  11635. getPointerOverSprite(): Nullable<Sprite>;
  11636. }
  11637. }
  11638. /**
  11639. * Defines the sprite scene component responsible to manage sprites
  11640. * in a given scene.
  11641. */
  11642. export class SpriteSceneComponent implements ISceneComponent {
  11643. /**
  11644. * The component name helpfull to identify the component in the list of scene components.
  11645. */
  11646. readonly name: string;
  11647. /**
  11648. * The scene the component belongs to.
  11649. */
  11650. scene: Scene;
  11651. /** @hidden */
  11652. private _spritePredicate;
  11653. /**
  11654. * Creates a new instance of the component for the given scene
  11655. * @param scene Defines the scene to register the component in
  11656. */
  11657. constructor(scene: Scene);
  11658. /**
  11659. * Registers the component in a given scene
  11660. */
  11661. register(): void;
  11662. /**
  11663. * Rebuilds the elements related to this component in case of
  11664. * context lost for instance.
  11665. */
  11666. rebuild(): void;
  11667. /**
  11668. * Disposes the component and the associated ressources.
  11669. */
  11670. dispose(): void;
  11671. private _pickSpriteButKeepRay;
  11672. private _pointerMove;
  11673. private _pointerDown;
  11674. private _pointerUp;
  11675. }
  11676. }
  11677. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11678. /** @hidden */
  11679. export var fogFragmentDeclaration: {
  11680. name: string;
  11681. shader: string;
  11682. };
  11683. }
  11684. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11685. /** @hidden */
  11686. export var fogFragment: {
  11687. name: string;
  11688. shader: string;
  11689. };
  11690. }
  11691. declare module "babylonjs/Shaders/sprites.fragment" {
  11692. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11693. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11694. /** @hidden */
  11695. export var spritesPixelShader: {
  11696. name: string;
  11697. shader: string;
  11698. };
  11699. }
  11700. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11701. /** @hidden */
  11702. export var fogVertexDeclaration: {
  11703. name: string;
  11704. shader: string;
  11705. };
  11706. }
  11707. declare module "babylonjs/Shaders/sprites.vertex" {
  11708. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11709. /** @hidden */
  11710. export var spritesVertexShader: {
  11711. name: string;
  11712. shader: string;
  11713. };
  11714. }
  11715. declare module "babylonjs/Sprites/spriteManager" {
  11716. import { IDisposable, Scene } from "babylonjs/scene";
  11717. import { Nullable } from "babylonjs/types";
  11718. import { Observable } from "babylonjs/Misc/observable";
  11719. import { Sprite } from "babylonjs/Sprites/sprite";
  11720. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11721. import { Camera } from "babylonjs/Cameras/camera";
  11722. import { Texture } from "babylonjs/Materials/Textures/texture";
  11723. import "babylonjs/Shaders/sprites.fragment";
  11724. import "babylonjs/Shaders/sprites.vertex";
  11725. import { Ray } from "babylonjs/Culling/ray";
  11726. /**
  11727. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11728. */
  11729. export interface ISpriteManager extends IDisposable {
  11730. /**
  11731. * Restricts the camera to viewing objects with the same layerMask.
  11732. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11733. */
  11734. layerMask: number;
  11735. /**
  11736. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11737. */
  11738. isPickable: boolean;
  11739. /**
  11740. * Specifies the rendering group id for this mesh (0 by default)
  11741. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11742. */
  11743. renderingGroupId: number;
  11744. /**
  11745. * Defines the list of sprites managed by the manager.
  11746. */
  11747. sprites: Array<Sprite>;
  11748. /**
  11749. * Tests the intersection of a sprite with a specific ray.
  11750. * @param ray The ray we are sending to test the collision
  11751. * @param camera The camera space we are sending rays in
  11752. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11753. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11754. * @returns picking info or null.
  11755. */
  11756. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11757. /**
  11758. * Intersects the sprites with a ray
  11759. * @param ray defines the ray to intersect with
  11760. * @param camera defines the current active camera
  11761. * @param predicate defines a predicate used to select candidate sprites
  11762. * @returns null if no hit or a PickingInfo array
  11763. */
  11764. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11765. /**
  11766. * Renders the list of sprites on screen.
  11767. */
  11768. render(): void;
  11769. }
  11770. /**
  11771. * Class used to manage multiple sprites on the same spritesheet
  11772. * @see http://doc.babylonjs.com/babylon101/sprites
  11773. */
  11774. export class SpriteManager implements ISpriteManager {
  11775. /** defines the manager's name */
  11776. name: string;
  11777. /** Gets the list of sprites */
  11778. sprites: Sprite[];
  11779. /** Gets or sets the rendering group id (0 by default) */
  11780. renderingGroupId: number;
  11781. /** Gets or sets camera layer mask */
  11782. layerMask: number;
  11783. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11784. fogEnabled: boolean;
  11785. /** Gets or sets a boolean indicating if the sprites are pickable */
  11786. isPickable: boolean;
  11787. /** Defines the default width of a cell in the spritesheet */
  11788. cellWidth: number;
  11789. /** Defines the default height of a cell in the spritesheet */
  11790. cellHeight: number;
  11791. /** Associative array from JSON sprite data file */
  11792. private _cellData;
  11793. /** Array of sprite names from JSON sprite data file */
  11794. private _spriteMap;
  11795. /** True when packed cell data from JSON file is ready*/
  11796. private _packedAndReady;
  11797. /**
  11798. * An event triggered when the manager is disposed.
  11799. */
  11800. onDisposeObservable: Observable<SpriteManager>;
  11801. private _onDisposeObserver;
  11802. /**
  11803. * Callback called when the manager is disposed
  11804. */
  11805. onDispose: () => void;
  11806. private _capacity;
  11807. private _fromPacked;
  11808. private _spriteTexture;
  11809. private _epsilon;
  11810. private _scene;
  11811. private _vertexData;
  11812. private _buffer;
  11813. private _vertexBuffers;
  11814. private _indexBuffer;
  11815. private _effectBase;
  11816. private _effectFog;
  11817. /**
  11818. * Gets or sets the spritesheet texture
  11819. */
  11820. texture: Texture;
  11821. /**
  11822. * Creates a new sprite manager
  11823. * @param name defines the manager's name
  11824. * @param imgUrl defines the sprite sheet url
  11825. * @param capacity defines the maximum allowed number of sprites
  11826. * @param cellSize defines the size of a sprite cell
  11827. * @param scene defines the hosting scene
  11828. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11829. * @param samplingMode defines the smapling mode to use with spritesheet
  11830. * @param fromPacked set to false; do not alter
  11831. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11832. */
  11833. constructor(
  11834. /** defines the manager's name */
  11835. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  11836. private _makePacked;
  11837. private _appendSpriteVertex;
  11838. /**
  11839. * Intersects the sprites with a ray
  11840. * @param ray defines the ray to intersect with
  11841. * @param camera defines the current active camera
  11842. * @param predicate defines a predicate used to select candidate sprites
  11843. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11844. * @returns null if no hit or a PickingInfo
  11845. */
  11846. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11847. /**
  11848. * Intersects the sprites with a ray
  11849. * @param ray defines the ray to intersect with
  11850. * @param camera defines the current active camera
  11851. * @param predicate defines a predicate used to select candidate sprites
  11852. * @returns null if no hit or a PickingInfo array
  11853. */
  11854. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11855. /**
  11856. * Render all child sprites
  11857. */
  11858. render(): void;
  11859. /**
  11860. * Release associated resources
  11861. */
  11862. dispose(): void;
  11863. }
  11864. }
  11865. declare module "babylonjs/Sprites/sprite" {
  11866. import { Vector3 } from "babylonjs/Maths/math.vector";
  11867. import { Nullable } from "babylonjs/types";
  11868. import { ActionManager } from "babylonjs/Actions/actionManager";
  11869. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11870. import { Color4 } from "babylonjs/Maths/math.color";
  11871. /**
  11872. * Class used to represent a sprite
  11873. * @see http://doc.babylonjs.com/babylon101/sprites
  11874. */
  11875. export class Sprite {
  11876. /** defines the name */
  11877. name: string;
  11878. /** Gets or sets the current world position */
  11879. position: Vector3;
  11880. /** Gets or sets the main color */
  11881. color: Color4;
  11882. /** Gets or sets the width */
  11883. width: number;
  11884. /** Gets or sets the height */
  11885. height: number;
  11886. /** Gets or sets rotation angle */
  11887. angle: number;
  11888. /** Gets or sets the cell index in the sprite sheet */
  11889. cellIndex: number;
  11890. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  11891. cellRef: string;
  11892. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  11893. invertU: number;
  11894. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  11895. invertV: number;
  11896. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  11897. disposeWhenFinishedAnimating: boolean;
  11898. /** Gets the list of attached animations */
  11899. animations: Animation[];
  11900. /** Gets or sets a boolean indicating if the sprite can be picked */
  11901. isPickable: boolean;
  11902. /**
  11903. * Gets or sets the associated action manager
  11904. */
  11905. actionManager: Nullable<ActionManager>;
  11906. private _animationStarted;
  11907. private _loopAnimation;
  11908. private _fromIndex;
  11909. private _toIndex;
  11910. private _delay;
  11911. private _direction;
  11912. private _manager;
  11913. private _time;
  11914. private _onAnimationEnd;
  11915. /**
  11916. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  11917. */
  11918. isVisible: boolean;
  11919. /**
  11920. * Gets or sets the sprite size
  11921. */
  11922. size: number;
  11923. /**
  11924. * Creates a new Sprite
  11925. * @param name defines the name
  11926. * @param manager defines the manager
  11927. */
  11928. constructor(
  11929. /** defines the name */
  11930. name: string, manager: ISpriteManager);
  11931. /**
  11932. * Starts an animation
  11933. * @param from defines the initial key
  11934. * @param to defines the end key
  11935. * @param loop defines if the animation must loop
  11936. * @param delay defines the start delay (in ms)
  11937. * @param onAnimationEnd defines a callback to call when animation ends
  11938. */
  11939. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  11940. /** Stops current animation (if any) */
  11941. stopAnimation(): void;
  11942. /** @hidden */
  11943. _animate(deltaTime: number): void;
  11944. /** Release associated resources */
  11945. dispose(): void;
  11946. }
  11947. }
  11948. declare module "babylonjs/Collisions/pickingInfo" {
  11949. import { Nullable } from "babylonjs/types";
  11950. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11952. import { Sprite } from "babylonjs/Sprites/sprite";
  11953. import { Ray } from "babylonjs/Culling/ray";
  11954. /**
  11955. * Information about the result of picking within a scene
  11956. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  11957. */
  11958. export class PickingInfo {
  11959. /** @hidden */
  11960. _pickingUnavailable: boolean;
  11961. /**
  11962. * If the pick collided with an object
  11963. */
  11964. hit: boolean;
  11965. /**
  11966. * Distance away where the pick collided
  11967. */
  11968. distance: number;
  11969. /**
  11970. * The location of pick collision
  11971. */
  11972. pickedPoint: Nullable<Vector3>;
  11973. /**
  11974. * The mesh corresponding the the pick collision
  11975. */
  11976. pickedMesh: Nullable<AbstractMesh>;
  11977. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  11978. bu: number;
  11979. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  11980. bv: number;
  11981. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  11982. faceId: number;
  11983. /** Id of the the submesh that was picked */
  11984. subMeshId: number;
  11985. /** If a sprite was picked, this will be the sprite the pick collided with */
  11986. pickedSprite: Nullable<Sprite>;
  11987. /**
  11988. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  11989. */
  11990. originMesh: Nullable<AbstractMesh>;
  11991. /**
  11992. * The ray that was used to perform the picking.
  11993. */
  11994. ray: Nullable<Ray>;
  11995. /**
  11996. * Gets the normal correspodning to the face the pick collided with
  11997. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  11998. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  11999. * @returns The normal correspodning to the face the pick collided with
  12000. */
  12001. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12002. /**
  12003. * Gets the texture coordinates of where the pick occured
  12004. * @returns the vector containing the coordnates of the texture
  12005. */
  12006. getTextureCoordinates(): Nullable<Vector2>;
  12007. }
  12008. }
  12009. declare module "babylonjs/Events/pointerEvents" {
  12010. import { Nullable } from "babylonjs/types";
  12011. import { Vector2 } from "babylonjs/Maths/math.vector";
  12012. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12013. import { Ray } from "babylonjs/Culling/ray";
  12014. /**
  12015. * Gather the list of pointer event types as constants.
  12016. */
  12017. export class PointerEventTypes {
  12018. /**
  12019. * 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.
  12020. */
  12021. static readonly POINTERDOWN: number;
  12022. /**
  12023. * The pointerup event is fired when a pointer is no longer active.
  12024. */
  12025. static readonly POINTERUP: number;
  12026. /**
  12027. * The pointermove event is fired when a pointer changes coordinates.
  12028. */
  12029. static readonly POINTERMOVE: number;
  12030. /**
  12031. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12032. */
  12033. static readonly POINTERWHEEL: number;
  12034. /**
  12035. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12036. */
  12037. static readonly POINTERPICK: number;
  12038. /**
  12039. * The pointertap event is fired when a the object has been touched and released without drag.
  12040. */
  12041. static readonly POINTERTAP: number;
  12042. /**
  12043. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12044. */
  12045. static readonly POINTERDOUBLETAP: number;
  12046. }
  12047. /**
  12048. * Base class of pointer info types.
  12049. */
  12050. export class PointerInfoBase {
  12051. /**
  12052. * Defines the type of event (PointerEventTypes)
  12053. */
  12054. type: number;
  12055. /**
  12056. * Defines the related dom event
  12057. */
  12058. event: PointerEvent | MouseWheelEvent;
  12059. /**
  12060. * Instantiates the base class of pointers info.
  12061. * @param type Defines the type of event (PointerEventTypes)
  12062. * @param event Defines the related dom event
  12063. */
  12064. constructor(
  12065. /**
  12066. * Defines the type of event (PointerEventTypes)
  12067. */
  12068. type: number,
  12069. /**
  12070. * Defines the related dom event
  12071. */
  12072. event: PointerEvent | MouseWheelEvent);
  12073. }
  12074. /**
  12075. * This class is used to store pointer related info for the onPrePointerObservable event.
  12076. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12077. */
  12078. export class PointerInfoPre extends PointerInfoBase {
  12079. /**
  12080. * Ray from a pointer if availible (eg. 6dof controller)
  12081. */
  12082. ray: Nullable<Ray>;
  12083. /**
  12084. * Defines the local position of the pointer on the canvas.
  12085. */
  12086. localPosition: Vector2;
  12087. /**
  12088. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12089. */
  12090. skipOnPointerObservable: boolean;
  12091. /**
  12092. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12093. * @param type Defines the type of event (PointerEventTypes)
  12094. * @param event Defines the related dom event
  12095. * @param localX Defines the local x coordinates of the pointer when the event occured
  12096. * @param localY Defines the local y coordinates of the pointer when the event occured
  12097. */
  12098. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12099. }
  12100. /**
  12101. * This type contains all the data related to a pointer event in Babylon.js.
  12102. * 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.
  12103. */
  12104. export class PointerInfo extends PointerInfoBase {
  12105. /**
  12106. * Defines the picking info associated to the info (if any)\
  12107. */
  12108. pickInfo: Nullable<PickingInfo>;
  12109. /**
  12110. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12111. * @param type Defines the type of event (PointerEventTypes)
  12112. * @param event Defines the related dom event
  12113. * @param pickInfo Defines the picking info associated to the info (if any)\
  12114. */
  12115. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12116. /**
  12117. * Defines the picking info associated to the info (if any)\
  12118. */
  12119. pickInfo: Nullable<PickingInfo>);
  12120. }
  12121. /**
  12122. * Data relating to a touch event on the screen.
  12123. */
  12124. export interface PointerTouch {
  12125. /**
  12126. * X coordinate of touch.
  12127. */
  12128. x: number;
  12129. /**
  12130. * Y coordinate of touch.
  12131. */
  12132. y: number;
  12133. /**
  12134. * Id of touch. Unique for each finger.
  12135. */
  12136. pointerId: number;
  12137. /**
  12138. * Event type passed from DOM.
  12139. */
  12140. type: any;
  12141. }
  12142. }
  12143. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12144. import { Observable } from "babylonjs/Misc/observable";
  12145. import { Nullable } from "babylonjs/types";
  12146. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12147. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12148. /**
  12149. * Manage the mouse inputs to control the movement of a free camera.
  12150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12151. */
  12152. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12153. /**
  12154. * Define if touch is enabled in the mouse input
  12155. */
  12156. touchEnabled: boolean;
  12157. /**
  12158. * Defines the camera the input is attached to.
  12159. */
  12160. camera: FreeCamera;
  12161. /**
  12162. * Defines the buttons associated with the input to handle camera move.
  12163. */
  12164. buttons: number[];
  12165. /**
  12166. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12167. */
  12168. angularSensibility: number;
  12169. private _pointerInput;
  12170. private _onMouseMove;
  12171. private _observer;
  12172. private previousPosition;
  12173. /**
  12174. * Observable for when a pointer move event occurs containing the move offset
  12175. */
  12176. onPointerMovedObservable: Observable<{
  12177. offsetX: number;
  12178. offsetY: number;
  12179. }>;
  12180. /**
  12181. * @hidden
  12182. * If the camera should be rotated automatically based on pointer movement
  12183. */
  12184. _allowCameraRotation: boolean;
  12185. /**
  12186. * Manage the mouse inputs to control the movement of a free camera.
  12187. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12188. * @param touchEnabled Defines if touch is enabled or not
  12189. */
  12190. constructor(
  12191. /**
  12192. * Define if touch is enabled in the mouse input
  12193. */
  12194. touchEnabled?: boolean);
  12195. /**
  12196. * Attach the input controls to a specific dom element to get the input from.
  12197. * @param element Defines the element the controls should be listened from
  12198. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12199. */
  12200. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12201. /**
  12202. * Called on JS contextmenu event.
  12203. * Override this method to provide functionality.
  12204. */
  12205. protected onContextMenu(evt: PointerEvent): void;
  12206. /**
  12207. * Detach the current controls from the specified dom element.
  12208. * @param element Defines the element to stop listening the inputs from
  12209. */
  12210. detachControl(element: Nullable<HTMLElement>): void;
  12211. /**
  12212. * Gets the class name of the current intput.
  12213. * @returns the class name
  12214. */
  12215. getClassName(): string;
  12216. /**
  12217. * Get the friendly name associated with the input class.
  12218. * @returns the input friendly name
  12219. */
  12220. getSimpleName(): string;
  12221. }
  12222. }
  12223. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12224. import { Nullable } from "babylonjs/types";
  12225. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12226. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12227. /**
  12228. * Manage the touch inputs to control the movement of a free camera.
  12229. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12230. */
  12231. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12232. /**
  12233. * Defines the camera the input is attached to.
  12234. */
  12235. camera: FreeCamera;
  12236. /**
  12237. * Defines the touch sensibility for rotation.
  12238. * The higher the faster.
  12239. */
  12240. touchAngularSensibility: number;
  12241. /**
  12242. * Defines the touch sensibility for move.
  12243. * The higher the faster.
  12244. */
  12245. touchMoveSensibility: number;
  12246. private _offsetX;
  12247. private _offsetY;
  12248. private _pointerPressed;
  12249. private _pointerInput;
  12250. private _observer;
  12251. private _onLostFocus;
  12252. /**
  12253. * Attach the input controls to a specific dom element to get the input from.
  12254. * @param element Defines the element the controls should be listened from
  12255. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12256. */
  12257. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12258. /**
  12259. * Detach the current controls from the specified dom element.
  12260. * @param element Defines the element to stop listening the inputs from
  12261. */
  12262. detachControl(element: Nullable<HTMLElement>): void;
  12263. /**
  12264. * Update the current camera state depending on the inputs that have been used this frame.
  12265. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12266. */
  12267. checkInputs(): void;
  12268. /**
  12269. * Gets the class name of the current intput.
  12270. * @returns the class name
  12271. */
  12272. getClassName(): string;
  12273. /**
  12274. * Get the friendly name associated with the input class.
  12275. * @returns the input friendly name
  12276. */
  12277. getSimpleName(): string;
  12278. }
  12279. }
  12280. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12281. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12282. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12283. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12284. import { Nullable } from "babylonjs/types";
  12285. /**
  12286. * Default Inputs manager for the FreeCamera.
  12287. * It groups all the default supported inputs for ease of use.
  12288. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12289. */
  12290. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12291. /**
  12292. * @hidden
  12293. */
  12294. _mouseInput: Nullable<FreeCameraMouseInput>;
  12295. /**
  12296. * Instantiates a new FreeCameraInputsManager.
  12297. * @param camera Defines the camera the inputs belong to
  12298. */
  12299. constructor(camera: FreeCamera);
  12300. /**
  12301. * Add keyboard input support to the input manager.
  12302. * @returns the current input manager
  12303. */
  12304. addKeyboard(): FreeCameraInputsManager;
  12305. /**
  12306. * Add mouse input support to the input manager.
  12307. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12308. * @returns the current input manager
  12309. */
  12310. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12311. /**
  12312. * Removes the mouse input support from the manager
  12313. * @returns the current input manager
  12314. */
  12315. removeMouse(): FreeCameraInputsManager;
  12316. /**
  12317. * Add touch input support to the input manager.
  12318. * @returns the current input manager
  12319. */
  12320. addTouch(): FreeCameraInputsManager;
  12321. /**
  12322. * Remove all attached input methods from a camera
  12323. */
  12324. clear(): void;
  12325. }
  12326. }
  12327. declare module "babylonjs/Cameras/freeCamera" {
  12328. import { Vector3 } from "babylonjs/Maths/math.vector";
  12329. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12330. import { Scene } from "babylonjs/scene";
  12331. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12332. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12333. /**
  12334. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12335. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12336. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12337. */
  12338. export class FreeCamera extends TargetCamera {
  12339. /**
  12340. * Define the collision ellipsoid of the camera.
  12341. * This is helpful to simulate a camera body like the player body around the camera
  12342. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12343. */
  12344. ellipsoid: Vector3;
  12345. /**
  12346. * Define an offset for the position of the ellipsoid around the camera.
  12347. * This can be helpful to determine the center of the body near the gravity center of the body
  12348. * instead of its head.
  12349. */
  12350. ellipsoidOffset: Vector3;
  12351. /**
  12352. * Enable or disable collisions of the camera with the rest of the scene objects.
  12353. */
  12354. checkCollisions: boolean;
  12355. /**
  12356. * Enable or disable gravity on the camera.
  12357. */
  12358. applyGravity: boolean;
  12359. /**
  12360. * Define the input manager associated to the camera.
  12361. */
  12362. inputs: FreeCameraInputsManager;
  12363. /**
  12364. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12365. * Higher values reduce sensitivity.
  12366. */
  12367. /**
  12368. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12369. * Higher values reduce sensitivity.
  12370. */
  12371. angularSensibility: number;
  12372. /**
  12373. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12374. */
  12375. keysUp: number[];
  12376. /**
  12377. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12378. */
  12379. keysDown: number[];
  12380. /**
  12381. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12382. */
  12383. keysLeft: number[];
  12384. /**
  12385. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12386. */
  12387. keysRight: number[];
  12388. /**
  12389. * Event raised when the camera collide with a mesh in the scene.
  12390. */
  12391. onCollide: (collidedMesh: AbstractMesh) => void;
  12392. private _collider;
  12393. private _needMoveForGravity;
  12394. private _oldPosition;
  12395. private _diffPosition;
  12396. private _newPosition;
  12397. /** @hidden */
  12398. _localDirection: Vector3;
  12399. /** @hidden */
  12400. _transformedDirection: Vector3;
  12401. /**
  12402. * Instantiates a Free Camera.
  12403. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12404. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12405. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12406. * @param name Define the name of the camera in the scene
  12407. * @param position Define the start position of the camera in the scene
  12408. * @param scene Define the scene the camera belongs to
  12409. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12410. */
  12411. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12412. /**
  12413. * Attached controls to the current camera.
  12414. * @param element Defines the element the controls should be listened from
  12415. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12416. */
  12417. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12418. /**
  12419. * Detach the current controls from the camera.
  12420. * The camera will stop reacting to inputs.
  12421. * @param element Defines the element to stop listening the inputs from
  12422. */
  12423. detachControl(element: HTMLElement): void;
  12424. private _collisionMask;
  12425. /**
  12426. * Define a collision mask to limit the list of object the camera can collide with
  12427. */
  12428. collisionMask: number;
  12429. /** @hidden */
  12430. _collideWithWorld(displacement: Vector3): void;
  12431. private _onCollisionPositionChange;
  12432. /** @hidden */
  12433. _checkInputs(): void;
  12434. /** @hidden */
  12435. _decideIfNeedsToMove(): boolean;
  12436. /** @hidden */
  12437. _updatePosition(): void;
  12438. /**
  12439. * Destroy the camera and release the current resources hold by it.
  12440. */
  12441. dispose(): void;
  12442. /**
  12443. * Gets the current object class name.
  12444. * @return the class name
  12445. */
  12446. getClassName(): string;
  12447. }
  12448. }
  12449. declare module "babylonjs/Gamepads/gamepad" {
  12450. import { Observable } from "babylonjs/Misc/observable";
  12451. /**
  12452. * Represents a gamepad control stick position
  12453. */
  12454. export class StickValues {
  12455. /**
  12456. * The x component of the control stick
  12457. */
  12458. x: number;
  12459. /**
  12460. * The y component of the control stick
  12461. */
  12462. y: number;
  12463. /**
  12464. * Initializes the gamepad x and y control stick values
  12465. * @param x The x component of the gamepad control stick value
  12466. * @param y The y component of the gamepad control stick value
  12467. */
  12468. constructor(
  12469. /**
  12470. * The x component of the control stick
  12471. */
  12472. x: number,
  12473. /**
  12474. * The y component of the control stick
  12475. */
  12476. y: number);
  12477. }
  12478. /**
  12479. * An interface which manages callbacks for gamepad button changes
  12480. */
  12481. export interface GamepadButtonChanges {
  12482. /**
  12483. * Called when a gamepad has been changed
  12484. */
  12485. changed: boolean;
  12486. /**
  12487. * Called when a gamepad press event has been triggered
  12488. */
  12489. pressChanged: boolean;
  12490. /**
  12491. * Called when a touch event has been triggered
  12492. */
  12493. touchChanged: boolean;
  12494. /**
  12495. * Called when a value has changed
  12496. */
  12497. valueChanged: boolean;
  12498. }
  12499. /**
  12500. * Represents a gamepad
  12501. */
  12502. export class Gamepad {
  12503. /**
  12504. * The id of the gamepad
  12505. */
  12506. id: string;
  12507. /**
  12508. * The index of the gamepad
  12509. */
  12510. index: number;
  12511. /**
  12512. * The browser gamepad
  12513. */
  12514. browserGamepad: any;
  12515. /**
  12516. * Specifies what type of gamepad this represents
  12517. */
  12518. type: number;
  12519. private _leftStick;
  12520. private _rightStick;
  12521. /** @hidden */
  12522. _isConnected: boolean;
  12523. private _leftStickAxisX;
  12524. private _leftStickAxisY;
  12525. private _rightStickAxisX;
  12526. private _rightStickAxisY;
  12527. /**
  12528. * Triggered when the left control stick has been changed
  12529. */
  12530. private _onleftstickchanged;
  12531. /**
  12532. * Triggered when the right control stick has been changed
  12533. */
  12534. private _onrightstickchanged;
  12535. /**
  12536. * Represents a gamepad controller
  12537. */
  12538. static GAMEPAD: number;
  12539. /**
  12540. * Represents a generic controller
  12541. */
  12542. static GENERIC: number;
  12543. /**
  12544. * Represents an XBox controller
  12545. */
  12546. static XBOX: number;
  12547. /**
  12548. * Represents a pose-enabled controller
  12549. */
  12550. static POSE_ENABLED: number;
  12551. /**
  12552. * Represents an Dual Shock controller
  12553. */
  12554. static DUALSHOCK: number;
  12555. /**
  12556. * Specifies whether the left control stick should be Y-inverted
  12557. */
  12558. protected _invertLeftStickY: boolean;
  12559. /**
  12560. * Specifies if the gamepad has been connected
  12561. */
  12562. readonly isConnected: boolean;
  12563. /**
  12564. * Initializes the gamepad
  12565. * @param id The id of the gamepad
  12566. * @param index The index of the gamepad
  12567. * @param browserGamepad The browser gamepad
  12568. * @param leftStickX The x component of the left joystick
  12569. * @param leftStickY The y component of the left joystick
  12570. * @param rightStickX The x component of the right joystick
  12571. * @param rightStickY The y component of the right joystick
  12572. */
  12573. constructor(
  12574. /**
  12575. * The id of the gamepad
  12576. */
  12577. id: string,
  12578. /**
  12579. * The index of the gamepad
  12580. */
  12581. index: number,
  12582. /**
  12583. * The browser gamepad
  12584. */
  12585. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12586. /**
  12587. * Callback triggered when the left joystick has changed
  12588. * @param callback
  12589. */
  12590. onleftstickchanged(callback: (values: StickValues) => void): void;
  12591. /**
  12592. * Callback triggered when the right joystick has changed
  12593. * @param callback
  12594. */
  12595. onrightstickchanged(callback: (values: StickValues) => void): void;
  12596. /**
  12597. * Gets the left joystick
  12598. */
  12599. /**
  12600. * Sets the left joystick values
  12601. */
  12602. leftStick: StickValues;
  12603. /**
  12604. * Gets the right joystick
  12605. */
  12606. /**
  12607. * Sets the right joystick value
  12608. */
  12609. rightStick: StickValues;
  12610. /**
  12611. * Updates the gamepad joystick positions
  12612. */
  12613. update(): void;
  12614. /**
  12615. * Disposes the gamepad
  12616. */
  12617. dispose(): void;
  12618. }
  12619. /**
  12620. * Represents a generic gamepad
  12621. */
  12622. export class GenericPad extends Gamepad {
  12623. private _buttons;
  12624. private _onbuttondown;
  12625. private _onbuttonup;
  12626. /**
  12627. * Observable triggered when a button has been pressed
  12628. */
  12629. onButtonDownObservable: Observable<number>;
  12630. /**
  12631. * Observable triggered when a button has been released
  12632. */
  12633. onButtonUpObservable: Observable<number>;
  12634. /**
  12635. * Callback triggered when a button has been pressed
  12636. * @param callback Called when a button has been pressed
  12637. */
  12638. onbuttondown(callback: (buttonPressed: number) => void): void;
  12639. /**
  12640. * Callback triggered when a button has been released
  12641. * @param callback Called when a button has been released
  12642. */
  12643. onbuttonup(callback: (buttonReleased: number) => void): void;
  12644. /**
  12645. * Initializes the generic gamepad
  12646. * @param id The id of the generic gamepad
  12647. * @param index The index of the generic gamepad
  12648. * @param browserGamepad The browser gamepad
  12649. */
  12650. constructor(id: string, index: number, browserGamepad: any);
  12651. private _setButtonValue;
  12652. /**
  12653. * Updates the generic gamepad
  12654. */
  12655. update(): void;
  12656. /**
  12657. * Disposes the generic gamepad
  12658. */
  12659. dispose(): void;
  12660. }
  12661. }
  12662. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  12663. import { Nullable } from "babylonjs/types";
  12664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  12665. import { Scene } from "babylonjs/scene";
  12666. module "babylonjs/Engines/engine" {
  12667. interface Engine {
  12668. /**
  12669. * Creates a raw texture
  12670. * @param data defines the data to store in the texture
  12671. * @param width defines the width of the texture
  12672. * @param height defines the height of the texture
  12673. * @param format defines the format of the data
  12674. * @param generateMipMaps defines if the engine should generate the mip levels
  12675. * @param invertY defines if data must be stored with Y axis inverted
  12676. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  12677. * @param compression defines the compression used (null by default)
  12678. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12679. * @returns the raw texture inside an InternalTexture
  12680. */
  12681. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  12682. /**
  12683. * Update a raw texture
  12684. * @param texture defines the texture to update
  12685. * @param data defines the data to store in the texture
  12686. * @param format defines the format of the data
  12687. * @param invertY defines if data must be stored with Y axis inverted
  12688. */
  12689. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12690. /**
  12691. * Update a raw texture
  12692. * @param texture defines the texture to update
  12693. * @param data defines the data to store in the texture
  12694. * @param format defines the format of the data
  12695. * @param invertY defines if data must be stored with Y axis inverted
  12696. * @param compression defines the compression used (null by default)
  12697. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12698. */
  12699. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  12700. /**
  12701. * Creates a new raw cube texture
  12702. * @param data defines the array of data to use to create each face
  12703. * @param size defines the size of the textures
  12704. * @param format defines the format of the data
  12705. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12706. * @param generateMipMaps defines if the engine should generate the mip levels
  12707. * @param invertY defines if data must be stored with Y axis inverted
  12708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12709. * @param compression defines the compression used (null by default)
  12710. * @returns the cube texture as an InternalTexture
  12711. */
  12712. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  12713. /**
  12714. * Update a raw cube texture
  12715. * @param texture defines the texture to udpdate
  12716. * @param data defines the data to store
  12717. * @param format defines the data format
  12718. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12719. * @param invertY defines if data must be stored with Y axis inverted
  12720. */
  12721. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  12722. /**
  12723. * Update a raw cube texture
  12724. * @param texture defines the texture to udpdate
  12725. * @param data defines the data to store
  12726. * @param format defines the data format
  12727. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12728. * @param invertY defines if data must be stored with Y axis inverted
  12729. * @param compression defines the compression used (null by default)
  12730. */
  12731. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  12732. /**
  12733. * Update a raw cube texture
  12734. * @param texture defines the texture to udpdate
  12735. * @param data defines the data to store
  12736. * @param format defines the data format
  12737. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  12738. * @param invertY defines if data must be stored with Y axis inverted
  12739. * @param compression defines the compression used (null by default)
  12740. * @param level defines which level of the texture to update
  12741. */
  12742. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  12743. /**
  12744. * Creates a new raw cube texture from a specified url
  12745. * @param url defines the url where the data is located
  12746. * @param scene defines the current scene
  12747. * @param size defines the size of the textures
  12748. * @param format defines the format of the data
  12749. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12750. * @param noMipmap defines if the engine should avoid generating the mip levels
  12751. * @param callback defines a callback used to extract texture data from loaded data
  12752. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12753. * @param onLoad defines a callback called when texture is loaded
  12754. * @param onError defines a callback called if there is an error
  12755. * @returns the cube texture as an InternalTexture
  12756. */
  12757. 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;
  12758. /**
  12759. * Creates a new raw cube texture from a specified url
  12760. * @param url defines the url where the data is located
  12761. * @param scene defines the current scene
  12762. * @param size defines the size of the textures
  12763. * @param format defines the format of the data
  12764. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  12765. * @param noMipmap defines if the engine should avoid generating the mip levels
  12766. * @param callback defines a callback used to extract texture data from loaded data
  12767. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  12768. * @param onLoad defines a callback called when texture is loaded
  12769. * @param onError defines a callback called if there is an error
  12770. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12771. * @param invertY defines if data must be stored with Y axis inverted
  12772. * @returns the cube texture as an InternalTexture
  12773. */
  12774. 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;
  12775. /**
  12776. * Creates a new raw 3D texture
  12777. * @param data defines the data used to create the texture
  12778. * @param width defines the width of the texture
  12779. * @param height defines the height of the texture
  12780. * @param depth defines the depth of the texture
  12781. * @param format defines the format of the texture
  12782. * @param generateMipMaps defines if the engine must generate mip levels
  12783. * @param invertY defines if data must be stored with Y axis inverted
  12784. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  12785. * @param compression defines the compressed used (can be null)
  12786. * @param textureType defines the compressed used (can be null)
  12787. * @returns a new raw 3D texture (stored in an InternalTexture)
  12788. */
  12789. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  12790. /**
  12791. * Update a raw 3D texture
  12792. * @param texture defines the texture to update
  12793. * @param data defines the data to store
  12794. * @param format defines the data format
  12795. * @param invertY defines if data must be stored with Y axis inverted
  12796. */
  12797. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  12798. /**
  12799. * Update a raw 3D texture
  12800. * @param texture defines the texture to update
  12801. * @param data defines the data to store
  12802. * @param format defines the data format
  12803. * @param invertY defines if data must be stored with Y axis inverted
  12804. * @param compression defines the used compression (can be null)
  12805. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  12806. */
  12807. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  12808. }
  12809. }
  12810. }
  12811. declare module "babylonjs/Materials/Textures/rawTexture" {
  12812. import { Scene } from "babylonjs/scene";
  12813. import { Texture } from "babylonjs/Materials/Textures/texture";
  12814. import "babylonjs/Engines/Extensions/engine.rawTexture";
  12815. /**
  12816. * Raw texture can help creating a texture directly from an array of data.
  12817. * This can be super useful if you either get the data from an uncompressed source or
  12818. * if you wish to create your texture pixel by pixel.
  12819. */
  12820. export class RawTexture extends Texture {
  12821. /**
  12822. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12823. */
  12824. format: number;
  12825. private _engine;
  12826. /**
  12827. * Instantiates a new RawTexture.
  12828. * Raw texture can help creating a texture directly from an array of data.
  12829. * This can be super useful if you either get the data from an uncompressed source or
  12830. * if you wish to create your texture pixel by pixel.
  12831. * @param data define the array of data to use to create the texture
  12832. * @param width define the width of the texture
  12833. * @param height define the height of the texture
  12834. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12835. * @param scene define the scene the texture belongs to
  12836. * @param generateMipMaps define whether mip maps should be generated or not
  12837. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12838. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12839. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12840. */
  12841. constructor(data: ArrayBufferView, width: number, height: number,
  12842. /**
  12843. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  12844. */
  12845. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  12846. /**
  12847. * Updates the texture underlying data.
  12848. * @param data Define the new data of the texture
  12849. */
  12850. update(data: ArrayBufferView): void;
  12851. /**
  12852. * Creates a luminance texture from some data.
  12853. * @param data Define the texture data
  12854. * @param width Define the width of the texture
  12855. * @param height Define the height of the texture
  12856. * @param scene Define the scene the texture belongs to
  12857. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12858. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12859. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12860. * @returns the luminance texture
  12861. */
  12862. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12863. /**
  12864. * Creates a luminance alpha texture from some data.
  12865. * @param data Define the texture data
  12866. * @param width Define the width of the texture
  12867. * @param height Define the height of the texture
  12868. * @param scene Define the scene the texture belongs to
  12869. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12870. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12871. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12872. * @returns the luminance alpha texture
  12873. */
  12874. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12875. /**
  12876. * Creates an alpha texture from some data.
  12877. * @param data Define the texture data
  12878. * @param width Define the width of the texture
  12879. * @param height Define the height of the texture
  12880. * @param scene Define the scene the texture belongs to
  12881. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12882. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12883. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12884. * @returns the alpha texture
  12885. */
  12886. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  12887. /**
  12888. * Creates a RGB texture from some data.
  12889. * @param data Define the texture data
  12890. * @param width Define the width of the texture
  12891. * @param height Define the height of the texture
  12892. * @param scene Define the scene the texture belongs to
  12893. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12894. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12895. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12896. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12897. * @returns the RGB alpha texture
  12898. */
  12899. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12900. /**
  12901. * Creates a RGBA texture from some data.
  12902. * @param data Define the texture data
  12903. * @param width Define the width of the texture
  12904. * @param height Define the height of the texture
  12905. * @param scene Define the scene the texture belongs to
  12906. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12907. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12908. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12909. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12910. * @returns the RGBA texture
  12911. */
  12912. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12913. /**
  12914. * Creates a R texture from some data.
  12915. * @param data Define the texture data
  12916. * @param width Define the width of the texture
  12917. * @param height Define the height of the texture
  12918. * @param scene Define the scene the texture belongs to
  12919. * @param generateMipMaps Define whether or not to create mip maps for the texture
  12920. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  12921. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  12922. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  12923. * @returns the R texture
  12924. */
  12925. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  12926. }
  12927. }
  12928. declare module "babylonjs/Maths/math.size" {
  12929. /**
  12930. * Interface for the size containing width and height
  12931. */
  12932. export interface ISize {
  12933. /**
  12934. * Width
  12935. */
  12936. width: number;
  12937. /**
  12938. * Heighht
  12939. */
  12940. height: number;
  12941. }
  12942. /**
  12943. * Size containing widht and height
  12944. */
  12945. export class Size implements ISize {
  12946. /**
  12947. * Width
  12948. */
  12949. width: number;
  12950. /**
  12951. * Height
  12952. */
  12953. height: number;
  12954. /**
  12955. * Creates a Size object from the given width and height (floats).
  12956. * @param width width of the new size
  12957. * @param height height of the new size
  12958. */
  12959. constructor(width: number, height: number);
  12960. /**
  12961. * Returns a string with the Size width and height
  12962. * @returns a string with the Size width and height
  12963. */
  12964. toString(): string;
  12965. /**
  12966. * "Size"
  12967. * @returns the string "Size"
  12968. */
  12969. getClassName(): string;
  12970. /**
  12971. * Returns the Size hash code.
  12972. * @returns a hash code for a unique width and height
  12973. */
  12974. getHashCode(): number;
  12975. /**
  12976. * Updates the current size from the given one.
  12977. * @param src the given size
  12978. */
  12979. copyFrom(src: Size): void;
  12980. /**
  12981. * Updates in place the current Size from the given floats.
  12982. * @param width width of the new size
  12983. * @param height height of the new size
  12984. * @returns the updated Size.
  12985. */
  12986. copyFromFloats(width: number, height: number): Size;
  12987. /**
  12988. * Updates in place the current Size from the given floats.
  12989. * @param width width to set
  12990. * @param height height to set
  12991. * @returns the updated Size.
  12992. */
  12993. set(width: number, height: number): Size;
  12994. /**
  12995. * Multiplies the width and height by numbers
  12996. * @param w factor to multiple the width by
  12997. * @param h factor to multiple the height by
  12998. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  12999. */
  13000. multiplyByFloats(w: number, h: number): Size;
  13001. /**
  13002. * Clones the size
  13003. * @returns a new Size copied from the given one.
  13004. */
  13005. clone(): Size;
  13006. /**
  13007. * True if the current Size and the given one width and height are strictly equal.
  13008. * @param other the other size to compare against
  13009. * @returns True if the current Size and the given one width and height are strictly equal.
  13010. */
  13011. equals(other: Size): boolean;
  13012. /**
  13013. * The surface of the Size : width * height (float).
  13014. */
  13015. readonly surface: number;
  13016. /**
  13017. * Create a new size of zero
  13018. * @returns a new Size set to (0.0, 0.0)
  13019. */
  13020. static Zero(): Size;
  13021. /**
  13022. * Sums the width and height of two sizes
  13023. * @param otherSize size to add to this size
  13024. * @returns a new Size set as the addition result of the current Size and the given one.
  13025. */
  13026. add(otherSize: Size): Size;
  13027. /**
  13028. * Subtracts the width and height of two
  13029. * @param otherSize size to subtract to this size
  13030. * @returns a new Size set as the subtraction result of the given one from the current Size.
  13031. */
  13032. subtract(otherSize: Size): Size;
  13033. /**
  13034. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  13035. * @param start starting size to lerp between
  13036. * @param end end size to lerp between
  13037. * @param amount amount to lerp between the start and end values
  13038. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  13039. */
  13040. static Lerp(start: Size, end: Size, amount: number): Size;
  13041. }
  13042. }
  13043. declare module "babylonjs/Animations/runtimeAnimation" {
  13044. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  13045. import { Animatable } from "babylonjs/Animations/animatable";
  13046. import { Scene } from "babylonjs/scene";
  13047. /**
  13048. * Defines a runtime animation
  13049. */
  13050. export class RuntimeAnimation {
  13051. private _events;
  13052. /**
  13053. * The current frame of the runtime animation
  13054. */
  13055. private _currentFrame;
  13056. /**
  13057. * The animation used by the runtime animation
  13058. */
  13059. private _animation;
  13060. /**
  13061. * The target of the runtime animation
  13062. */
  13063. private _target;
  13064. /**
  13065. * The initiating animatable
  13066. */
  13067. private _host;
  13068. /**
  13069. * The original value of the runtime animation
  13070. */
  13071. private _originalValue;
  13072. /**
  13073. * The original blend value of the runtime animation
  13074. */
  13075. private _originalBlendValue;
  13076. /**
  13077. * The offsets cache of the runtime animation
  13078. */
  13079. private _offsetsCache;
  13080. /**
  13081. * The high limits cache of the runtime animation
  13082. */
  13083. private _highLimitsCache;
  13084. /**
  13085. * Specifies if the runtime animation has been stopped
  13086. */
  13087. private _stopped;
  13088. /**
  13089. * The blending factor of the runtime animation
  13090. */
  13091. private _blendingFactor;
  13092. /**
  13093. * The BabylonJS scene
  13094. */
  13095. private _scene;
  13096. /**
  13097. * The current value of the runtime animation
  13098. */
  13099. private _currentValue;
  13100. /** @hidden */
  13101. _animationState: _IAnimationState;
  13102. /**
  13103. * The active target of the runtime animation
  13104. */
  13105. private _activeTargets;
  13106. private _currentActiveTarget;
  13107. private _directTarget;
  13108. /**
  13109. * The target path of the runtime animation
  13110. */
  13111. private _targetPath;
  13112. /**
  13113. * The weight of the runtime animation
  13114. */
  13115. private _weight;
  13116. /**
  13117. * The ratio offset of the runtime animation
  13118. */
  13119. private _ratioOffset;
  13120. /**
  13121. * The previous delay of the runtime animation
  13122. */
  13123. private _previousDelay;
  13124. /**
  13125. * The previous ratio of the runtime animation
  13126. */
  13127. private _previousRatio;
  13128. private _enableBlending;
  13129. private _keys;
  13130. private _minFrame;
  13131. private _maxFrame;
  13132. private _minValue;
  13133. private _maxValue;
  13134. private _targetIsArray;
  13135. /**
  13136. * Gets the current frame of the runtime animation
  13137. */
  13138. readonly currentFrame: number;
  13139. /**
  13140. * Gets the weight of the runtime animation
  13141. */
  13142. readonly weight: number;
  13143. /**
  13144. * Gets the current value of the runtime animation
  13145. */
  13146. readonly currentValue: any;
  13147. /**
  13148. * Gets the target path of the runtime animation
  13149. */
  13150. readonly targetPath: string;
  13151. /**
  13152. * Gets the actual target of the runtime animation
  13153. */
  13154. readonly target: any;
  13155. /** @hidden */
  13156. _onLoop: () => void;
  13157. /**
  13158. * Create a new RuntimeAnimation object
  13159. * @param target defines the target of the animation
  13160. * @param animation defines the source animation object
  13161. * @param scene defines the hosting scene
  13162. * @param host defines the initiating Animatable
  13163. */
  13164. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  13165. private _preparePath;
  13166. /**
  13167. * Gets the animation from the runtime animation
  13168. */
  13169. readonly animation: Animation;
  13170. /**
  13171. * Resets the runtime animation to the beginning
  13172. * @param restoreOriginal defines whether to restore the target property to the original value
  13173. */
  13174. reset(restoreOriginal?: boolean): void;
  13175. /**
  13176. * Specifies if the runtime animation is stopped
  13177. * @returns Boolean specifying if the runtime animation is stopped
  13178. */
  13179. isStopped(): boolean;
  13180. /**
  13181. * Disposes of the runtime animation
  13182. */
  13183. dispose(): void;
  13184. /**
  13185. * Apply the interpolated value to the target
  13186. * @param currentValue defines the value computed by the animation
  13187. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  13188. */
  13189. setValue(currentValue: any, weight: number): void;
  13190. private _getOriginalValues;
  13191. private _setValue;
  13192. /**
  13193. * Gets the loop pmode of the runtime animation
  13194. * @returns Loop Mode
  13195. */
  13196. private _getCorrectLoopMode;
  13197. /**
  13198. * Move the current animation to a given frame
  13199. * @param frame defines the frame to move to
  13200. */
  13201. goToFrame(frame: number): void;
  13202. /**
  13203. * @hidden Internal use only
  13204. */
  13205. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  13206. /**
  13207. * Execute the current animation
  13208. * @param delay defines the delay to add to the current frame
  13209. * @param from defines the lower bound of the animation range
  13210. * @param to defines the upper bound of the animation range
  13211. * @param loop defines if the current animation must loop
  13212. * @param speedRatio defines the current speed ratio
  13213. * @param weight defines the weight of the animation (default is -1 so no weight)
  13214. * @param onLoop optional callback called when animation loops
  13215. * @returns a boolean indicating if the animation is running
  13216. */
  13217. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  13218. }
  13219. }
  13220. declare module "babylonjs/Animations/animatable" {
  13221. import { Animation } from "babylonjs/Animations/animation";
  13222. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  13223. import { Nullable } from "babylonjs/types";
  13224. import { Observable } from "babylonjs/Misc/observable";
  13225. import { Scene } from "babylonjs/scene";
  13226. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  13227. import { Node } from "babylonjs/node";
  13228. /**
  13229. * Class used to store an actual running animation
  13230. */
  13231. export class Animatable {
  13232. /** defines the target object */
  13233. target: any;
  13234. /** defines the starting frame number (default is 0) */
  13235. fromFrame: number;
  13236. /** defines the ending frame number (default is 100) */
  13237. toFrame: number;
  13238. /** defines if the animation must loop (default is false) */
  13239. loopAnimation: boolean;
  13240. /** defines a callback to call when animation ends if it is not looping */
  13241. onAnimationEnd?: (() => void) | null | undefined;
  13242. /** defines a callback to call when animation loops */
  13243. onAnimationLoop?: (() => void) | null | undefined;
  13244. private _localDelayOffset;
  13245. private _pausedDelay;
  13246. private _runtimeAnimations;
  13247. private _paused;
  13248. private _scene;
  13249. private _speedRatio;
  13250. private _weight;
  13251. private _syncRoot;
  13252. /**
  13253. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  13254. * This will only apply for non looping animation (default is true)
  13255. */
  13256. disposeOnEnd: boolean;
  13257. /**
  13258. * Gets a boolean indicating if the animation has started
  13259. */
  13260. animationStarted: boolean;
  13261. /**
  13262. * Observer raised when the animation ends
  13263. */
  13264. onAnimationEndObservable: Observable<Animatable>;
  13265. /**
  13266. * Observer raised when the animation loops
  13267. */
  13268. onAnimationLoopObservable: Observable<Animatable>;
  13269. /**
  13270. * Gets the root Animatable used to synchronize and normalize animations
  13271. */
  13272. readonly syncRoot: Nullable<Animatable>;
  13273. /**
  13274. * Gets the current frame of the first RuntimeAnimation
  13275. * Used to synchronize Animatables
  13276. */
  13277. readonly masterFrame: number;
  13278. /**
  13279. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  13280. */
  13281. weight: number;
  13282. /**
  13283. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  13284. */
  13285. speedRatio: number;
  13286. /**
  13287. * Creates a new Animatable
  13288. * @param scene defines the hosting scene
  13289. * @param target defines the target object
  13290. * @param fromFrame defines the starting frame number (default is 0)
  13291. * @param toFrame defines the ending frame number (default is 100)
  13292. * @param loopAnimation defines if the animation must loop (default is false)
  13293. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  13294. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  13295. * @param animations defines a group of animation to add to the new Animatable
  13296. * @param onAnimationLoop defines a callback to call when animation loops
  13297. */
  13298. constructor(scene: Scene,
  13299. /** defines the target object */
  13300. target: any,
  13301. /** defines the starting frame number (default is 0) */
  13302. fromFrame?: number,
  13303. /** defines the ending frame number (default is 100) */
  13304. toFrame?: number,
  13305. /** defines if the animation must loop (default is false) */
  13306. loopAnimation?: boolean, speedRatio?: number,
  13307. /** defines a callback to call when animation ends if it is not looping */
  13308. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  13309. /** defines a callback to call when animation loops */
  13310. onAnimationLoop?: (() => void) | null | undefined);
  13311. /**
  13312. * Synchronize and normalize current Animatable with a source Animatable
  13313. * This is useful when using animation weights and when animations are not of the same length
  13314. * @param root defines the root Animatable to synchronize with
  13315. * @returns the current Animatable
  13316. */
  13317. syncWith(root: Animatable): Animatable;
  13318. /**
  13319. * Gets the list of runtime animations
  13320. * @returns an array of RuntimeAnimation
  13321. */
  13322. getAnimations(): RuntimeAnimation[];
  13323. /**
  13324. * Adds more animations to the current animatable
  13325. * @param target defines the target of the animations
  13326. * @param animations defines the new animations to add
  13327. */
  13328. appendAnimations(target: any, animations: Animation[]): void;
  13329. /**
  13330. * Gets the source animation for a specific property
  13331. * @param property defines the propertyu to look for
  13332. * @returns null or the source animation for the given property
  13333. */
  13334. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  13335. /**
  13336. * Gets the runtime animation for a specific property
  13337. * @param property defines the propertyu to look for
  13338. * @returns null or the runtime animation for the given property
  13339. */
  13340. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  13341. /**
  13342. * Resets the animatable to its original state
  13343. */
  13344. reset(): void;
  13345. /**
  13346. * Allows the animatable to blend with current running animations
  13347. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13348. * @param blendingSpeed defines the blending speed to use
  13349. */
  13350. enableBlending(blendingSpeed: number): void;
  13351. /**
  13352. * Disable animation blending
  13353. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13354. */
  13355. disableBlending(): void;
  13356. /**
  13357. * Jump directly to a given frame
  13358. * @param frame defines the frame to jump to
  13359. */
  13360. goToFrame(frame: number): void;
  13361. /**
  13362. * Pause the animation
  13363. */
  13364. pause(): void;
  13365. /**
  13366. * Restart the animation
  13367. */
  13368. restart(): void;
  13369. private _raiseOnAnimationEnd;
  13370. /**
  13371. * Stop and delete the current animation
  13372. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  13373. * @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)
  13374. */
  13375. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  13376. /**
  13377. * Wait asynchronously for the animation to end
  13378. * @returns a promise which will be fullfilled when the animation ends
  13379. */
  13380. waitAsync(): Promise<Animatable>;
  13381. /** @hidden */
  13382. _animate(delay: number): boolean;
  13383. }
  13384. module "babylonjs/scene" {
  13385. interface Scene {
  13386. /** @hidden */
  13387. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  13388. /** @hidden */
  13389. _processLateAnimationBindingsForMatrices(holder: {
  13390. totalWeight: number;
  13391. animations: RuntimeAnimation[];
  13392. originalValue: Matrix;
  13393. }): any;
  13394. /** @hidden */
  13395. _processLateAnimationBindingsForQuaternions(holder: {
  13396. totalWeight: number;
  13397. animations: RuntimeAnimation[];
  13398. originalValue: Quaternion;
  13399. }, refQuaternion: Quaternion): Quaternion;
  13400. /** @hidden */
  13401. _processLateAnimationBindings(): void;
  13402. /**
  13403. * Will start the animation sequence of a given target
  13404. * @param target defines the target
  13405. * @param from defines from which frame should animation start
  13406. * @param to defines until which frame should animation run.
  13407. * @param weight defines the weight to apply to the animation (1.0 by default)
  13408. * @param loop defines if the animation loops
  13409. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13410. * @param onAnimationEnd defines the function to be executed when the animation ends
  13411. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13412. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13413. * @param onAnimationLoop defines the callback to call when an animation loops
  13414. * @returns the animatable object created for this animation
  13415. */
  13416. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13417. /**
  13418. * Will start the animation sequence of a given target
  13419. * @param target defines the target
  13420. * @param from defines from which frame should animation start
  13421. * @param to defines until which frame should animation run.
  13422. * @param loop defines if the animation loops
  13423. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13424. * @param onAnimationEnd defines the function to be executed when the animation ends
  13425. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13426. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13427. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  13428. * @param onAnimationLoop defines the callback to call when an animation loops
  13429. * @returns the animatable object created for this animation
  13430. */
  13431. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  13432. /**
  13433. * Will start the animation sequence of a given target and its hierarchy
  13434. * @param target defines the target
  13435. * @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.
  13436. * @param from defines from which frame should animation start
  13437. * @param to defines until which frame should animation run.
  13438. * @param loop defines if the animation loops
  13439. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  13440. * @param onAnimationEnd defines the function to be executed when the animation ends
  13441. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  13442. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  13443. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  13444. * @param onAnimationLoop defines the callback to call when an animation loops
  13445. * @returns the list of created animatables
  13446. */
  13447. 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[];
  13448. /**
  13449. * Begin a new animation on a given node
  13450. * @param target defines the target where the animation will take place
  13451. * @param animations defines the list of animations to start
  13452. * @param from defines the initial value
  13453. * @param to defines the final value
  13454. * @param loop defines if you want animation to loop (off by default)
  13455. * @param speedRatio defines the speed ratio to apply to all animations
  13456. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13457. * @param onAnimationLoop defines the callback to call when an animation loops
  13458. * @returns the list of created animatables
  13459. */
  13460. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  13461. /**
  13462. * Begin a new animation on a given node and its hierarchy
  13463. * @param target defines the root node where the animation will take place
  13464. * @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.
  13465. * @param animations defines the list of animations to start
  13466. * @param from defines the initial value
  13467. * @param to defines the final value
  13468. * @param loop defines if you want animation to loop (off by default)
  13469. * @param speedRatio defines the speed ratio to apply to all animations
  13470. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  13471. * @param onAnimationLoop defines the callback to call when an animation loops
  13472. * @returns the list of animatables created for all nodes
  13473. */
  13474. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  13475. /**
  13476. * Gets the animatable associated with a specific target
  13477. * @param target defines the target of the animatable
  13478. * @returns the required animatable if found
  13479. */
  13480. getAnimatableByTarget(target: any): Nullable<Animatable>;
  13481. /**
  13482. * Gets all animatables associated with a given target
  13483. * @param target defines the target to look animatables for
  13484. * @returns an array of Animatables
  13485. */
  13486. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  13487. /**
  13488. * Stops and removes all animations that have been applied to the scene
  13489. */
  13490. stopAllAnimations(): void;
  13491. /**
  13492. * Gets the current delta time used by animation engine
  13493. */
  13494. deltaTime: number;
  13495. }
  13496. }
  13497. module "babylonjs/Bones/bone" {
  13498. interface Bone {
  13499. /**
  13500. * Copy an animation range from another bone
  13501. * @param source defines the source bone
  13502. * @param rangeName defines the range name to copy
  13503. * @param frameOffset defines the frame offset
  13504. * @param rescaleAsRequired defines if rescaling must be applied if required
  13505. * @param skelDimensionsRatio defines the scaling ratio
  13506. * @returns true if operation was successful
  13507. */
  13508. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  13509. }
  13510. }
  13511. }
  13512. declare module "babylonjs/Animations/animationPropertiesOverride" {
  13513. /**
  13514. * Class used to override all child animations of a given target
  13515. */
  13516. export class AnimationPropertiesOverride {
  13517. /**
  13518. * Gets or sets a value indicating if animation blending must be used
  13519. */
  13520. enableBlending: boolean;
  13521. /**
  13522. * Gets or sets the blending speed to use when enableBlending is true
  13523. */
  13524. blendingSpeed: number;
  13525. /**
  13526. * Gets or sets the default loop mode to use
  13527. */
  13528. loopMode: number;
  13529. }
  13530. }
  13531. declare module "babylonjs/Bones/skeleton" {
  13532. import { Bone } from "babylonjs/Bones/bone";
  13533. import { Observable } from "babylonjs/Misc/observable";
  13534. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13535. import { Scene } from "babylonjs/scene";
  13536. import { Nullable } from "babylonjs/types";
  13537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13538. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  13539. import { Animatable } from "babylonjs/Animations/animatable";
  13540. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13541. import { Animation } from "babylonjs/Animations/animation";
  13542. import { AnimationRange } from "babylonjs/Animations/animationRange";
  13543. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  13545. /**
  13546. * Class used to handle skinning animations
  13547. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13548. */
  13549. export class Skeleton implements IAnimatable {
  13550. /** defines the skeleton name */
  13551. name: string;
  13552. /** defines the skeleton Id */
  13553. id: string;
  13554. /**
  13555. * Defines the list of child bones
  13556. */
  13557. bones: Bone[];
  13558. /**
  13559. * Defines an estimate of the dimension of the skeleton at rest
  13560. */
  13561. dimensionsAtRest: Vector3;
  13562. /**
  13563. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  13564. */
  13565. needInitialSkinMatrix: boolean;
  13566. /**
  13567. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  13568. */
  13569. overrideMesh: Nullable<AbstractMesh>;
  13570. /**
  13571. * Gets the list of animations attached to this skeleton
  13572. */
  13573. animations: Array<Animation>;
  13574. private _scene;
  13575. private _isDirty;
  13576. private _transformMatrices;
  13577. private _transformMatrixTexture;
  13578. private _meshesWithPoseMatrix;
  13579. private _animatables;
  13580. private _identity;
  13581. private _synchronizedWithMesh;
  13582. private _ranges;
  13583. private _lastAbsoluteTransformsUpdateId;
  13584. private _canUseTextureForBones;
  13585. private _uniqueId;
  13586. /** @hidden */
  13587. _numBonesWithLinkedTransformNode: number;
  13588. /** @hidden */
  13589. _hasWaitingData: Nullable<boolean>;
  13590. /**
  13591. * Specifies if the skeleton should be serialized
  13592. */
  13593. doNotSerialize: boolean;
  13594. private _useTextureToStoreBoneMatrices;
  13595. /**
  13596. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  13597. * Please note that this option is not available if the hardware does not support it
  13598. */
  13599. useTextureToStoreBoneMatrices: boolean;
  13600. private _animationPropertiesOverride;
  13601. /**
  13602. * Gets or sets the animation properties override
  13603. */
  13604. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13605. /**
  13606. * List of inspectable custom properties (used by the Inspector)
  13607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13608. */
  13609. inspectableCustomProperties: IInspectable[];
  13610. /**
  13611. * An observable triggered before computing the skeleton's matrices
  13612. */
  13613. onBeforeComputeObservable: Observable<Skeleton>;
  13614. /**
  13615. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  13616. */
  13617. readonly isUsingTextureForMatrices: boolean;
  13618. /**
  13619. * Gets the unique ID of this skeleton
  13620. */
  13621. readonly uniqueId: number;
  13622. /**
  13623. * Creates a new skeleton
  13624. * @param name defines the skeleton name
  13625. * @param id defines the skeleton Id
  13626. * @param scene defines the hosting scene
  13627. */
  13628. constructor(
  13629. /** defines the skeleton name */
  13630. name: string,
  13631. /** defines the skeleton Id */
  13632. id: string, scene: Scene);
  13633. /**
  13634. * Gets the current object class name.
  13635. * @return the class name
  13636. */
  13637. getClassName(): string;
  13638. /**
  13639. * Returns an array containing the root bones
  13640. * @returns an array containing the root bones
  13641. */
  13642. getChildren(): Array<Bone>;
  13643. /**
  13644. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  13645. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13646. * @returns a Float32Array containing matrices data
  13647. */
  13648. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  13649. /**
  13650. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  13651. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  13652. * @returns a raw texture containing the data
  13653. */
  13654. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  13655. /**
  13656. * Gets the current hosting scene
  13657. * @returns a scene object
  13658. */
  13659. getScene(): Scene;
  13660. /**
  13661. * Gets a string representing the current skeleton data
  13662. * @param fullDetails defines a boolean indicating if we want a verbose version
  13663. * @returns a string representing the current skeleton data
  13664. */
  13665. toString(fullDetails?: boolean): string;
  13666. /**
  13667. * Get bone's index searching by name
  13668. * @param name defines bone's name to search for
  13669. * @return the indice of the bone. Returns -1 if not found
  13670. */
  13671. getBoneIndexByName(name: string): number;
  13672. /**
  13673. * Creater a new animation range
  13674. * @param name defines the name of the range
  13675. * @param from defines the start key
  13676. * @param to defines the end key
  13677. */
  13678. createAnimationRange(name: string, from: number, to: number): void;
  13679. /**
  13680. * Delete a specific animation range
  13681. * @param name defines the name of the range
  13682. * @param deleteFrames defines if frames must be removed as well
  13683. */
  13684. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  13685. /**
  13686. * Gets a specific animation range
  13687. * @param name defines the name of the range to look for
  13688. * @returns the requested animation range or null if not found
  13689. */
  13690. getAnimationRange(name: string): Nullable<AnimationRange>;
  13691. /**
  13692. * Gets the list of all animation ranges defined on this skeleton
  13693. * @returns an array
  13694. */
  13695. getAnimationRanges(): Nullable<AnimationRange>[];
  13696. /**
  13697. * Copy animation range from a source skeleton.
  13698. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  13699. * @param source defines the source skeleton
  13700. * @param name defines the name of the range to copy
  13701. * @param rescaleAsRequired defines if rescaling must be applied if required
  13702. * @returns true if operation was successful
  13703. */
  13704. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  13705. /**
  13706. * Forces the skeleton to go to rest pose
  13707. */
  13708. returnToRest(): void;
  13709. private _getHighestAnimationFrame;
  13710. /**
  13711. * Begin a specific animation range
  13712. * @param name defines the name of the range to start
  13713. * @param loop defines if looping must be turned on (false by default)
  13714. * @param speedRatio defines the speed ratio to apply (1 by default)
  13715. * @param onAnimationEnd defines a callback which will be called when animation will end
  13716. * @returns a new animatable
  13717. */
  13718. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  13719. /** @hidden */
  13720. _markAsDirty(): void;
  13721. /** @hidden */
  13722. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13723. /** @hidden */
  13724. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  13725. private _computeTransformMatrices;
  13726. /**
  13727. * Build all resources required to render a skeleton
  13728. */
  13729. prepare(): void;
  13730. /**
  13731. * Gets the list of animatables currently running for this skeleton
  13732. * @returns an array of animatables
  13733. */
  13734. getAnimatables(): IAnimatable[];
  13735. /**
  13736. * Clone the current skeleton
  13737. * @param name defines the name of the new skeleton
  13738. * @param id defines the id of the new skeleton
  13739. * @returns the new skeleton
  13740. */
  13741. clone(name: string, id: string): Skeleton;
  13742. /**
  13743. * Enable animation blending for this skeleton
  13744. * @param blendingSpeed defines the blending speed to apply
  13745. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  13746. */
  13747. enableBlending(blendingSpeed?: number): void;
  13748. /**
  13749. * Releases all resources associated with the current skeleton
  13750. */
  13751. dispose(): void;
  13752. /**
  13753. * Serialize the skeleton in a JSON object
  13754. * @returns a JSON object
  13755. */
  13756. serialize(): any;
  13757. /**
  13758. * Creates a new skeleton from serialized data
  13759. * @param parsedSkeleton defines the serialized data
  13760. * @param scene defines the hosting scene
  13761. * @returns a new skeleton
  13762. */
  13763. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  13764. /**
  13765. * Compute all node absolute transforms
  13766. * @param forceUpdate defines if computation must be done even if cache is up to date
  13767. */
  13768. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  13769. /**
  13770. * Gets the root pose matrix
  13771. * @returns a matrix
  13772. */
  13773. getPoseMatrix(): Nullable<Matrix>;
  13774. /**
  13775. * Sorts bones per internal index
  13776. */
  13777. sortBones(): void;
  13778. private _sortBones;
  13779. }
  13780. }
  13781. declare module "babylonjs/Bones/bone" {
  13782. import { Skeleton } from "babylonjs/Bones/skeleton";
  13783. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  13784. import { Nullable } from "babylonjs/types";
  13785. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  13786. import { TransformNode } from "babylonjs/Meshes/transformNode";
  13787. import { Node } from "babylonjs/node";
  13788. import { Space } from "babylonjs/Maths/math.axis";
  13789. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  13790. /**
  13791. * Class used to store bone information
  13792. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  13793. */
  13794. export class Bone extends Node {
  13795. /**
  13796. * defines the bone name
  13797. */
  13798. name: string;
  13799. private static _tmpVecs;
  13800. private static _tmpQuat;
  13801. private static _tmpMats;
  13802. /**
  13803. * Gets the list of child bones
  13804. */
  13805. children: Bone[];
  13806. /** Gets the animations associated with this bone */
  13807. animations: import("babylonjs/Animations/animation").Animation[];
  13808. /**
  13809. * Gets or sets bone length
  13810. */
  13811. length: number;
  13812. /**
  13813. * @hidden Internal only
  13814. * Set this value to map this bone to a different index in the transform matrices
  13815. * Set this value to -1 to exclude the bone from the transform matrices
  13816. */
  13817. _index: Nullable<number>;
  13818. private _skeleton;
  13819. private _localMatrix;
  13820. private _restPose;
  13821. private _baseMatrix;
  13822. private _absoluteTransform;
  13823. private _invertedAbsoluteTransform;
  13824. private _parent;
  13825. private _scalingDeterminant;
  13826. private _worldTransform;
  13827. private _localScaling;
  13828. private _localRotation;
  13829. private _localPosition;
  13830. private _needToDecompose;
  13831. private _needToCompose;
  13832. /** @hidden */
  13833. _linkedTransformNode: Nullable<TransformNode>;
  13834. /** @hidden */
  13835. _waitingTransformNodeId: Nullable<string>;
  13836. /** @hidden */
  13837. /** @hidden */
  13838. _matrix: Matrix;
  13839. /**
  13840. * Create a new bone
  13841. * @param name defines the bone name
  13842. * @param skeleton defines the parent skeleton
  13843. * @param parentBone defines the parent (can be null if the bone is the root)
  13844. * @param localMatrix defines the local matrix
  13845. * @param restPose defines the rest pose matrix
  13846. * @param baseMatrix defines the base matrix
  13847. * @param index defines index of the bone in the hiearchy
  13848. */
  13849. constructor(
  13850. /**
  13851. * defines the bone name
  13852. */
  13853. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  13854. /**
  13855. * Gets the current object class name.
  13856. * @return the class name
  13857. */
  13858. getClassName(): string;
  13859. /**
  13860. * Gets the parent skeleton
  13861. * @returns a skeleton
  13862. */
  13863. getSkeleton(): Skeleton;
  13864. /**
  13865. * Gets parent bone
  13866. * @returns a bone or null if the bone is the root of the bone hierarchy
  13867. */
  13868. getParent(): Nullable<Bone>;
  13869. /**
  13870. * Returns an array containing the root bones
  13871. * @returns an array containing the root bones
  13872. */
  13873. getChildren(): Array<Bone>;
  13874. /**
  13875. * Sets the parent bone
  13876. * @param parent defines the parent (can be null if the bone is the root)
  13877. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13878. */
  13879. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  13880. /**
  13881. * Gets the local matrix
  13882. * @returns a matrix
  13883. */
  13884. getLocalMatrix(): Matrix;
  13885. /**
  13886. * Gets the base matrix (initial matrix which remains unchanged)
  13887. * @returns a matrix
  13888. */
  13889. getBaseMatrix(): Matrix;
  13890. /**
  13891. * Gets the rest pose matrix
  13892. * @returns a matrix
  13893. */
  13894. getRestPose(): Matrix;
  13895. /**
  13896. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  13897. */
  13898. getWorldMatrix(): Matrix;
  13899. /**
  13900. * Sets the local matrix to rest pose matrix
  13901. */
  13902. returnToRest(): void;
  13903. /**
  13904. * Gets the inverse of the absolute transform matrix.
  13905. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  13906. * @returns a matrix
  13907. */
  13908. getInvertedAbsoluteTransform(): Matrix;
  13909. /**
  13910. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  13911. * @returns a matrix
  13912. */
  13913. getAbsoluteTransform(): Matrix;
  13914. /**
  13915. * Links with the given transform node.
  13916. * The local matrix of this bone is copied from the transform node every frame.
  13917. * @param transformNode defines the transform node to link to
  13918. */
  13919. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  13920. /**
  13921. * Gets the node used to drive the bone's transformation
  13922. * @returns a transform node or null
  13923. */
  13924. getTransformNode(): Nullable<TransformNode>;
  13925. /** Gets or sets current position (in local space) */
  13926. position: Vector3;
  13927. /** Gets or sets current rotation (in local space) */
  13928. rotation: Vector3;
  13929. /** Gets or sets current rotation quaternion (in local space) */
  13930. rotationQuaternion: Quaternion;
  13931. /** Gets or sets current scaling (in local space) */
  13932. scaling: Vector3;
  13933. /**
  13934. * Gets the animation properties override
  13935. */
  13936. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  13937. private _decompose;
  13938. private _compose;
  13939. /**
  13940. * Update the base and local matrices
  13941. * @param matrix defines the new base or local matrix
  13942. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  13943. * @param updateLocalMatrix defines if the local matrix should be updated
  13944. */
  13945. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  13946. /** @hidden */
  13947. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  13948. /**
  13949. * Flag the bone as dirty (Forcing it to update everything)
  13950. */
  13951. markAsDirty(): void;
  13952. /** @hidden */
  13953. _markAsDirtyAndCompose(): void;
  13954. private _markAsDirtyAndDecompose;
  13955. /**
  13956. * Translate the bone in local or world space
  13957. * @param vec The amount to translate the bone
  13958. * @param space The space that the translation is in
  13959. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13960. */
  13961. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13962. /**
  13963. * Set the postion of the bone in local or world space
  13964. * @param position The position to set the bone
  13965. * @param space The space that the position is in
  13966. * @param mesh The mesh that this bone is attached to. This is only used in world space
  13967. */
  13968. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  13969. /**
  13970. * Set the absolute position of the bone (world space)
  13971. * @param position The position to set the bone
  13972. * @param mesh The mesh that this bone is attached to
  13973. */
  13974. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  13975. /**
  13976. * Scale the bone on the x, y and z axes (in local space)
  13977. * @param x The amount to scale the bone on the x axis
  13978. * @param y The amount to scale the bone on the y axis
  13979. * @param z The amount to scale the bone on the z axis
  13980. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  13981. */
  13982. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  13983. /**
  13984. * Set the bone scaling in local space
  13985. * @param scale defines the scaling vector
  13986. */
  13987. setScale(scale: Vector3): void;
  13988. /**
  13989. * Gets the current scaling in local space
  13990. * @returns the current scaling vector
  13991. */
  13992. getScale(): Vector3;
  13993. /**
  13994. * Gets the current scaling in local space and stores it in a target vector
  13995. * @param result defines the target vector
  13996. */
  13997. getScaleToRef(result: Vector3): void;
  13998. /**
  13999. * Set the yaw, pitch, and roll of the bone in local or world space
  14000. * @param yaw The rotation of the bone on the y axis
  14001. * @param pitch The rotation of the bone on the x axis
  14002. * @param roll The rotation of the bone on the z axis
  14003. * @param space The space that the axes of rotation are in
  14004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14005. */
  14006. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  14007. /**
  14008. * Add a rotation to the bone on an axis in local or world space
  14009. * @param axis The axis to rotate the bone on
  14010. * @param amount The amount to rotate the bone
  14011. * @param space The space that the axis is in
  14012. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14013. */
  14014. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  14015. /**
  14016. * Set the rotation of the bone to a particular axis angle in local or world space
  14017. * @param axis The axis to rotate the bone on
  14018. * @param angle The angle that the bone should be rotated to
  14019. * @param space The space that the axis is in
  14020. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14021. */
  14022. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  14023. /**
  14024. * Set the euler rotation of the bone in local of world space
  14025. * @param rotation The euler rotation that the bone should be set to
  14026. * @param space The space that the rotation is in
  14027. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14028. */
  14029. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  14030. /**
  14031. * Set the quaternion rotation of the bone in local of world space
  14032. * @param quat The quaternion rotation that the bone should be set to
  14033. * @param space The space that the rotation is in
  14034. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14035. */
  14036. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  14037. /**
  14038. * Set the rotation matrix of the bone in local of world space
  14039. * @param rotMat The rotation matrix that the bone should be set to
  14040. * @param space The space that the rotation is in
  14041. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14042. */
  14043. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  14044. private _rotateWithMatrix;
  14045. private _getNegativeRotationToRef;
  14046. /**
  14047. * Get the position of the bone in local or world space
  14048. * @param space The space that the returned position is in
  14049. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14050. * @returns The position of the bone
  14051. */
  14052. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14053. /**
  14054. * Copy the position of the bone to a vector3 in local or world space
  14055. * @param space The space that the returned position is in
  14056. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14057. * @param result The vector3 to copy the position to
  14058. */
  14059. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  14060. /**
  14061. * Get the absolute position of the bone (world space)
  14062. * @param mesh The mesh that this bone is attached to
  14063. * @returns The absolute position of the bone
  14064. */
  14065. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  14066. /**
  14067. * Copy the absolute position of the bone (world space) to the result param
  14068. * @param mesh The mesh that this bone is attached to
  14069. * @param result The vector3 to copy the absolute position to
  14070. */
  14071. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  14072. /**
  14073. * Compute the absolute transforms of this bone and its children
  14074. */
  14075. computeAbsoluteTransforms(): void;
  14076. /**
  14077. * Get the world direction from an axis that is in the local space of the bone
  14078. * @param localAxis The local direction that is used to compute the world direction
  14079. * @param mesh The mesh that this bone is attached to
  14080. * @returns The world direction
  14081. */
  14082. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14083. /**
  14084. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  14085. * @param localAxis The local direction that is used to compute the world direction
  14086. * @param mesh The mesh that this bone is attached to
  14087. * @param result The vector3 that the world direction will be copied to
  14088. */
  14089. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14090. /**
  14091. * Get the euler rotation of the bone in local or world space
  14092. * @param space The space that the rotation should be in
  14093. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14094. * @returns The euler rotation
  14095. */
  14096. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  14097. /**
  14098. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  14099. * @param space The space that the rotation should be in
  14100. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14101. * @param result The vector3 that the rotation should be copied to
  14102. */
  14103. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14104. /**
  14105. * Get the quaternion rotation of the bone in either local or world space
  14106. * @param space The space that the rotation should be in
  14107. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14108. * @returns The quaternion rotation
  14109. */
  14110. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  14111. /**
  14112. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  14113. * @param space The space that the rotation should be in
  14114. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14115. * @param result The quaternion that the rotation should be copied to
  14116. */
  14117. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  14118. /**
  14119. * Get the rotation matrix of the bone in local or world space
  14120. * @param space The space that the rotation should be in
  14121. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14122. * @returns The rotation matrix
  14123. */
  14124. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  14125. /**
  14126. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  14127. * @param space The space that the rotation should be in
  14128. * @param mesh The mesh that this bone is attached to. This is only used in world space
  14129. * @param result The quaternion that the rotation should be copied to
  14130. */
  14131. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  14132. /**
  14133. * Get the world position of a point that is in the local space of the bone
  14134. * @param position The local position
  14135. * @param mesh The mesh that this bone is attached to
  14136. * @returns The world position
  14137. */
  14138. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14139. /**
  14140. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  14141. * @param position The local position
  14142. * @param mesh The mesh that this bone is attached to
  14143. * @param result The vector3 that the world position should be copied to
  14144. */
  14145. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14146. /**
  14147. * Get the local position of a point that is in world space
  14148. * @param position The world position
  14149. * @param mesh The mesh that this bone is attached to
  14150. * @returns The local position
  14151. */
  14152. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  14153. /**
  14154. * Get the local position of a point that is in world space and copy it to the result param
  14155. * @param position The world position
  14156. * @param mesh The mesh that this bone is attached to
  14157. * @param result The vector3 that the local position should be copied to
  14158. */
  14159. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  14160. }
  14161. }
  14162. declare module "babylonjs/Meshes/transformNode" {
  14163. import { DeepImmutable } from "babylonjs/types";
  14164. import { Observable } from "babylonjs/Misc/observable";
  14165. import { Nullable } from "babylonjs/types";
  14166. import { Camera } from "babylonjs/Cameras/camera";
  14167. import { Scene } from "babylonjs/scene";
  14168. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14169. import { Node } from "babylonjs/node";
  14170. import { Bone } from "babylonjs/Bones/bone";
  14171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14172. import { Space } from "babylonjs/Maths/math.axis";
  14173. /**
  14174. * 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.
  14175. * @see https://doc.babylonjs.com/how_to/transformnode
  14176. */
  14177. export class TransformNode extends Node {
  14178. /**
  14179. * Object will not rotate to face the camera
  14180. */
  14181. static BILLBOARDMODE_NONE: number;
  14182. /**
  14183. * Object will rotate to face the camera but only on the x axis
  14184. */
  14185. static BILLBOARDMODE_X: number;
  14186. /**
  14187. * Object will rotate to face the camera but only on the y axis
  14188. */
  14189. static BILLBOARDMODE_Y: number;
  14190. /**
  14191. * Object will rotate to face the camera but only on the z axis
  14192. */
  14193. static BILLBOARDMODE_Z: number;
  14194. /**
  14195. * Object will rotate to face the camera
  14196. */
  14197. static BILLBOARDMODE_ALL: number;
  14198. /**
  14199. * Object will rotate to face the camera's position instead of orientation
  14200. */
  14201. static BILLBOARDMODE_USE_POSITION: number;
  14202. private _forward;
  14203. private _forwardInverted;
  14204. private _up;
  14205. private _right;
  14206. private _rightInverted;
  14207. private _position;
  14208. private _rotation;
  14209. private _rotationQuaternion;
  14210. protected _scaling: Vector3;
  14211. protected _isDirty: boolean;
  14212. private _transformToBoneReferal;
  14213. private _isAbsoluteSynced;
  14214. private _billboardMode;
  14215. /**
  14216. * Gets or sets the billboard mode. Default is 0.
  14217. *
  14218. * | Value | Type | Description |
  14219. * | --- | --- | --- |
  14220. * | 0 | BILLBOARDMODE_NONE | |
  14221. * | 1 | BILLBOARDMODE_X | |
  14222. * | 2 | BILLBOARDMODE_Y | |
  14223. * | 4 | BILLBOARDMODE_Z | |
  14224. * | 7 | BILLBOARDMODE_ALL | |
  14225. *
  14226. */
  14227. billboardMode: number;
  14228. private _preserveParentRotationForBillboard;
  14229. /**
  14230. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  14231. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  14232. */
  14233. preserveParentRotationForBillboard: boolean;
  14234. /**
  14235. * 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
  14236. */
  14237. scalingDeterminant: number;
  14238. private _infiniteDistance;
  14239. /**
  14240. * Gets or sets the distance of the object to max, often used by skybox
  14241. */
  14242. infiniteDistance: boolean;
  14243. /**
  14244. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  14245. * By default the system will update normals to compensate
  14246. */
  14247. ignoreNonUniformScaling: boolean;
  14248. /**
  14249. * 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
  14250. */
  14251. reIntegrateRotationIntoRotationQuaternion: boolean;
  14252. /** @hidden */
  14253. _poseMatrix: Nullable<Matrix>;
  14254. /** @hidden */
  14255. _localMatrix: Matrix;
  14256. private _usePivotMatrix;
  14257. private _absolutePosition;
  14258. private _absoluteScaling;
  14259. private _absoluteRotationQuaternion;
  14260. private _pivotMatrix;
  14261. private _pivotMatrixInverse;
  14262. protected _postMultiplyPivotMatrix: boolean;
  14263. protected _isWorldMatrixFrozen: boolean;
  14264. /** @hidden */
  14265. _indexInSceneTransformNodesArray: number;
  14266. /**
  14267. * An event triggered after the world matrix is updated
  14268. */
  14269. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  14270. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  14271. /**
  14272. * Gets a string identifying the name of the class
  14273. * @returns "TransformNode" string
  14274. */
  14275. getClassName(): string;
  14276. /**
  14277. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  14278. */
  14279. position: Vector3;
  14280. /**
  14281. * 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)).
  14282. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  14283. */
  14284. rotation: Vector3;
  14285. /**
  14286. * 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)).
  14287. */
  14288. scaling: Vector3;
  14289. /**
  14290. * 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).
  14291. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  14292. */
  14293. rotationQuaternion: Nullable<Quaternion>;
  14294. /**
  14295. * The forward direction of that transform in world space.
  14296. */
  14297. readonly forward: Vector3;
  14298. /**
  14299. * The up direction of that transform in world space.
  14300. */
  14301. readonly up: Vector3;
  14302. /**
  14303. * The right direction of that transform in world space.
  14304. */
  14305. readonly right: Vector3;
  14306. /**
  14307. * Copies the parameter passed Matrix into the mesh Pose matrix.
  14308. * @param matrix the matrix to copy the pose from
  14309. * @returns this TransformNode.
  14310. */
  14311. updatePoseMatrix(matrix: Matrix): TransformNode;
  14312. /**
  14313. * Returns the mesh Pose matrix.
  14314. * @returns the pose matrix
  14315. */
  14316. getPoseMatrix(): Matrix;
  14317. /** @hidden */
  14318. _isSynchronized(): boolean;
  14319. /** @hidden */
  14320. _initCache(): void;
  14321. /**
  14322. * Flag the transform node as dirty (Forcing it to update everything)
  14323. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  14324. * @returns this transform node
  14325. */
  14326. markAsDirty(property: string): TransformNode;
  14327. /**
  14328. * Returns the current mesh absolute position.
  14329. * Returns a Vector3.
  14330. */
  14331. readonly absolutePosition: Vector3;
  14332. /**
  14333. * Returns the current mesh absolute scaling.
  14334. * Returns a Vector3.
  14335. */
  14336. readonly absoluteScaling: Vector3;
  14337. /**
  14338. * Returns the current mesh absolute rotation.
  14339. * Returns a Quaternion.
  14340. */
  14341. readonly absoluteRotationQuaternion: Quaternion;
  14342. /**
  14343. * Sets a new matrix to apply before all other transformation
  14344. * @param matrix defines the transform matrix
  14345. * @returns the current TransformNode
  14346. */
  14347. setPreTransformMatrix(matrix: Matrix): TransformNode;
  14348. /**
  14349. * Sets a new pivot matrix to the current node
  14350. * @param matrix defines the new pivot matrix to use
  14351. * @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
  14352. * @returns the current TransformNode
  14353. */
  14354. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  14355. /**
  14356. * Returns the mesh pivot matrix.
  14357. * Default : Identity.
  14358. * @returns the matrix
  14359. */
  14360. getPivotMatrix(): Matrix;
  14361. /**
  14362. * Instantiate (when possible) or clone that node with its hierarchy
  14363. * @param newParent defines the new parent to use for the instance (or clone)
  14364. * @returns an instance (or a clone) of the current node with its hiearchy
  14365. */
  14366. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  14367. /**
  14368. * Prevents the World matrix to be computed any longer
  14369. * @param newWorldMatrix defines an optional matrix to use as world matrix
  14370. * @returns the TransformNode.
  14371. */
  14372. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  14373. /**
  14374. * Allows back the World matrix computation.
  14375. * @returns the TransformNode.
  14376. */
  14377. unfreezeWorldMatrix(): this;
  14378. /**
  14379. * True if the World matrix has been frozen.
  14380. */
  14381. readonly isWorldMatrixFrozen: boolean;
  14382. /**
  14383. * Retuns the mesh absolute position in the World.
  14384. * @returns a Vector3.
  14385. */
  14386. getAbsolutePosition(): Vector3;
  14387. /**
  14388. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  14389. * @param absolutePosition the absolute position to set
  14390. * @returns the TransformNode.
  14391. */
  14392. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  14393. /**
  14394. * Sets the mesh position in its local space.
  14395. * @param vector3 the position to set in localspace
  14396. * @returns the TransformNode.
  14397. */
  14398. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  14399. /**
  14400. * Returns the mesh position in the local space from the current World matrix values.
  14401. * @returns a new Vector3.
  14402. */
  14403. getPositionExpressedInLocalSpace(): Vector3;
  14404. /**
  14405. * Translates the mesh along the passed Vector3 in its local space.
  14406. * @param vector3 the distance to translate in localspace
  14407. * @returns the TransformNode.
  14408. */
  14409. locallyTranslate(vector3: Vector3): TransformNode;
  14410. private static _lookAtVectorCache;
  14411. /**
  14412. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  14413. * @param targetPoint the position (must be in same space as current mesh) to look at
  14414. * @param yawCor optional yaw (y-axis) correction in radians
  14415. * @param pitchCor optional pitch (x-axis) correction in radians
  14416. * @param rollCor optional roll (z-axis) correction in radians
  14417. * @param space the choosen space of the target
  14418. * @returns the TransformNode.
  14419. */
  14420. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  14421. /**
  14422. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14423. * This Vector3 is expressed in the World space.
  14424. * @param localAxis axis to rotate
  14425. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  14426. */
  14427. getDirection(localAxis: Vector3): Vector3;
  14428. /**
  14429. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  14430. * localAxis is expressed in the mesh local space.
  14431. * result is computed in the Wordl space from the mesh World matrix.
  14432. * @param localAxis axis to rotate
  14433. * @param result the resulting transformnode
  14434. * @returns this TransformNode.
  14435. */
  14436. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  14437. /**
  14438. * Sets this transform node rotation to the given local axis.
  14439. * @param localAxis the axis in local space
  14440. * @param yawCor optional yaw (y-axis) correction in radians
  14441. * @param pitchCor optional pitch (x-axis) correction in radians
  14442. * @param rollCor optional roll (z-axis) correction in radians
  14443. * @returns this TransformNode
  14444. */
  14445. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  14446. /**
  14447. * Sets a new pivot point to the current node
  14448. * @param point defines the new pivot point to use
  14449. * @param space defines if the point is in world or local space (local by default)
  14450. * @returns the current TransformNode
  14451. */
  14452. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  14453. /**
  14454. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  14455. * @returns the pivot point
  14456. */
  14457. getPivotPoint(): Vector3;
  14458. /**
  14459. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  14460. * @param result the vector3 to store the result
  14461. * @returns this TransformNode.
  14462. */
  14463. getPivotPointToRef(result: Vector3): TransformNode;
  14464. /**
  14465. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  14466. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  14467. */
  14468. getAbsolutePivotPoint(): Vector3;
  14469. /**
  14470. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  14471. * @param result vector3 to store the result
  14472. * @returns this TransformNode.
  14473. */
  14474. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  14475. /**
  14476. * Defines the passed node as the parent of the current node.
  14477. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  14478. * @see https://doc.babylonjs.com/how_to/parenting
  14479. * @param node the node ot set as the parent
  14480. * @returns this TransformNode.
  14481. */
  14482. setParent(node: Nullable<Node>): TransformNode;
  14483. private _nonUniformScaling;
  14484. /**
  14485. * True if the scaling property of this object is non uniform eg. (1,2,1)
  14486. */
  14487. readonly nonUniformScaling: boolean;
  14488. /** @hidden */
  14489. _updateNonUniformScalingState(value: boolean): boolean;
  14490. /**
  14491. * Attach the current TransformNode to another TransformNode associated with a bone
  14492. * @param bone Bone affecting the TransformNode
  14493. * @param affectedTransformNode TransformNode associated with the bone
  14494. * @returns this object
  14495. */
  14496. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  14497. /**
  14498. * Detach the transform node if its associated with a bone
  14499. * @returns this object
  14500. */
  14501. detachFromBone(): TransformNode;
  14502. private static _rotationAxisCache;
  14503. /**
  14504. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  14505. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14506. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14507. * The passed axis is also normalized.
  14508. * @param axis the axis to rotate around
  14509. * @param amount the amount to rotate in radians
  14510. * @param space Space to rotate in (Default: local)
  14511. * @returns the TransformNode.
  14512. */
  14513. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  14514. /**
  14515. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  14516. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  14517. * The passed axis is also normalized. .
  14518. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  14519. * @param point the point to rotate around
  14520. * @param axis the axis to rotate around
  14521. * @param amount the amount to rotate in radians
  14522. * @returns the TransformNode
  14523. */
  14524. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  14525. /**
  14526. * Translates the mesh along the axis vector for the passed distance in the given space.
  14527. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  14528. * @param axis the axis to translate in
  14529. * @param distance the distance to translate
  14530. * @param space Space to rotate in (Default: local)
  14531. * @returns the TransformNode.
  14532. */
  14533. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  14534. /**
  14535. * Adds a rotation step to the mesh current rotation.
  14536. * x, y, z are Euler angles expressed in radians.
  14537. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  14538. * This means this rotation is made in the mesh local space only.
  14539. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  14540. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  14541. * ```javascript
  14542. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  14543. * ```
  14544. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  14545. * 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.
  14546. * @param x Rotation to add
  14547. * @param y Rotation to add
  14548. * @param z Rotation to add
  14549. * @returns the TransformNode.
  14550. */
  14551. addRotation(x: number, y: number, z: number): TransformNode;
  14552. /**
  14553. * @hidden
  14554. */
  14555. protected _getEffectiveParent(): Nullable<Node>;
  14556. /**
  14557. * Computes the world matrix of the node
  14558. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  14559. * @returns the world matrix
  14560. */
  14561. computeWorldMatrix(force?: boolean): Matrix;
  14562. protected _afterComputeWorldMatrix(): void;
  14563. /**
  14564. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  14565. * @param func callback function to add
  14566. *
  14567. * @returns the TransformNode.
  14568. */
  14569. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14570. /**
  14571. * Removes a registered callback function.
  14572. * @param func callback function to remove
  14573. * @returns the TransformNode.
  14574. */
  14575. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  14576. /**
  14577. * Gets the position of the current mesh in camera space
  14578. * @param camera defines the camera to use
  14579. * @returns a position
  14580. */
  14581. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  14582. /**
  14583. * Returns the distance from the mesh to the active camera
  14584. * @param camera defines the camera to use
  14585. * @returns the distance
  14586. */
  14587. getDistanceToCamera(camera?: Nullable<Camera>): number;
  14588. /**
  14589. * Clone the current transform node
  14590. * @param name Name of the new clone
  14591. * @param newParent New parent for the clone
  14592. * @param doNotCloneChildren Do not clone children hierarchy
  14593. * @returns the new transform node
  14594. */
  14595. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  14596. /**
  14597. * Serializes the objects information.
  14598. * @param currentSerializationObject defines the object to serialize in
  14599. * @returns the serialized object
  14600. */
  14601. serialize(currentSerializationObject?: any): any;
  14602. /**
  14603. * Returns a new TransformNode object parsed from the source provided.
  14604. * @param parsedTransformNode is the source.
  14605. * @param scene the scne the object belongs to
  14606. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  14607. * @returns a new TransformNode object parsed from the source provided.
  14608. */
  14609. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  14610. /**
  14611. * Get all child-transformNodes of this node
  14612. * @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
  14613. * @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
  14614. * @returns an array of TransformNode
  14615. */
  14616. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  14617. /**
  14618. * Releases resources associated with this transform node.
  14619. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  14620. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  14621. */
  14622. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  14623. /**
  14624. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  14625. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  14626. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  14627. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  14628. * @returns the current mesh
  14629. */
  14630. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  14631. private _syncAbsoluteScalingAndRotation;
  14632. }
  14633. }
  14634. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  14635. import { Observable } from "babylonjs/Misc/observable";
  14636. import { Nullable } from "babylonjs/types";
  14637. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  14639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14640. import { Ray } from "babylonjs/Culling/ray";
  14641. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  14642. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  14643. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  14644. /**
  14645. * Defines the types of pose enabled controllers that are supported
  14646. */
  14647. export enum PoseEnabledControllerType {
  14648. /**
  14649. * HTC Vive
  14650. */
  14651. VIVE = 0,
  14652. /**
  14653. * Oculus Rift
  14654. */
  14655. OCULUS = 1,
  14656. /**
  14657. * Windows mixed reality
  14658. */
  14659. WINDOWS = 2,
  14660. /**
  14661. * Samsung gear VR
  14662. */
  14663. GEAR_VR = 3,
  14664. /**
  14665. * Google Daydream
  14666. */
  14667. DAYDREAM = 4,
  14668. /**
  14669. * Generic
  14670. */
  14671. GENERIC = 5
  14672. }
  14673. /**
  14674. * Defines the MutableGamepadButton interface for the state of a gamepad button
  14675. */
  14676. export interface MutableGamepadButton {
  14677. /**
  14678. * Value of the button/trigger
  14679. */
  14680. value: number;
  14681. /**
  14682. * If the button/trigger is currently touched
  14683. */
  14684. touched: boolean;
  14685. /**
  14686. * If the button/trigger is currently pressed
  14687. */
  14688. pressed: boolean;
  14689. }
  14690. /**
  14691. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  14692. * @hidden
  14693. */
  14694. export interface ExtendedGamepadButton extends GamepadButton {
  14695. /**
  14696. * If the button/trigger is currently pressed
  14697. */
  14698. readonly pressed: boolean;
  14699. /**
  14700. * If the button/trigger is currently touched
  14701. */
  14702. readonly touched: boolean;
  14703. /**
  14704. * Value of the button/trigger
  14705. */
  14706. readonly value: number;
  14707. }
  14708. /** @hidden */
  14709. export interface _GamePadFactory {
  14710. /**
  14711. * Returns wether or not the current gamepad can be created for this type of controller.
  14712. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14713. * @returns true if it can be created, otherwise false
  14714. */
  14715. canCreate(gamepadInfo: any): boolean;
  14716. /**
  14717. * Creates a new instance of the Gamepad.
  14718. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  14719. * @returns the new gamepad instance
  14720. */
  14721. create(gamepadInfo: any): Gamepad;
  14722. }
  14723. /**
  14724. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14725. */
  14726. export class PoseEnabledControllerHelper {
  14727. /** @hidden */
  14728. static _ControllerFactories: _GamePadFactory[];
  14729. /** @hidden */
  14730. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  14731. /**
  14732. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  14733. * @param vrGamepad the gamepad to initialized
  14734. * @returns a vr controller of the type the gamepad identified as
  14735. */
  14736. static InitiateController(vrGamepad: any): Gamepad;
  14737. }
  14738. /**
  14739. * Defines the PoseEnabledController object that contains state of a vr capable controller
  14740. */
  14741. export class PoseEnabledController extends Gamepad implements PoseControlled {
  14742. /**
  14743. * If the controller is used in a webXR session
  14744. */
  14745. isXR: boolean;
  14746. private _deviceRoomPosition;
  14747. private _deviceRoomRotationQuaternion;
  14748. /**
  14749. * The device position in babylon space
  14750. */
  14751. devicePosition: Vector3;
  14752. /**
  14753. * The device rotation in babylon space
  14754. */
  14755. deviceRotationQuaternion: Quaternion;
  14756. /**
  14757. * The scale factor of the device in babylon space
  14758. */
  14759. deviceScaleFactor: number;
  14760. /**
  14761. * (Likely devicePosition should be used instead) The device position in its room space
  14762. */
  14763. position: Vector3;
  14764. /**
  14765. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  14766. */
  14767. rotationQuaternion: Quaternion;
  14768. /**
  14769. * The type of controller (Eg. Windows mixed reality)
  14770. */
  14771. controllerType: PoseEnabledControllerType;
  14772. protected _calculatedPosition: Vector3;
  14773. private _calculatedRotation;
  14774. /**
  14775. * The raw pose from the device
  14776. */
  14777. rawPose: DevicePose;
  14778. private _trackPosition;
  14779. private _maxRotationDistFromHeadset;
  14780. private _draggedRoomRotation;
  14781. /**
  14782. * @hidden
  14783. */
  14784. _disableTrackPosition(fixedPosition: Vector3): void;
  14785. /**
  14786. * Internal, the mesh attached to the controller
  14787. * @hidden
  14788. */
  14789. _mesh: Nullable<AbstractMesh>;
  14790. private _poseControlledCamera;
  14791. private _leftHandSystemQuaternion;
  14792. /**
  14793. * Internal, matrix used to convert room space to babylon space
  14794. * @hidden
  14795. */
  14796. _deviceToWorld: Matrix;
  14797. /**
  14798. * Node to be used when casting a ray from the controller
  14799. * @hidden
  14800. */
  14801. _pointingPoseNode: Nullable<TransformNode>;
  14802. /**
  14803. * Name of the child mesh that can be used to cast a ray from the controller
  14804. */
  14805. static readonly POINTING_POSE: string;
  14806. /**
  14807. * Creates a new PoseEnabledController from a gamepad
  14808. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  14809. */
  14810. constructor(browserGamepad: any);
  14811. private _workingMatrix;
  14812. /**
  14813. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  14814. */
  14815. update(): void;
  14816. /**
  14817. * Updates only the pose device and mesh without doing any button event checking
  14818. */
  14819. protected _updatePoseAndMesh(): void;
  14820. /**
  14821. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  14822. * @param poseData raw pose fromthe device
  14823. */
  14824. updateFromDevice(poseData: DevicePose): void;
  14825. /**
  14826. * @hidden
  14827. */
  14828. _meshAttachedObservable: Observable<AbstractMesh>;
  14829. /**
  14830. * Attaches a mesh to the controller
  14831. * @param mesh the mesh to be attached
  14832. */
  14833. attachToMesh(mesh: AbstractMesh): void;
  14834. /**
  14835. * Attaches the controllers mesh to a camera
  14836. * @param camera the camera the mesh should be attached to
  14837. */
  14838. attachToPoseControlledCamera(camera: TargetCamera): void;
  14839. /**
  14840. * Disposes of the controller
  14841. */
  14842. dispose(): void;
  14843. /**
  14844. * The mesh that is attached to the controller
  14845. */
  14846. readonly mesh: Nullable<AbstractMesh>;
  14847. /**
  14848. * Gets the ray of the controller in the direction the controller is pointing
  14849. * @param length the length the resulting ray should be
  14850. * @returns a ray in the direction the controller is pointing
  14851. */
  14852. getForwardRay(length?: number): Ray;
  14853. }
  14854. }
  14855. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  14856. import { Observable } from "babylonjs/Misc/observable";
  14857. import { Scene } from "babylonjs/scene";
  14858. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14859. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  14860. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  14861. import { Nullable } from "babylonjs/types";
  14862. /**
  14863. * Defines the WebVRController object that represents controllers tracked in 3D space
  14864. */
  14865. export abstract class WebVRController extends PoseEnabledController {
  14866. /**
  14867. * Internal, the default controller model for the controller
  14868. */
  14869. protected _defaultModel: Nullable<AbstractMesh>;
  14870. /**
  14871. * Fired when the trigger state has changed
  14872. */
  14873. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  14874. /**
  14875. * Fired when the main button state has changed
  14876. */
  14877. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14878. /**
  14879. * Fired when the secondary button state has changed
  14880. */
  14881. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  14882. /**
  14883. * Fired when the pad state has changed
  14884. */
  14885. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  14886. /**
  14887. * Fired when controllers stick values have changed
  14888. */
  14889. onPadValuesChangedObservable: Observable<StickValues>;
  14890. /**
  14891. * Array of button availible on the controller
  14892. */
  14893. protected _buttons: Array<MutableGamepadButton>;
  14894. private _onButtonStateChange;
  14895. /**
  14896. * Fired when a controller button's state has changed
  14897. * @param callback the callback containing the button that was modified
  14898. */
  14899. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  14900. /**
  14901. * X and Y axis corresponding to the controllers joystick
  14902. */
  14903. pad: StickValues;
  14904. /**
  14905. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  14906. */
  14907. hand: string;
  14908. /**
  14909. * The default controller model for the controller
  14910. */
  14911. readonly defaultModel: Nullable<AbstractMesh>;
  14912. /**
  14913. * Creates a new WebVRController from a gamepad
  14914. * @param vrGamepad the gamepad that the WebVRController should be created from
  14915. */
  14916. constructor(vrGamepad: any);
  14917. /**
  14918. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  14919. */
  14920. update(): void;
  14921. /**
  14922. * Function to be called when a button is modified
  14923. */
  14924. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  14925. /**
  14926. * Loads a mesh and attaches it to the controller
  14927. * @param scene the scene the mesh should be added to
  14928. * @param meshLoaded callback for when the mesh has been loaded
  14929. */
  14930. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  14931. private _setButtonValue;
  14932. private _changes;
  14933. private _checkChanges;
  14934. /**
  14935. * Disposes of th webVRCOntroller
  14936. */
  14937. dispose(): void;
  14938. }
  14939. }
  14940. declare module "babylonjs/Lights/hemisphericLight" {
  14941. import { Nullable } from "babylonjs/types";
  14942. import { Scene } from "babylonjs/scene";
  14943. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  14944. import { Color3 } from "babylonjs/Maths/math.color";
  14945. import { Effect } from "babylonjs/Materials/effect";
  14946. import { Light } from "babylonjs/Lights/light";
  14947. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  14948. /**
  14949. * The HemisphericLight simulates the ambient environment light,
  14950. * so the passed direction is the light reflection direction, not the incoming direction.
  14951. */
  14952. export class HemisphericLight extends Light {
  14953. /**
  14954. * The groundColor is the light in the opposite direction to the one specified during creation.
  14955. * 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.
  14956. */
  14957. groundColor: Color3;
  14958. /**
  14959. * The light reflection direction, not the incoming direction.
  14960. */
  14961. direction: Vector3;
  14962. /**
  14963. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  14964. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  14965. * The HemisphericLight can't cast shadows.
  14966. * Documentation : https://doc.babylonjs.com/babylon101/lights
  14967. * @param name The friendly name of the light
  14968. * @param direction The direction of the light reflection
  14969. * @param scene The scene the light belongs to
  14970. */
  14971. constructor(name: string, direction: Vector3, scene: Scene);
  14972. protected _buildUniformLayout(): void;
  14973. /**
  14974. * Returns the string "HemisphericLight".
  14975. * @return The class name
  14976. */
  14977. getClassName(): string;
  14978. /**
  14979. * Sets the HemisphericLight direction towards the passed target (Vector3).
  14980. * Returns the updated direction.
  14981. * @param target The target the direction should point to
  14982. * @return The computed direction
  14983. */
  14984. setDirectionToTarget(target: Vector3): Vector3;
  14985. /**
  14986. * Returns the shadow generator associated to the light.
  14987. * @returns Always null for hemispheric lights because it does not support shadows.
  14988. */
  14989. getShadowGenerator(): Nullable<IShadowGenerator>;
  14990. /**
  14991. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  14992. * @param effect The effect to update
  14993. * @param lightIndex The index of the light in the effect to update
  14994. * @returns The hemispheric light
  14995. */
  14996. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  14997. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  14998. /**
  14999. * Computes the world matrix of the node
  15000. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15001. * @param useWasUpdatedFlag defines a reserved property
  15002. * @returns the world matrix
  15003. */
  15004. computeWorldMatrix(): Matrix;
  15005. /**
  15006. * Returns the integer 3.
  15007. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  15008. */
  15009. getTypeID(): number;
  15010. /**
  15011. * Prepares the list of defines specific to the light type.
  15012. * @param defines the list of defines
  15013. * @param lightIndex defines the index of the light for the effect
  15014. */
  15015. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  15016. }
  15017. }
  15018. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  15019. /** @hidden */
  15020. export var vrMultiviewToSingleviewPixelShader: {
  15021. name: string;
  15022. shader: string;
  15023. };
  15024. }
  15025. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  15026. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15027. import { Scene } from "babylonjs/scene";
  15028. /**
  15029. * Renders to multiple views with a single draw call
  15030. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  15031. */
  15032. export class MultiviewRenderTarget extends RenderTargetTexture {
  15033. /**
  15034. * Creates a multiview render target
  15035. * @param scene scene used with the render target
  15036. * @param size the size of the render target (used for each view)
  15037. */
  15038. constructor(scene: Scene, size?: number | {
  15039. width: number;
  15040. height: number;
  15041. } | {
  15042. ratio: number;
  15043. });
  15044. /**
  15045. * @hidden
  15046. * @param faceIndex the face index, if its a cube texture
  15047. */
  15048. _bindFrameBuffer(faceIndex?: number): void;
  15049. /**
  15050. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  15051. * @returns the view count
  15052. */
  15053. getViewCount(): number;
  15054. }
  15055. }
  15056. declare module "babylonjs/Maths/math.frustum" {
  15057. import { Matrix } from "babylonjs/Maths/math.vector";
  15058. import { DeepImmutable } from "babylonjs/types";
  15059. import { Plane } from "babylonjs/Maths/math.plane";
  15060. /**
  15061. * Represents a camera frustum
  15062. */
  15063. export class Frustum {
  15064. /**
  15065. * Gets the planes representing the frustum
  15066. * @param transform matrix to be applied to the returned planes
  15067. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  15068. */
  15069. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  15070. /**
  15071. * Gets the near frustum plane transformed by the transform matrix
  15072. * @param transform transformation matrix to be applied to the resulting frustum plane
  15073. * @param frustumPlane the resuling frustum plane
  15074. */
  15075. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15076. /**
  15077. * Gets the far frustum plane transformed by the transform matrix
  15078. * @param transform transformation matrix to be applied to the resulting frustum plane
  15079. * @param frustumPlane the resuling frustum plane
  15080. */
  15081. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15082. /**
  15083. * Gets the left frustum plane transformed by the transform matrix
  15084. * @param transform transformation matrix to be applied to the resulting frustum plane
  15085. * @param frustumPlane the resuling frustum plane
  15086. */
  15087. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15088. /**
  15089. * Gets the right frustum plane transformed by the transform matrix
  15090. * @param transform transformation matrix to be applied to the resulting frustum plane
  15091. * @param frustumPlane the resuling frustum plane
  15092. */
  15093. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15094. /**
  15095. * Gets the top frustum plane transformed by the transform matrix
  15096. * @param transform transformation matrix to be applied to the resulting frustum plane
  15097. * @param frustumPlane the resuling frustum plane
  15098. */
  15099. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15100. /**
  15101. * Gets the bottom frustum plane transformed by the transform matrix
  15102. * @param transform transformation matrix to be applied to the resulting frustum plane
  15103. * @param frustumPlane the resuling frustum plane
  15104. */
  15105. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  15106. /**
  15107. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  15108. * @param transform transformation matrix to be applied to the resulting frustum planes
  15109. * @param frustumPlanes the resuling frustum planes
  15110. */
  15111. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  15112. }
  15113. }
  15114. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  15115. import { Camera } from "babylonjs/Cameras/camera";
  15116. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15117. import { Nullable } from "babylonjs/types";
  15118. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  15119. import { Matrix } from "babylonjs/Maths/math.vector";
  15120. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  15121. module "babylonjs/Engines/engine" {
  15122. interface Engine {
  15123. /**
  15124. * Creates a new multiview render target
  15125. * @param width defines the width of the texture
  15126. * @param height defines the height of the texture
  15127. * @returns the created multiview texture
  15128. */
  15129. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  15130. /**
  15131. * Binds a multiview framebuffer to be drawn to
  15132. * @param multiviewTexture texture to bind
  15133. */
  15134. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  15135. }
  15136. }
  15137. module "babylonjs/Cameras/camera" {
  15138. interface Camera {
  15139. /**
  15140. * @hidden
  15141. * 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)
  15142. */
  15143. _useMultiviewToSingleView: boolean;
  15144. /**
  15145. * @hidden
  15146. * 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)
  15147. */
  15148. _multiviewTexture: Nullable<RenderTargetTexture>;
  15149. /**
  15150. * @hidden
  15151. * ensures the multiview texture of the camera exists and has the specified width/height
  15152. * @param width height to set on the multiview texture
  15153. * @param height width to set on the multiview texture
  15154. */
  15155. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  15156. }
  15157. }
  15158. module "babylonjs/scene" {
  15159. interface Scene {
  15160. /** @hidden */
  15161. _transformMatrixR: Matrix;
  15162. /** @hidden */
  15163. _multiviewSceneUbo: Nullable<UniformBuffer>;
  15164. /** @hidden */
  15165. _createMultiviewUbo(): void;
  15166. /** @hidden */
  15167. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  15168. /** @hidden */
  15169. _renderMultiviewToSingleView(camera: Camera): void;
  15170. }
  15171. }
  15172. }
  15173. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  15174. import { Camera } from "babylonjs/Cameras/camera";
  15175. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  15176. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  15177. import "babylonjs/Engines/Extensions/engine.multiview";
  15178. /**
  15179. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  15180. * This will not be used for webXR as it supports displaying texture arrays directly
  15181. */
  15182. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  15183. /**
  15184. * Initializes a VRMultiviewToSingleview
  15185. * @param name name of the post process
  15186. * @param camera camera to be applied to
  15187. * @param scaleFactor scaling factor to the size of the output texture
  15188. */
  15189. constructor(name: string, camera: Camera, scaleFactor: number);
  15190. }
  15191. }
  15192. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  15193. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  15194. import { Nullable } from "babylonjs/types";
  15195. import { Size } from "babylonjs/Maths/math.size";
  15196. import { Observable } from "babylonjs/Misc/observable";
  15197. module "babylonjs/Engines/engine" {
  15198. interface Engine {
  15199. /** @hidden */
  15200. _vrDisplay: any;
  15201. /** @hidden */
  15202. _vrSupported: boolean;
  15203. /** @hidden */
  15204. _oldSize: Size;
  15205. /** @hidden */
  15206. _oldHardwareScaleFactor: number;
  15207. /** @hidden */
  15208. _vrExclusivePointerMode: boolean;
  15209. /** @hidden */
  15210. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  15211. /** @hidden */
  15212. _onVRDisplayPointerRestricted: () => void;
  15213. /** @hidden */
  15214. _onVRDisplayPointerUnrestricted: () => void;
  15215. /** @hidden */
  15216. _onVrDisplayConnect: Nullable<(display: any) => void>;
  15217. /** @hidden */
  15218. _onVrDisplayDisconnect: Nullable<() => void>;
  15219. /** @hidden */
  15220. _onVrDisplayPresentChange: Nullable<() => void>;
  15221. /**
  15222. * Observable signaled when VR display mode changes
  15223. */
  15224. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  15225. /**
  15226. * Observable signaled when VR request present is complete
  15227. */
  15228. onVRRequestPresentComplete: Observable<boolean>;
  15229. /**
  15230. * Observable signaled when VR request present starts
  15231. */
  15232. onVRRequestPresentStart: Observable<Engine>;
  15233. /**
  15234. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  15235. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  15236. */
  15237. isInVRExclusivePointerMode: boolean;
  15238. /**
  15239. * Gets a boolean indicating if a webVR device was detected
  15240. * @returns true if a webVR device was detected
  15241. */
  15242. isVRDevicePresent(): boolean;
  15243. /**
  15244. * Gets the current webVR device
  15245. * @returns the current webVR device (or null)
  15246. */
  15247. getVRDevice(): any;
  15248. /**
  15249. * Initializes a webVR display and starts listening to display change events
  15250. * The onVRDisplayChangedObservable will be notified upon these changes
  15251. * @returns A promise containing a VRDisplay and if vr is supported
  15252. */
  15253. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  15254. /** @hidden */
  15255. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  15256. /**
  15257. * Call this function to switch to webVR mode
  15258. * Will do nothing if webVR is not supported or if there is no webVR device
  15259. * @see http://doc.babylonjs.com/how_to/webvr_camera
  15260. */
  15261. enableVR(): void;
  15262. /** @hidden */
  15263. _onVRFullScreenTriggered(): void;
  15264. }
  15265. }
  15266. }
  15267. declare module "babylonjs/Cameras/VR/webVRCamera" {
  15268. import { Nullable } from "babylonjs/types";
  15269. import { Observable } from "babylonjs/Misc/observable";
  15270. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  15271. import { Scene } from "babylonjs/scene";
  15272. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15273. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  15274. import { Node } from "babylonjs/node";
  15275. import { Ray } from "babylonjs/Culling/ray";
  15276. import "babylonjs/Cameras/RigModes/webVRRigMode";
  15277. import "babylonjs/Engines/Extensions/engine.webVR";
  15278. /**
  15279. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  15280. * IMPORTANT!! The data is right-hand data.
  15281. * @export
  15282. * @interface DevicePose
  15283. */
  15284. export interface DevicePose {
  15285. /**
  15286. * The position of the device, values in array are [x,y,z].
  15287. */
  15288. readonly position: Nullable<Float32Array>;
  15289. /**
  15290. * The linearVelocity of the device, values in array are [x,y,z].
  15291. */
  15292. readonly linearVelocity: Nullable<Float32Array>;
  15293. /**
  15294. * The linearAcceleration of the device, values in array are [x,y,z].
  15295. */
  15296. readonly linearAcceleration: Nullable<Float32Array>;
  15297. /**
  15298. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  15299. */
  15300. readonly orientation: Nullable<Float32Array>;
  15301. /**
  15302. * The angularVelocity of the device, values in array are [x,y,z].
  15303. */
  15304. readonly angularVelocity: Nullable<Float32Array>;
  15305. /**
  15306. * The angularAcceleration of the device, values in array are [x,y,z].
  15307. */
  15308. readonly angularAcceleration: Nullable<Float32Array>;
  15309. }
  15310. /**
  15311. * Interface representing a pose controlled object in Babylon.
  15312. * A pose controlled object has both regular pose values as well as pose values
  15313. * from an external device such as a VR head mounted display
  15314. */
  15315. export interface PoseControlled {
  15316. /**
  15317. * The position of the object in babylon space.
  15318. */
  15319. position: Vector3;
  15320. /**
  15321. * The rotation quaternion of the object in babylon space.
  15322. */
  15323. rotationQuaternion: Quaternion;
  15324. /**
  15325. * The position of the device in babylon space.
  15326. */
  15327. devicePosition?: Vector3;
  15328. /**
  15329. * The rotation quaternion of the device in babylon space.
  15330. */
  15331. deviceRotationQuaternion: Quaternion;
  15332. /**
  15333. * The raw pose coming from the device.
  15334. */
  15335. rawPose: Nullable<DevicePose>;
  15336. /**
  15337. * The scale of the device to be used when translating from device space to babylon space.
  15338. */
  15339. deviceScaleFactor: number;
  15340. /**
  15341. * Updates the poseControlled values based on the input device pose.
  15342. * @param poseData the pose data to update the object with
  15343. */
  15344. updateFromDevice(poseData: DevicePose): void;
  15345. }
  15346. /**
  15347. * Set of options to customize the webVRCamera
  15348. */
  15349. export interface WebVROptions {
  15350. /**
  15351. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  15352. */
  15353. trackPosition?: boolean;
  15354. /**
  15355. * Sets the scale of the vrDevice in babylon space. (default: 1)
  15356. */
  15357. positionScale?: number;
  15358. /**
  15359. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  15360. */
  15361. displayName?: string;
  15362. /**
  15363. * Should the native controller meshes be initialized. (default: true)
  15364. */
  15365. controllerMeshes?: boolean;
  15366. /**
  15367. * Creating a default HemiLight only on controllers. (default: true)
  15368. */
  15369. defaultLightingOnControllers?: boolean;
  15370. /**
  15371. * If you don't want to use the default VR button of the helper. (default: false)
  15372. */
  15373. useCustomVRButton?: boolean;
  15374. /**
  15375. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  15376. */
  15377. customVRButton?: HTMLButtonElement;
  15378. /**
  15379. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  15380. */
  15381. rayLength?: number;
  15382. /**
  15383. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  15384. */
  15385. defaultHeight?: number;
  15386. /**
  15387. * If multiview should be used if availible (default: false)
  15388. */
  15389. useMultiview?: boolean;
  15390. }
  15391. /**
  15392. * This represents a WebVR camera.
  15393. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  15394. * @example http://doc.babylonjs.com/how_to/webvr_camera
  15395. */
  15396. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  15397. private webVROptions;
  15398. /**
  15399. * @hidden
  15400. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  15401. */
  15402. _vrDevice: any;
  15403. /**
  15404. * The rawPose of the vrDevice.
  15405. */
  15406. rawPose: Nullable<DevicePose>;
  15407. private _onVREnabled;
  15408. private _specsVersion;
  15409. private _attached;
  15410. private _frameData;
  15411. protected _descendants: Array<Node>;
  15412. private _deviceRoomPosition;
  15413. /** @hidden */
  15414. _deviceRoomRotationQuaternion: Quaternion;
  15415. private _standingMatrix;
  15416. /**
  15417. * Represents device position in babylon space.
  15418. */
  15419. devicePosition: Vector3;
  15420. /**
  15421. * Represents device rotation in babylon space.
  15422. */
  15423. deviceRotationQuaternion: Quaternion;
  15424. /**
  15425. * The scale of the device to be used when translating from device space to babylon space.
  15426. */
  15427. deviceScaleFactor: number;
  15428. private _deviceToWorld;
  15429. private _worldToDevice;
  15430. /**
  15431. * References to the webVR controllers for the vrDevice.
  15432. */
  15433. controllers: Array<WebVRController>;
  15434. /**
  15435. * Emits an event when a controller is attached.
  15436. */
  15437. onControllersAttachedObservable: Observable<WebVRController[]>;
  15438. /**
  15439. * Emits an event when a controller's mesh has been loaded;
  15440. */
  15441. onControllerMeshLoadedObservable: Observable<WebVRController>;
  15442. /**
  15443. * Emits an event when the HMD's pose has been updated.
  15444. */
  15445. onPoseUpdatedFromDeviceObservable: Observable<any>;
  15446. private _poseSet;
  15447. /**
  15448. * If the rig cameras be used as parent instead of this camera.
  15449. */
  15450. rigParenting: boolean;
  15451. private _lightOnControllers;
  15452. private _defaultHeight?;
  15453. /**
  15454. * Instantiates a WebVRFreeCamera.
  15455. * @param name The name of the WebVRFreeCamera
  15456. * @param position The starting anchor position for the camera
  15457. * @param scene The scene the camera belongs to
  15458. * @param webVROptions a set of customizable options for the webVRCamera
  15459. */
  15460. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  15461. /**
  15462. * Gets the device distance from the ground in meters.
  15463. * @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.
  15464. */
  15465. deviceDistanceToRoomGround(): number;
  15466. /**
  15467. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15468. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  15469. */
  15470. useStandingMatrix(callback?: (bool: boolean) => void): void;
  15471. /**
  15472. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  15473. * @returns A promise with a boolean set to if the standing matrix is supported.
  15474. */
  15475. useStandingMatrixAsync(): Promise<boolean>;
  15476. /**
  15477. * Disposes the camera
  15478. */
  15479. dispose(): void;
  15480. /**
  15481. * Gets a vrController by name.
  15482. * @param name The name of the controller to retreive
  15483. * @returns the controller matching the name specified or null if not found
  15484. */
  15485. getControllerByName(name: string): Nullable<WebVRController>;
  15486. private _leftController;
  15487. /**
  15488. * The controller corresponding to the users left hand.
  15489. */
  15490. readonly leftController: Nullable<WebVRController>;
  15491. private _rightController;
  15492. /**
  15493. * The controller corresponding to the users right hand.
  15494. */
  15495. readonly rightController: Nullable<WebVRController>;
  15496. /**
  15497. * Casts a ray forward from the vrCamera's gaze.
  15498. * @param length Length of the ray (default: 100)
  15499. * @returns the ray corresponding to the gaze
  15500. */
  15501. getForwardRay(length?: number): Ray;
  15502. /**
  15503. * @hidden
  15504. * Updates the camera based on device's frame data
  15505. */
  15506. _checkInputs(): void;
  15507. /**
  15508. * Updates the poseControlled values based on the input device pose.
  15509. * @param poseData Pose coming from the device
  15510. */
  15511. updateFromDevice(poseData: DevicePose): void;
  15512. private _htmlElementAttached;
  15513. private _detachIfAttached;
  15514. /**
  15515. * WebVR's attach control will start broadcasting frames to the device.
  15516. * Note that in certain browsers (chrome for example) this function must be called
  15517. * within a user-interaction callback. Example:
  15518. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  15519. *
  15520. * @param element html element to attach the vrDevice to
  15521. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  15522. */
  15523. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  15524. /**
  15525. * Detaches the camera from the html element and disables VR
  15526. *
  15527. * @param element html element to detach from
  15528. */
  15529. detachControl(element: HTMLElement): void;
  15530. /**
  15531. * @returns the name of this class
  15532. */
  15533. getClassName(): string;
  15534. /**
  15535. * Calls resetPose on the vrDisplay
  15536. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  15537. */
  15538. resetToCurrentRotation(): void;
  15539. /**
  15540. * @hidden
  15541. * Updates the rig cameras (left and right eye)
  15542. */
  15543. _updateRigCameras(): void;
  15544. private _workingVector;
  15545. private _oneVector;
  15546. private _workingMatrix;
  15547. private updateCacheCalled;
  15548. private _correctPositionIfNotTrackPosition;
  15549. /**
  15550. * @hidden
  15551. * Updates the cached values of the camera
  15552. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  15553. */
  15554. _updateCache(ignoreParentClass?: boolean): void;
  15555. /**
  15556. * @hidden
  15557. * Get current device position in babylon world
  15558. */
  15559. _computeDevicePosition(): void;
  15560. /**
  15561. * Updates the current device position and rotation in the babylon world
  15562. */
  15563. update(): void;
  15564. /**
  15565. * @hidden
  15566. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  15567. * @returns an identity matrix
  15568. */
  15569. _getViewMatrix(): Matrix;
  15570. private _tmpMatrix;
  15571. /**
  15572. * This function is called by the two RIG cameras.
  15573. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  15574. * @hidden
  15575. */
  15576. _getWebVRViewMatrix(): Matrix;
  15577. /** @hidden */
  15578. _getWebVRProjectionMatrix(): Matrix;
  15579. private _onGamepadConnectedObserver;
  15580. private _onGamepadDisconnectedObserver;
  15581. private _updateCacheWhenTrackingDisabledObserver;
  15582. /**
  15583. * Initializes the controllers and their meshes
  15584. */
  15585. initControllers(): void;
  15586. }
  15587. }
  15588. declare module "babylonjs/PostProcesses/postProcess" {
  15589. import { Nullable } from "babylonjs/types";
  15590. import { SmartArray } from "babylonjs/Misc/smartArray";
  15591. import { Observable } from "babylonjs/Misc/observable";
  15592. import { Vector2 } from "babylonjs/Maths/math.vector";
  15593. import { Camera } from "babylonjs/Cameras/camera";
  15594. import { Effect } from "babylonjs/Materials/effect";
  15595. import "babylonjs/Shaders/postprocess.vertex";
  15596. import { IInspectable } from "babylonjs/Misc/iInspectable";
  15597. import { Engine } from "babylonjs/Engines/engine";
  15598. import { Color4 } from "babylonjs/Maths/math.color";
  15599. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  15600. /**
  15601. * Size options for a post process
  15602. */
  15603. export type PostProcessOptions = {
  15604. width: number;
  15605. height: number;
  15606. };
  15607. /**
  15608. * PostProcess can be used to apply a shader to a texture after it has been rendered
  15609. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  15610. */
  15611. export class PostProcess {
  15612. /** Name of the PostProcess. */
  15613. name: string;
  15614. /**
  15615. * Gets or sets the unique id of the post process
  15616. */
  15617. uniqueId: number;
  15618. /**
  15619. * Width of the texture to apply the post process on
  15620. */
  15621. width: number;
  15622. /**
  15623. * Height of the texture to apply the post process on
  15624. */
  15625. height: number;
  15626. /**
  15627. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  15628. * @hidden
  15629. */
  15630. _outputTexture: Nullable<InternalTexture>;
  15631. /**
  15632. * Sampling mode used by the shader
  15633. * See https://doc.babylonjs.com/classes/3.1/texture
  15634. */
  15635. renderTargetSamplingMode: number;
  15636. /**
  15637. * Clear color to use when screen clearing
  15638. */
  15639. clearColor: Color4;
  15640. /**
  15641. * If the buffer needs to be cleared before applying the post process. (default: true)
  15642. * Should be set to false if shader will overwrite all previous pixels.
  15643. */
  15644. autoClear: boolean;
  15645. /**
  15646. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  15647. */
  15648. alphaMode: number;
  15649. /**
  15650. * Sets the setAlphaBlendConstants of the babylon engine
  15651. */
  15652. alphaConstants: Color4;
  15653. /**
  15654. * Animations to be used for the post processing
  15655. */
  15656. animations: import("babylonjs/Animations/animation").Animation[];
  15657. /**
  15658. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  15659. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  15660. */
  15661. enablePixelPerfectMode: boolean;
  15662. /**
  15663. * Force the postprocess to be applied without taking in account viewport
  15664. */
  15665. forceFullscreenViewport: boolean;
  15666. /**
  15667. * List of inspectable custom properties (used by the Inspector)
  15668. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  15669. */
  15670. inspectableCustomProperties: IInspectable[];
  15671. /**
  15672. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  15673. *
  15674. * | Value | Type | Description |
  15675. * | ----- | ----------------------------------- | ----------- |
  15676. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  15677. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  15678. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  15679. *
  15680. */
  15681. scaleMode: number;
  15682. /**
  15683. * Force textures to be a power of two (default: false)
  15684. */
  15685. alwaysForcePOT: boolean;
  15686. private _samples;
  15687. /**
  15688. * Number of sample textures (default: 1)
  15689. */
  15690. samples: number;
  15691. /**
  15692. * Modify the scale of the post process to be the same as the viewport (default: false)
  15693. */
  15694. adaptScaleToCurrentViewport: boolean;
  15695. private _camera;
  15696. private _scene;
  15697. private _engine;
  15698. private _options;
  15699. private _reusable;
  15700. private _textureType;
  15701. /**
  15702. * Smart array of input and output textures for the post process.
  15703. * @hidden
  15704. */
  15705. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  15706. /**
  15707. * The index in _textures that corresponds to the output texture.
  15708. * @hidden
  15709. */
  15710. _currentRenderTextureInd: number;
  15711. private _effect;
  15712. private _samplers;
  15713. private _fragmentUrl;
  15714. private _vertexUrl;
  15715. private _parameters;
  15716. private _scaleRatio;
  15717. protected _indexParameters: any;
  15718. private _shareOutputWithPostProcess;
  15719. private _texelSize;
  15720. private _forcedOutputTexture;
  15721. /**
  15722. * Returns the fragment url or shader name used in the post process.
  15723. * @returns the fragment url or name in the shader store.
  15724. */
  15725. getEffectName(): string;
  15726. /**
  15727. * An event triggered when the postprocess is activated.
  15728. */
  15729. onActivateObservable: Observable<Camera>;
  15730. private _onActivateObserver;
  15731. /**
  15732. * A function that is added to the onActivateObservable
  15733. */
  15734. onActivate: Nullable<(camera: Camera) => void>;
  15735. /**
  15736. * An event triggered when the postprocess changes its size.
  15737. */
  15738. onSizeChangedObservable: Observable<PostProcess>;
  15739. private _onSizeChangedObserver;
  15740. /**
  15741. * A function that is added to the onSizeChangedObservable
  15742. */
  15743. onSizeChanged: (postProcess: PostProcess) => void;
  15744. /**
  15745. * An event triggered when the postprocess applies its effect.
  15746. */
  15747. onApplyObservable: Observable<Effect>;
  15748. private _onApplyObserver;
  15749. /**
  15750. * A function that is added to the onApplyObservable
  15751. */
  15752. onApply: (effect: Effect) => void;
  15753. /**
  15754. * An event triggered before rendering the postprocess
  15755. */
  15756. onBeforeRenderObservable: Observable<Effect>;
  15757. private _onBeforeRenderObserver;
  15758. /**
  15759. * A function that is added to the onBeforeRenderObservable
  15760. */
  15761. onBeforeRender: (effect: Effect) => void;
  15762. /**
  15763. * An event triggered after rendering the postprocess
  15764. */
  15765. onAfterRenderObservable: Observable<Effect>;
  15766. private _onAfterRenderObserver;
  15767. /**
  15768. * A function that is added to the onAfterRenderObservable
  15769. */
  15770. onAfterRender: (efect: Effect) => void;
  15771. /**
  15772. * 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
  15773. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  15774. */
  15775. inputTexture: InternalTexture;
  15776. /**
  15777. * Gets the camera which post process is applied to.
  15778. * @returns The camera the post process is applied to.
  15779. */
  15780. getCamera(): Camera;
  15781. /**
  15782. * Gets the texel size of the postprocess.
  15783. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  15784. */
  15785. readonly texelSize: Vector2;
  15786. /**
  15787. * Creates a new instance PostProcess
  15788. * @param name The name of the PostProcess.
  15789. * @param fragmentUrl The url of the fragment shader to be used.
  15790. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  15791. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  15792. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15793. * @param camera The camera to apply the render pass to.
  15794. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15795. * @param engine The engine which the post process will be applied. (default: current engine)
  15796. * @param reusable If the post process can be reused on the same frame. (default: false)
  15797. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  15798. * @param textureType Type of textures used when performing the post process. (default: 0)
  15799. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  15800. * @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
  15801. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  15802. */
  15803. constructor(
  15804. /** Name of the PostProcess. */
  15805. 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);
  15806. /**
  15807. * Gets a string idenfifying the name of the class
  15808. * @returns "PostProcess" string
  15809. */
  15810. getClassName(): string;
  15811. /**
  15812. * Gets the engine which this post process belongs to.
  15813. * @returns The engine the post process was enabled with.
  15814. */
  15815. getEngine(): Engine;
  15816. /**
  15817. * The effect that is created when initializing the post process.
  15818. * @returns The created effect corresponding the the postprocess.
  15819. */
  15820. getEffect(): Effect;
  15821. /**
  15822. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  15823. * @param postProcess The post process to share the output with.
  15824. * @returns This post process.
  15825. */
  15826. shareOutputWith(postProcess: PostProcess): PostProcess;
  15827. /**
  15828. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  15829. * This should be called if the post process that shares output with this post process is disabled/disposed.
  15830. */
  15831. useOwnOutput(): void;
  15832. /**
  15833. * Updates the effect with the current post process compile time values and recompiles the shader.
  15834. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15835. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15836. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15837. * @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
  15838. * @param onCompiled Called when the shader has been compiled.
  15839. * @param onError Called if there is an error when compiling a shader.
  15840. */
  15841. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15842. /**
  15843. * The post process is reusable if it can be used multiple times within one frame.
  15844. * @returns If the post process is reusable
  15845. */
  15846. isReusable(): boolean;
  15847. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  15848. markTextureDirty(): void;
  15849. /**
  15850. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  15851. * 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.
  15852. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  15853. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  15854. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  15855. * @returns The target texture that was bound to be written to.
  15856. */
  15857. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  15858. /**
  15859. * If the post process is supported.
  15860. */
  15861. readonly isSupported: boolean;
  15862. /**
  15863. * The aspect ratio of the output texture.
  15864. */
  15865. readonly aspectRatio: number;
  15866. /**
  15867. * Get a value indicating if the post-process is ready to be used
  15868. * @returns true if the post-process is ready (shader is compiled)
  15869. */
  15870. isReady(): boolean;
  15871. /**
  15872. * Binds all textures and uniforms to the shader, this will be run on every pass.
  15873. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  15874. */
  15875. apply(): Nullable<Effect>;
  15876. private _disposeTextures;
  15877. /**
  15878. * Disposes the post process.
  15879. * @param camera The camera to dispose the post process on.
  15880. */
  15881. dispose(camera?: Camera): void;
  15882. }
  15883. }
  15884. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  15885. /** @hidden */
  15886. export var kernelBlurVaryingDeclaration: {
  15887. name: string;
  15888. shader: string;
  15889. };
  15890. }
  15891. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  15892. /** @hidden */
  15893. export var kernelBlurFragment: {
  15894. name: string;
  15895. shader: string;
  15896. };
  15897. }
  15898. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  15899. /** @hidden */
  15900. export var kernelBlurFragment2: {
  15901. name: string;
  15902. shader: string;
  15903. };
  15904. }
  15905. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  15906. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15907. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  15908. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  15909. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  15910. /** @hidden */
  15911. export var kernelBlurPixelShader: {
  15912. name: string;
  15913. shader: string;
  15914. };
  15915. }
  15916. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  15917. /** @hidden */
  15918. export var kernelBlurVertex: {
  15919. name: string;
  15920. shader: string;
  15921. };
  15922. }
  15923. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  15924. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  15925. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  15926. /** @hidden */
  15927. export var kernelBlurVertexShader: {
  15928. name: string;
  15929. shader: string;
  15930. };
  15931. }
  15932. declare module "babylonjs/PostProcesses/blurPostProcess" {
  15933. import { Vector2 } from "babylonjs/Maths/math.vector";
  15934. import { Nullable } from "babylonjs/types";
  15935. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  15936. import { Camera } from "babylonjs/Cameras/camera";
  15937. import { Effect } from "babylonjs/Materials/effect";
  15938. import { Engine } from "babylonjs/Engines/engine";
  15939. import "babylonjs/Shaders/kernelBlur.fragment";
  15940. import "babylonjs/Shaders/kernelBlur.vertex";
  15941. /**
  15942. * The Blur Post Process which blurs an image based on a kernel and direction.
  15943. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  15944. */
  15945. export class BlurPostProcess extends PostProcess {
  15946. /** The direction in which to blur the image. */
  15947. direction: Vector2;
  15948. private blockCompilation;
  15949. protected _kernel: number;
  15950. protected _idealKernel: number;
  15951. protected _packedFloat: boolean;
  15952. private _staticDefines;
  15953. /**
  15954. * Sets the length in pixels of the blur sample region
  15955. */
  15956. /**
  15957. * Gets the length in pixels of the blur sample region
  15958. */
  15959. kernel: number;
  15960. /**
  15961. * Sets wether or not the blur needs to unpack/repack floats
  15962. */
  15963. /**
  15964. * Gets wether or not the blur is unpacking/repacking floats
  15965. */
  15966. packedFloat: boolean;
  15967. /**
  15968. * Creates a new instance BlurPostProcess
  15969. * @param name The name of the effect.
  15970. * @param direction The direction in which to blur the image.
  15971. * @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.
  15972. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  15973. * @param camera The camera to apply the render pass to.
  15974. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  15975. * @param engine The engine which the post process will be applied. (default: current engine)
  15976. * @param reusable If the post process can be reused on the same frame. (default: false)
  15977. * @param textureType Type of textures used when performing the post process. (default: 0)
  15978. * @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)
  15979. */
  15980. constructor(name: string,
  15981. /** The direction in which to blur the image. */
  15982. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  15983. /**
  15984. * Updates the effect with the current post process compile time values and recompiles the shader.
  15985. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  15986. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  15987. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  15988. * @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
  15989. * @param onCompiled Called when the shader has been compiled.
  15990. * @param onError Called if there is an error when compiling a shader.
  15991. */
  15992. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15993. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  15994. /**
  15995. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  15996. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  15997. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  15998. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  15999. * The gaps between physical kernels are compensated for in the weighting of the samples
  16000. * @param idealKernel Ideal blur kernel.
  16001. * @return Nearest best kernel.
  16002. */
  16003. protected _nearestBestKernel(idealKernel: number): number;
  16004. /**
  16005. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  16006. * @param x The point on the Gaussian distribution to sample.
  16007. * @return the value of the Gaussian function at x.
  16008. */
  16009. protected _gaussianWeight(x: number): number;
  16010. /**
  16011. * Generates a string that can be used as a floating point number in GLSL.
  16012. * @param x Value to print.
  16013. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  16014. * @return GLSL float string.
  16015. */
  16016. protected _glslFloat(x: number, decimalFigures?: number): string;
  16017. }
  16018. }
  16019. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  16020. import { Scene } from "babylonjs/scene";
  16021. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  16022. import { Plane } from "babylonjs/Maths/math.plane";
  16023. /**
  16024. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16025. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16026. * You can then easily use it as a reflectionTexture on a flat surface.
  16027. * In case the surface is not a plane, please consider relying on reflection probes.
  16028. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16029. */
  16030. export class MirrorTexture extends RenderTargetTexture {
  16031. private scene;
  16032. /**
  16033. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  16034. * 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.
  16035. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16036. */
  16037. mirrorPlane: Plane;
  16038. /**
  16039. * Define the blur ratio used to blur the reflection if needed.
  16040. */
  16041. blurRatio: number;
  16042. /**
  16043. * Define the adaptive blur kernel used to blur the reflection if needed.
  16044. * This will autocompute the closest best match for the `blurKernel`
  16045. */
  16046. adaptiveBlurKernel: number;
  16047. /**
  16048. * Define the blur kernel used to blur the reflection if needed.
  16049. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16050. */
  16051. blurKernel: number;
  16052. /**
  16053. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  16054. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16055. */
  16056. blurKernelX: number;
  16057. /**
  16058. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  16059. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  16060. */
  16061. blurKernelY: number;
  16062. private _autoComputeBlurKernel;
  16063. protected _onRatioRescale(): void;
  16064. private _updateGammaSpace;
  16065. private _imageProcessingConfigChangeObserver;
  16066. private _transformMatrix;
  16067. private _mirrorMatrix;
  16068. private _savedViewMatrix;
  16069. private _blurX;
  16070. private _blurY;
  16071. private _adaptiveBlurKernel;
  16072. private _blurKernelX;
  16073. private _blurKernelY;
  16074. private _blurRatio;
  16075. /**
  16076. * Instantiates a Mirror Texture.
  16077. * Mirror texture can be used to simulate the view from a mirror in a scene.
  16078. * It will dynamically be rendered every frame to adapt to the camera point of view.
  16079. * You can then easily use it as a reflectionTexture on a flat surface.
  16080. * In case the surface is not a plane, please consider relying on reflection probes.
  16081. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  16082. * @param name
  16083. * @param size
  16084. * @param scene
  16085. * @param generateMipMaps
  16086. * @param type
  16087. * @param samplingMode
  16088. * @param generateDepthBuffer
  16089. */
  16090. constructor(name: string, size: number | {
  16091. width: number;
  16092. height: number;
  16093. } | {
  16094. ratio: number;
  16095. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  16096. private _preparePostProcesses;
  16097. /**
  16098. * Clone the mirror texture.
  16099. * @returns the cloned texture
  16100. */
  16101. clone(): MirrorTexture;
  16102. /**
  16103. * Serialize the texture to a JSON representation you could use in Parse later on
  16104. * @returns the serialized JSON representation
  16105. */
  16106. serialize(): any;
  16107. /**
  16108. * Dispose the texture and release its associated resources.
  16109. */
  16110. dispose(): void;
  16111. }
  16112. }
  16113. declare module "babylonjs/Materials/Textures/texture" {
  16114. import { Observable } from "babylonjs/Misc/observable";
  16115. import { Nullable } from "babylonjs/types";
  16116. import { Scene } from "babylonjs/scene";
  16117. import { Matrix } from "babylonjs/Maths/math.vector";
  16118. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16119. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16120. import { Engine } from "babylonjs/Engines/engine";
  16121. /**
  16122. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16123. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16124. */
  16125. export class Texture extends BaseTexture {
  16126. /**
  16127. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  16128. */
  16129. static SerializeBuffers: boolean;
  16130. /** @hidden */
  16131. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  16132. /** @hidden */
  16133. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  16134. /** @hidden */
  16135. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  16136. /** nearest is mag = nearest and min = nearest and mip = linear */
  16137. static readonly NEAREST_SAMPLINGMODE: number;
  16138. /** nearest is mag = nearest and min = nearest and mip = linear */
  16139. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  16140. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16141. static readonly BILINEAR_SAMPLINGMODE: number;
  16142. /** Bilinear is mag = linear and min = linear and mip = nearest */
  16143. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  16144. /** Trilinear is mag = linear and min = linear and mip = linear */
  16145. static readonly TRILINEAR_SAMPLINGMODE: number;
  16146. /** Trilinear is mag = linear and min = linear and mip = linear */
  16147. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  16148. /** mag = nearest and min = nearest and mip = nearest */
  16149. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  16150. /** mag = nearest and min = linear and mip = nearest */
  16151. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  16152. /** mag = nearest and min = linear and mip = linear */
  16153. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  16154. /** mag = nearest and min = linear and mip = none */
  16155. static readonly NEAREST_LINEAR: number;
  16156. /** mag = nearest and min = nearest and mip = none */
  16157. static readonly NEAREST_NEAREST: number;
  16158. /** mag = linear and min = nearest and mip = nearest */
  16159. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  16160. /** mag = linear and min = nearest and mip = linear */
  16161. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  16162. /** mag = linear and min = linear and mip = none */
  16163. static readonly LINEAR_LINEAR: number;
  16164. /** mag = linear and min = nearest and mip = none */
  16165. static readonly LINEAR_NEAREST: number;
  16166. /** Explicit coordinates mode */
  16167. static readonly EXPLICIT_MODE: number;
  16168. /** Spherical coordinates mode */
  16169. static readonly SPHERICAL_MODE: number;
  16170. /** Planar coordinates mode */
  16171. static readonly PLANAR_MODE: number;
  16172. /** Cubic coordinates mode */
  16173. static readonly CUBIC_MODE: number;
  16174. /** Projection coordinates mode */
  16175. static readonly PROJECTION_MODE: number;
  16176. /** Inverse Cubic coordinates mode */
  16177. static readonly SKYBOX_MODE: number;
  16178. /** Inverse Cubic coordinates mode */
  16179. static readonly INVCUBIC_MODE: number;
  16180. /** Equirectangular coordinates mode */
  16181. static readonly EQUIRECTANGULAR_MODE: number;
  16182. /** Equirectangular Fixed coordinates mode */
  16183. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  16184. /** Equirectangular Fixed Mirrored coordinates mode */
  16185. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  16186. /** Texture is not repeating outside of 0..1 UVs */
  16187. static readonly CLAMP_ADDRESSMODE: number;
  16188. /** Texture is repeating outside of 0..1 UVs */
  16189. static readonly WRAP_ADDRESSMODE: number;
  16190. /** Texture is repeating and mirrored */
  16191. static readonly MIRROR_ADDRESSMODE: number;
  16192. /**
  16193. * 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
  16194. */
  16195. static UseSerializedUrlIfAny: boolean;
  16196. /**
  16197. * Define the url of the texture.
  16198. */
  16199. url: Nullable<string>;
  16200. /**
  16201. * Define an offset on the texture to offset the u coordinates of the UVs
  16202. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16203. */
  16204. uOffset: number;
  16205. /**
  16206. * Define an offset on the texture to offset the v coordinates of the UVs
  16207. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  16208. */
  16209. vOffset: number;
  16210. /**
  16211. * Define an offset on the texture to scale the u coordinates of the UVs
  16212. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16213. */
  16214. uScale: number;
  16215. /**
  16216. * Define an offset on the texture to scale the v coordinates of the UVs
  16217. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  16218. */
  16219. vScale: number;
  16220. /**
  16221. * Define an offset on the texture to rotate around the u coordinates of the UVs
  16222. * @see http://doc.babylonjs.com/how_to/more_materials
  16223. */
  16224. uAng: number;
  16225. /**
  16226. * Define an offset on the texture to rotate around the v coordinates of the UVs
  16227. * @see http://doc.babylonjs.com/how_to/more_materials
  16228. */
  16229. vAng: number;
  16230. /**
  16231. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  16232. * @see http://doc.babylonjs.com/how_to/more_materials
  16233. */
  16234. wAng: number;
  16235. /**
  16236. * Defines the center of rotation (U)
  16237. */
  16238. uRotationCenter: number;
  16239. /**
  16240. * Defines the center of rotation (V)
  16241. */
  16242. vRotationCenter: number;
  16243. /**
  16244. * Defines the center of rotation (W)
  16245. */
  16246. wRotationCenter: number;
  16247. /**
  16248. * Are mip maps generated for this texture or not.
  16249. */
  16250. readonly noMipmap: boolean;
  16251. /**
  16252. * List of inspectable custom properties (used by the Inspector)
  16253. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16254. */
  16255. inspectableCustomProperties: Nullable<IInspectable[]>;
  16256. private _noMipmap;
  16257. /** @hidden */
  16258. _invertY: boolean;
  16259. private _rowGenerationMatrix;
  16260. private _cachedTextureMatrix;
  16261. private _projectionModeMatrix;
  16262. private _t0;
  16263. private _t1;
  16264. private _t2;
  16265. private _cachedUOffset;
  16266. private _cachedVOffset;
  16267. private _cachedUScale;
  16268. private _cachedVScale;
  16269. private _cachedUAng;
  16270. private _cachedVAng;
  16271. private _cachedWAng;
  16272. private _cachedProjectionMatrixId;
  16273. private _cachedCoordinatesMode;
  16274. /** @hidden */
  16275. protected _initialSamplingMode: number;
  16276. /** @hidden */
  16277. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  16278. private _deleteBuffer;
  16279. protected _format: Nullable<number>;
  16280. private _delayedOnLoad;
  16281. private _delayedOnError;
  16282. /**
  16283. * Observable triggered once the texture has been loaded.
  16284. */
  16285. onLoadObservable: Observable<Texture>;
  16286. protected _isBlocking: boolean;
  16287. /**
  16288. * Is the texture preventing material to render while loading.
  16289. * If false, a default texture will be used instead of the loading one during the preparation step.
  16290. */
  16291. isBlocking: boolean;
  16292. /**
  16293. * Get the current sampling mode associated with the texture.
  16294. */
  16295. readonly samplingMode: number;
  16296. /**
  16297. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  16298. */
  16299. readonly invertY: boolean;
  16300. /**
  16301. * Instantiates a new texture.
  16302. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  16303. * @see http://doc.babylonjs.com/babylon101/materials#texture
  16304. * @param url define the url of the picture to load as a texture
  16305. * @param scene define the scene or engine the texture will belong to
  16306. * @param noMipmap define if the texture will require mip maps or not
  16307. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16308. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16309. * @param onLoad define a callback triggered when the texture has been loaded
  16310. * @param onError define a callback triggered when an error occurred during the loading session
  16311. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16312. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16313. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16314. */
  16315. 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);
  16316. /**
  16317. * Update the url (and optional buffer) of this texture if url was null during construction.
  16318. * @param url the url of the texture
  16319. * @param buffer the buffer of the texture (defaults to null)
  16320. * @param onLoad callback called when the texture is loaded (defaults to null)
  16321. */
  16322. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  16323. /**
  16324. * Finish the loading sequence of a texture flagged as delayed load.
  16325. * @hidden
  16326. */
  16327. delayLoad(): void;
  16328. private _prepareRowForTextureGeneration;
  16329. /**
  16330. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  16331. * @returns the transform matrix of the texture.
  16332. */
  16333. getTextureMatrix(): Matrix;
  16334. /**
  16335. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  16336. * @returns The reflection texture transform
  16337. */
  16338. getReflectionTextureMatrix(): Matrix;
  16339. /**
  16340. * Clones the texture.
  16341. * @returns the cloned texture
  16342. */
  16343. clone(): Texture;
  16344. /**
  16345. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  16346. * @returns The JSON representation of the texture
  16347. */
  16348. serialize(): any;
  16349. /**
  16350. * Get the current class name of the texture useful for serialization or dynamic coding.
  16351. * @returns "Texture"
  16352. */
  16353. getClassName(): string;
  16354. /**
  16355. * Dispose the texture and release its associated resources.
  16356. */
  16357. dispose(): void;
  16358. /**
  16359. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  16360. * @param parsedTexture Define the JSON representation of the texture
  16361. * @param scene Define the scene the parsed texture should be instantiated in
  16362. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  16363. * @returns The parsed texture if successful
  16364. */
  16365. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  16366. /**
  16367. * Creates a texture from its base 64 representation.
  16368. * @param data Define the base64 payload without the data: prefix
  16369. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16370. * @param scene Define the scene the texture should belong to
  16371. * @param noMipmap Forces the texture to not create mip map information if true
  16372. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16373. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16374. * @param onLoad define a callback triggered when the texture has been loaded
  16375. * @param onError define a callback triggered when an error occurred during the loading session
  16376. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16377. * @returns the created texture
  16378. */
  16379. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  16380. /**
  16381. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  16382. * @param data Define the base64 payload without the data: prefix
  16383. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  16384. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  16385. * @param scene Define the scene the texture should belong to
  16386. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  16387. * @param noMipmap Forces the texture to not create mip map information if true
  16388. * @param invertY define if the texture needs to be inverted on the y axis during loading
  16389. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  16390. * @param onLoad define a callback triggered when the texture has been loaded
  16391. * @param onError define a callback triggered when an error occurred during the loading session
  16392. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  16393. * @returns the created texture
  16394. */
  16395. 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;
  16396. }
  16397. }
  16398. declare module "babylonjs/PostProcesses/postProcessManager" {
  16399. import { Nullable } from "babylonjs/types";
  16400. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16401. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  16402. import { Scene } from "babylonjs/scene";
  16403. /**
  16404. * PostProcessManager is used to manage one or more post processes or post process pipelines
  16405. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  16406. */
  16407. export class PostProcessManager {
  16408. private _scene;
  16409. private _indexBuffer;
  16410. private _vertexBuffers;
  16411. /**
  16412. * Creates a new instance PostProcess
  16413. * @param scene The scene that the post process is associated with.
  16414. */
  16415. constructor(scene: Scene);
  16416. private _prepareBuffers;
  16417. private _buildIndexBuffer;
  16418. /**
  16419. * Rebuilds the vertex buffers of the manager.
  16420. * @hidden
  16421. */
  16422. _rebuild(): void;
  16423. /**
  16424. * Prepares a frame to be run through a post process.
  16425. * @param sourceTexture The input texture to the post procesess. (default: null)
  16426. * @param postProcesses An array of post processes to be run. (default: null)
  16427. * @returns True if the post processes were able to be run.
  16428. * @hidden
  16429. */
  16430. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  16431. /**
  16432. * Manually render a set of post processes to a texture.
  16433. * @param postProcesses An array of post processes to be run.
  16434. * @param targetTexture The target texture to render to.
  16435. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  16436. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  16437. * @param lodLevel defines which lod of the texture to render to
  16438. */
  16439. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  16440. /**
  16441. * Finalize the result of the output of the postprocesses.
  16442. * @param doNotPresent If true the result will not be displayed to the screen.
  16443. * @param targetTexture The target texture to render to.
  16444. * @param faceIndex The index of the face to bind the target texture to.
  16445. * @param postProcesses The array of post processes to render.
  16446. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  16447. * @hidden
  16448. */
  16449. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  16450. /**
  16451. * Disposes of the post process manager.
  16452. */
  16453. dispose(): void;
  16454. }
  16455. }
  16456. declare module "babylonjs/Misc/gradients" {
  16457. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16458. /** Interface used by value gradients (color, factor, ...) */
  16459. export interface IValueGradient {
  16460. /**
  16461. * Gets or sets the gradient value (between 0 and 1)
  16462. */
  16463. gradient: number;
  16464. }
  16465. /** Class used to store color4 gradient */
  16466. export class ColorGradient implements IValueGradient {
  16467. /**
  16468. * Gets or sets the gradient value (between 0 and 1)
  16469. */
  16470. gradient: number;
  16471. /**
  16472. * Gets or sets first associated color
  16473. */
  16474. color1: Color4;
  16475. /**
  16476. * Gets or sets second associated color
  16477. */
  16478. color2?: Color4;
  16479. /**
  16480. * Will get a color picked randomly between color1 and color2.
  16481. * If color2 is undefined then color1 will be used
  16482. * @param result defines the target Color4 to store the result in
  16483. */
  16484. getColorToRef(result: Color4): void;
  16485. }
  16486. /** Class used to store color 3 gradient */
  16487. export class Color3Gradient implements IValueGradient {
  16488. /**
  16489. * Gets or sets the gradient value (between 0 and 1)
  16490. */
  16491. gradient: number;
  16492. /**
  16493. * Gets or sets the associated color
  16494. */
  16495. color: Color3;
  16496. }
  16497. /** Class used to store factor gradient */
  16498. export class FactorGradient implements IValueGradient {
  16499. /**
  16500. * Gets or sets the gradient value (between 0 and 1)
  16501. */
  16502. gradient: number;
  16503. /**
  16504. * Gets or sets first associated factor
  16505. */
  16506. factor1: number;
  16507. /**
  16508. * Gets or sets second associated factor
  16509. */
  16510. factor2?: number;
  16511. /**
  16512. * Will get a number picked randomly between factor1 and factor2.
  16513. * If factor2 is undefined then factor1 will be used
  16514. * @returns the picked number
  16515. */
  16516. getFactor(): number;
  16517. }
  16518. /**
  16519. * Helper used to simplify some generic gradient tasks
  16520. */
  16521. export class GradientHelper {
  16522. /**
  16523. * Gets the current gradient from an array of IValueGradient
  16524. * @param ratio defines the current ratio to get
  16525. * @param gradients defines the array of IValueGradient
  16526. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  16527. */
  16528. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  16529. }
  16530. }
  16531. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  16532. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16533. import { Nullable } from "babylonjs/types";
  16534. module "babylonjs/Engines/thinEngine" {
  16535. interface ThinEngine {
  16536. /**
  16537. * Creates a dynamic texture
  16538. * @param width defines the width of the texture
  16539. * @param height defines the height of the texture
  16540. * @param generateMipMaps defines if the engine should generate the mip levels
  16541. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  16542. * @returns the dynamic texture inside an InternalTexture
  16543. */
  16544. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  16545. /**
  16546. * Update the content of a dynamic texture
  16547. * @param texture defines the texture to update
  16548. * @param canvas defines the canvas containing the source
  16549. * @param invertY defines if data must be stored with Y axis inverted
  16550. * @param premulAlpha defines if alpha is stored as premultiplied
  16551. * @param format defines the format of the data
  16552. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  16553. */
  16554. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  16555. }
  16556. }
  16557. }
  16558. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  16559. import { Scene } from "babylonjs/scene";
  16560. import { Texture } from "babylonjs/Materials/Textures/texture";
  16561. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  16562. /**
  16563. * A class extending Texture allowing drawing on a texture
  16564. * @see http://doc.babylonjs.com/how_to/dynamictexture
  16565. */
  16566. export class DynamicTexture extends Texture {
  16567. private _generateMipMaps;
  16568. private _canvas;
  16569. private _context;
  16570. private _engine;
  16571. /**
  16572. * Creates a DynamicTexture
  16573. * @param name defines the name of the texture
  16574. * @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
  16575. * @param scene defines the scene where you want the texture
  16576. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  16577. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  16578. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  16579. */
  16580. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  16581. /**
  16582. * Get the current class name of the texture useful for serialization or dynamic coding.
  16583. * @returns "DynamicTexture"
  16584. */
  16585. getClassName(): string;
  16586. /**
  16587. * Gets the current state of canRescale
  16588. */
  16589. readonly canRescale: boolean;
  16590. private _recreate;
  16591. /**
  16592. * Scales the texture
  16593. * @param ratio the scale factor to apply to both width and height
  16594. */
  16595. scale(ratio: number): void;
  16596. /**
  16597. * Resizes the texture
  16598. * @param width the new width
  16599. * @param height the new height
  16600. */
  16601. scaleTo(width: number, height: number): void;
  16602. /**
  16603. * Gets the context of the canvas used by the texture
  16604. * @returns the canvas context of the dynamic texture
  16605. */
  16606. getContext(): CanvasRenderingContext2D;
  16607. /**
  16608. * Clears the texture
  16609. */
  16610. clear(): void;
  16611. /**
  16612. * Updates the texture
  16613. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16614. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  16615. */
  16616. update(invertY?: boolean, premulAlpha?: boolean): void;
  16617. /**
  16618. * Draws text onto the texture
  16619. * @param text defines the text to be drawn
  16620. * @param x defines the placement of the text from the left
  16621. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  16622. * @param font defines the font to be used with font-style, font-size, font-name
  16623. * @param color defines the color used for the text
  16624. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  16625. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  16626. * @param update defines whether texture is immediately update (default is true)
  16627. */
  16628. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  16629. /**
  16630. * Clones the texture
  16631. * @returns the clone of the texture.
  16632. */
  16633. clone(): DynamicTexture;
  16634. /**
  16635. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  16636. * @returns a serialized dynamic texture object
  16637. */
  16638. serialize(): any;
  16639. /** @hidden */
  16640. _rebuild(): void;
  16641. }
  16642. }
  16643. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  16644. import { Scene } from "babylonjs/scene";
  16645. import { ISceneComponent } from "babylonjs/sceneComponent";
  16646. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16647. module "babylonjs/abstractScene" {
  16648. interface AbstractScene {
  16649. /**
  16650. * The list of procedural textures added to the scene
  16651. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16652. */
  16653. proceduralTextures: Array<ProceduralTexture>;
  16654. }
  16655. }
  16656. /**
  16657. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  16658. * in a given scene.
  16659. */
  16660. export class ProceduralTextureSceneComponent implements ISceneComponent {
  16661. /**
  16662. * The component name helpfull to identify the component in the list of scene components.
  16663. */
  16664. readonly name: string;
  16665. /**
  16666. * The scene the component belongs to.
  16667. */
  16668. scene: Scene;
  16669. /**
  16670. * Creates a new instance of the component for the given scene
  16671. * @param scene Defines the scene to register the component in
  16672. */
  16673. constructor(scene: Scene);
  16674. /**
  16675. * Registers the component in a given scene
  16676. */
  16677. register(): void;
  16678. /**
  16679. * Rebuilds the elements related to this component in case of
  16680. * context lost for instance.
  16681. */
  16682. rebuild(): void;
  16683. /**
  16684. * Disposes the component and the associated ressources.
  16685. */
  16686. dispose(): void;
  16687. private _beforeClear;
  16688. }
  16689. }
  16690. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  16691. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  16692. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  16693. module "babylonjs/Engines/thinEngine" {
  16694. interface ThinEngine {
  16695. /**
  16696. * Creates a new render target cube texture
  16697. * @param size defines the size of the texture
  16698. * @param options defines the options used to create the texture
  16699. * @returns a new render target cube texture stored in an InternalTexture
  16700. */
  16701. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  16702. }
  16703. }
  16704. }
  16705. declare module "babylonjs/Shaders/procedural.vertex" {
  16706. /** @hidden */
  16707. export var proceduralVertexShader: {
  16708. name: string;
  16709. shader: string;
  16710. };
  16711. }
  16712. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  16713. import { Observable } from "babylonjs/Misc/observable";
  16714. import { Nullable } from "babylonjs/types";
  16715. import { Scene } from "babylonjs/scene";
  16716. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  16717. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  16718. import { Effect } from "babylonjs/Materials/effect";
  16719. import { Texture } from "babylonjs/Materials/Textures/texture";
  16720. import "babylonjs/Engines/Extensions/engine.renderTarget";
  16721. import "babylonjs/Shaders/procedural.vertex";
  16722. /**
  16723. * 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.
  16724. * This is the base class of any Procedural texture and contains most of the shareable code.
  16725. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16726. */
  16727. export class ProceduralTexture extends Texture {
  16728. isCube: boolean;
  16729. /**
  16730. * Define if the texture is enabled or not (disabled texture will not render)
  16731. */
  16732. isEnabled: boolean;
  16733. /**
  16734. * Define if the texture must be cleared before rendering (default is true)
  16735. */
  16736. autoClear: boolean;
  16737. /**
  16738. * Callback called when the texture is generated
  16739. */
  16740. onGenerated: () => void;
  16741. /**
  16742. * Event raised when the texture is generated
  16743. */
  16744. onGeneratedObservable: Observable<ProceduralTexture>;
  16745. /** @hidden */
  16746. _generateMipMaps: boolean;
  16747. /** @hidden **/
  16748. _effect: Effect;
  16749. /** @hidden */
  16750. _textures: {
  16751. [key: string]: Texture;
  16752. };
  16753. private _size;
  16754. private _currentRefreshId;
  16755. private _refreshRate;
  16756. private _vertexBuffers;
  16757. private _indexBuffer;
  16758. private _uniforms;
  16759. private _samplers;
  16760. private _fragment;
  16761. private _floats;
  16762. private _ints;
  16763. private _floatsArrays;
  16764. private _colors3;
  16765. private _colors4;
  16766. private _vectors2;
  16767. private _vectors3;
  16768. private _matrices;
  16769. private _fallbackTexture;
  16770. private _fallbackTextureUsed;
  16771. private _engine;
  16772. private _cachedDefines;
  16773. private _contentUpdateId;
  16774. private _contentData;
  16775. /**
  16776. * Instantiates a new procedural texture.
  16777. * 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.
  16778. * This is the base class of any Procedural texture and contains most of the shareable code.
  16779. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  16780. * @param name Define the name of the texture
  16781. * @param size Define the size of the texture to create
  16782. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  16783. * @param scene Define the scene the texture belongs to
  16784. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  16785. * @param generateMipMaps Define if the texture should creates mip maps or not
  16786. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  16787. */
  16788. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  16789. /**
  16790. * The effect that is created when initializing the post process.
  16791. * @returns The created effect corresponding the the postprocess.
  16792. */
  16793. getEffect(): Effect;
  16794. /**
  16795. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  16796. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  16797. */
  16798. getContent(): Nullable<ArrayBufferView>;
  16799. private _createIndexBuffer;
  16800. /** @hidden */
  16801. _rebuild(): void;
  16802. /**
  16803. * Resets the texture in order to recreate its associated resources.
  16804. * This can be called in case of context loss
  16805. */
  16806. reset(): void;
  16807. protected _getDefines(): string;
  16808. /**
  16809. * Is the texture ready to be used ? (rendered at least once)
  16810. * @returns true if ready, otherwise, false.
  16811. */
  16812. isReady(): boolean;
  16813. /**
  16814. * Resets the refresh counter of the texture and start bak from scratch.
  16815. * Could be useful to regenerate the texture if it is setup to render only once.
  16816. */
  16817. resetRefreshCounter(): void;
  16818. /**
  16819. * Set the fragment shader to use in order to render the texture.
  16820. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  16821. */
  16822. setFragment(fragment: any): void;
  16823. /**
  16824. * Define the refresh rate of the texture or the rendering frequency.
  16825. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  16826. */
  16827. refreshRate: number;
  16828. /** @hidden */
  16829. _shouldRender(): boolean;
  16830. /**
  16831. * Get the size the texture is rendering at.
  16832. * @returns the size (texture is always squared)
  16833. */
  16834. getRenderSize(): number;
  16835. /**
  16836. * Resize the texture to new value.
  16837. * @param size Define the new size the texture should have
  16838. * @param generateMipMaps Define whether the new texture should create mip maps
  16839. */
  16840. resize(size: number, generateMipMaps: boolean): void;
  16841. private _checkUniform;
  16842. /**
  16843. * Set a texture in the shader program used to render.
  16844. * @param name Define the name of the uniform samplers as defined in the shader
  16845. * @param texture Define the texture to bind to this sampler
  16846. * @return the texture itself allowing "fluent" like uniform updates
  16847. */
  16848. setTexture(name: string, texture: Texture): ProceduralTexture;
  16849. /**
  16850. * Set a float in the shader.
  16851. * @param name Define the name of the uniform as defined in the shader
  16852. * @param value Define the value to give to the uniform
  16853. * @return the texture itself allowing "fluent" like uniform updates
  16854. */
  16855. setFloat(name: string, value: number): ProceduralTexture;
  16856. /**
  16857. * Set a int in the shader.
  16858. * @param name Define the name of the uniform as defined in the shader
  16859. * @param value Define the value to give to the uniform
  16860. * @return the texture itself allowing "fluent" like uniform updates
  16861. */
  16862. setInt(name: string, value: number): ProceduralTexture;
  16863. /**
  16864. * Set an array of floats in the shader.
  16865. * @param name Define the name of the uniform as defined in the shader
  16866. * @param value Define the value to give to the uniform
  16867. * @return the texture itself allowing "fluent" like uniform updates
  16868. */
  16869. setFloats(name: string, value: number[]): ProceduralTexture;
  16870. /**
  16871. * Set a vec3 in the shader from a Color3.
  16872. * @param name Define the name of the uniform as defined in the shader
  16873. * @param value Define the value to give to the uniform
  16874. * @return the texture itself allowing "fluent" like uniform updates
  16875. */
  16876. setColor3(name: string, value: Color3): ProceduralTexture;
  16877. /**
  16878. * Set a vec4 in the shader from a Color4.
  16879. * @param name Define the name of the uniform as defined in the shader
  16880. * @param value Define the value to give to the uniform
  16881. * @return the texture itself allowing "fluent" like uniform updates
  16882. */
  16883. setColor4(name: string, value: Color4): ProceduralTexture;
  16884. /**
  16885. * Set a vec2 in the shader from a Vector2.
  16886. * @param name Define the name of the uniform as defined in the shader
  16887. * @param value Define the value to give to the uniform
  16888. * @return the texture itself allowing "fluent" like uniform updates
  16889. */
  16890. setVector2(name: string, value: Vector2): ProceduralTexture;
  16891. /**
  16892. * Set a vec3 in the shader from a Vector3.
  16893. * @param name Define the name of the uniform as defined in the shader
  16894. * @param value Define the value to give to the uniform
  16895. * @return the texture itself allowing "fluent" like uniform updates
  16896. */
  16897. setVector3(name: string, value: Vector3): ProceduralTexture;
  16898. /**
  16899. * Set a mat4 in the shader from a MAtrix.
  16900. * @param name Define the name of the uniform as defined in the shader
  16901. * @param value Define the value to give to the uniform
  16902. * @return the texture itself allowing "fluent" like uniform updates
  16903. */
  16904. setMatrix(name: string, value: Matrix): ProceduralTexture;
  16905. /**
  16906. * Render the texture to its associated render target.
  16907. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  16908. */
  16909. render(useCameraPostProcess?: boolean): void;
  16910. /**
  16911. * Clone the texture.
  16912. * @returns the cloned texture
  16913. */
  16914. clone(): ProceduralTexture;
  16915. /**
  16916. * Dispose the texture and release its asoociated resources.
  16917. */
  16918. dispose(): void;
  16919. }
  16920. }
  16921. declare module "babylonjs/Particles/baseParticleSystem" {
  16922. import { Nullable } from "babylonjs/types";
  16923. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  16924. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16925. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  16926. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  16927. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16928. import { Scene } from "babylonjs/scene";
  16929. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  16930. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16931. import { Texture } from "babylonjs/Materials/Textures/texture";
  16932. import { Color4 } from "babylonjs/Maths/math.color";
  16933. import { Animation } from "babylonjs/Animations/animation";
  16934. /**
  16935. * This represents the base class for particle system in Babylon.
  16936. * 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.
  16937. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  16938. * @example https://doc.babylonjs.com/babylon101/particles
  16939. */
  16940. export class BaseParticleSystem {
  16941. /**
  16942. * Source color is added to the destination color without alpha affecting the result
  16943. */
  16944. static BLENDMODE_ONEONE: number;
  16945. /**
  16946. * Blend current color and particle color using particle’s alpha
  16947. */
  16948. static BLENDMODE_STANDARD: number;
  16949. /**
  16950. * Add current color and particle color multiplied by particle’s alpha
  16951. */
  16952. static BLENDMODE_ADD: number;
  16953. /**
  16954. * Multiply current color with particle color
  16955. */
  16956. static BLENDMODE_MULTIPLY: number;
  16957. /**
  16958. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  16959. */
  16960. static BLENDMODE_MULTIPLYADD: number;
  16961. /**
  16962. * List of animations used by the particle system.
  16963. */
  16964. animations: Animation[];
  16965. /**
  16966. * The id of the Particle system.
  16967. */
  16968. id: string;
  16969. /**
  16970. * The friendly name of the Particle system.
  16971. */
  16972. name: string;
  16973. /**
  16974. * The rendering group used by the Particle system to chose when to render.
  16975. */
  16976. renderingGroupId: number;
  16977. /**
  16978. * The emitter represents the Mesh or position we are attaching the particle system to.
  16979. */
  16980. emitter: Nullable<AbstractMesh | Vector3>;
  16981. /**
  16982. * The maximum number of particles to emit per frame
  16983. */
  16984. emitRate: number;
  16985. /**
  16986. * If you want to launch only a few particles at once, that can be done, as well.
  16987. */
  16988. manualEmitCount: number;
  16989. /**
  16990. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16991. */
  16992. updateSpeed: number;
  16993. /**
  16994. * The amount of time the particle system is running (depends of the overall update speed).
  16995. */
  16996. targetStopDuration: number;
  16997. /**
  16998. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16999. */
  17000. disposeOnStop: boolean;
  17001. /**
  17002. * Minimum power of emitting particles.
  17003. */
  17004. minEmitPower: number;
  17005. /**
  17006. * Maximum power of emitting particles.
  17007. */
  17008. maxEmitPower: number;
  17009. /**
  17010. * Minimum life time of emitting particles.
  17011. */
  17012. minLifeTime: number;
  17013. /**
  17014. * Maximum life time of emitting particles.
  17015. */
  17016. maxLifeTime: number;
  17017. /**
  17018. * Minimum Size of emitting particles.
  17019. */
  17020. minSize: number;
  17021. /**
  17022. * Maximum Size of emitting particles.
  17023. */
  17024. maxSize: number;
  17025. /**
  17026. * Minimum scale of emitting particles on X axis.
  17027. */
  17028. minScaleX: number;
  17029. /**
  17030. * Maximum scale of emitting particles on X axis.
  17031. */
  17032. maxScaleX: number;
  17033. /**
  17034. * Minimum scale of emitting particles on Y axis.
  17035. */
  17036. minScaleY: number;
  17037. /**
  17038. * Maximum scale of emitting particles on Y axis.
  17039. */
  17040. maxScaleY: number;
  17041. /**
  17042. * Gets or sets the minimal initial rotation in radians.
  17043. */
  17044. minInitialRotation: number;
  17045. /**
  17046. * Gets or sets the maximal initial rotation in radians.
  17047. */
  17048. maxInitialRotation: number;
  17049. /**
  17050. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  17051. */
  17052. minAngularSpeed: number;
  17053. /**
  17054. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  17055. */
  17056. maxAngularSpeed: number;
  17057. /**
  17058. * The texture used to render each particle. (this can be a spritesheet)
  17059. */
  17060. particleTexture: Nullable<Texture>;
  17061. /**
  17062. * The layer mask we are rendering the particles through.
  17063. */
  17064. layerMask: number;
  17065. /**
  17066. * This can help using your own shader to render the particle system.
  17067. * The according effect will be created
  17068. */
  17069. customShader: any;
  17070. /**
  17071. * By default particle system starts as soon as they are created. This prevents the
  17072. * automatic start to happen and let you decide when to start emitting particles.
  17073. */
  17074. preventAutoStart: boolean;
  17075. private _noiseTexture;
  17076. /**
  17077. * Gets or sets a texture used to add random noise to particle positions
  17078. */
  17079. noiseTexture: Nullable<ProceduralTexture>;
  17080. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  17081. noiseStrength: Vector3;
  17082. /**
  17083. * Callback triggered when the particle animation is ending.
  17084. */
  17085. onAnimationEnd: Nullable<() => void>;
  17086. /**
  17087. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  17088. */
  17089. blendMode: number;
  17090. /**
  17091. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  17092. * to override the particles.
  17093. */
  17094. forceDepthWrite: boolean;
  17095. /** 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 */
  17096. preWarmCycles: number;
  17097. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  17098. preWarmStepOffset: number;
  17099. /**
  17100. * 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)
  17101. */
  17102. spriteCellChangeSpeed: number;
  17103. /**
  17104. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  17105. */
  17106. startSpriteCellID: number;
  17107. /**
  17108. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  17109. */
  17110. endSpriteCellID: number;
  17111. /**
  17112. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  17113. */
  17114. spriteCellWidth: number;
  17115. /**
  17116. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  17117. */
  17118. spriteCellHeight: number;
  17119. /**
  17120. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  17121. */
  17122. spriteRandomStartCell: boolean;
  17123. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  17124. translationPivot: Vector2;
  17125. /** @hidden */
  17126. protected _isAnimationSheetEnabled: boolean;
  17127. /**
  17128. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  17129. */
  17130. beginAnimationOnStart: boolean;
  17131. /**
  17132. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  17133. */
  17134. beginAnimationFrom: number;
  17135. /**
  17136. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  17137. */
  17138. beginAnimationTo: number;
  17139. /**
  17140. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  17141. */
  17142. beginAnimationLoop: boolean;
  17143. /**
  17144. * Gets or sets a world offset applied to all particles
  17145. */
  17146. worldOffset: Vector3;
  17147. /**
  17148. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  17149. */
  17150. isAnimationSheetEnabled: boolean;
  17151. /**
  17152. * Get hosting scene
  17153. * @returns the scene
  17154. */
  17155. getScene(): Scene;
  17156. /**
  17157. * You can use gravity if you want to give an orientation to your particles.
  17158. */
  17159. gravity: Vector3;
  17160. protected _colorGradients: Nullable<Array<ColorGradient>>;
  17161. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  17162. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  17163. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  17164. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  17165. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  17166. protected _dragGradients: Nullable<Array<FactorGradient>>;
  17167. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  17168. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  17169. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  17170. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  17171. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  17172. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  17173. /**
  17174. * Defines the delay in milliseconds before starting the system (0 by default)
  17175. */
  17176. startDelay: number;
  17177. /**
  17178. * Gets the current list of drag gradients.
  17179. * You must use addDragGradient and removeDragGradient to udpate this list
  17180. * @returns the list of drag gradients
  17181. */
  17182. getDragGradients(): Nullable<Array<FactorGradient>>;
  17183. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  17184. limitVelocityDamping: number;
  17185. /**
  17186. * Gets the current list of limit velocity gradients.
  17187. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  17188. * @returns the list of limit velocity gradients
  17189. */
  17190. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  17191. /**
  17192. * Gets the current list of color gradients.
  17193. * You must use addColorGradient and removeColorGradient to udpate this list
  17194. * @returns the list of color gradients
  17195. */
  17196. getColorGradients(): Nullable<Array<ColorGradient>>;
  17197. /**
  17198. * Gets the current list of size gradients.
  17199. * You must use addSizeGradient and removeSizeGradient to udpate this list
  17200. * @returns the list of size gradients
  17201. */
  17202. getSizeGradients(): Nullable<Array<FactorGradient>>;
  17203. /**
  17204. * Gets the current list of color remap gradients.
  17205. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  17206. * @returns the list of color remap gradients
  17207. */
  17208. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  17209. /**
  17210. * Gets the current list of alpha remap gradients.
  17211. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  17212. * @returns the list of alpha remap gradients
  17213. */
  17214. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  17215. /**
  17216. * Gets the current list of life time gradients.
  17217. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  17218. * @returns the list of life time gradients
  17219. */
  17220. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  17221. /**
  17222. * Gets the current list of angular speed gradients.
  17223. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  17224. * @returns the list of angular speed gradients
  17225. */
  17226. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  17227. /**
  17228. * Gets the current list of velocity gradients.
  17229. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  17230. * @returns the list of velocity gradients
  17231. */
  17232. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  17233. /**
  17234. * Gets the current list of start size gradients.
  17235. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  17236. * @returns the list of start size gradients
  17237. */
  17238. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  17239. /**
  17240. * Gets the current list of emit rate gradients.
  17241. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  17242. * @returns the list of emit rate gradients
  17243. */
  17244. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  17245. /**
  17246. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17247. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17248. */
  17249. direction1: Vector3;
  17250. /**
  17251. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  17252. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17253. */
  17254. direction2: Vector3;
  17255. /**
  17256. * 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.
  17257. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17258. */
  17259. minEmitBox: Vector3;
  17260. /**
  17261. * 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.
  17262. * This only works when particleEmitterTyps is a BoxParticleEmitter
  17263. */
  17264. maxEmitBox: Vector3;
  17265. /**
  17266. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17267. */
  17268. color1: Color4;
  17269. /**
  17270. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  17271. */
  17272. color2: Color4;
  17273. /**
  17274. * Color the particle will have at the end of its lifetime
  17275. */
  17276. colorDead: Color4;
  17277. /**
  17278. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  17279. */
  17280. textureMask: Color4;
  17281. /**
  17282. * The particle emitter type defines the emitter used by the particle system.
  17283. * It can be for example box, sphere, or cone...
  17284. */
  17285. particleEmitterType: IParticleEmitterType;
  17286. /** @hidden */
  17287. _isSubEmitter: boolean;
  17288. /**
  17289. * Gets or sets the billboard mode to use when isBillboardBased = true.
  17290. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  17291. */
  17292. billboardMode: number;
  17293. protected _isBillboardBased: boolean;
  17294. /**
  17295. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  17296. */
  17297. isBillboardBased: boolean;
  17298. /**
  17299. * The scene the particle system belongs to.
  17300. */
  17301. protected _scene: Scene;
  17302. /**
  17303. * Local cache of defines for image processing.
  17304. */
  17305. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  17306. /**
  17307. * Default configuration related to image processing available in the standard Material.
  17308. */
  17309. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  17310. /**
  17311. * Gets the image processing configuration used either in this material.
  17312. */
  17313. /**
  17314. * Sets the Default image processing configuration used either in the this material.
  17315. *
  17316. * If sets to null, the scene one is in use.
  17317. */
  17318. imageProcessingConfiguration: ImageProcessingConfiguration;
  17319. /**
  17320. * Attaches a new image processing configuration to the Standard Material.
  17321. * @param configuration
  17322. */
  17323. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  17324. /** @hidden */
  17325. protected _reset(): void;
  17326. /** @hidden */
  17327. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  17328. /**
  17329. * Instantiates a particle system.
  17330. * 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.
  17331. * @param name The name of the particle system
  17332. */
  17333. constructor(name: string);
  17334. /**
  17335. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  17336. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17337. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17338. * @returns the emitter
  17339. */
  17340. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  17341. /**
  17342. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  17343. * @param radius The radius of the hemisphere to emit from
  17344. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17345. * @returns the emitter
  17346. */
  17347. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  17348. /**
  17349. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  17350. * @param radius The radius of the sphere to emit from
  17351. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  17352. * @returns the emitter
  17353. */
  17354. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  17355. /**
  17356. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  17357. * @param radius The radius of the sphere to emit from
  17358. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  17359. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  17360. * @returns the emitter
  17361. */
  17362. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  17363. /**
  17364. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  17365. * @param radius The radius of the emission cylinder
  17366. * @param height The height of the emission cylinder
  17367. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  17368. * @param directionRandomizer How much to randomize the particle direction [0-1]
  17369. * @returns the emitter
  17370. */
  17371. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  17372. /**
  17373. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  17374. * @param radius The radius of the cylinder to emit from
  17375. * @param height The height of the emission cylinder
  17376. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  17377. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  17378. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  17379. * @returns the emitter
  17380. */
  17381. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  17382. /**
  17383. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  17384. * @param radius The radius of the cone to emit from
  17385. * @param angle The base angle of the cone
  17386. * @returns the emitter
  17387. */
  17388. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  17389. /**
  17390. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  17391. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  17392. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  17393. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17394. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  17395. * @returns the emitter
  17396. */
  17397. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  17398. }
  17399. }
  17400. declare module "babylonjs/Particles/subEmitter" {
  17401. import { Scene } from "babylonjs/scene";
  17402. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17403. /**
  17404. * Type of sub emitter
  17405. */
  17406. export enum SubEmitterType {
  17407. /**
  17408. * Attached to the particle over it's lifetime
  17409. */
  17410. ATTACHED = 0,
  17411. /**
  17412. * Created when the particle dies
  17413. */
  17414. END = 1
  17415. }
  17416. /**
  17417. * Sub emitter class used to emit particles from an existing particle
  17418. */
  17419. export class SubEmitter {
  17420. /**
  17421. * the particle system to be used by the sub emitter
  17422. */
  17423. particleSystem: ParticleSystem;
  17424. /**
  17425. * Type of the submitter (Default: END)
  17426. */
  17427. type: SubEmitterType;
  17428. /**
  17429. * 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)
  17430. * Note: This only is supported when using an emitter of type Mesh
  17431. */
  17432. inheritDirection: boolean;
  17433. /**
  17434. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  17435. */
  17436. inheritedVelocityAmount: number;
  17437. /**
  17438. * Creates a sub emitter
  17439. * @param particleSystem the particle system to be used by the sub emitter
  17440. */
  17441. constructor(
  17442. /**
  17443. * the particle system to be used by the sub emitter
  17444. */
  17445. particleSystem: ParticleSystem);
  17446. /**
  17447. * Clones the sub emitter
  17448. * @returns the cloned sub emitter
  17449. */
  17450. clone(): SubEmitter;
  17451. /**
  17452. * Serialize current object to a JSON object
  17453. * @returns the serialized object
  17454. */
  17455. serialize(): any;
  17456. /** @hidden */
  17457. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  17458. /**
  17459. * Creates a new SubEmitter from a serialized JSON version
  17460. * @param serializationObject defines the JSON object to read from
  17461. * @param scene defines the hosting scene
  17462. * @param rootUrl defines the rootUrl for data loading
  17463. * @returns a new SubEmitter
  17464. */
  17465. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  17466. /** Release associated resources */
  17467. dispose(): void;
  17468. }
  17469. }
  17470. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  17471. /** @hidden */
  17472. export var clipPlaneFragmentDeclaration: {
  17473. name: string;
  17474. shader: string;
  17475. };
  17476. }
  17477. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  17478. /** @hidden */
  17479. export var imageProcessingDeclaration: {
  17480. name: string;
  17481. shader: string;
  17482. };
  17483. }
  17484. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  17485. /** @hidden */
  17486. export var imageProcessingFunctions: {
  17487. name: string;
  17488. shader: string;
  17489. };
  17490. }
  17491. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  17492. /** @hidden */
  17493. export var clipPlaneFragment: {
  17494. name: string;
  17495. shader: string;
  17496. };
  17497. }
  17498. declare module "babylonjs/Shaders/particles.fragment" {
  17499. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17500. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  17501. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  17502. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  17503. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17504. /** @hidden */
  17505. export var particlesPixelShader: {
  17506. name: string;
  17507. shader: string;
  17508. };
  17509. }
  17510. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  17511. /** @hidden */
  17512. export var clipPlaneVertexDeclaration: {
  17513. name: string;
  17514. shader: string;
  17515. };
  17516. }
  17517. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  17518. /** @hidden */
  17519. export var clipPlaneVertex: {
  17520. name: string;
  17521. shader: string;
  17522. };
  17523. }
  17524. declare module "babylonjs/Shaders/particles.vertex" {
  17525. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17526. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17527. /** @hidden */
  17528. export var particlesVertexShader: {
  17529. name: string;
  17530. shader: string;
  17531. };
  17532. }
  17533. declare module "babylonjs/Particles/particleSystem" {
  17534. import { Nullable } from "babylonjs/types";
  17535. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  17536. import { Observable } from "babylonjs/Misc/observable";
  17537. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17538. import { Effect } from "babylonjs/Materials/effect";
  17539. import { Scene, IDisposable } from "babylonjs/scene";
  17540. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17541. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  17542. import { Particle } from "babylonjs/Particles/particle";
  17543. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17544. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  17545. import "babylonjs/Shaders/particles.fragment";
  17546. import "babylonjs/Shaders/particles.vertex";
  17547. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  17548. /**
  17549. * This represents a particle system in Babylon.
  17550. * 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.
  17551. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  17552. * @example https://doc.babylonjs.com/babylon101/particles
  17553. */
  17554. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  17555. /**
  17556. * Billboard mode will only apply to Y axis
  17557. */
  17558. static readonly BILLBOARDMODE_Y: number;
  17559. /**
  17560. * Billboard mode will apply to all axes
  17561. */
  17562. static readonly BILLBOARDMODE_ALL: number;
  17563. /**
  17564. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  17565. */
  17566. static readonly BILLBOARDMODE_STRETCHED: number;
  17567. /**
  17568. * This function can be defined to provide custom update for active particles.
  17569. * This function will be called instead of regular update (age, position, color, etc.).
  17570. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  17571. */
  17572. updateFunction: (particles: Particle[]) => void;
  17573. private _emitterWorldMatrix;
  17574. /**
  17575. * This function can be defined to specify initial direction for every new particle.
  17576. * It by default use the emitterType defined function
  17577. */
  17578. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  17579. /**
  17580. * This function can be defined to specify initial position for every new particle.
  17581. * It by default use the emitterType defined function
  17582. */
  17583. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  17584. /**
  17585. * @hidden
  17586. */
  17587. _inheritedVelocityOffset: Vector3;
  17588. /**
  17589. * An event triggered when the system is disposed
  17590. */
  17591. onDisposeObservable: Observable<ParticleSystem>;
  17592. private _onDisposeObserver;
  17593. /**
  17594. * Sets a callback that will be triggered when the system is disposed
  17595. */
  17596. onDispose: () => void;
  17597. private _particles;
  17598. private _epsilon;
  17599. private _capacity;
  17600. private _stockParticles;
  17601. private _newPartsExcess;
  17602. private _vertexData;
  17603. private _vertexBuffer;
  17604. private _vertexBuffers;
  17605. private _spriteBuffer;
  17606. private _indexBuffer;
  17607. private _effect;
  17608. private _customEffect;
  17609. private _cachedDefines;
  17610. private _scaledColorStep;
  17611. private _colorDiff;
  17612. private _scaledDirection;
  17613. private _scaledGravity;
  17614. private _currentRenderId;
  17615. private _alive;
  17616. private _useInstancing;
  17617. private _started;
  17618. private _stopped;
  17619. private _actualFrame;
  17620. private _scaledUpdateSpeed;
  17621. private _vertexBufferSize;
  17622. /** @hidden */
  17623. _currentEmitRateGradient: Nullable<FactorGradient>;
  17624. /** @hidden */
  17625. _currentEmitRate1: number;
  17626. /** @hidden */
  17627. _currentEmitRate2: number;
  17628. /** @hidden */
  17629. _currentStartSizeGradient: Nullable<FactorGradient>;
  17630. /** @hidden */
  17631. _currentStartSize1: number;
  17632. /** @hidden */
  17633. _currentStartSize2: number;
  17634. private readonly _rawTextureWidth;
  17635. private _rampGradientsTexture;
  17636. private _useRampGradients;
  17637. /** Gets or sets a boolean indicating that ramp gradients must be used
  17638. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  17639. */
  17640. useRampGradients: boolean;
  17641. /**
  17642. * 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.
  17643. * 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: [])
  17644. */
  17645. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  17646. private _subEmitters;
  17647. /**
  17648. * @hidden
  17649. * If the particle systems emitter should be disposed when the particle system is disposed
  17650. */
  17651. _disposeEmitterOnDispose: boolean;
  17652. /**
  17653. * The current active Sub-systems, this property is used by the root particle system only.
  17654. */
  17655. activeSubSystems: Array<ParticleSystem>;
  17656. private _rootParticleSystem;
  17657. /**
  17658. * Gets the current list of active particles
  17659. */
  17660. readonly particles: Particle[];
  17661. /**
  17662. * Returns the string "ParticleSystem"
  17663. * @returns a string containing the class name
  17664. */
  17665. getClassName(): string;
  17666. /**
  17667. * Instantiates a particle system.
  17668. * 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.
  17669. * @param name The name of the particle system
  17670. * @param capacity The max number of particles alive at the same time
  17671. * @param scene The scene the particle system belongs to
  17672. * @param customEffect a custom effect used to change the way particles are rendered by default
  17673. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  17674. * @param epsilon Offset used to render the particles
  17675. */
  17676. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  17677. private _addFactorGradient;
  17678. private _removeFactorGradient;
  17679. /**
  17680. * Adds a new life time gradient
  17681. * @param gradient defines the gradient to use (between 0 and 1)
  17682. * @param factor defines the life time factor to affect to the specified gradient
  17683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17684. * @returns the current particle system
  17685. */
  17686. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17687. /**
  17688. * Remove a specific life time gradient
  17689. * @param gradient defines the gradient to remove
  17690. * @returns the current particle system
  17691. */
  17692. removeLifeTimeGradient(gradient: number): IParticleSystem;
  17693. /**
  17694. * Adds a new size gradient
  17695. * @param gradient defines the gradient to use (between 0 and 1)
  17696. * @param factor defines the size factor to affect to the specified gradient
  17697. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17698. * @returns the current particle system
  17699. */
  17700. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17701. /**
  17702. * Remove a specific size gradient
  17703. * @param gradient defines the gradient to remove
  17704. * @returns the current particle system
  17705. */
  17706. removeSizeGradient(gradient: number): IParticleSystem;
  17707. /**
  17708. * Adds a new color remap gradient
  17709. * @param gradient defines the gradient to use (between 0 and 1)
  17710. * @param min defines the color remap minimal range
  17711. * @param max defines the color remap maximal range
  17712. * @returns the current particle system
  17713. */
  17714. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17715. /**
  17716. * Remove a specific color remap gradient
  17717. * @param gradient defines the gradient to remove
  17718. * @returns the current particle system
  17719. */
  17720. removeColorRemapGradient(gradient: number): IParticleSystem;
  17721. /**
  17722. * Adds a new alpha remap gradient
  17723. * @param gradient defines the gradient to use (between 0 and 1)
  17724. * @param min defines the alpha remap minimal range
  17725. * @param max defines the alpha remap maximal range
  17726. * @returns the current particle system
  17727. */
  17728. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  17729. /**
  17730. * Remove a specific alpha remap gradient
  17731. * @param gradient defines the gradient to remove
  17732. * @returns the current particle system
  17733. */
  17734. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  17735. /**
  17736. * Adds a new angular speed gradient
  17737. * @param gradient defines the gradient to use (between 0 and 1)
  17738. * @param factor defines the angular speed to affect to the specified gradient
  17739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17740. * @returns the current particle system
  17741. */
  17742. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17743. /**
  17744. * Remove a specific angular speed gradient
  17745. * @param gradient defines the gradient to remove
  17746. * @returns the current particle system
  17747. */
  17748. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  17749. /**
  17750. * Adds a new velocity gradient
  17751. * @param gradient defines the gradient to use (between 0 and 1)
  17752. * @param factor defines the velocity to affect to the specified gradient
  17753. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17754. * @returns the current particle system
  17755. */
  17756. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17757. /**
  17758. * Remove a specific velocity gradient
  17759. * @param gradient defines the gradient to remove
  17760. * @returns the current particle system
  17761. */
  17762. removeVelocityGradient(gradient: number): IParticleSystem;
  17763. /**
  17764. * Adds a new limit velocity gradient
  17765. * @param gradient defines the gradient to use (between 0 and 1)
  17766. * @param factor defines the limit velocity value to affect to the specified gradient
  17767. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17768. * @returns the current particle system
  17769. */
  17770. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17771. /**
  17772. * Remove a specific limit velocity gradient
  17773. * @param gradient defines the gradient to remove
  17774. * @returns the current particle system
  17775. */
  17776. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  17777. /**
  17778. * Adds a new drag gradient
  17779. * @param gradient defines the gradient to use (between 0 and 1)
  17780. * @param factor defines the drag value to affect to the specified gradient
  17781. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17782. * @returns the current particle system
  17783. */
  17784. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17785. /**
  17786. * Remove a specific drag gradient
  17787. * @param gradient defines the gradient to remove
  17788. * @returns the current particle system
  17789. */
  17790. removeDragGradient(gradient: number): IParticleSystem;
  17791. /**
  17792. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  17793. * @param gradient defines the gradient to use (between 0 and 1)
  17794. * @param factor defines the emit rate value to affect to the specified gradient
  17795. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17796. * @returns the current particle system
  17797. */
  17798. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17799. /**
  17800. * Remove a specific emit rate gradient
  17801. * @param gradient defines the gradient to remove
  17802. * @returns the current particle system
  17803. */
  17804. removeEmitRateGradient(gradient: number): IParticleSystem;
  17805. /**
  17806. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  17807. * @param gradient defines the gradient to use (between 0 and 1)
  17808. * @param factor defines the start size value to affect to the specified gradient
  17809. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  17810. * @returns the current particle system
  17811. */
  17812. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  17813. /**
  17814. * Remove a specific start size gradient
  17815. * @param gradient defines the gradient to remove
  17816. * @returns the current particle system
  17817. */
  17818. removeStartSizeGradient(gradient: number): IParticleSystem;
  17819. private _createRampGradientTexture;
  17820. /**
  17821. * Gets the current list of ramp gradients.
  17822. * You must use addRampGradient and removeRampGradient to udpate this list
  17823. * @returns the list of ramp gradients
  17824. */
  17825. getRampGradients(): Nullable<Array<Color3Gradient>>;
  17826. /**
  17827. * Adds a new ramp gradient used to remap particle colors
  17828. * @param gradient defines the gradient to use (between 0 and 1)
  17829. * @param color defines the color to affect to the specified gradient
  17830. * @returns the current particle system
  17831. */
  17832. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  17833. /**
  17834. * Remove a specific ramp gradient
  17835. * @param gradient defines the gradient to remove
  17836. * @returns the current particle system
  17837. */
  17838. removeRampGradient(gradient: number): ParticleSystem;
  17839. /**
  17840. * Adds a new color gradient
  17841. * @param gradient defines the gradient to use (between 0 and 1)
  17842. * @param color1 defines the color to affect to the specified gradient
  17843. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  17844. * @returns this particle system
  17845. */
  17846. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  17847. /**
  17848. * Remove a specific color gradient
  17849. * @param gradient defines the gradient to remove
  17850. * @returns this particle system
  17851. */
  17852. removeColorGradient(gradient: number): IParticleSystem;
  17853. private _fetchR;
  17854. protected _reset(): void;
  17855. private _resetEffect;
  17856. private _createVertexBuffers;
  17857. private _createIndexBuffer;
  17858. /**
  17859. * Gets the maximum number of particles active at the same time.
  17860. * @returns The max number of active particles.
  17861. */
  17862. getCapacity(): number;
  17863. /**
  17864. * Gets whether there are still active particles in the system.
  17865. * @returns True if it is alive, otherwise false.
  17866. */
  17867. isAlive(): boolean;
  17868. /**
  17869. * Gets if the system has been started. (Note: this will still be true after stop is called)
  17870. * @returns True if it has been started, otherwise false.
  17871. */
  17872. isStarted(): boolean;
  17873. private _prepareSubEmitterInternalArray;
  17874. /**
  17875. * Starts the particle system and begins to emit
  17876. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  17877. */
  17878. start(delay?: number): void;
  17879. /**
  17880. * Stops the particle system.
  17881. * @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.
  17882. */
  17883. stop(stopSubEmitters?: boolean): void;
  17884. /**
  17885. * Remove all active particles
  17886. */
  17887. reset(): void;
  17888. /**
  17889. * @hidden (for internal use only)
  17890. */
  17891. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  17892. /**
  17893. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  17894. * Its lifetime will start back at 0.
  17895. */
  17896. recycleParticle: (particle: Particle) => void;
  17897. private _stopSubEmitters;
  17898. private _createParticle;
  17899. private _removeFromRoot;
  17900. private _emitFromParticle;
  17901. private _update;
  17902. /** @hidden */
  17903. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  17904. /** @hidden */
  17905. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  17906. /** @hidden */
  17907. private _getEffect;
  17908. /**
  17909. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  17910. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  17911. */
  17912. animate(preWarmOnly?: boolean): void;
  17913. private _appendParticleVertices;
  17914. /**
  17915. * Rebuilds the particle system.
  17916. */
  17917. rebuild(): void;
  17918. /**
  17919. * Is this system ready to be used/rendered
  17920. * @return true if the system is ready
  17921. */
  17922. isReady(): boolean;
  17923. private _render;
  17924. /**
  17925. * Renders the particle system in its current state.
  17926. * @returns the current number of particles
  17927. */
  17928. render(): number;
  17929. /**
  17930. * Disposes the particle system and free the associated resources
  17931. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  17932. */
  17933. dispose(disposeTexture?: boolean): void;
  17934. /**
  17935. * Clones the particle system.
  17936. * @param name The name of the cloned object
  17937. * @param newEmitter The new emitter to use
  17938. * @returns the cloned particle system
  17939. */
  17940. clone(name: string, newEmitter: any): ParticleSystem;
  17941. /**
  17942. * Serializes the particle system to a JSON object.
  17943. * @returns the JSON object
  17944. */
  17945. serialize(): any;
  17946. /** @hidden */
  17947. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  17948. /** @hidden */
  17949. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  17950. /**
  17951. * Parses a JSON object to create a particle system.
  17952. * @param parsedParticleSystem The JSON object to parse
  17953. * @param scene The scene to create the particle system in
  17954. * @param rootUrl The root url to use to load external dependencies like texture
  17955. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  17956. * @returns the Parsed particle system
  17957. */
  17958. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  17959. }
  17960. }
  17961. declare module "babylonjs/Particles/particle" {
  17962. import { Nullable } from "babylonjs/types";
  17963. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  17964. import { Color4 } from "babylonjs/Maths/math.color";
  17965. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  17966. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  17967. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  17968. /**
  17969. * A particle represents one of the element emitted by a particle system.
  17970. * This is mainly define by its coordinates, direction, velocity and age.
  17971. */
  17972. export class Particle {
  17973. /**
  17974. * The particle system the particle belongs to.
  17975. */
  17976. particleSystem: ParticleSystem;
  17977. private static _Count;
  17978. /**
  17979. * Unique ID of the particle
  17980. */
  17981. id: number;
  17982. /**
  17983. * The world position of the particle in the scene.
  17984. */
  17985. position: Vector3;
  17986. /**
  17987. * The world direction of the particle in the scene.
  17988. */
  17989. direction: Vector3;
  17990. /**
  17991. * The color of the particle.
  17992. */
  17993. color: Color4;
  17994. /**
  17995. * The color change of the particle per step.
  17996. */
  17997. colorStep: Color4;
  17998. /**
  17999. * Defines how long will the life of the particle be.
  18000. */
  18001. lifeTime: number;
  18002. /**
  18003. * The current age of the particle.
  18004. */
  18005. age: number;
  18006. /**
  18007. * The current size of the particle.
  18008. */
  18009. size: number;
  18010. /**
  18011. * The current scale of the particle.
  18012. */
  18013. scale: Vector2;
  18014. /**
  18015. * The current angle of the particle.
  18016. */
  18017. angle: number;
  18018. /**
  18019. * Defines how fast is the angle changing.
  18020. */
  18021. angularSpeed: number;
  18022. /**
  18023. * Defines the cell index used by the particle to be rendered from a sprite.
  18024. */
  18025. cellIndex: number;
  18026. /**
  18027. * The information required to support color remapping
  18028. */
  18029. remapData: Vector4;
  18030. /** @hidden */
  18031. _randomCellOffset?: number;
  18032. /** @hidden */
  18033. _initialDirection: Nullable<Vector3>;
  18034. /** @hidden */
  18035. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  18036. /** @hidden */
  18037. _initialStartSpriteCellID: number;
  18038. /** @hidden */
  18039. _initialEndSpriteCellID: number;
  18040. /** @hidden */
  18041. _currentColorGradient: Nullable<ColorGradient>;
  18042. /** @hidden */
  18043. _currentColor1: Color4;
  18044. /** @hidden */
  18045. _currentColor2: Color4;
  18046. /** @hidden */
  18047. _currentSizeGradient: Nullable<FactorGradient>;
  18048. /** @hidden */
  18049. _currentSize1: number;
  18050. /** @hidden */
  18051. _currentSize2: number;
  18052. /** @hidden */
  18053. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  18054. /** @hidden */
  18055. _currentAngularSpeed1: number;
  18056. /** @hidden */
  18057. _currentAngularSpeed2: number;
  18058. /** @hidden */
  18059. _currentVelocityGradient: Nullable<FactorGradient>;
  18060. /** @hidden */
  18061. _currentVelocity1: number;
  18062. /** @hidden */
  18063. _currentVelocity2: number;
  18064. /** @hidden */
  18065. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  18066. /** @hidden */
  18067. _currentLimitVelocity1: number;
  18068. /** @hidden */
  18069. _currentLimitVelocity2: number;
  18070. /** @hidden */
  18071. _currentDragGradient: Nullable<FactorGradient>;
  18072. /** @hidden */
  18073. _currentDrag1: number;
  18074. /** @hidden */
  18075. _currentDrag2: number;
  18076. /** @hidden */
  18077. _randomNoiseCoordinates1: Vector3;
  18078. /** @hidden */
  18079. _randomNoiseCoordinates2: Vector3;
  18080. /**
  18081. * Creates a new instance Particle
  18082. * @param particleSystem the particle system the particle belongs to
  18083. */
  18084. constructor(
  18085. /**
  18086. * The particle system the particle belongs to.
  18087. */
  18088. particleSystem: ParticleSystem);
  18089. private updateCellInfoFromSystem;
  18090. /**
  18091. * Defines how the sprite cell index is updated for the particle
  18092. */
  18093. updateCellIndex(): void;
  18094. /** @hidden */
  18095. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  18096. /** @hidden */
  18097. _inheritParticleInfoToSubEmitters(): void;
  18098. /** @hidden */
  18099. _reset(): void;
  18100. /**
  18101. * Copy the properties of particle to another one.
  18102. * @param other the particle to copy the information to.
  18103. */
  18104. copyTo(other: Particle): void;
  18105. }
  18106. }
  18107. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  18108. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18109. import { Effect } from "babylonjs/Materials/effect";
  18110. import { Particle } from "babylonjs/Particles/particle";
  18111. /**
  18112. * Particle emitter represents a volume emitting particles.
  18113. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  18114. */
  18115. export interface IParticleEmitterType {
  18116. /**
  18117. * Called by the particle System when the direction is computed for the created particle.
  18118. * @param worldMatrix is the world matrix of the particle system
  18119. * @param directionToUpdate is the direction vector to update with the result
  18120. * @param particle is the particle we are computed the direction for
  18121. */
  18122. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18123. /**
  18124. * Called by the particle System when the position is computed for the created particle.
  18125. * @param worldMatrix is the world matrix of the particle system
  18126. * @param positionToUpdate is the position vector to update with the result
  18127. * @param particle is the particle we are computed the position for
  18128. */
  18129. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18130. /**
  18131. * Clones the current emitter and returns a copy of it
  18132. * @returns the new emitter
  18133. */
  18134. clone(): IParticleEmitterType;
  18135. /**
  18136. * Called by the GPUParticleSystem to setup the update shader
  18137. * @param effect defines the update shader
  18138. */
  18139. applyToShader(effect: Effect): void;
  18140. /**
  18141. * Returns a string to use to update the GPU particles update shader
  18142. * @returns the effect defines string
  18143. */
  18144. getEffectDefines(): string;
  18145. /**
  18146. * Returns a string representing the class name
  18147. * @returns a string containing the class name
  18148. */
  18149. getClassName(): string;
  18150. /**
  18151. * Serializes the particle system to a JSON object.
  18152. * @returns the JSON object
  18153. */
  18154. serialize(): any;
  18155. /**
  18156. * Parse properties from a JSON object
  18157. * @param serializationObject defines the JSON object
  18158. */
  18159. parse(serializationObject: any): void;
  18160. }
  18161. }
  18162. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  18163. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18164. import { Effect } from "babylonjs/Materials/effect";
  18165. import { Particle } from "babylonjs/Particles/particle";
  18166. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18167. /**
  18168. * Particle emitter emitting particles from the inside of a box.
  18169. * It emits the particles randomly between 2 given directions.
  18170. */
  18171. export class BoxParticleEmitter implements IParticleEmitterType {
  18172. /**
  18173. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18174. */
  18175. direction1: Vector3;
  18176. /**
  18177. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18178. */
  18179. direction2: Vector3;
  18180. /**
  18181. * 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.
  18182. */
  18183. minEmitBox: Vector3;
  18184. /**
  18185. * 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.
  18186. */
  18187. maxEmitBox: Vector3;
  18188. /**
  18189. * Creates a new instance BoxParticleEmitter
  18190. */
  18191. constructor();
  18192. /**
  18193. * Called by the particle System when the direction is computed for the created particle.
  18194. * @param worldMatrix is the world matrix of the particle system
  18195. * @param directionToUpdate is the direction vector to update with the result
  18196. * @param particle is the particle we are computed the direction for
  18197. */
  18198. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18199. /**
  18200. * Called by the particle System when the position is computed for the created particle.
  18201. * @param worldMatrix is the world matrix of the particle system
  18202. * @param positionToUpdate is the position vector to update with the result
  18203. * @param particle is the particle we are computed the position for
  18204. */
  18205. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18206. /**
  18207. * Clones the current emitter and returns a copy of it
  18208. * @returns the new emitter
  18209. */
  18210. clone(): BoxParticleEmitter;
  18211. /**
  18212. * Called by the GPUParticleSystem to setup the update shader
  18213. * @param effect defines the update shader
  18214. */
  18215. applyToShader(effect: Effect): void;
  18216. /**
  18217. * Returns a string to use to update the GPU particles update shader
  18218. * @returns a string containng the defines string
  18219. */
  18220. getEffectDefines(): string;
  18221. /**
  18222. * Returns the string "BoxParticleEmitter"
  18223. * @returns a string containing the class name
  18224. */
  18225. getClassName(): string;
  18226. /**
  18227. * Serializes the particle system to a JSON object.
  18228. * @returns the JSON object
  18229. */
  18230. serialize(): any;
  18231. /**
  18232. * Parse properties from a JSON object
  18233. * @param serializationObject defines the JSON object
  18234. */
  18235. parse(serializationObject: any): void;
  18236. }
  18237. }
  18238. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  18239. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18240. import { Effect } from "babylonjs/Materials/effect";
  18241. import { Particle } from "babylonjs/Particles/particle";
  18242. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18243. /**
  18244. * Particle emitter emitting particles from the inside of a cone.
  18245. * It emits the particles alongside the cone volume from the base to the particle.
  18246. * The emission direction might be randomized.
  18247. */
  18248. export class ConeParticleEmitter implements IParticleEmitterType {
  18249. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18250. directionRandomizer: number;
  18251. private _radius;
  18252. private _angle;
  18253. private _height;
  18254. /**
  18255. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  18256. */
  18257. radiusRange: number;
  18258. /**
  18259. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  18260. */
  18261. heightRange: number;
  18262. /**
  18263. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  18264. */
  18265. emitFromSpawnPointOnly: boolean;
  18266. /**
  18267. * Gets or sets the radius of the emission cone
  18268. */
  18269. radius: number;
  18270. /**
  18271. * Gets or sets the angle of the emission cone
  18272. */
  18273. angle: number;
  18274. private _buildHeight;
  18275. /**
  18276. * Creates a new instance ConeParticleEmitter
  18277. * @param radius the radius of the emission cone (1 by default)
  18278. * @param angle the cone base angle (PI by default)
  18279. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  18280. */
  18281. constructor(radius?: number, angle?: number,
  18282. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  18283. directionRandomizer?: number);
  18284. /**
  18285. * Called by the particle System when the direction is computed for the created particle.
  18286. * @param worldMatrix is the world matrix of the particle system
  18287. * @param directionToUpdate is the direction vector to update with the result
  18288. * @param particle is the particle we are computed the direction for
  18289. */
  18290. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18291. /**
  18292. * Called by the particle System when the position is computed for the created particle.
  18293. * @param worldMatrix is the world matrix of the particle system
  18294. * @param positionToUpdate is the position vector to update with the result
  18295. * @param particle is the particle we are computed the position for
  18296. */
  18297. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18298. /**
  18299. * Clones the current emitter and returns a copy of it
  18300. * @returns the new emitter
  18301. */
  18302. clone(): ConeParticleEmitter;
  18303. /**
  18304. * Called by the GPUParticleSystem to setup the update shader
  18305. * @param effect defines the update shader
  18306. */
  18307. applyToShader(effect: Effect): void;
  18308. /**
  18309. * Returns a string to use to update the GPU particles update shader
  18310. * @returns a string containng the defines string
  18311. */
  18312. getEffectDefines(): string;
  18313. /**
  18314. * Returns the string "ConeParticleEmitter"
  18315. * @returns a string containing the class name
  18316. */
  18317. getClassName(): string;
  18318. /**
  18319. * Serializes the particle system to a JSON object.
  18320. * @returns the JSON object
  18321. */
  18322. serialize(): any;
  18323. /**
  18324. * Parse properties from a JSON object
  18325. * @param serializationObject defines the JSON object
  18326. */
  18327. parse(serializationObject: any): void;
  18328. }
  18329. }
  18330. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  18331. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18332. import { Effect } from "babylonjs/Materials/effect";
  18333. import { Particle } from "babylonjs/Particles/particle";
  18334. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18335. /**
  18336. * Particle emitter emitting particles from the inside of a cylinder.
  18337. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  18338. */
  18339. export class CylinderParticleEmitter implements IParticleEmitterType {
  18340. /**
  18341. * The radius of the emission cylinder.
  18342. */
  18343. radius: number;
  18344. /**
  18345. * The height of the emission cylinder.
  18346. */
  18347. height: number;
  18348. /**
  18349. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18350. */
  18351. radiusRange: number;
  18352. /**
  18353. * How much to randomize the particle direction [0-1].
  18354. */
  18355. directionRandomizer: number;
  18356. /**
  18357. * Creates a new instance CylinderParticleEmitter
  18358. * @param radius the radius of the emission cylinder (1 by default)
  18359. * @param height the height of the emission cylinder (1 by default)
  18360. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18361. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18362. */
  18363. constructor(
  18364. /**
  18365. * The radius of the emission cylinder.
  18366. */
  18367. radius?: number,
  18368. /**
  18369. * The height of the emission cylinder.
  18370. */
  18371. height?: number,
  18372. /**
  18373. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18374. */
  18375. radiusRange?: number,
  18376. /**
  18377. * How much to randomize the particle direction [0-1].
  18378. */
  18379. directionRandomizer?: number);
  18380. /**
  18381. * Called by the particle System when the direction is computed for the created particle.
  18382. * @param worldMatrix is the world matrix of the particle system
  18383. * @param directionToUpdate is the direction vector to update with the result
  18384. * @param particle is the particle we are computed the direction for
  18385. */
  18386. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18387. /**
  18388. * Called by the particle System when the position is computed for the created particle.
  18389. * @param worldMatrix is the world matrix of the particle system
  18390. * @param positionToUpdate is the position vector to update with the result
  18391. * @param particle is the particle we are computed the position for
  18392. */
  18393. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18394. /**
  18395. * Clones the current emitter and returns a copy of it
  18396. * @returns the new emitter
  18397. */
  18398. clone(): CylinderParticleEmitter;
  18399. /**
  18400. * Called by the GPUParticleSystem to setup the update shader
  18401. * @param effect defines the update shader
  18402. */
  18403. applyToShader(effect: Effect): void;
  18404. /**
  18405. * Returns a string to use to update the GPU particles update shader
  18406. * @returns a string containng the defines string
  18407. */
  18408. getEffectDefines(): string;
  18409. /**
  18410. * Returns the string "CylinderParticleEmitter"
  18411. * @returns a string containing the class name
  18412. */
  18413. getClassName(): string;
  18414. /**
  18415. * Serializes the particle system to a JSON object.
  18416. * @returns the JSON object
  18417. */
  18418. serialize(): any;
  18419. /**
  18420. * Parse properties from a JSON object
  18421. * @param serializationObject defines the JSON object
  18422. */
  18423. parse(serializationObject: any): void;
  18424. }
  18425. /**
  18426. * Particle emitter emitting particles from the inside of a cylinder.
  18427. * It emits the particles randomly between two vectors.
  18428. */
  18429. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  18430. /**
  18431. * The min limit of the emission direction.
  18432. */
  18433. direction1: Vector3;
  18434. /**
  18435. * The max limit of the emission direction.
  18436. */
  18437. direction2: Vector3;
  18438. /**
  18439. * Creates a new instance CylinderDirectedParticleEmitter
  18440. * @param radius the radius of the emission cylinder (1 by default)
  18441. * @param height the height of the emission cylinder (1 by default)
  18442. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18443. * @param direction1 the min limit of the emission direction (up vector by default)
  18444. * @param direction2 the max limit of the emission direction (up vector by default)
  18445. */
  18446. constructor(radius?: number, height?: number, radiusRange?: number,
  18447. /**
  18448. * The min limit of the emission direction.
  18449. */
  18450. direction1?: Vector3,
  18451. /**
  18452. * The max limit of the emission direction.
  18453. */
  18454. direction2?: Vector3);
  18455. /**
  18456. * Called by the particle System when the direction is computed for the created particle.
  18457. * @param worldMatrix is the world matrix of the particle system
  18458. * @param directionToUpdate is the direction vector to update with the result
  18459. * @param particle is the particle we are computed the direction for
  18460. */
  18461. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18462. /**
  18463. * Clones the current emitter and returns a copy of it
  18464. * @returns the new emitter
  18465. */
  18466. clone(): CylinderDirectedParticleEmitter;
  18467. /**
  18468. * Called by the GPUParticleSystem to setup the update shader
  18469. * @param effect defines the update shader
  18470. */
  18471. applyToShader(effect: Effect): void;
  18472. /**
  18473. * Returns a string to use to update the GPU particles update shader
  18474. * @returns a string containng the defines string
  18475. */
  18476. getEffectDefines(): string;
  18477. /**
  18478. * Returns the string "CylinderDirectedParticleEmitter"
  18479. * @returns a string containing the class name
  18480. */
  18481. getClassName(): string;
  18482. /**
  18483. * Serializes the particle system to a JSON object.
  18484. * @returns the JSON object
  18485. */
  18486. serialize(): any;
  18487. /**
  18488. * Parse properties from a JSON object
  18489. * @param serializationObject defines the JSON object
  18490. */
  18491. parse(serializationObject: any): void;
  18492. }
  18493. }
  18494. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  18495. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18496. import { Effect } from "babylonjs/Materials/effect";
  18497. import { Particle } from "babylonjs/Particles/particle";
  18498. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18499. /**
  18500. * Particle emitter emitting particles from the inside of a hemisphere.
  18501. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  18502. */
  18503. export class HemisphericParticleEmitter implements IParticleEmitterType {
  18504. /**
  18505. * The radius of the emission hemisphere.
  18506. */
  18507. radius: number;
  18508. /**
  18509. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18510. */
  18511. radiusRange: number;
  18512. /**
  18513. * How much to randomize the particle direction [0-1].
  18514. */
  18515. directionRandomizer: number;
  18516. /**
  18517. * Creates a new instance HemisphericParticleEmitter
  18518. * @param radius the radius of the emission hemisphere (1 by default)
  18519. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18520. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18521. */
  18522. constructor(
  18523. /**
  18524. * The radius of the emission hemisphere.
  18525. */
  18526. radius?: number,
  18527. /**
  18528. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18529. */
  18530. radiusRange?: number,
  18531. /**
  18532. * How much to randomize the particle direction [0-1].
  18533. */
  18534. directionRandomizer?: number);
  18535. /**
  18536. * Called by the particle System when the direction is computed for the created particle.
  18537. * @param worldMatrix is the world matrix of the particle system
  18538. * @param directionToUpdate is the direction vector to update with the result
  18539. * @param particle is the particle we are computed the direction for
  18540. */
  18541. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18542. /**
  18543. * Called by the particle System when the position is computed for the created particle.
  18544. * @param worldMatrix is the world matrix of the particle system
  18545. * @param positionToUpdate is the position vector to update with the result
  18546. * @param particle is the particle we are computed the position for
  18547. */
  18548. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18549. /**
  18550. * Clones the current emitter and returns a copy of it
  18551. * @returns the new emitter
  18552. */
  18553. clone(): HemisphericParticleEmitter;
  18554. /**
  18555. * Called by the GPUParticleSystem to setup the update shader
  18556. * @param effect defines the update shader
  18557. */
  18558. applyToShader(effect: Effect): void;
  18559. /**
  18560. * Returns a string to use to update the GPU particles update shader
  18561. * @returns a string containng the defines string
  18562. */
  18563. getEffectDefines(): string;
  18564. /**
  18565. * Returns the string "HemisphericParticleEmitter"
  18566. * @returns a string containing the class name
  18567. */
  18568. getClassName(): string;
  18569. /**
  18570. * Serializes the particle system to a JSON object.
  18571. * @returns the JSON object
  18572. */
  18573. serialize(): any;
  18574. /**
  18575. * Parse properties from a JSON object
  18576. * @param serializationObject defines the JSON object
  18577. */
  18578. parse(serializationObject: any): void;
  18579. }
  18580. }
  18581. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  18582. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18583. import { Effect } from "babylonjs/Materials/effect";
  18584. import { Particle } from "babylonjs/Particles/particle";
  18585. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18586. /**
  18587. * Particle emitter emitting particles from a point.
  18588. * It emits the particles randomly between 2 given directions.
  18589. */
  18590. export class PointParticleEmitter implements IParticleEmitterType {
  18591. /**
  18592. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18593. */
  18594. direction1: Vector3;
  18595. /**
  18596. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  18597. */
  18598. direction2: Vector3;
  18599. /**
  18600. * Creates a new instance PointParticleEmitter
  18601. */
  18602. constructor();
  18603. /**
  18604. * Called by the particle System when the direction is computed for the created particle.
  18605. * @param worldMatrix is the world matrix of the particle system
  18606. * @param directionToUpdate is the direction vector to update with the result
  18607. * @param particle is the particle we are computed the direction for
  18608. */
  18609. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18610. /**
  18611. * Called by the particle System when the position is computed for the created particle.
  18612. * @param worldMatrix is the world matrix of the particle system
  18613. * @param positionToUpdate is the position vector to update with the result
  18614. * @param particle is the particle we are computed the position for
  18615. */
  18616. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18617. /**
  18618. * Clones the current emitter and returns a copy of it
  18619. * @returns the new emitter
  18620. */
  18621. clone(): PointParticleEmitter;
  18622. /**
  18623. * Called by the GPUParticleSystem to setup the update shader
  18624. * @param effect defines the update shader
  18625. */
  18626. applyToShader(effect: Effect): void;
  18627. /**
  18628. * Returns a string to use to update the GPU particles update shader
  18629. * @returns a string containng the defines string
  18630. */
  18631. getEffectDefines(): string;
  18632. /**
  18633. * Returns the string "PointParticleEmitter"
  18634. * @returns a string containing the class name
  18635. */
  18636. getClassName(): string;
  18637. /**
  18638. * Serializes the particle system to a JSON object.
  18639. * @returns the JSON object
  18640. */
  18641. serialize(): any;
  18642. /**
  18643. * Parse properties from a JSON object
  18644. * @param serializationObject defines the JSON object
  18645. */
  18646. parse(serializationObject: any): void;
  18647. }
  18648. }
  18649. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  18650. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  18651. import { Effect } from "babylonjs/Materials/effect";
  18652. import { Particle } from "babylonjs/Particles/particle";
  18653. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18654. /**
  18655. * Particle emitter emitting particles from the inside of a sphere.
  18656. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  18657. */
  18658. export class SphereParticleEmitter implements IParticleEmitterType {
  18659. /**
  18660. * The radius of the emission sphere.
  18661. */
  18662. radius: number;
  18663. /**
  18664. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18665. */
  18666. radiusRange: number;
  18667. /**
  18668. * How much to randomize the particle direction [0-1].
  18669. */
  18670. directionRandomizer: number;
  18671. /**
  18672. * Creates a new instance SphereParticleEmitter
  18673. * @param radius the radius of the emission sphere (1 by default)
  18674. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  18675. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  18676. */
  18677. constructor(
  18678. /**
  18679. * The radius of the emission sphere.
  18680. */
  18681. radius?: number,
  18682. /**
  18683. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  18684. */
  18685. radiusRange?: number,
  18686. /**
  18687. * How much to randomize the particle direction [0-1].
  18688. */
  18689. directionRandomizer?: number);
  18690. /**
  18691. * Called by the particle System when the direction is computed for the created particle.
  18692. * @param worldMatrix is the world matrix of the particle system
  18693. * @param directionToUpdate is the direction vector to update with the result
  18694. * @param particle is the particle we are computed the direction for
  18695. */
  18696. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18697. /**
  18698. * Called by the particle System when the position is computed for the created particle.
  18699. * @param worldMatrix is the world matrix of the particle system
  18700. * @param positionToUpdate is the position vector to update with the result
  18701. * @param particle is the particle we are computed the position for
  18702. */
  18703. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  18704. /**
  18705. * Clones the current emitter and returns a copy of it
  18706. * @returns the new emitter
  18707. */
  18708. clone(): SphereParticleEmitter;
  18709. /**
  18710. * Called by the GPUParticleSystem to setup the update shader
  18711. * @param effect defines the update shader
  18712. */
  18713. applyToShader(effect: Effect): void;
  18714. /**
  18715. * Returns a string to use to update the GPU particles update shader
  18716. * @returns a string containng the defines string
  18717. */
  18718. getEffectDefines(): string;
  18719. /**
  18720. * Returns the string "SphereParticleEmitter"
  18721. * @returns a string containing the class name
  18722. */
  18723. getClassName(): string;
  18724. /**
  18725. * Serializes the particle system to a JSON object.
  18726. * @returns the JSON object
  18727. */
  18728. serialize(): any;
  18729. /**
  18730. * Parse properties from a JSON object
  18731. * @param serializationObject defines the JSON object
  18732. */
  18733. parse(serializationObject: any): void;
  18734. }
  18735. /**
  18736. * Particle emitter emitting particles from the inside of a sphere.
  18737. * It emits the particles randomly between two vectors.
  18738. */
  18739. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  18740. /**
  18741. * The min limit of the emission direction.
  18742. */
  18743. direction1: Vector3;
  18744. /**
  18745. * The max limit of the emission direction.
  18746. */
  18747. direction2: Vector3;
  18748. /**
  18749. * Creates a new instance SphereDirectedParticleEmitter
  18750. * @param radius the radius of the emission sphere (1 by default)
  18751. * @param direction1 the min limit of the emission direction (up vector by default)
  18752. * @param direction2 the max limit of the emission direction (up vector by default)
  18753. */
  18754. constructor(radius?: number,
  18755. /**
  18756. * The min limit of the emission direction.
  18757. */
  18758. direction1?: Vector3,
  18759. /**
  18760. * The max limit of the emission direction.
  18761. */
  18762. direction2?: Vector3);
  18763. /**
  18764. * Called by the particle System when the direction is computed for the created particle.
  18765. * @param worldMatrix is the world matrix of the particle system
  18766. * @param directionToUpdate is the direction vector to update with the result
  18767. * @param particle is the particle we are computed the direction for
  18768. */
  18769. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  18770. /**
  18771. * Clones the current emitter and returns a copy of it
  18772. * @returns the new emitter
  18773. */
  18774. clone(): SphereDirectedParticleEmitter;
  18775. /**
  18776. * Called by the GPUParticleSystem to setup the update shader
  18777. * @param effect defines the update shader
  18778. */
  18779. applyToShader(effect: Effect): void;
  18780. /**
  18781. * Returns a string to use to update the GPU particles update shader
  18782. * @returns a string containng the defines string
  18783. */
  18784. getEffectDefines(): string;
  18785. /**
  18786. * Returns the string "SphereDirectedParticleEmitter"
  18787. * @returns a string containing the class name
  18788. */
  18789. getClassName(): string;
  18790. /**
  18791. * Serializes the particle system to a JSON object.
  18792. * @returns the JSON object
  18793. */
  18794. serialize(): any;
  18795. /**
  18796. * Parse properties from a JSON object
  18797. * @param serializationObject defines the JSON object
  18798. */
  18799. parse(serializationObject: any): void;
  18800. }
  18801. }
  18802. declare module "babylonjs/Particles/EmitterTypes/index" {
  18803. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  18804. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  18805. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  18806. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  18807. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  18808. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  18809. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  18810. }
  18811. declare module "babylonjs/Particles/IParticleSystem" {
  18812. import { Nullable } from "babylonjs/types";
  18813. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  18814. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  18815. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18816. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18817. import { Texture } from "babylonjs/Materials/Textures/texture";
  18818. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  18819. import { Scene } from "babylonjs/scene";
  18820. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  18821. import { Animation } from "babylonjs/Animations/animation";
  18822. /**
  18823. * Interface representing a particle system in Babylon.js.
  18824. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  18825. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  18826. */
  18827. export interface IParticleSystem {
  18828. /**
  18829. * List of animations used by the particle system.
  18830. */
  18831. animations: Animation[];
  18832. /**
  18833. * The id of the Particle system.
  18834. */
  18835. id: string;
  18836. /**
  18837. * The name of the Particle system.
  18838. */
  18839. name: string;
  18840. /**
  18841. * The emitter represents the Mesh or position we are attaching the particle system to.
  18842. */
  18843. emitter: Nullable<AbstractMesh | Vector3>;
  18844. /**
  18845. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  18846. */
  18847. isBillboardBased: boolean;
  18848. /**
  18849. * The rendering group used by the Particle system to chose when to render.
  18850. */
  18851. renderingGroupId: number;
  18852. /**
  18853. * The layer mask we are rendering the particles through.
  18854. */
  18855. layerMask: number;
  18856. /**
  18857. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  18858. */
  18859. updateSpeed: number;
  18860. /**
  18861. * The amount of time the particle system is running (depends of the overall update speed).
  18862. */
  18863. targetStopDuration: number;
  18864. /**
  18865. * The texture used to render each particle. (this can be a spritesheet)
  18866. */
  18867. particleTexture: Nullable<Texture>;
  18868. /**
  18869. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  18870. */
  18871. blendMode: number;
  18872. /**
  18873. * Minimum life time of emitting particles.
  18874. */
  18875. minLifeTime: number;
  18876. /**
  18877. * Maximum life time of emitting particles.
  18878. */
  18879. maxLifeTime: number;
  18880. /**
  18881. * Minimum Size of emitting particles.
  18882. */
  18883. minSize: number;
  18884. /**
  18885. * Maximum Size of emitting particles.
  18886. */
  18887. maxSize: number;
  18888. /**
  18889. * Minimum scale of emitting particles on X axis.
  18890. */
  18891. minScaleX: number;
  18892. /**
  18893. * Maximum scale of emitting particles on X axis.
  18894. */
  18895. maxScaleX: number;
  18896. /**
  18897. * Minimum scale of emitting particles on Y axis.
  18898. */
  18899. minScaleY: number;
  18900. /**
  18901. * Maximum scale of emitting particles on Y axis.
  18902. */
  18903. maxScaleY: number;
  18904. /**
  18905. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18906. */
  18907. color1: Color4;
  18908. /**
  18909. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  18910. */
  18911. color2: Color4;
  18912. /**
  18913. * Color the particle will have at the end of its lifetime.
  18914. */
  18915. colorDead: Color4;
  18916. /**
  18917. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  18918. */
  18919. emitRate: number;
  18920. /**
  18921. * You can use gravity if you want to give an orientation to your particles.
  18922. */
  18923. gravity: Vector3;
  18924. /**
  18925. * Minimum power of emitting particles.
  18926. */
  18927. minEmitPower: number;
  18928. /**
  18929. * Maximum power of emitting particles.
  18930. */
  18931. maxEmitPower: number;
  18932. /**
  18933. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  18934. */
  18935. minAngularSpeed: number;
  18936. /**
  18937. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  18938. */
  18939. maxAngularSpeed: number;
  18940. /**
  18941. * Gets or sets the minimal initial rotation in radians.
  18942. */
  18943. minInitialRotation: number;
  18944. /**
  18945. * Gets or sets the maximal initial rotation in radians.
  18946. */
  18947. maxInitialRotation: number;
  18948. /**
  18949. * The particle emitter type defines the emitter used by the particle system.
  18950. * It can be for example box, sphere, or cone...
  18951. */
  18952. particleEmitterType: Nullable<IParticleEmitterType>;
  18953. /**
  18954. * Defines the delay in milliseconds before starting the system (0 by default)
  18955. */
  18956. startDelay: number;
  18957. /**
  18958. * 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
  18959. */
  18960. preWarmCycles: number;
  18961. /**
  18962. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  18963. */
  18964. preWarmStepOffset: number;
  18965. /**
  18966. * 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)
  18967. */
  18968. spriteCellChangeSpeed: number;
  18969. /**
  18970. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  18971. */
  18972. startSpriteCellID: number;
  18973. /**
  18974. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  18975. */
  18976. endSpriteCellID: number;
  18977. /**
  18978. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  18979. */
  18980. spriteCellWidth: number;
  18981. /**
  18982. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  18983. */
  18984. spriteCellHeight: number;
  18985. /**
  18986. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  18987. */
  18988. spriteRandomStartCell: boolean;
  18989. /**
  18990. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  18991. */
  18992. isAnimationSheetEnabled: boolean;
  18993. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  18994. translationPivot: Vector2;
  18995. /**
  18996. * Gets or sets a texture used to add random noise to particle positions
  18997. */
  18998. noiseTexture: Nullable<BaseTexture>;
  18999. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  19000. noiseStrength: Vector3;
  19001. /**
  19002. * Gets or sets the billboard mode to use when isBillboardBased = true.
  19003. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  19004. */
  19005. billboardMode: number;
  19006. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  19007. limitVelocityDamping: number;
  19008. /**
  19009. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  19010. */
  19011. beginAnimationOnStart: boolean;
  19012. /**
  19013. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  19014. */
  19015. beginAnimationFrom: number;
  19016. /**
  19017. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  19018. */
  19019. beginAnimationTo: number;
  19020. /**
  19021. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  19022. */
  19023. beginAnimationLoop: boolean;
  19024. /**
  19025. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  19026. */
  19027. disposeOnStop: boolean;
  19028. /**
  19029. * Gets the maximum number of particles active at the same time.
  19030. * @returns The max number of active particles.
  19031. */
  19032. getCapacity(): number;
  19033. /**
  19034. * Gets if the system has been started. (Note: this will still be true after stop is called)
  19035. * @returns True if it has been started, otherwise false.
  19036. */
  19037. isStarted(): boolean;
  19038. /**
  19039. * Animates the particle system for this frame.
  19040. */
  19041. animate(): void;
  19042. /**
  19043. * Renders the particle system in its current state.
  19044. * @returns the current number of particles
  19045. */
  19046. render(): number;
  19047. /**
  19048. * Dispose the particle system and frees its associated resources.
  19049. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  19050. */
  19051. dispose(disposeTexture?: boolean): void;
  19052. /**
  19053. * Clones the particle system.
  19054. * @param name The name of the cloned object
  19055. * @param newEmitter The new emitter to use
  19056. * @returns the cloned particle system
  19057. */
  19058. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  19059. /**
  19060. * Serializes the particle system to a JSON object.
  19061. * @returns the JSON object
  19062. */
  19063. serialize(): any;
  19064. /**
  19065. * Rebuild the particle system
  19066. */
  19067. rebuild(): void;
  19068. /**
  19069. * Starts the particle system and begins to emit
  19070. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  19071. */
  19072. start(delay?: number): void;
  19073. /**
  19074. * Stops the particle system.
  19075. */
  19076. stop(): void;
  19077. /**
  19078. * Remove all active particles
  19079. */
  19080. reset(): void;
  19081. /**
  19082. * Is this system ready to be used/rendered
  19083. * @return true if the system is ready
  19084. */
  19085. isReady(): boolean;
  19086. /**
  19087. * Adds a new color gradient
  19088. * @param gradient defines the gradient to use (between 0 and 1)
  19089. * @param color1 defines the color to affect to the specified gradient
  19090. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  19091. * @returns the current particle system
  19092. */
  19093. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  19094. /**
  19095. * Remove a specific color gradient
  19096. * @param gradient defines the gradient to remove
  19097. * @returns the current particle system
  19098. */
  19099. removeColorGradient(gradient: number): IParticleSystem;
  19100. /**
  19101. * Adds a new size gradient
  19102. * @param gradient defines the gradient to use (between 0 and 1)
  19103. * @param factor defines the size factor to affect to the specified gradient
  19104. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19105. * @returns the current particle system
  19106. */
  19107. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19108. /**
  19109. * Remove a specific size gradient
  19110. * @param gradient defines the gradient to remove
  19111. * @returns the current particle system
  19112. */
  19113. removeSizeGradient(gradient: number): IParticleSystem;
  19114. /**
  19115. * Gets the current list of color gradients.
  19116. * You must use addColorGradient and removeColorGradient to udpate this list
  19117. * @returns the list of color gradients
  19118. */
  19119. getColorGradients(): Nullable<Array<ColorGradient>>;
  19120. /**
  19121. * Gets the current list of size gradients.
  19122. * You must use addSizeGradient and removeSizeGradient to udpate this list
  19123. * @returns the list of size gradients
  19124. */
  19125. getSizeGradients(): Nullable<Array<FactorGradient>>;
  19126. /**
  19127. * Gets the current list of angular speed gradients.
  19128. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  19129. * @returns the list of angular speed gradients
  19130. */
  19131. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  19132. /**
  19133. * Adds a new angular speed gradient
  19134. * @param gradient defines the gradient to use (between 0 and 1)
  19135. * @param factor defines the angular speed to affect to the specified gradient
  19136. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19137. * @returns the current particle system
  19138. */
  19139. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19140. /**
  19141. * Remove a specific angular speed gradient
  19142. * @param gradient defines the gradient to remove
  19143. * @returns the current particle system
  19144. */
  19145. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  19146. /**
  19147. * Gets the current list of velocity gradients.
  19148. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  19149. * @returns the list of velocity gradients
  19150. */
  19151. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  19152. /**
  19153. * Adds a new velocity gradient
  19154. * @param gradient defines the gradient to use (between 0 and 1)
  19155. * @param factor defines the velocity to affect to the specified gradient
  19156. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19157. * @returns the current particle system
  19158. */
  19159. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19160. /**
  19161. * Remove a specific velocity gradient
  19162. * @param gradient defines the gradient to remove
  19163. * @returns the current particle system
  19164. */
  19165. removeVelocityGradient(gradient: number): IParticleSystem;
  19166. /**
  19167. * Gets the current list of limit velocity gradients.
  19168. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  19169. * @returns the list of limit velocity gradients
  19170. */
  19171. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  19172. /**
  19173. * Adds a new limit velocity gradient
  19174. * @param gradient defines the gradient to use (between 0 and 1)
  19175. * @param factor defines the limit velocity to affect to the specified gradient
  19176. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19177. * @returns the current particle system
  19178. */
  19179. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19180. /**
  19181. * Remove a specific limit velocity gradient
  19182. * @param gradient defines the gradient to remove
  19183. * @returns the current particle system
  19184. */
  19185. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  19186. /**
  19187. * Adds a new drag gradient
  19188. * @param gradient defines the gradient to use (between 0 and 1)
  19189. * @param factor defines the drag to affect to the specified gradient
  19190. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19191. * @returns the current particle system
  19192. */
  19193. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19194. /**
  19195. * Remove a specific drag gradient
  19196. * @param gradient defines the gradient to remove
  19197. * @returns the current particle system
  19198. */
  19199. removeDragGradient(gradient: number): IParticleSystem;
  19200. /**
  19201. * Gets the current list of drag gradients.
  19202. * You must use addDragGradient and removeDragGradient to udpate this list
  19203. * @returns the list of drag gradients
  19204. */
  19205. getDragGradients(): Nullable<Array<FactorGradient>>;
  19206. /**
  19207. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  19208. * @param gradient defines the gradient to use (between 0 and 1)
  19209. * @param factor defines the emit rate to affect to the specified gradient
  19210. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19211. * @returns the current particle system
  19212. */
  19213. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19214. /**
  19215. * Remove a specific emit rate gradient
  19216. * @param gradient defines the gradient to remove
  19217. * @returns the current particle system
  19218. */
  19219. removeEmitRateGradient(gradient: number): IParticleSystem;
  19220. /**
  19221. * Gets the current list of emit rate gradients.
  19222. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  19223. * @returns the list of emit rate gradients
  19224. */
  19225. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  19226. /**
  19227. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  19228. * @param gradient defines the gradient to use (between 0 and 1)
  19229. * @param factor defines the start size to affect to the specified gradient
  19230. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19231. * @returns the current particle system
  19232. */
  19233. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19234. /**
  19235. * Remove a specific start size gradient
  19236. * @param gradient defines the gradient to remove
  19237. * @returns the current particle system
  19238. */
  19239. removeStartSizeGradient(gradient: number): IParticleSystem;
  19240. /**
  19241. * Gets the current list of start size gradients.
  19242. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  19243. * @returns the list of start size gradients
  19244. */
  19245. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  19246. /**
  19247. * Adds a new life time gradient
  19248. * @param gradient defines the gradient to use (between 0 and 1)
  19249. * @param factor defines the life time factor to affect to the specified gradient
  19250. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  19251. * @returns the current particle system
  19252. */
  19253. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  19254. /**
  19255. * Remove a specific life time gradient
  19256. * @param gradient defines the gradient to remove
  19257. * @returns the current particle system
  19258. */
  19259. removeLifeTimeGradient(gradient: number): IParticleSystem;
  19260. /**
  19261. * Gets the current list of life time gradients.
  19262. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  19263. * @returns the list of life time gradients
  19264. */
  19265. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  19266. /**
  19267. * Gets the current list of color gradients.
  19268. * You must use addColorGradient and removeColorGradient to udpate this list
  19269. * @returns the list of color gradients
  19270. */
  19271. getColorGradients(): Nullable<Array<ColorGradient>>;
  19272. /**
  19273. * Adds a new ramp gradient used to remap particle colors
  19274. * @param gradient defines the gradient to use (between 0 and 1)
  19275. * @param color defines the color to affect to the specified gradient
  19276. * @returns the current particle system
  19277. */
  19278. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  19279. /**
  19280. * Gets the current list of ramp gradients.
  19281. * You must use addRampGradient and removeRampGradient to udpate this list
  19282. * @returns the list of ramp gradients
  19283. */
  19284. getRampGradients(): Nullable<Array<Color3Gradient>>;
  19285. /** Gets or sets a boolean indicating that ramp gradients must be used
  19286. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  19287. */
  19288. useRampGradients: boolean;
  19289. /**
  19290. * Adds a new color remap gradient
  19291. * @param gradient defines the gradient to use (between 0 and 1)
  19292. * @param min defines the color remap minimal range
  19293. * @param max defines the color remap maximal range
  19294. * @returns the current particle system
  19295. */
  19296. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19297. /**
  19298. * Gets the current list of color remap gradients.
  19299. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  19300. * @returns the list of color remap gradients
  19301. */
  19302. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  19303. /**
  19304. * Adds a new alpha remap gradient
  19305. * @param gradient defines the gradient to use (between 0 and 1)
  19306. * @param min defines the alpha remap minimal range
  19307. * @param max defines the alpha remap maximal range
  19308. * @returns the current particle system
  19309. */
  19310. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  19311. /**
  19312. * Gets the current list of alpha remap gradients.
  19313. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  19314. * @returns the list of alpha remap gradients
  19315. */
  19316. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  19317. /**
  19318. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  19319. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19320. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19321. * @returns the emitter
  19322. */
  19323. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  19324. /**
  19325. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  19326. * @param radius The radius of the hemisphere to emit from
  19327. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19328. * @returns the emitter
  19329. */
  19330. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  19331. /**
  19332. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  19333. * @param radius The radius of the sphere to emit from
  19334. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  19335. * @returns the emitter
  19336. */
  19337. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  19338. /**
  19339. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  19340. * @param radius The radius of the sphere to emit from
  19341. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  19342. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  19343. * @returns the emitter
  19344. */
  19345. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19346. /**
  19347. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  19348. * @param radius The radius of the emission cylinder
  19349. * @param height The height of the emission cylinder
  19350. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  19351. * @param directionRandomizer How much to randomize the particle direction [0-1]
  19352. * @returns the emitter
  19353. */
  19354. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  19355. /**
  19356. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  19357. * @param radius The radius of the cylinder to emit from
  19358. * @param height The height of the emission cylinder
  19359. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  19360. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  19361. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  19362. * @returns the emitter
  19363. */
  19364. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  19365. /**
  19366. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  19367. * @param radius The radius of the cone to emit from
  19368. * @param angle The base angle of the cone
  19369. * @returns the emitter
  19370. */
  19371. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  19372. /**
  19373. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  19374. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  19375. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  19376. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19377. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  19378. * @returns the emitter
  19379. */
  19380. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  19381. /**
  19382. * Get hosting scene
  19383. * @returns the scene
  19384. */
  19385. getScene(): Scene;
  19386. }
  19387. }
  19388. declare module "babylonjs/Meshes/instancedMesh" {
  19389. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  19390. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  19391. import { Camera } from "babylonjs/Cameras/camera";
  19392. import { Node } from "babylonjs/node";
  19393. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19394. import { Mesh } from "babylonjs/Meshes/mesh";
  19395. import { Material } from "babylonjs/Materials/material";
  19396. import { Skeleton } from "babylonjs/Bones/skeleton";
  19397. import { Light } from "babylonjs/Lights/light";
  19398. /**
  19399. * Creates an instance based on a source mesh.
  19400. */
  19401. export class InstancedMesh extends AbstractMesh {
  19402. private _sourceMesh;
  19403. private _currentLOD;
  19404. /** @hidden */
  19405. _indexInSourceMeshInstanceArray: number;
  19406. constructor(name: string, source: Mesh);
  19407. /**
  19408. * Returns the string "InstancedMesh".
  19409. */
  19410. getClassName(): string;
  19411. /** Gets the list of lights affecting that mesh */
  19412. readonly lightSources: Light[];
  19413. _resyncLightSources(): void;
  19414. _resyncLighSource(light: Light): void;
  19415. _removeLightSource(light: Light, dispose: boolean): void;
  19416. /**
  19417. * If the source mesh receives shadows
  19418. */
  19419. readonly receiveShadows: boolean;
  19420. /**
  19421. * The material of the source mesh
  19422. */
  19423. readonly material: Nullable<Material>;
  19424. /**
  19425. * Visibility of the source mesh
  19426. */
  19427. readonly visibility: number;
  19428. /**
  19429. * Skeleton of the source mesh
  19430. */
  19431. readonly skeleton: Nullable<Skeleton>;
  19432. /**
  19433. * Rendering ground id of the source mesh
  19434. */
  19435. renderingGroupId: number;
  19436. /**
  19437. * Returns the total number of vertices (integer).
  19438. */
  19439. getTotalVertices(): number;
  19440. /**
  19441. * Returns a positive integer : the total number of indices in this mesh geometry.
  19442. * @returns the numner of indices or zero if the mesh has no geometry.
  19443. */
  19444. getTotalIndices(): number;
  19445. /**
  19446. * The source mesh of the instance
  19447. */
  19448. readonly sourceMesh: Mesh;
  19449. /**
  19450. * Is this node ready to be used/rendered
  19451. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  19452. * @return {boolean} is it ready
  19453. */
  19454. isReady(completeCheck?: boolean): boolean;
  19455. /**
  19456. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  19457. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  19458. * @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.
  19459. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  19460. */
  19461. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  19462. /**
  19463. * Sets the vertex data of the mesh geometry for the requested `kind`.
  19464. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  19465. * The `data` are either a numeric array either a Float32Array.
  19466. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  19467. * 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).
  19468. * Note that a new underlying VertexBuffer object is created each call.
  19469. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  19470. *
  19471. * Possible `kind` values :
  19472. * - VertexBuffer.PositionKind
  19473. * - VertexBuffer.UVKind
  19474. * - VertexBuffer.UV2Kind
  19475. * - VertexBuffer.UV3Kind
  19476. * - VertexBuffer.UV4Kind
  19477. * - VertexBuffer.UV5Kind
  19478. * - VertexBuffer.UV6Kind
  19479. * - VertexBuffer.ColorKind
  19480. * - VertexBuffer.MatricesIndicesKind
  19481. * - VertexBuffer.MatricesIndicesExtraKind
  19482. * - VertexBuffer.MatricesWeightsKind
  19483. * - VertexBuffer.MatricesWeightsExtraKind
  19484. *
  19485. * Returns the Mesh.
  19486. */
  19487. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  19488. /**
  19489. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  19490. * If the mesh has no geometry, it is simply returned as it is.
  19491. * The `data` are either a numeric array either a Float32Array.
  19492. * No new underlying VertexBuffer object is created.
  19493. * 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.
  19494. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  19495. *
  19496. * Possible `kind` values :
  19497. * - VertexBuffer.PositionKind
  19498. * - VertexBuffer.UVKind
  19499. * - VertexBuffer.UV2Kind
  19500. * - VertexBuffer.UV3Kind
  19501. * - VertexBuffer.UV4Kind
  19502. * - VertexBuffer.UV5Kind
  19503. * - VertexBuffer.UV6Kind
  19504. * - VertexBuffer.ColorKind
  19505. * - VertexBuffer.MatricesIndicesKind
  19506. * - VertexBuffer.MatricesIndicesExtraKind
  19507. * - VertexBuffer.MatricesWeightsKind
  19508. * - VertexBuffer.MatricesWeightsExtraKind
  19509. *
  19510. * Returns the Mesh.
  19511. */
  19512. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  19513. /**
  19514. * Sets the mesh indices.
  19515. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  19516. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  19517. * This method creates a new index buffer each call.
  19518. * Returns the Mesh.
  19519. */
  19520. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  19521. /**
  19522. * Boolean : True if the mesh owns the requested kind of data.
  19523. */
  19524. isVerticesDataPresent(kind: string): boolean;
  19525. /**
  19526. * Returns an array of indices (IndicesArray).
  19527. */
  19528. getIndices(): Nullable<IndicesArray>;
  19529. readonly _positions: Nullable<Vector3[]>;
  19530. /**
  19531. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  19532. * This means the mesh underlying bounding box and sphere are recomputed.
  19533. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  19534. * @returns the current mesh
  19535. */
  19536. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  19537. /** @hidden */
  19538. _preActivate(): InstancedMesh;
  19539. /** @hidden */
  19540. _activate(renderId: number, intermediateRendering: boolean): boolean;
  19541. /** @hidden */
  19542. _postActivate(): void;
  19543. getWorldMatrix(): Matrix;
  19544. readonly isAnInstance: boolean;
  19545. /**
  19546. * Returns the current associated LOD AbstractMesh.
  19547. */
  19548. getLOD(camera: Camera): AbstractMesh;
  19549. /** @hidden */
  19550. _syncSubMeshes(): InstancedMesh;
  19551. /** @hidden */
  19552. _generatePointsArray(): boolean;
  19553. /**
  19554. * Creates a new InstancedMesh from the current mesh.
  19555. * - name (string) : the cloned mesh name
  19556. * - newParent (optional Node) : the optional Node to parent the clone to.
  19557. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  19558. *
  19559. * Returns the clone.
  19560. */
  19561. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19562. /**
  19563. * Disposes the InstancedMesh.
  19564. * Returns nothing.
  19565. */
  19566. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  19567. }
  19568. }
  19569. declare module "babylonjs/Materials/shaderMaterial" {
  19570. import { Scene } from "babylonjs/scene";
  19571. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  19572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19573. import { Mesh } from "babylonjs/Meshes/mesh";
  19574. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  19575. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  19576. import { Texture } from "babylonjs/Materials/Textures/texture";
  19577. import { Material } from "babylonjs/Materials/material";
  19578. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  19579. /**
  19580. * Defines the options associated with the creation of a shader material.
  19581. */
  19582. export interface IShaderMaterialOptions {
  19583. /**
  19584. * Does the material work in alpha blend mode
  19585. */
  19586. needAlphaBlending: boolean;
  19587. /**
  19588. * Does the material work in alpha test mode
  19589. */
  19590. needAlphaTesting: boolean;
  19591. /**
  19592. * The list of attribute names used in the shader
  19593. */
  19594. attributes: string[];
  19595. /**
  19596. * The list of unifrom names used in the shader
  19597. */
  19598. uniforms: string[];
  19599. /**
  19600. * The list of UBO names used in the shader
  19601. */
  19602. uniformBuffers: string[];
  19603. /**
  19604. * The list of sampler names used in the shader
  19605. */
  19606. samplers: string[];
  19607. /**
  19608. * The list of defines used in the shader
  19609. */
  19610. defines: string[];
  19611. }
  19612. /**
  19613. * 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.
  19614. *
  19615. * This returned material effects how the mesh will look based on the code in the shaders.
  19616. *
  19617. * @see http://doc.babylonjs.com/how_to/shader_material
  19618. */
  19619. export class ShaderMaterial extends Material {
  19620. private _shaderPath;
  19621. private _options;
  19622. private _textures;
  19623. private _textureArrays;
  19624. private _floats;
  19625. private _ints;
  19626. private _floatsArrays;
  19627. private _colors3;
  19628. private _colors3Arrays;
  19629. private _colors4;
  19630. private _colors4Arrays;
  19631. private _vectors2;
  19632. private _vectors3;
  19633. private _vectors4;
  19634. private _matrices;
  19635. private _matrices3x3;
  19636. private _matrices2x2;
  19637. private _vectors2Arrays;
  19638. private _vectors3Arrays;
  19639. private _vectors4Arrays;
  19640. private _cachedWorldViewMatrix;
  19641. private _cachedWorldViewProjectionMatrix;
  19642. private _renderId;
  19643. /**
  19644. * Instantiate a new shader material.
  19645. * 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.
  19646. * This returned material effects how the mesh will look based on the code in the shaders.
  19647. * @see http://doc.babylonjs.com/how_to/shader_material
  19648. * @param name Define the name of the material in the scene
  19649. * @param scene Define the scene the material belongs to
  19650. * @param shaderPath Defines the route to the shader code in one of three ways:
  19651. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  19652. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  19653. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  19654. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  19655. * @param options Define the options used to create the shader
  19656. */
  19657. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  19658. /**
  19659. * Gets the options used to compile the shader.
  19660. * They can be modified to trigger a new compilation
  19661. */
  19662. readonly options: IShaderMaterialOptions;
  19663. /**
  19664. * Gets the current class name of the material e.g. "ShaderMaterial"
  19665. * Mainly use in serialization.
  19666. * @returns the class name
  19667. */
  19668. getClassName(): string;
  19669. /**
  19670. * Specifies if the material will require alpha blending
  19671. * @returns a boolean specifying if alpha blending is needed
  19672. */
  19673. needAlphaBlending(): boolean;
  19674. /**
  19675. * Specifies if this material should be rendered in alpha test mode
  19676. * @returns a boolean specifying if an alpha test is needed.
  19677. */
  19678. needAlphaTesting(): boolean;
  19679. private _checkUniform;
  19680. /**
  19681. * Set a texture in the shader.
  19682. * @param name Define the name of the uniform samplers as defined in the shader
  19683. * @param texture Define the texture to bind to this sampler
  19684. * @return the material itself allowing "fluent" like uniform updates
  19685. */
  19686. setTexture(name: string, texture: Texture): ShaderMaterial;
  19687. /**
  19688. * Set a texture array in the shader.
  19689. * @param name Define the name of the uniform sampler array as defined in the shader
  19690. * @param textures Define the list of textures to bind to this sampler
  19691. * @return the material itself allowing "fluent" like uniform updates
  19692. */
  19693. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  19694. /**
  19695. * Set a float in the shader.
  19696. * @param name Define the name of the uniform as defined in the shader
  19697. * @param value Define the value to give to the uniform
  19698. * @return the material itself allowing "fluent" like uniform updates
  19699. */
  19700. setFloat(name: string, value: number): ShaderMaterial;
  19701. /**
  19702. * Set a int in the shader.
  19703. * @param name Define the name of the uniform as defined in the shader
  19704. * @param value Define the value to give to the uniform
  19705. * @return the material itself allowing "fluent" like uniform updates
  19706. */
  19707. setInt(name: string, value: number): ShaderMaterial;
  19708. /**
  19709. * Set an array of floats in the shader.
  19710. * @param name Define the name of the uniform as defined in the shader
  19711. * @param value Define the value to give to the uniform
  19712. * @return the material itself allowing "fluent" like uniform updates
  19713. */
  19714. setFloats(name: string, value: number[]): ShaderMaterial;
  19715. /**
  19716. * Set a vec3 in the shader from a Color3.
  19717. * @param name Define the name of the uniform as defined in the shader
  19718. * @param value Define the value to give to the uniform
  19719. * @return the material itself allowing "fluent" like uniform updates
  19720. */
  19721. setColor3(name: string, value: Color3): ShaderMaterial;
  19722. /**
  19723. * Set a vec3 array in the shader from a Color3 array.
  19724. * @param name Define the name of the uniform as defined in the shader
  19725. * @param value Define the value to give to the uniform
  19726. * @return the material itself allowing "fluent" like uniform updates
  19727. */
  19728. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  19729. /**
  19730. * Set a vec4 in the shader from a Color4.
  19731. * @param name Define the name of the uniform as defined in the shader
  19732. * @param value Define the value to give to the uniform
  19733. * @return the material itself allowing "fluent" like uniform updates
  19734. */
  19735. setColor4(name: string, value: Color4): ShaderMaterial;
  19736. /**
  19737. * Set a vec4 array in the shader from a Color4 array.
  19738. * @param name Define the name of the uniform as defined in the shader
  19739. * @param value Define the value to give to the uniform
  19740. * @return the material itself allowing "fluent" like uniform updates
  19741. */
  19742. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  19743. /**
  19744. * Set a vec2 in the shader from a Vector2.
  19745. * @param name Define the name of the uniform as defined in the shader
  19746. * @param value Define the value to give to the uniform
  19747. * @return the material itself allowing "fluent" like uniform updates
  19748. */
  19749. setVector2(name: string, value: Vector2): ShaderMaterial;
  19750. /**
  19751. * Set a vec3 in the shader from a Vector3.
  19752. * @param name Define the name of the uniform as defined in the shader
  19753. * @param value Define the value to give to the uniform
  19754. * @return the material itself allowing "fluent" like uniform updates
  19755. */
  19756. setVector3(name: string, value: Vector3): ShaderMaterial;
  19757. /**
  19758. * Set a vec4 in the shader from a Vector4.
  19759. * @param name Define the name of the uniform as defined in the shader
  19760. * @param value Define the value to give to the uniform
  19761. * @return the material itself allowing "fluent" like uniform updates
  19762. */
  19763. setVector4(name: string, value: Vector4): ShaderMaterial;
  19764. /**
  19765. * Set a mat4 in the shader from a Matrix.
  19766. * @param name Define the name of the uniform as defined in the shader
  19767. * @param value Define the value to give to the uniform
  19768. * @return the material itself allowing "fluent" like uniform updates
  19769. */
  19770. setMatrix(name: string, value: Matrix): ShaderMaterial;
  19771. /**
  19772. * Set a mat3 in the shader from a Float32Array.
  19773. * @param name Define the name of the uniform as defined in the shader
  19774. * @param value Define the value to give to the uniform
  19775. * @return the material itself allowing "fluent" like uniform updates
  19776. */
  19777. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  19778. /**
  19779. * Set a mat2 in the shader from a Float32Array.
  19780. * @param name Define the name of the uniform as defined in the shader
  19781. * @param value Define the value to give to the uniform
  19782. * @return the material itself allowing "fluent" like uniform updates
  19783. */
  19784. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  19785. /**
  19786. * Set a vec2 array in the shader from a number array.
  19787. * @param name Define the name of the uniform as defined in the shader
  19788. * @param value Define the value to give to the uniform
  19789. * @return the material itself allowing "fluent" like uniform updates
  19790. */
  19791. setArray2(name: string, value: number[]): ShaderMaterial;
  19792. /**
  19793. * Set a vec3 array in the shader from a number array.
  19794. * @param name Define the name of the uniform as defined in the shader
  19795. * @param value Define the value to give to the uniform
  19796. * @return the material itself allowing "fluent" like uniform updates
  19797. */
  19798. setArray3(name: string, value: number[]): ShaderMaterial;
  19799. /**
  19800. * Set a vec4 array in the shader from a number array.
  19801. * @param name Define the name of the uniform as defined in the shader
  19802. * @param value Define the value to give to the uniform
  19803. * @return the material itself allowing "fluent" like uniform updates
  19804. */
  19805. setArray4(name: string, value: number[]): ShaderMaterial;
  19806. private _checkCache;
  19807. /**
  19808. * Specifies that the submesh is ready to be used
  19809. * @param mesh defines the mesh to check
  19810. * @param subMesh defines which submesh to check
  19811. * @param useInstances specifies that instances should be used
  19812. * @returns a boolean indicating that the submesh is ready or not
  19813. */
  19814. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  19815. /**
  19816. * Checks if the material is ready to render the requested mesh
  19817. * @param mesh Define the mesh to render
  19818. * @param useInstances Define whether or not the material is used with instances
  19819. * @returns true if ready, otherwise false
  19820. */
  19821. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  19822. /**
  19823. * Binds the world matrix to the material
  19824. * @param world defines the world transformation matrix
  19825. */
  19826. bindOnlyWorldMatrix(world: Matrix): void;
  19827. /**
  19828. * Binds the material to the mesh
  19829. * @param world defines the world transformation matrix
  19830. * @param mesh defines the mesh to bind the material to
  19831. */
  19832. bind(world: Matrix, mesh?: Mesh): void;
  19833. /**
  19834. * Gets the active textures from the material
  19835. * @returns an array of textures
  19836. */
  19837. getActiveTextures(): BaseTexture[];
  19838. /**
  19839. * Specifies if the material uses a texture
  19840. * @param texture defines the texture to check against the material
  19841. * @returns a boolean specifying if the material uses the texture
  19842. */
  19843. hasTexture(texture: BaseTexture): boolean;
  19844. /**
  19845. * Makes a duplicate of the material, and gives it a new name
  19846. * @param name defines the new name for the duplicated material
  19847. * @returns the cloned material
  19848. */
  19849. clone(name: string): ShaderMaterial;
  19850. /**
  19851. * Disposes the material
  19852. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  19853. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  19854. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  19855. */
  19856. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  19857. /**
  19858. * Serializes this material in a JSON representation
  19859. * @returns the serialized material object
  19860. */
  19861. serialize(): any;
  19862. /**
  19863. * Creates a shader material from parsed shader material data
  19864. * @param source defines the JSON represnetation of the material
  19865. * @param scene defines the hosting scene
  19866. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  19867. * @returns a new material
  19868. */
  19869. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  19870. }
  19871. }
  19872. declare module "babylonjs/Shaders/color.fragment" {
  19873. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  19874. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  19875. /** @hidden */
  19876. export var colorPixelShader: {
  19877. name: string;
  19878. shader: string;
  19879. };
  19880. }
  19881. declare module "babylonjs/Shaders/color.vertex" {
  19882. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  19883. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  19884. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  19885. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  19886. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  19887. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  19888. /** @hidden */
  19889. export var colorVertexShader: {
  19890. name: string;
  19891. shader: string;
  19892. };
  19893. }
  19894. declare module "babylonjs/Meshes/linesMesh" {
  19895. import { Nullable } from "babylonjs/types";
  19896. import { Scene } from "babylonjs/scene";
  19897. import { Color3 } from "babylonjs/Maths/math.color";
  19898. import { Node } from "babylonjs/node";
  19899. import { SubMesh } from "babylonjs/Meshes/subMesh";
  19900. import { Mesh } from "babylonjs/Meshes/mesh";
  19901. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  19902. import { Effect } from "babylonjs/Materials/effect";
  19903. import { Material } from "babylonjs/Materials/material";
  19904. import "babylonjs/Shaders/color.fragment";
  19905. import "babylonjs/Shaders/color.vertex";
  19906. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19907. /**
  19908. * Line mesh
  19909. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  19910. */
  19911. export class LinesMesh extends Mesh {
  19912. /**
  19913. * If vertex color should be applied to the mesh
  19914. */
  19915. readonly useVertexColor?: boolean | undefined;
  19916. /**
  19917. * If vertex alpha should be applied to the mesh
  19918. */
  19919. readonly useVertexAlpha?: boolean | undefined;
  19920. /**
  19921. * Color of the line (Default: White)
  19922. */
  19923. color: Color3;
  19924. /**
  19925. * Alpha of the line (Default: 1)
  19926. */
  19927. alpha: number;
  19928. /**
  19929. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  19930. * This margin is expressed in world space coordinates, so its value may vary.
  19931. * Default value is 0.1
  19932. */
  19933. intersectionThreshold: number;
  19934. private _colorShader;
  19935. private color4;
  19936. /**
  19937. * Creates a new LinesMesh
  19938. * @param name defines the name
  19939. * @param scene defines the hosting scene
  19940. * @param parent defines the parent mesh if any
  19941. * @param source defines the optional source LinesMesh used to clone data from
  19942. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  19943. * When false, achieved by calling a clone(), also passing False.
  19944. * This will make creation of children, recursive.
  19945. * @param useVertexColor defines if this LinesMesh supports vertex color
  19946. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  19947. */
  19948. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  19949. /**
  19950. * If vertex color should be applied to the mesh
  19951. */
  19952. useVertexColor?: boolean | undefined,
  19953. /**
  19954. * If vertex alpha should be applied to the mesh
  19955. */
  19956. useVertexAlpha?: boolean | undefined);
  19957. private _addClipPlaneDefine;
  19958. private _removeClipPlaneDefine;
  19959. isReady(): boolean;
  19960. /**
  19961. * Returns the string "LineMesh"
  19962. */
  19963. getClassName(): string;
  19964. /**
  19965. * @hidden
  19966. */
  19967. /**
  19968. * @hidden
  19969. */
  19970. material: Material;
  19971. /**
  19972. * @hidden
  19973. */
  19974. readonly checkCollisions: boolean;
  19975. /** @hidden */
  19976. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  19977. /** @hidden */
  19978. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  19979. /**
  19980. * Disposes of the line mesh
  19981. * @param doNotRecurse If children should be disposed
  19982. */
  19983. dispose(doNotRecurse?: boolean): void;
  19984. /**
  19985. * Returns a new LineMesh object cloned from the current one.
  19986. */
  19987. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  19988. /**
  19989. * Creates a new InstancedLinesMesh object from the mesh model.
  19990. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  19991. * @param name defines the name of the new instance
  19992. * @returns a new InstancedLinesMesh
  19993. */
  19994. createInstance(name: string): InstancedLinesMesh;
  19995. }
  19996. /**
  19997. * Creates an instance based on a source LinesMesh
  19998. */
  19999. export class InstancedLinesMesh extends InstancedMesh {
  20000. /**
  20001. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  20002. * This margin is expressed in world space coordinates, so its value may vary.
  20003. * Initilized with the intersectionThreshold value of the source LinesMesh
  20004. */
  20005. intersectionThreshold: number;
  20006. constructor(name: string, source: LinesMesh);
  20007. /**
  20008. * Returns the string "InstancedLinesMesh".
  20009. */
  20010. getClassName(): string;
  20011. }
  20012. }
  20013. declare module "babylonjs/Shaders/line.fragment" {
  20014. /** @hidden */
  20015. export var linePixelShader: {
  20016. name: string;
  20017. shader: string;
  20018. };
  20019. }
  20020. declare module "babylonjs/Shaders/line.vertex" {
  20021. /** @hidden */
  20022. export var lineVertexShader: {
  20023. name: string;
  20024. shader: string;
  20025. };
  20026. }
  20027. declare module "babylonjs/Rendering/edgesRenderer" {
  20028. import { Nullable } from "babylonjs/types";
  20029. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  20030. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20031. import { Vector3 } from "babylonjs/Maths/math.vector";
  20032. import { IDisposable } from "babylonjs/scene";
  20033. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  20034. import "babylonjs/Shaders/line.fragment";
  20035. import "babylonjs/Shaders/line.vertex";
  20036. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  20037. module "babylonjs/Meshes/abstractMesh" {
  20038. interface AbstractMesh {
  20039. /**
  20040. * Gets the edgesRenderer associated with the mesh
  20041. */
  20042. edgesRenderer: Nullable<EdgesRenderer>;
  20043. }
  20044. }
  20045. module "babylonjs/Meshes/linesMesh" {
  20046. interface LinesMesh {
  20047. /**
  20048. * Enables the edge rendering mode on the mesh.
  20049. * This mode makes the mesh edges visible
  20050. * @param epsilon defines the maximal distance between two angles to detect a face
  20051. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20052. * @returns the currentAbstractMesh
  20053. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20054. */
  20055. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  20056. }
  20057. }
  20058. module "babylonjs/Meshes/linesMesh" {
  20059. interface InstancedLinesMesh {
  20060. /**
  20061. * Enables the edge rendering mode on the mesh.
  20062. * This mode makes the mesh edges visible
  20063. * @param epsilon defines the maximal distance between two angles to detect a face
  20064. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  20065. * @returns the current InstancedLinesMesh
  20066. * @see https://www.babylonjs-playground.com/#19O9TU#0
  20067. */
  20068. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  20069. }
  20070. }
  20071. /**
  20072. * Defines the minimum contract an Edges renderer should follow.
  20073. */
  20074. export interface IEdgesRenderer extends IDisposable {
  20075. /**
  20076. * Gets or sets a boolean indicating if the edgesRenderer is active
  20077. */
  20078. isEnabled: boolean;
  20079. /**
  20080. * Renders the edges of the attached mesh,
  20081. */
  20082. render(): void;
  20083. /**
  20084. * Checks wether or not the edges renderer is ready to render.
  20085. * @return true if ready, otherwise false.
  20086. */
  20087. isReady(): boolean;
  20088. }
  20089. /**
  20090. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  20091. */
  20092. export class EdgesRenderer implements IEdgesRenderer {
  20093. /**
  20094. * Define the size of the edges with an orthographic camera
  20095. */
  20096. edgesWidthScalerForOrthographic: number;
  20097. /**
  20098. * Define the size of the edges with a perspective camera
  20099. */
  20100. edgesWidthScalerForPerspective: number;
  20101. protected _source: AbstractMesh;
  20102. protected _linesPositions: number[];
  20103. protected _linesNormals: number[];
  20104. protected _linesIndices: number[];
  20105. protected _epsilon: number;
  20106. protected _indicesCount: number;
  20107. protected _lineShader: ShaderMaterial;
  20108. protected _ib: DataBuffer;
  20109. protected _buffers: {
  20110. [key: string]: Nullable<VertexBuffer>;
  20111. };
  20112. protected _checkVerticesInsteadOfIndices: boolean;
  20113. private _meshRebuildObserver;
  20114. private _meshDisposeObserver;
  20115. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  20116. isEnabled: boolean;
  20117. /**
  20118. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  20119. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  20120. * @param source Mesh used to create edges
  20121. * @param epsilon sum of angles in adjacency to check for edge
  20122. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  20123. * @param generateEdgesLines - should generate Lines or only prepare resources.
  20124. */
  20125. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  20126. protected _prepareRessources(): void;
  20127. /** @hidden */
  20128. _rebuild(): void;
  20129. /**
  20130. * Releases the required resources for the edges renderer
  20131. */
  20132. dispose(): void;
  20133. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  20134. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  20135. /**
  20136. * Checks if the pair of p0 and p1 is en edge
  20137. * @param faceIndex
  20138. * @param edge
  20139. * @param faceNormals
  20140. * @param p0
  20141. * @param p1
  20142. * @private
  20143. */
  20144. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  20145. /**
  20146. * push line into the position, normal and index buffer
  20147. * @protected
  20148. */
  20149. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  20150. /**
  20151. * Generates lines edges from adjacencjes
  20152. * @private
  20153. */
  20154. _generateEdgesLines(): void;
  20155. /**
  20156. * Checks wether or not the edges renderer is ready to render.
  20157. * @return true if ready, otherwise false.
  20158. */
  20159. isReady(): boolean;
  20160. /**
  20161. * Renders the edges of the attached mesh,
  20162. */
  20163. render(): void;
  20164. }
  20165. /**
  20166. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  20167. */
  20168. export class LineEdgesRenderer extends EdgesRenderer {
  20169. /**
  20170. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  20171. * @param source LineMesh used to generate edges
  20172. * @param epsilon not important (specified angle for edge detection)
  20173. * @param checkVerticesInsteadOfIndices not important for LineMesh
  20174. */
  20175. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  20176. /**
  20177. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  20178. */
  20179. _generateEdgesLines(): void;
  20180. }
  20181. }
  20182. declare module "babylonjs/Rendering/renderingGroup" {
  20183. import { SmartArray } from "babylonjs/Misc/smartArray";
  20184. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20185. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20186. import { Nullable } from "babylonjs/types";
  20187. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20188. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  20189. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20190. import { Material } from "babylonjs/Materials/material";
  20191. import { Scene } from "babylonjs/scene";
  20192. /**
  20193. * This represents the object necessary to create a rendering group.
  20194. * This is exclusively used and created by the rendering manager.
  20195. * To modify the behavior, you use the available helpers in your scene or meshes.
  20196. * @hidden
  20197. */
  20198. export class RenderingGroup {
  20199. index: number;
  20200. private static _zeroVector;
  20201. private _scene;
  20202. private _opaqueSubMeshes;
  20203. private _transparentSubMeshes;
  20204. private _alphaTestSubMeshes;
  20205. private _depthOnlySubMeshes;
  20206. private _particleSystems;
  20207. private _spriteManagers;
  20208. private _opaqueSortCompareFn;
  20209. private _alphaTestSortCompareFn;
  20210. private _transparentSortCompareFn;
  20211. private _renderOpaque;
  20212. private _renderAlphaTest;
  20213. private _renderTransparent;
  20214. /** @hidden */
  20215. _edgesRenderers: SmartArray<IEdgesRenderer>;
  20216. onBeforeTransparentRendering: () => void;
  20217. /**
  20218. * Set the opaque sort comparison function.
  20219. * If null the sub meshes will be render in the order they were created
  20220. */
  20221. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20222. /**
  20223. * Set the alpha test sort comparison function.
  20224. * If null the sub meshes will be render in the order they were created
  20225. */
  20226. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20227. /**
  20228. * Set the transparent sort comparison function.
  20229. * If null the sub meshes will be render in the order they were created
  20230. */
  20231. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  20232. /**
  20233. * Creates a new rendering group.
  20234. * @param index The rendering group index
  20235. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  20236. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  20237. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  20238. */
  20239. 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>);
  20240. /**
  20241. * Render all the sub meshes contained in the group.
  20242. * @param customRenderFunction Used to override the default render behaviour of the group.
  20243. * @returns true if rendered some submeshes.
  20244. */
  20245. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  20246. /**
  20247. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  20248. * @param subMeshes The submeshes to render
  20249. */
  20250. private renderOpaqueSorted;
  20251. /**
  20252. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  20253. * @param subMeshes The submeshes to render
  20254. */
  20255. private renderAlphaTestSorted;
  20256. /**
  20257. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  20258. * @param subMeshes The submeshes to render
  20259. */
  20260. private renderTransparentSorted;
  20261. /**
  20262. * Renders the submeshes in a specified order.
  20263. * @param subMeshes The submeshes to sort before render
  20264. * @param sortCompareFn The comparison function use to sort
  20265. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  20266. * @param transparent Specifies to activate blending if true
  20267. */
  20268. private static renderSorted;
  20269. /**
  20270. * Renders the submeshes in the order they were dispatched (no sort applied).
  20271. * @param subMeshes The submeshes to render
  20272. */
  20273. private static renderUnsorted;
  20274. /**
  20275. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20276. * are rendered back to front if in the same alpha index.
  20277. *
  20278. * @param a The first submesh
  20279. * @param b The second submesh
  20280. * @returns The result of the comparison
  20281. */
  20282. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  20283. /**
  20284. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20285. * are rendered back to front.
  20286. *
  20287. * @param a The first submesh
  20288. * @param b The second submesh
  20289. * @returns The result of the comparison
  20290. */
  20291. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  20292. /**
  20293. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  20294. * are rendered front to back (prevent overdraw).
  20295. *
  20296. * @param a The first submesh
  20297. * @param b The second submesh
  20298. * @returns The result of the comparison
  20299. */
  20300. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  20301. /**
  20302. * Resets the different lists of submeshes to prepare a new frame.
  20303. */
  20304. prepare(): void;
  20305. dispose(): void;
  20306. /**
  20307. * Inserts the submesh in its correct queue depending on its material.
  20308. * @param subMesh The submesh to dispatch
  20309. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20310. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20311. */
  20312. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20313. dispatchSprites(spriteManager: ISpriteManager): void;
  20314. dispatchParticles(particleSystem: IParticleSystem): void;
  20315. private _renderParticles;
  20316. private _renderSprites;
  20317. }
  20318. }
  20319. declare module "babylonjs/Rendering/renderingManager" {
  20320. import { Nullable } from "babylonjs/types";
  20321. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20322. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20323. import { SmartArray } from "babylonjs/Misc/smartArray";
  20324. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  20325. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  20326. import { Material } from "babylonjs/Materials/material";
  20327. import { Scene } from "babylonjs/scene";
  20328. import { Camera } from "babylonjs/Cameras/camera";
  20329. /**
  20330. * Interface describing the different options available in the rendering manager
  20331. * regarding Auto Clear between groups.
  20332. */
  20333. export interface IRenderingManagerAutoClearSetup {
  20334. /**
  20335. * Defines whether or not autoclear is enable.
  20336. */
  20337. autoClear: boolean;
  20338. /**
  20339. * Defines whether or not to autoclear the depth buffer.
  20340. */
  20341. depth: boolean;
  20342. /**
  20343. * Defines whether or not to autoclear the stencil buffer.
  20344. */
  20345. stencil: boolean;
  20346. }
  20347. /**
  20348. * This class is used by the onRenderingGroupObservable
  20349. */
  20350. export class RenderingGroupInfo {
  20351. /**
  20352. * The Scene that being rendered
  20353. */
  20354. scene: Scene;
  20355. /**
  20356. * The camera currently used for the rendering pass
  20357. */
  20358. camera: Nullable<Camera>;
  20359. /**
  20360. * The ID of the renderingGroup being processed
  20361. */
  20362. renderingGroupId: number;
  20363. }
  20364. /**
  20365. * This is the manager responsible of all the rendering for meshes sprites and particles.
  20366. * It is enable to manage the different groups as well as the different necessary sort functions.
  20367. * This should not be used directly aside of the few static configurations
  20368. */
  20369. export class RenderingManager {
  20370. /**
  20371. * The max id used for rendering groups (not included)
  20372. */
  20373. static MAX_RENDERINGGROUPS: number;
  20374. /**
  20375. * The min id used for rendering groups (included)
  20376. */
  20377. static MIN_RENDERINGGROUPS: number;
  20378. /**
  20379. * Used to globally prevent autoclearing scenes.
  20380. */
  20381. static AUTOCLEAR: boolean;
  20382. /**
  20383. * @hidden
  20384. */
  20385. _useSceneAutoClearSetup: boolean;
  20386. private _scene;
  20387. private _renderingGroups;
  20388. private _depthStencilBufferAlreadyCleaned;
  20389. private _autoClearDepthStencil;
  20390. private _customOpaqueSortCompareFn;
  20391. private _customAlphaTestSortCompareFn;
  20392. private _customTransparentSortCompareFn;
  20393. private _renderingGroupInfo;
  20394. /**
  20395. * Instantiates a new rendering group for a particular scene
  20396. * @param scene Defines the scene the groups belongs to
  20397. */
  20398. constructor(scene: Scene);
  20399. private _clearDepthStencilBuffer;
  20400. /**
  20401. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  20402. * @hidden
  20403. */
  20404. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  20405. /**
  20406. * Resets the different information of the group to prepare a new frame
  20407. * @hidden
  20408. */
  20409. reset(): void;
  20410. /**
  20411. * Dispose and release the group and its associated resources.
  20412. * @hidden
  20413. */
  20414. dispose(): void;
  20415. /**
  20416. * Clear the info related to rendering groups preventing retention points during dispose.
  20417. */
  20418. freeRenderingGroups(): void;
  20419. private _prepareRenderingGroup;
  20420. /**
  20421. * Add a sprite manager to the rendering manager in order to render it this frame.
  20422. * @param spriteManager Define the sprite manager to render
  20423. */
  20424. dispatchSprites(spriteManager: ISpriteManager): void;
  20425. /**
  20426. * Add a particle system to the rendering manager in order to render it this frame.
  20427. * @param particleSystem Define the particle system to render
  20428. */
  20429. dispatchParticles(particleSystem: IParticleSystem): void;
  20430. /**
  20431. * Add a submesh to the manager in order to render it this frame
  20432. * @param subMesh The submesh to dispatch
  20433. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  20434. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  20435. */
  20436. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  20437. /**
  20438. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20439. * This allowed control for front to back rendering or reversly depending of the special needs.
  20440. *
  20441. * @param renderingGroupId The rendering group id corresponding to its index
  20442. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20443. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20444. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20445. */
  20446. 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;
  20447. /**
  20448. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20449. *
  20450. * @param renderingGroupId The rendering group id corresponding to its index
  20451. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20452. * @param depth Automatically clears depth between groups if true and autoClear is true.
  20453. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  20454. */
  20455. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  20456. /**
  20457. * Gets the current auto clear configuration for one rendering group of the rendering
  20458. * manager.
  20459. * @param index the rendering group index to get the information for
  20460. * @returns The auto clear setup for the requested rendering group
  20461. */
  20462. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  20463. }
  20464. }
  20465. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  20466. import { Observable } from "babylonjs/Misc/observable";
  20467. import { SmartArray } from "babylonjs/Misc/smartArray";
  20468. import { Nullable } from "babylonjs/types";
  20469. import { Camera } from "babylonjs/Cameras/camera";
  20470. import { Scene } from "babylonjs/scene";
  20471. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20472. import { Color4 } from "babylonjs/Maths/math.color";
  20473. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  20474. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20475. import { SubMesh } from "babylonjs/Meshes/subMesh";
  20476. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20477. import { Texture } from "babylonjs/Materials/Textures/texture";
  20478. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20479. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  20480. import "babylonjs/Engines/Extensions/engine.renderTarget";
  20481. import { Engine } from "babylonjs/Engines/engine";
  20482. /**
  20483. * This Helps creating a texture that will be created from a camera in your scene.
  20484. * It is basically a dynamic texture that could be used to create special effects for instance.
  20485. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  20486. */
  20487. export class RenderTargetTexture extends Texture {
  20488. isCube: boolean;
  20489. /**
  20490. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  20491. */
  20492. static readonly REFRESHRATE_RENDER_ONCE: number;
  20493. /**
  20494. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  20495. */
  20496. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  20497. /**
  20498. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  20499. * the central point of your effect and can save a lot of performances.
  20500. */
  20501. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  20502. /**
  20503. * Use this predicate to dynamically define the list of mesh you want to render.
  20504. * If set, the renderList property will be overwritten.
  20505. */
  20506. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  20507. private _renderList;
  20508. /**
  20509. * Use this list to define the list of mesh you want to render.
  20510. */
  20511. renderList: Nullable<Array<AbstractMesh>>;
  20512. private _hookArray;
  20513. /**
  20514. * Define if particles should be rendered in your texture.
  20515. */
  20516. renderParticles: boolean;
  20517. /**
  20518. * Define if sprites should be rendered in your texture.
  20519. */
  20520. renderSprites: boolean;
  20521. /**
  20522. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  20523. */
  20524. coordinatesMode: number;
  20525. /**
  20526. * Define the camera used to render the texture.
  20527. */
  20528. activeCamera: Nullable<Camera>;
  20529. /**
  20530. * Override the render function of the texture with your own one.
  20531. */
  20532. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  20533. /**
  20534. * Define if camera post processes should be use while rendering the texture.
  20535. */
  20536. useCameraPostProcesses: boolean;
  20537. /**
  20538. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  20539. */
  20540. ignoreCameraViewport: boolean;
  20541. private _postProcessManager;
  20542. private _postProcesses;
  20543. private _resizeObserver;
  20544. /**
  20545. * An event triggered when the texture is unbind.
  20546. */
  20547. onBeforeBindObservable: Observable<RenderTargetTexture>;
  20548. /**
  20549. * An event triggered when the texture is unbind.
  20550. */
  20551. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  20552. private _onAfterUnbindObserver;
  20553. /**
  20554. * Set a after unbind callback in the texture.
  20555. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  20556. */
  20557. onAfterUnbind: () => void;
  20558. /**
  20559. * An event triggered before rendering the texture
  20560. */
  20561. onBeforeRenderObservable: Observable<number>;
  20562. private _onBeforeRenderObserver;
  20563. /**
  20564. * Set a before render callback in the texture.
  20565. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  20566. */
  20567. onBeforeRender: (faceIndex: number) => void;
  20568. /**
  20569. * An event triggered after rendering the texture
  20570. */
  20571. onAfterRenderObservable: Observable<number>;
  20572. private _onAfterRenderObserver;
  20573. /**
  20574. * Set a after render callback in the texture.
  20575. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  20576. */
  20577. onAfterRender: (faceIndex: number) => void;
  20578. /**
  20579. * An event triggered after the texture clear
  20580. */
  20581. onClearObservable: Observable<Engine>;
  20582. private _onClearObserver;
  20583. /**
  20584. * Set a clear callback in the texture.
  20585. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  20586. */
  20587. onClear: (Engine: Engine) => void;
  20588. /**
  20589. * An event triggered when the texture is resized.
  20590. */
  20591. onResizeObservable: Observable<RenderTargetTexture>;
  20592. /**
  20593. * Define the clear color of the Render Target if it should be different from the scene.
  20594. */
  20595. clearColor: Color4;
  20596. protected _size: number | {
  20597. width: number;
  20598. height: number;
  20599. };
  20600. protected _initialSizeParameter: number | {
  20601. width: number;
  20602. height: number;
  20603. } | {
  20604. ratio: number;
  20605. };
  20606. protected _sizeRatio: Nullable<number>;
  20607. /** @hidden */
  20608. _generateMipMaps: boolean;
  20609. protected _renderingManager: RenderingManager;
  20610. /** @hidden */
  20611. _waitingRenderList: string[];
  20612. protected _doNotChangeAspectRatio: boolean;
  20613. protected _currentRefreshId: number;
  20614. protected _refreshRate: number;
  20615. protected _textureMatrix: Matrix;
  20616. protected _samples: number;
  20617. protected _renderTargetOptions: RenderTargetCreationOptions;
  20618. /**
  20619. * Gets render target creation options that were used.
  20620. */
  20621. readonly renderTargetOptions: RenderTargetCreationOptions;
  20622. protected _engine: Engine;
  20623. protected _onRatioRescale(): void;
  20624. /**
  20625. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  20626. * It must define where the camera used to render the texture is set
  20627. */
  20628. boundingBoxPosition: Vector3;
  20629. private _boundingBoxSize;
  20630. /**
  20631. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  20632. * When defined, the cubemap will switch to local mode
  20633. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  20634. * @example https://www.babylonjs-playground.com/#RNASML
  20635. */
  20636. boundingBoxSize: Vector3;
  20637. /**
  20638. * In case the RTT has been created with a depth texture, get the associated
  20639. * depth texture.
  20640. * Otherwise, return null.
  20641. */
  20642. depthStencilTexture: Nullable<InternalTexture>;
  20643. /**
  20644. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  20645. * or used a shadow, depth texture...
  20646. * @param name The friendly name of the texture
  20647. * @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)
  20648. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  20649. * @param generateMipMaps True if mip maps need to be generated after render.
  20650. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  20651. * @param type The type of the buffer in the RTT (int, half float, float...)
  20652. * @param isCube True if a cube texture needs to be created
  20653. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  20654. * @param generateDepthBuffer True to generate a depth buffer
  20655. * @param generateStencilBuffer True to generate a stencil buffer
  20656. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  20657. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  20658. * @param delayAllocation if the texture allocation should be delayed (default: false)
  20659. */
  20660. constructor(name: string, size: number | {
  20661. width: number;
  20662. height: number;
  20663. } | {
  20664. ratio: number;
  20665. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  20666. /**
  20667. * Creates a depth stencil texture.
  20668. * This is only available in WebGL 2 or with the depth texture extension available.
  20669. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  20670. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  20671. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  20672. */
  20673. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  20674. private _processSizeParameter;
  20675. /**
  20676. * Define the number of samples to use in case of MSAA.
  20677. * It defaults to one meaning no MSAA has been enabled.
  20678. */
  20679. samples: number;
  20680. /**
  20681. * Resets the refresh counter of the texture and start bak from scratch.
  20682. * Could be useful to regenerate the texture if it is setup to render only once.
  20683. */
  20684. resetRefreshCounter(): void;
  20685. /**
  20686. * Define the refresh rate of the texture or the rendering frequency.
  20687. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  20688. */
  20689. refreshRate: number;
  20690. /**
  20691. * Adds a post process to the render target rendering passes.
  20692. * @param postProcess define the post process to add
  20693. */
  20694. addPostProcess(postProcess: PostProcess): void;
  20695. /**
  20696. * Clear all the post processes attached to the render target
  20697. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  20698. */
  20699. clearPostProcesses(dispose?: boolean): void;
  20700. /**
  20701. * Remove one of the post process from the list of attached post processes to the texture
  20702. * @param postProcess define the post process to remove from the list
  20703. */
  20704. removePostProcess(postProcess: PostProcess): void;
  20705. /** @hidden */
  20706. _shouldRender(): boolean;
  20707. /**
  20708. * Gets the actual render size of the texture.
  20709. * @returns the width of the render size
  20710. */
  20711. getRenderSize(): number;
  20712. /**
  20713. * Gets the actual render width of the texture.
  20714. * @returns the width of the render size
  20715. */
  20716. getRenderWidth(): number;
  20717. /**
  20718. * Gets the actual render height of the texture.
  20719. * @returns the height of the render size
  20720. */
  20721. getRenderHeight(): number;
  20722. /**
  20723. * Get if the texture can be rescaled or not.
  20724. */
  20725. readonly canRescale: boolean;
  20726. /**
  20727. * Resize the texture using a ratio.
  20728. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  20729. */
  20730. scale(ratio: number): void;
  20731. /**
  20732. * Get the texture reflection matrix used to rotate/transform the reflection.
  20733. * @returns the reflection matrix
  20734. */
  20735. getReflectionTextureMatrix(): Matrix;
  20736. /**
  20737. * Resize the texture to a new desired size.
  20738. * Be carrefull as it will recreate all the data in the new texture.
  20739. * @param size Define the new size. It can be:
  20740. * - a number for squared texture,
  20741. * - an object containing { width: number, height: number }
  20742. * - or an object containing a ratio { ratio: number }
  20743. */
  20744. resize(size: number | {
  20745. width: number;
  20746. height: number;
  20747. } | {
  20748. ratio: number;
  20749. }): void;
  20750. /**
  20751. * Renders all the objects from the render list into the texture.
  20752. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  20753. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  20754. */
  20755. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  20756. private _bestReflectionRenderTargetDimension;
  20757. /**
  20758. * @hidden
  20759. * @param faceIndex face index to bind to if this is a cubetexture
  20760. */
  20761. _bindFrameBuffer(faceIndex?: number): void;
  20762. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  20763. private renderToTarget;
  20764. /**
  20765. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  20766. * This allowed control for front to back rendering or reversly depending of the special needs.
  20767. *
  20768. * @param renderingGroupId The rendering group id corresponding to its index
  20769. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  20770. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  20771. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  20772. */
  20773. 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;
  20774. /**
  20775. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  20776. *
  20777. * @param renderingGroupId The rendering group id corresponding to its index
  20778. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  20779. */
  20780. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  20781. /**
  20782. * Clones the texture.
  20783. * @returns the cloned texture
  20784. */
  20785. clone(): RenderTargetTexture;
  20786. /**
  20787. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  20788. * @returns The JSON representation of the texture
  20789. */
  20790. serialize(): any;
  20791. /**
  20792. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  20793. */
  20794. disposeFramebufferObjects(): void;
  20795. /**
  20796. * Dispose the texture and release its associated resources.
  20797. */
  20798. dispose(): void;
  20799. /** @hidden */
  20800. _rebuild(): void;
  20801. /**
  20802. * Clear the info related to rendering groups preventing retention point in material dispose.
  20803. */
  20804. freeRenderingGroups(): void;
  20805. /**
  20806. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20807. * @returns the view count
  20808. */
  20809. getViewCount(): number;
  20810. }
  20811. }
  20812. declare module "babylonjs/Materials/material" {
  20813. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  20814. import { SmartArray } from "babylonjs/Misc/smartArray";
  20815. import { Observable } from "babylonjs/Misc/observable";
  20816. import { Nullable } from "babylonjs/types";
  20817. import { Scene } from "babylonjs/scene";
  20818. import { Matrix } from "babylonjs/Maths/math.vector";
  20819. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  20820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20821. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20822. import { Effect } from "babylonjs/Materials/effect";
  20823. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20824. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20825. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20826. import { IInspectable } from "babylonjs/Misc/iInspectable";
  20827. import { Mesh } from "babylonjs/Meshes/mesh";
  20828. import { Animation } from "babylonjs/Animations/animation";
  20829. /**
  20830. * Base class for the main features of a material in Babylon.js
  20831. */
  20832. export class Material implements IAnimatable {
  20833. /**
  20834. * Returns the triangle fill mode
  20835. */
  20836. static readonly TriangleFillMode: number;
  20837. /**
  20838. * Returns the wireframe mode
  20839. */
  20840. static readonly WireFrameFillMode: number;
  20841. /**
  20842. * Returns the point fill mode
  20843. */
  20844. static readonly PointFillMode: number;
  20845. /**
  20846. * Returns the point list draw mode
  20847. */
  20848. static readonly PointListDrawMode: number;
  20849. /**
  20850. * Returns the line list draw mode
  20851. */
  20852. static readonly LineListDrawMode: number;
  20853. /**
  20854. * Returns the line loop draw mode
  20855. */
  20856. static readonly LineLoopDrawMode: number;
  20857. /**
  20858. * Returns the line strip draw mode
  20859. */
  20860. static readonly LineStripDrawMode: number;
  20861. /**
  20862. * Returns the triangle strip draw mode
  20863. */
  20864. static readonly TriangleStripDrawMode: number;
  20865. /**
  20866. * Returns the triangle fan draw mode
  20867. */
  20868. static readonly TriangleFanDrawMode: number;
  20869. /**
  20870. * Stores the clock-wise side orientation
  20871. */
  20872. static readonly ClockWiseSideOrientation: number;
  20873. /**
  20874. * Stores the counter clock-wise side orientation
  20875. */
  20876. static readonly CounterClockWiseSideOrientation: number;
  20877. /**
  20878. * The dirty texture flag value
  20879. */
  20880. static readonly TextureDirtyFlag: number;
  20881. /**
  20882. * The dirty light flag value
  20883. */
  20884. static readonly LightDirtyFlag: number;
  20885. /**
  20886. * The dirty fresnel flag value
  20887. */
  20888. static readonly FresnelDirtyFlag: number;
  20889. /**
  20890. * The dirty attribute flag value
  20891. */
  20892. static readonly AttributesDirtyFlag: number;
  20893. /**
  20894. * The dirty misc flag value
  20895. */
  20896. static readonly MiscDirtyFlag: number;
  20897. /**
  20898. * The all dirty flag value
  20899. */
  20900. static readonly AllDirtyFlag: number;
  20901. /**
  20902. * The ID of the material
  20903. */
  20904. id: string;
  20905. /**
  20906. * Gets or sets the unique id of the material
  20907. */
  20908. uniqueId: number;
  20909. /**
  20910. * The name of the material
  20911. */
  20912. name: string;
  20913. /**
  20914. * Gets or sets user defined metadata
  20915. */
  20916. metadata: any;
  20917. /**
  20918. * For internal use only. Please do not use.
  20919. */
  20920. reservedDataStore: any;
  20921. /**
  20922. * Specifies if the ready state should be checked on each call
  20923. */
  20924. checkReadyOnEveryCall: boolean;
  20925. /**
  20926. * Specifies if the ready state should be checked once
  20927. */
  20928. checkReadyOnlyOnce: boolean;
  20929. /**
  20930. * The state of the material
  20931. */
  20932. state: string;
  20933. /**
  20934. * The alpha value of the material
  20935. */
  20936. protected _alpha: number;
  20937. /**
  20938. * List of inspectable custom properties (used by the Inspector)
  20939. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  20940. */
  20941. inspectableCustomProperties: IInspectable[];
  20942. /**
  20943. * Sets the alpha value of the material
  20944. */
  20945. /**
  20946. * Gets the alpha value of the material
  20947. */
  20948. alpha: number;
  20949. /**
  20950. * Specifies if back face culling is enabled
  20951. */
  20952. protected _backFaceCulling: boolean;
  20953. /**
  20954. * Sets the back-face culling state
  20955. */
  20956. /**
  20957. * Gets the back-face culling state
  20958. */
  20959. backFaceCulling: boolean;
  20960. /**
  20961. * Stores the value for side orientation
  20962. */
  20963. sideOrientation: number;
  20964. /**
  20965. * Callback triggered when the material is compiled
  20966. */
  20967. onCompiled: Nullable<(effect: Effect) => void>;
  20968. /**
  20969. * Callback triggered when an error occurs
  20970. */
  20971. onError: Nullable<(effect: Effect, errors: string) => void>;
  20972. /**
  20973. * Callback triggered to get the render target textures
  20974. */
  20975. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  20976. /**
  20977. * Gets a boolean indicating that current material needs to register RTT
  20978. */
  20979. readonly hasRenderTargetTextures: boolean;
  20980. /**
  20981. * Specifies if the material should be serialized
  20982. */
  20983. doNotSerialize: boolean;
  20984. /**
  20985. * @hidden
  20986. */
  20987. _storeEffectOnSubMeshes: boolean;
  20988. /**
  20989. * Stores the animations for the material
  20990. */
  20991. animations: Nullable<Array<Animation>>;
  20992. /**
  20993. * An event triggered when the material is disposed
  20994. */
  20995. onDisposeObservable: Observable<Material>;
  20996. /**
  20997. * An observer which watches for dispose events
  20998. */
  20999. private _onDisposeObserver;
  21000. private _onUnBindObservable;
  21001. /**
  21002. * Called during a dispose event
  21003. */
  21004. onDispose: () => void;
  21005. private _onBindObservable;
  21006. /**
  21007. * An event triggered when the material is bound
  21008. */
  21009. readonly onBindObservable: Observable<AbstractMesh>;
  21010. /**
  21011. * An observer which watches for bind events
  21012. */
  21013. private _onBindObserver;
  21014. /**
  21015. * Called during a bind event
  21016. */
  21017. onBind: (Mesh: AbstractMesh) => void;
  21018. /**
  21019. * An event triggered when the material is unbound
  21020. */
  21021. readonly onUnBindObservable: Observable<Material>;
  21022. /**
  21023. * Stores the value of the alpha mode
  21024. */
  21025. private _alphaMode;
  21026. /**
  21027. * Sets the value of the alpha mode.
  21028. *
  21029. * | Value | Type | Description |
  21030. * | --- | --- | --- |
  21031. * | 0 | ALPHA_DISABLE | |
  21032. * | 1 | ALPHA_ADD | |
  21033. * | 2 | ALPHA_COMBINE | |
  21034. * | 3 | ALPHA_SUBTRACT | |
  21035. * | 4 | ALPHA_MULTIPLY | |
  21036. * | 5 | ALPHA_MAXIMIZED | |
  21037. * | 6 | ALPHA_ONEONE | |
  21038. * | 7 | ALPHA_PREMULTIPLIED | |
  21039. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  21040. * | 9 | ALPHA_INTERPOLATE | |
  21041. * | 10 | ALPHA_SCREENMODE | |
  21042. *
  21043. */
  21044. /**
  21045. * Gets the value of the alpha mode
  21046. */
  21047. alphaMode: number;
  21048. /**
  21049. * Stores the state of the need depth pre-pass value
  21050. */
  21051. private _needDepthPrePass;
  21052. /**
  21053. * Sets the need depth pre-pass value
  21054. */
  21055. /**
  21056. * Gets the depth pre-pass value
  21057. */
  21058. needDepthPrePass: boolean;
  21059. /**
  21060. * Specifies if depth writing should be disabled
  21061. */
  21062. disableDepthWrite: boolean;
  21063. /**
  21064. * Specifies if depth writing should be forced
  21065. */
  21066. forceDepthWrite: boolean;
  21067. /**
  21068. * Specifies if there should be a separate pass for culling
  21069. */
  21070. separateCullingPass: boolean;
  21071. /**
  21072. * Stores the state specifing if fog should be enabled
  21073. */
  21074. private _fogEnabled;
  21075. /**
  21076. * Sets the state for enabling fog
  21077. */
  21078. /**
  21079. * Gets the value of the fog enabled state
  21080. */
  21081. fogEnabled: boolean;
  21082. /**
  21083. * Stores the size of points
  21084. */
  21085. pointSize: number;
  21086. /**
  21087. * Stores the z offset value
  21088. */
  21089. zOffset: number;
  21090. /**
  21091. * Gets a value specifying if wireframe mode is enabled
  21092. */
  21093. /**
  21094. * Sets the state of wireframe mode
  21095. */
  21096. wireframe: boolean;
  21097. /**
  21098. * Gets the value specifying if point clouds are enabled
  21099. */
  21100. /**
  21101. * Sets the state of point cloud mode
  21102. */
  21103. pointsCloud: boolean;
  21104. /**
  21105. * Gets the material fill mode
  21106. */
  21107. /**
  21108. * Sets the material fill mode
  21109. */
  21110. fillMode: number;
  21111. /**
  21112. * @hidden
  21113. * Stores the effects for the material
  21114. */
  21115. _effect: Nullable<Effect>;
  21116. /**
  21117. * @hidden
  21118. * Specifies if the material was previously ready
  21119. */
  21120. _wasPreviouslyReady: boolean;
  21121. /**
  21122. * Specifies if uniform buffers should be used
  21123. */
  21124. private _useUBO;
  21125. /**
  21126. * Stores a reference to the scene
  21127. */
  21128. private _scene;
  21129. /**
  21130. * Stores the fill mode state
  21131. */
  21132. private _fillMode;
  21133. /**
  21134. * Specifies if the depth write state should be cached
  21135. */
  21136. private _cachedDepthWriteState;
  21137. /**
  21138. * Stores the uniform buffer
  21139. */
  21140. protected _uniformBuffer: UniformBuffer;
  21141. /** @hidden */
  21142. _indexInSceneMaterialArray: number;
  21143. /** @hidden */
  21144. meshMap: Nullable<{
  21145. [id: string]: AbstractMesh | undefined;
  21146. }>;
  21147. /**
  21148. * Creates a material instance
  21149. * @param name defines the name of the material
  21150. * @param scene defines the scene to reference
  21151. * @param doNotAdd specifies if the material should be added to the scene
  21152. */
  21153. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  21154. /**
  21155. * Returns a string representation of the current material
  21156. * @param fullDetails defines a boolean indicating which levels of logging is desired
  21157. * @returns a string with material information
  21158. */
  21159. toString(fullDetails?: boolean): string;
  21160. /**
  21161. * Gets the class name of the material
  21162. * @returns a string with the class name of the material
  21163. */
  21164. getClassName(): string;
  21165. /**
  21166. * Specifies if updates for the material been locked
  21167. */
  21168. readonly isFrozen: boolean;
  21169. /**
  21170. * Locks updates for the material
  21171. */
  21172. freeze(): void;
  21173. /**
  21174. * Unlocks updates for the material
  21175. */
  21176. unfreeze(): void;
  21177. /**
  21178. * Specifies if the material is ready to be used
  21179. * @param mesh defines the mesh to check
  21180. * @param useInstances specifies if instances should be used
  21181. * @returns a boolean indicating if the material is ready to be used
  21182. */
  21183. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  21184. /**
  21185. * Specifies that the submesh is ready to be used
  21186. * @param mesh defines the mesh to check
  21187. * @param subMesh defines which submesh to check
  21188. * @param useInstances specifies that instances should be used
  21189. * @returns a boolean indicating that the submesh is ready or not
  21190. */
  21191. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21192. /**
  21193. * Returns the material effect
  21194. * @returns the effect associated with the material
  21195. */
  21196. getEffect(): Nullable<Effect>;
  21197. /**
  21198. * Returns the current scene
  21199. * @returns a Scene
  21200. */
  21201. getScene(): Scene;
  21202. /**
  21203. * Specifies if the material will require alpha blending
  21204. * @returns a boolean specifying if alpha blending is needed
  21205. */
  21206. needAlphaBlending(): boolean;
  21207. /**
  21208. * Specifies if the mesh will require alpha blending
  21209. * @param mesh defines the mesh to check
  21210. * @returns a boolean specifying if alpha blending is needed for the mesh
  21211. */
  21212. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  21213. /**
  21214. * Specifies if this material should be rendered in alpha test mode
  21215. * @returns a boolean specifying if an alpha test is needed.
  21216. */
  21217. needAlphaTesting(): boolean;
  21218. /**
  21219. * Gets the texture used for the alpha test
  21220. * @returns the texture to use for alpha testing
  21221. */
  21222. getAlphaTestTexture(): Nullable<BaseTexture>;
  21223. /**
  21224. * Marks the material to indicate that it needs to be re-calculated
  21225. */
  21226. markDirty(): void;
  21227. /** @hidden */
  21228. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  21229. /**
  21230. * Binds the material to the mesh
  21231. * @param world defines the world transformation matrix
  21232. * @param mesh defines the mesh to bind the material to
  21233. */
  21234. bind(world: Matrix, mesh?: Mesh): void;
  21235. /**
  21236. * Binds the submesh to the material
  21237. * @param world defines the world transformation matrix
  21238. * @param mesh defines the mesh containing the submesh
  21239. * @param subMesh defines the submesh to bind the material to
  21240. */
  21241. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  21242. /**
  21243. * Binds the world matrix to the material
  21244. * @param world defines the world transformation matrix
  21245. */
  21246. bindOnlyWorldMatrix(world: Matrix): void;
  21247. /**
  21248. * Binds the scene's uniform buffer to the effect.
  21249. * @param effect defines the effect to bind to the scene uniform buffer
  21250. * @param sceneUbo defines the uniform buffer storing scene data
  21251. */
  21252. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  21253. /**
  21254. * Binds the view matrix to the effect
  21255. * @param effect defines the effect to bind the view matrix to
  21256. */
  21257. bindView(effect: Effect): void;
  21258. /**
  21259. * Binds the view projection matrix to the effect
  21260. * @param effect defines the effect to bind the view projection matrix to
  21261. */
  21262. bindViewProjection(effect: Effect): void;
  21263. /**
  21264. * Specifies if material alpha testing should be turned on for the mesh
  21265. * @param mesh defines the mesh to check
  21266. */
  21267. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  21268. /**
  21269. * Processes to execute after binding the material to a mesh
  21270. * @param mesh defines the rendered mesh
  21271. */
  21272. protected _afterBind(mesh?: Mesh): void;
  21273. /**
  21274. * Unbinds the material from the mesh
  21275. */
  21276. unbind(): void;
  21277. /**
  21278. * Gets the active textures from the material
  21279. * @returns an array of textures
  21280. */
  21281. getActiveTextures(): BaseTexture[];
  21282. /**
  21283. * Specifies if the material uses a texture
  21284. * @param texture defines the texture to check against the material
  21285. * @returns a boolean specifying if the material uses the texture
  21286. */
  21287. hasTexture(texture: BaseTexture): boolean;
  21288. /**
  21289. * Makes a duplicate of the material, and gives it a new name
  21290. * @param name defines the new name for the duplicated material
  21291. * @returns the cloned material
  21292. */
  21293. clone(name: string): Nullable<Material>;
  21294. /**
  21295. * Gets the meshes bound to the material
  21296. * @returns an array of meshes bound to the material
  21297. */
  21298. getBindedMeshes(): AbstractMesh[];
  21299. /**
  21300. * Force shader compilation
  21301. * @param mesh defines the mesh associated with this material
  21302. * @param onCompiled defines a function to execute once the material is compiled
  21303. * @param options defines the options to configure the compilation
  21304. */
  21305. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  21306. clipPlane: boolean;
  21307. }>): void;
  21308. /**
  21309. * Force shader compilation
  21310. * @param mesh defines the mesh that will use this material
  21311. * @param options defines additional options for compiling the shaders
  21312. * @returns a promise that resolves when the compilation completes
  21313. */
  21314. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  21315. clipPlane: boolean;
  21316. }>): Promise<void>;
  21317. private static readonly _AllDirtyCallBack;
  21318. private static readonly _ImageProcessingDirtyCallBack;
  21319. private static readonly _TextureDirtyCallBack;
  21320. private static readonly _FresnelDirtyCallBack;
  21321. private static readonly _MiscDirtyCallBack;
  21322. private static readonly _LightsDirtyCallBack;
  21323. private static readonly _AttributeDirtyCallBack;
  21324. private static _FresnelAndMiscDirtyCallBack;
  21325. private static _TextureAndMiscDirtyCallBack;
  21326. private static readonly _DirtyCallbackArray;
  21327. private static readonly _RunDirtyCallBacks;
  21328. /**
  21329. * Marks a define in the material to indicate that it needs to be re-computed
  21330. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  21331. */
  21332. markAsDirty(flag: number): void;
  21333. /**
  21334. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  21335. * @param func defines a function which checks material defines against the submeshes
  21336. */
  21337. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  21338. /**
  21339. * Indicates that we need to re-calculated for all submeshes
  21340. */
  21341. protected _markAllSubMeshesAsAllDirty(): void;
  21342. /**
  21343. * Indicates that image processing needs to be re-calculated for all submeshes
  21344. */
  21345. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  21346. /**
  21347. * Indicates that textures need to be re-calculated for all submeshes
  21348. */
  21349. protected _markAllSubMeshesAsTexturesDirty(): void;
  21350. /**
  21351. * Indicates that fresnel needs to be re-calculated for all submeshes
  21352. */
  21353. protected _markAllSubMeshesAsFresnelDirty(): void;
  21354. /**
  21355. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  21356. */
  21357. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  21358. /**
  21359. * Indicates that lights need to be re-calculated for all submeshes
  21360. */
  21361. protected _markAllSubMeshesAsLightsDirty(): void;
  21362. /**
  21363. * Indicates that attributes need to be re-calculated for all submeshes
  21364. */
  21365. protected _markAllSubMeshesAsAttributesDirty(): void;
  21366. /**
  21367. * Indicates that misc needs to be re-calculated for all submeshes
  21368. */
  21369. protected _markAllSubMeshesAsMiscDirty(): void;
  21370. /**
  21371. * Indicates that textures and misc need to be re-calculated for all submeshes
  21372. */
  21373. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  21374. /**
  21375. * Disposes the material
  21376. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  21377. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  21378. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  21379. */
  21380. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  21381. /** @hidden */
  21382. private releaseVertexArrayObject;
  21383. /**
  21384. * Serializes this material
  21385. * @returns the serialized material object
  21386. */
  21387. serialize(): any;
  21388. /**
  21389. * Creates a material from parsed material data
  21390. * @param parsedMaterial defines parsed material data
  21391. * @param scene defines the hosting scene
  21392. * @param rootUrl defines the root URL to use to load textures
  21393. * @returns a new material
  21394. */
  21395. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  21396. }
  21397. }
  21398. declare module "babylonjs/Materials/multiMaterial" {
  21399. import { Nullable } from "babylonjs/types";
  21400. import { Scene } from "babylonjs/scene";
  21401. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21402. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  21403. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21404. import { Material } from "babylonjs/Materials/material";
  21405. /**
  21406. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21407. * separate meshes. This can be use to improve performances.
  21408. * @see http://doc.babylonjs.com/how_to/multi_materials
  21409. */
  21410. export class MultiMaterial extends Material {
  21411. private _subMaterials;
  21412. /**
  21413. * Gets or Sets the list of Materials used within the multi material.
  21414. * They need to be ordered according to the submeshes order in the associated mesh
  21415. */
  21416. subMaterials: Nullable<Material>[];
  21417. /**
  21418. * Function used to align with Node.getChildren()
  21419. * @returns the list of Materials used within the multi material
  21420. */
  21421. getChildren(): Nullable<Material>[];
  21422. /**
  21423. * Instantiates a new Multi Material
  21424. * A multi-material is used to apply different materials to different parts of the same object without the need of
  21425. * separate meshes. This can be use to improve performances.
  21426. * @see http://doc.babylonjs.com/how_to/multi_materials
  21427. * @param name Define the name in the scene
  21428. * @param scene Define the scene the material belongs to
  21429. */
  21430. constructor(name: string, scene: Scene);
  21431. private _hookArray;
  21432. /**
  21433. * Get one of the submaterial by its index in the submaterials array
  21434. * @param index The index to look the sub material at
  21435. * @returns The Material if the index has been defined
  21436. */
  21437. getSubMaterial(index: number): Nullable<Material>;
  21438. /**
  21439. * Get the list of active textures for the whole sub materials list.
  21440. * @returns All the textures that will be used during the rendering
  21441. */
  21442. getActiveTextures(): BaseTexture[];
  21443. /**
  21444. * Gets the current class name of the material e.g. "MultiMaterial"
  21445. * Mainly use in serialization.
  21446. * @returns the class name
  21447. */
  21448. getClassName(): string;
  21449. /**
  21450. * Checks if the material is ready to render the requested sub mesh
  21451. * @param mesh Define the mesh the submesh belongs to
  21452. * @param subMesh Define the sub mesh to look readyness for
  21453. * @param useInstances Define whether or not the material is used with instances
  21454. * @returns true if ready, otherwise false
  21455. */
  21456. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  21457. /**
  21458. * Clones the current material and its related sub materials
  21459. * @param name Define the name of the newly cloned material
  21460. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  21461. * @returns the cloned material
  21462. */
  21463. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  21464. /**
  21465. * Serializes the materials into a JSON representation.
  21466. * @returns the JSON representation
  21467. */
  21468. serialize(): any;
  21469. /**
  21470. * Dispose the material and release its associated resources
  21471. * @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)
  21472. * @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)
  21473. * @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)
  21474. */
  21475. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  21476. /**
  21477. * Creates a MultiMaterial from parsed MultiMaterial data.
  21478. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  21479. * @param scene defines the hosting scene
  21480. * @returns a new MultiMaterial
  21481. */
  21482. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  21483. }
  21484. }
  21485. declare module "babylonjs/Meshes/subMesh" {
  21486. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  21487. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  21488. import { Engine } from "babylonjs/Engines/engine";
  21489. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  21490. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21491. import { Effect } from "babylonjs/Materials/effect";
  21492. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21493. import { Plane } from "babylonjs/Maths/math.plane";
  21494. import { Collider } from "babylonjs/Collisions/collider";
  21495. import { Material } from "babylonjs/Materials/material";
  21496. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  21497. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21498. import { Mesh } from "babylonjs/Meshes/mesh";
  21499. import { Ray } from "babylonjs/Culling/ray";
  21500. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  21501. /**
  21502. * Base class for submeshes
  21503. */
  21504. export class BaseSubMesh {
  21505. /** @hidden */
  21506. _materialDefines: Nullable<MaterialDefines>;
  21507. /** @hidden */
  21508. _materialEffect: Nullable<Effect>;
  21509. /**
  21510. * Gets associated effect
  21511. */
  21512. readonly effect: Nullable<Effect>;
  21513. /**
  21514. * Sets associated effect (effect used to render this submesh)
  21515. * @param effect defines the effect to associate with
  21516. * @param defines defines the set of defines used to compile this effect
  21517. */
  21518. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  21519. }
  21520. /**
  21521. * Defines a subdivision inside a mesh
  21522. */
  21523. export class SubMesh extends BaseSubMesh implements ICullable {
  21524. /** the material index to use */
  21525. materialIndex: number;
  21526. /** vertex index start */
  21527. verticesStart: number;
  21528. /** vertices count */
  21529. verticesCount: number;
  21530. /** index start */
  21531. indexStart: number;
  21532. /** indices count */
  21533. indexCount: number;
  21534. /** @hidden */
  21535. _linesIndexCount: number;
  21536. private _mesh;
  21537. private _renderingMesh;
  21538. private _boundingInfo;
  21539. private _linesIndexBuffer;
  21540. /** @hidden */
  21541. _lastColliderWorldVertices: Nullable<Vector3[]>;
  21542. /** @hidden */
  21543. _trianglePlanes: Plane[];
  21544. /** @hidden */
  21545. _lastColliderTransformMatrix: Nullable<Matrix>;
  21546. /** @hidden */
  21547. _renderId: number;
  21548. /** @hidden */
  21549. _alphaIndex: number;
  21550. /** @hidden */
  21551. _distanceToCamera: number;
  21552. /** @hidden */
  21553. _id: number;
  21554. private _currentMaterial;
  21555. /**
  21556. * Add a new submesh to a mesh
  21557. * @param materialIndex defines the material index to use
  21558. * @param verticesStart defines vertex index start
  21559. * @param verticesCount defines vertices count
  21560. * @param indexStart defines index start
  21561. * @param indexCount defines indices count
  21562. * @param mesh defines the parent mesh
  21563. * @param renderingMesh defines an optional rendering mesh
  21564. * @param createBoundingBox defines if bounding box should be created for this submesh
  21565. * @returns the new submesh
  21566. */
  21567. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  21568. /**
  21569. * Creates a new submesh
  21570. * @param materialIndex defines the material index to use
  21571. * @param verticesStart defines vertex index start
  21572. * @param verticesCount defines vertices count
  21573. * @param indexStart defines index start
  21574. * @param indexCount defines indices count
  21575. * @param mesh defines the parent mesh
  21576. * @param renderingMesh defines an optional rendering mesh
  21577. * @param createBoundingBox defines if bounding box should be created for this submesh
  21578. */
  21579. constructor(
  21580. /** the material index to use */
  21581. materialIndex: number,
  21582. /** vertex index start */
  21583. verticesStart: number,
  21584. /** vertices count */
  21585. verticesCount: number,
  21586. /** index start */
  21587. indexStart: number,
  21588. /** indices count */
  21589. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  21590. /**
  21591. * Returns true if this submesh covers the entire parent mesh
  21592. * @ignorenaming
  21593. */
  21594. readonly IsGlobal: boolean;
  21595. /**
  21596. * Returns the submesh BoudingInfo object
  21597. * @returns current bounding info (or mesh's one if the submesh is global)
  21598. */
  21599. getBoundingInfo(): BoundingInfo;
  21600. /**
  21601. * Sets the submesh BoundingInfo
  21602. * @param boundingInfo defines the new bounding info to use
  21603. * @returns the SubMesh
  21604. */
  21605. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  21606. /**
  21607. * Returns the mesh of the current submesh
  21608. * @return the parent mesh
  21609. */
  21610. getMesh(): AbstractMesh;
  21611. /**
  21612. * Returns the rendering mesh of the submesh
  21613. * @returns the rendering mesh (could be different from parent mesh)
  21614. */
  21615. getRenderingMesh(): Mesh;
  21616. /**
  21617. * Returns the submesh material
  21618. * @returns null or the current material
  21619. */
  21620. getMaterial(): Nullable<Material>;
  21621. /**
  21622. * Sets a new updated BoundingInfo object to the submesh
  21623. * @param data defines an optional position array to use to determine the bounding info
  21624. * @returns the SubMesh
  21625. */
  21626. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  21627. /** @hidden */
  21628. _checkCollision(collider: Collider): boolean;
  21629. /**
  21630. * Updates the submesh BoundingInfo
  21631. * @param world defines the world matrix to use to update the bounding info
  21632. * @returns the submesh
  21633. */
  21634. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  21635. /**
  21636. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  21637. * @param frustumPlanes defines the frustum planes
  21638. * @returns true if the submesh is intersecting with the frustum
  21639. */
  21640. isInFrustum(frustumPlanes: Plane[]): boolean;
  21641. /**
  21642. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  21643. * @param frustumPlanes defines the frustum planes
  21644. * @returns true if the submesh is inside the frustum
  21645. */
  21646. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  21647. /**
  21648. * Renders the submesh
  21649. * @param enableAlphaMode defines if alpha needs to be used
  21650. * @returns the submesh
  21651. */
  21652. render(enableAlphaMode: boolean): SubMesh;
  21653. /**
  21654. * @hidden
  21655. */
  21656. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  21657. /**
  21658. * Checks if the submesh intersects with a ray
  21659. * @param ray defines the ray to test
  21660. * @returns true is the passed ray intersects the submesh bounding box
  21661. */
  21662. canIntersects(ray: Ray): boolean;
  21663. /**
  21664. * Intersects current submesh with a ray
  21665. * @param ray defines the ray to test
  21666. * @param positions defines mesh's positions array
  21667. * @param indices defines mesh's indices array
  21668. * @param fastCheck defines if only bounding info should be used
  21669. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  21670. * @returns intersection info or null if no intersection
  21671. */
  21672. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  21673. /** @hidden */
  21674. private _intersectLines;
  21675. /** @hidden */
  21676. private _intersectUnIndexedLines;
  21677. /** @hidden */
  21678. private _intersectTriangles;
  21679. /** @hidden */
  21680. private _intersectUnIndexedTriangles;
  21681. /** @hidden */
  21682. _rebuild(): void;
  21683. /**
  21684. * Creates a new submesh from the passed mesh
  21685. * @param newMesh defines the new hosting mesh
  21686. * @param newRenderingMesh defines an optional rendering mesh
  21687. * @returns the new submesh
  21688. */
  21689. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  21690. /**
  21691. * Release associated resources
  21692. */
  21693. dispose(): void;
  21694. /**
  21695. * Gets the class name
  21696. * @returns the string "SubMesh".
  21697. */
  21698. getClassName(): string;
  21699. /**
  21700. * Creates a new submesh from indices data
  21701. * @param materialIndex the index of the main mesh material
  21702. * @param startIndex the index where to start the copy in the mesh indices array
  21703. * @param indexCount the number of indices to copy then from the startIndex
  21704. * @param mesh the main mesh to create the submesh from
  21705. * @param renderingMesh the optional rendering mesh
  21706. * @returns a new submesh
  21707. */
  21708. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  21709. }
  21710. }
  21711. declare module "babylonjs/Loading/sceneLoaderFlags" {
  21712. /**
  21713. * Class used to represent data loading progression
  21714. */
  21715. export class SceneLoaderFlags {
  21716. private static _ForceFullSceneLoadingForIncremental;
  21717. private static _ShowLoadingScreen;
  21718. private static _CleanBoneMatrixWeights;
  21719. private static _loggingLevel;
  21720. /**
  21721. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  21722. */
  21723. static ForceFullSceneLoadingForIncremental: boolean;
  21724. /**
  21725. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  21726. */
  21727. static ShowLoadingScreen: boolean;
  21728. /**
  21729. * Defines the current logging level (while loading the scene)
  21730. * @ignorenaming
  21731. */
  21732. static loggingLevel: number;
  21733. /**
  21734. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  21735. */
  21736. static CleanBoneMatrixWeights: boolean;
  21737. }
  21738. }
  21739. declare module "babylonjs/Meshes/geometry" {
  21740. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  21741. import { Scene } from "babylonjs/scene";
  21742. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  21743. import { Engine } from "babylonjs/Engines/engine";
  21744. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  21745. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21746. import { Effect } from "babylonjs/Materials/effect";
  21747. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  21748. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  21749. import { Mesh } from "babylonjs/Meshes/mesh";
  21750. /**
  21751. * Class used to store geometry data (vertex buffers + index buffer)
  21752. */
  21753. export class Geometry implements IGetSetVerticesData {
  21754. /**
  21755. * Gets or sets the ID of the geometry
  21756. */
  21757. id: string;
  21758. /**
  21759. * Gets or sets the unique ID of the geometry
  21760. */
  21761. uniqueId: number;
  21762. /**
  21763. * Gets the delay loading state of the geometry (none by default which means not delayed)
  21764. */
  21765. delayLoadState: number;
  21766. /**
  21767. * Gets the file containing the data to load when running in delay load state
  21768. */
  21769. delayLoadingFile: Nullable<string>;
  21770. /**
  21771. * Callback called when the geometry is updated
  21772. */
  21773. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  21774. private _scene;
  21775. private _engine;
  21776. private _meshes;
  21777. private _totalVertices;
  21778. /** @hidden */
  21779. _indices: IndicesArray;
  21780. /** @hidden */
  21781. _vertexBuffers: {
  21782. [key: string]: VertexBuffer;
  21783. };
  21784. private _isDisposed;
  21785. private _extend;
  21786. private _boundingBias;
  21787. /** @hidden */
  21788. _delayInfo: Array<string>;
  21789. private _indexBuffer;
  21790. private _indexBufferIsUpdatable;
  21791. /** @hidden */
  21792. _boundingInfo: Nullable<BoundingInfo>;
  21793. /** @hidden */
  21794. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  21795. /** @hidden */
  21796. _softwareSkinningFrameId: number;
  21797. private _vertexArrayObjects;
  21798. private _updatable;
  21799. /** @hidden */
  21800. _positions: Nullable<Vector3[]>;
  21801. /**
  21802. * 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
  21803. */
  21804. /**
  21805. * 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
  21806. */
  21807. boundingBias: Vector2;
  21808. /**
  21809. * Static function used to attach a new empty geometry to a mesh
  21810. * @param mesh defines the mesh to attach the geometry to
  21811. * @returns the new Geometry
  21812. */
  21813. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  21814. /**
  21815. * Creates a new geometry
  21816. * @param id defines the unique ID
  21817. * @param scene defines the hosting scene
  21818. * @param vertexData defines the VertexData used to get geometry data
  21819. * @param updatable defines if geometry must be updatable (false by default)
  21820. * @param mesh defines the mesh that will be associated with the geometry
  21821. */
  21822. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  21823. /**
  21824. * Gets the current extend of the geometry
  21825. */
  21826. readonly extend: {
  21827. minimum: Vector3;
  21828. maximum: Vector3;
  21829. };
  21830. /**
  21831. * Gets the hosting scene
  21832. * @returns the hosting Scene
  21833. */
  21834. getScene(): Scene;
  21835. /**
  21836. * Gets the hosting engine
  21837. * @returns the hosting Engine
  21838. */
  21839. getEngine(): Engine;
  21840. /**
  21841. * Defines if the geometry is ready to use
  21842. * @returns true if the geometry is ready to be used
  21843. */
  21844. isReady(): boolean;
  21845. /**
  21846. * Gets a value indicating that the geometry should not be serialized
  21847. */
  21848. readonly doNotSerialize: boolean;
  21849. /** @hidden */
  21850. _rebuild(): void;
  21851. /**
  21852. * Affects all geometry data in one call
  21853. * @param vertexData defines the geometry data
  21854. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  21855. */
  21856. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  21857. /**
  21858. * Set specific vertex data
  21859. * @param kind defines the data kind (Position, normal, etc...)
  21860. * @param data defines the vertex data to use
  21861. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  21862. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  21863. */
  21864. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  21865. /**
  21866. * Removes a specific vertex data
  21867. * @param kind defines the data kind (Position, normal, etc...)
  21868. */
  21869. removeVerticesData(kind: string): void;
  21870. /**
  21871. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  21872. * @param buffer defines the vertex buffer to use
  21873. * @param totalVertices defines the total number of vertices for position kind (could be null)
  21874. */
  21875. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  21876. /**
  21877. * Update a specific vertex buffer
  21878. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  21879. * It will do nothing if the buffer is not updatable
  21880. * @param kind defines the data kind (Position, normal, etc...)
  21881. * @param data defines the data to use
  21882. * @param offset defines the offset in the target buffer where to store the data
  21883. * @param useBytes set to true if the offset is in bytes
  21884. */
  21885. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  21886. /**
  21887. * Update a specific vertex buffer
  21888. * This function will create a new buffer if the current one is not updatable
  21889. * @param kind defines the data kind (Position, normal, etc...)
  21890. * @param data defines the data to use
  21891. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  21892. */
  21893. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  21894. private _updateBoundingInfo;
  21895. /** @hidden */
  21896. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  21897. /**
  21898. * Gets total number of vertices
  21899. * @returns the total number of vertices
  21900. */
  21901. getTotalVertices(): number;
  21902. /**
  21903. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  21904. * @param kind defines the data kind (Position, normal, etc...)
  21905. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21906. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21907. * @returns a float array containing vertex data
  21908. */
  21909. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21910. /**
  21911. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  21912. * @param kind defines the data kind (Position, normal, etc...)
  21913. * @returns true if the vertex buffer with the specified kind is updatable
  21914. */
  21915. isVertexBufferUpdatable(kind: string): boolean;
  21916. /**
  21917. * Gets a specific vertex buffer
  21918. * @param kind defines the data kind (Position, normal, etc...)
  21919. * @returns a VertexBuffer
  21920. */
  21921. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21922. /**
  21923. * Returns all vertex buffers
  21924. * @return an object holding all vertex buffers indexed by kind
  21925. */
  21926. getVertexBuffers(): Nullable<{
  21927. [key: string]: VertexBuffer;
  21928. }>;
  21929. /**
  21930. * Gets a boolean indicating if specific vertex buffer is present
  21931. * @param kind defines the data kind (Position, normal, etc...)
  21932. * @returns true if data is present
  21933. */
  21934. isVerticesDataPresent(kind: string): boolean;
  21935. /**
  21936. * Gets a list of all attached data kinds (Position, normal, etc...)
  21937. * @returns a list of string containing all kinds
  21938. */
  21939. getVerticesDataKinds(): string[];
  21940. /**
  21941. * Update index buffer
  21942. * @param indices defines the indices to store in the index buffer
  21943. * @param offset defines the offset in the target buffer where to store the data
  21944. * @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)
  21945. */
  21946. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  21947. /**
  21948. * Creates a new index buffer
  21949. * @param indices defines the indices to store in the index buffer
  21950. * @param totalVertices defines the total number of vertices (could be null)
  21951. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  21952. */
  21953. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  21954. /**
  21955. * Return the total number of indices
  21956. * @returns the total number of indices
  21957. */
  21958. getTotalIndices(): number;
  21959. /**
  21960. * Gets the index buffer array
  21961. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  21962. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21963. * @returns the index buffer array
  21964. */
  21965. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21966. /**
  21967. * Gets the index buffer
  21968. * @return the index buffer
  21969. */
  21970. getIndexBuffer(): Nullable<DataBuffer>;
  21971. /** @hidden */
  21972. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  21973. /**
  21974. * Release the associated resources for a specific mesh
  21975. * @param mesh defines the source mesh
  21976. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  21977. */
  21978. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  21979. /**
  21980. * Apply current geometry to a given mesh
  21981. * @param mesh defines the mesh to apply geometry to
  21982. */
  21983. applyToMesh(mesh: Mesh): void;
  21984. private _updateExtend;
  21985. private _applyToMesh;
  21986. private notifyUpdate;
  21987. /**
  21988. * Load the geometry if it was flagged as delay loaded
  21989. * @param scene defines the hosting scene
  21990. * @param onLoaded defines a callback called when the geometry is loaded
  21991. */
  21992. load(scene: Scene, onLoaded?: () => void): void;
  21993. private _queueLoad;
  21994. /**
  21995. * Invert the geometry to move from a right handed system to a left handed one.
  21996. */
  21997. toLeftHanded(): void;
  21998. /** @hidden */
  21999. _resetPointsArrayCache(): void;
  22000. /** @hidden */
  22001. _generatePointsArray(): boolean;
  22002. /**
  22003. * Gets a value indicating if the geometry is disposed
  22004. * @returns true if the geometry was disposed
  22005. */
  22006. isDisposed(): boolean;
  22007. private _disposeVertexArrayObjects;
  22008. /**
  22009. * Free all associated resources
  22010. */
  22011. dispose(): void;
  22012. /**
  22013. * Clone the current geometry into a new geometry
  22014. * @param id defines the unique ID of the new geometry
  22015. * @returns a new geometry object
  22016. */
  22017. copy(id: string): Geometry;
  22018. /**
  22019. * Serialize the current geometry info (and not the vertices data) into a JSON object
  22020. * @return a JSON representation of the current geometry data (without the vertices data)
  22021. */
  22022. serialize(): any;
  22023. private toNumberArray;
  22024. /**
  22025. * Serialize all vertices data into a JSON oject
  22026. * @returns a JSON representation of the current geometry data
  22027. */
  22028. serializeVerticeData(): any;
  22029. /**
  22030. * Extracts a clone of a mesh geometry
  22031. * @param mesh defines the source mesh
  22032. * @param id defines the unique ID of the new geometry object
  22033. * @returns the new geometry object
  22034. */
  22035. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  22036. /**
  22037. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  22038. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  22039. * Be aware Math.random() could cause collisions, but:
  22040. * "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"
  22041. * @returns a string containing a new GUID
  22042. */
  22043. static RandomId(): string;
  22044. /** @hidden */
  22045. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  22046. private static _CleanMatricesWeights;
  22047. /**
  22048. * Create a new geometry from persisted data (Using .babylon file format)
  22049. * @param parsedVertexData defines the persisted data
  22050. * @param scene defines the hosting scene
  22051. * @param rootUrl defines the root url to use to load assets (like delayed data)
  22052. * @returns the new geometry object
  22053. */
  22054. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  22055. }
  22056. }
  22057. declare module "babylonjs/Meshes/mesh.vertexData" {
  22058. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  22059. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  22060. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  22061. import { Geometry } from "babylonjs/Meshes/geometry";
  22062. import { Mesh } from "babylonjs/Meshes/mesh";
  22063. /**
  22064. * Define an interface for all classes that will get and set the data on vertices
  22065. */
  22066. export interface IGetSetVerticesData {
  22067. /**
  22068. * Gets a boolean indicating if specific vertex data is present
  22069. * @param kind defines the vertex data kind to use
  22070. * @returns true is data kind is present
  22071. */
  22072. isVerticesDataPresent(kind: string): boolean;
  22073. /**
  22074. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  22075. * @param kind defines the data kind (Position, normal, etc...)
  22076. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  22077. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22078. * @returns a float array containing vertex data
  22079. */
  22080. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  22081. /**
  22082. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  22083. * @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.
  22084. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  22085. * @returns the indices array or an empty array if the mesh has no geometry
  22086. */
  22087. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  22088. /**
  22089. * Set specific vertex data
  22090. * @param kind defines the data kind (Position, normal, etc...)
  22091. * @param data defines the vertex data to use
  22092. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  22093. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  22094. */
  22095. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  22096. /**
  22097. * Update a specific associated vertex buffer
  22098. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  22099. * - VertexBuffer.PositionKind
  22100. * - VertexBuffer.UVKind
  22101. * - VertexBuffer.UV2Kind
  22102. * - VertexBuffer.UV3Kind
  22103. * - VertexBuffer.UV4Kind
  22104. * - VertexBuffer.UV5Kind
  22105. * - VertexBuffer.UV6Kind
  22106. * - VertexBuffer.ColorKind
  22107. * - VertexBuffer.MatricesIndicesKind
  22108. * - VertexBuffer.MatricesIndicesExtraKind
  22109. * - VertexBuffer.MatricesWeightsKind
  22110. * - VertexBuffer.MatricesWeightsExtraKind
  22111. * @param data defines the data source
  22112. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  22113. * @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)
  22114. */
  22115. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  22116. /**
  22117. * Creates a new index buffer
  22118. * @param indices defines the indices to store in the index buffer
  22119. * @param totalVertices defines the total number of vertices (could be null)
  22120. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  22121. */
  22122. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  22123. }
  22124. /**
  22125. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  22126. */
  22127. export class VertexData {
  22128. /**
  22129. * Mesh side orientation : usually the external or front surface
  22130. */
  22131. static readonly FRONTSIDE: number;
  22132. /**
  22133. * Mesh side orientation : usually the internal or back surface
  22134. */
  22135. static readonly BACKSIDE: number;
  22136. /**
  22137. * Mesh side orientation : both internal and external or front and back surfaces
  22138. */
  22139. static readonly DOUBLESIDE: number;
  22140. /**
  22141. * Mesh side orientation : by default, `FRONTSIDE`
  22142. */
  22143. static readonly DEFAULTSIDE: number;
  22144. /**
  22145. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  22146. */
  22147. positions: Nullable<FloatArray>;
  22148. /**
  22149. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  22150. */
  22151. normals: Nullable<FloatArray>;
  22152. /**
  22153. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  22154. */
  22155. tangents: Nullable<FloatArray>;
  22156. /**
  22157. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22158. */
  22159. uvs: Nullable<FloatArray>;
  22160. /**
  22161. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22162. */
  22163. uvs2: Nullable<FloatArray>;
  22164. /**
  22165. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22166. */
  22167. uvs3: Nullable<FloatArray>;
  22168. /**
  22169. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22170. */
  22171. uvs4: Nullable<FloatArray>;
  22172. /**
  22173. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22174. */
  22175. uvs5: Nullable<FloatArray>;
  22176. /**
  22177. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  22178. */
  22179. uvs6: Nullable<FloatArray>;
  22180. /**
  22181. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  22182. */
  22183. colors: Nullable<FloatArray>;
  22184. /**
  22185. * 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).
  22186. */
  22187. matricesIndices: Nullable<FloatArray>;
  22188. /**
  22189. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  22190. */
  22191. matricesWeights: Nullable<FloatArray>;
  22192. /**
  22193. * An array extending the number of possible indices
  22194. */
  22195. matricesIndicesExtra: Nullable<FloatArray>;
  22196. /**
  22197. * An array extending the number of possible weights when the number of indices is extended
  22198. */
  22199. matricesWeightsExtra: Nullable<FloatArray>;
  22200. /**
  22201. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  22202. */
  22203. indices: Nullable<IndicesArray>;
  22204. /**
  22205. * Uses the passed data array to set the set the values for the specified kind of data
  22206. * @param data a linear array of floating numbers
  22207. * @param kind the type of data that is being set, eg positions, colors etc
  22208. */
  22209. set(data: FloatArray, kind: string): void;
  22210. /**
  22211. * Associates the vertexData to the passed Mesh.
  22212. * Sets it as updatable or not (default `false`)
  22213. * @param mesh the mesh the vertexData is applied to
  22214. * @param updatable when used and having the value true allows new data to update the vertexData
  22215. * @returns the VertexData
  22216. */
  22217. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  22218. /**
  22219. * Associates the vertexData to the passed Geometry.
  22220. * Sets it as updatable or not (default `false`)
  22221. * @param geometry the geometry the vertexData is applied to
  22222. * @param updatable when used and having the value true allows new data to update the vertexData
  22223. * @returns VertexData
  22224. */
  22225. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  22226. /**
  22227. * Updates the associated mesh
  22228. * @param mesh the mesh to be updated
  22229. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22230. * @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
  22231. * @returns VertexData
  22232. */
  22233. updateMesh(mesh: Mesh): VertexData;
  22234. /**
  22235. * Updates the associated geometry
  22236. * @param geometry the geometry to be updated
  22237. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  22238. * @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
  22239. * @returns VertexData.
  22240. */
  22241. updateGeometry(geometry: Geometry): VertexData;
  22242. private _applyTo;
  22243. private _update;
  22244. /**
  22245. * Transforms each position and each normal of the vertexData according to the passed Matrix
  22246. * @param matrix the transforming matrix
  22247. * @returns the VertexData
  22248. */
  22249. transform(matrix: Matrix): VertexData;
  22250. /**
  22251. * Merges the passed VertexData into the current one
  22252. * @param other the VertexData to be merged into the current one
  22253. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  22254. * @returns the modified VertexData
  22255. */
  22256. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  22257. private _mergeElement;
  22258. private _validate;
  22259. /**
  22260. * Serializes the VertexData
  22261. * @returns a serialized object
  22262. */
  22263. serialize(): any;
  22264. /**
  22265. * Extracts the vertexData from a mesh
  22266. * @param mesh the mesh from which to extract the VertexData
  22267. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  22268. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22269. * @returns the object VertexData associated to the passed mesh
  22270. */
  22271. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22272. /**
  22273. * Extracts the vertexData from the geometry
  22274. * @param geometry the geometry from which to extract the VertexData
  22275. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  22276. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  22277. * @returns the object VertexData associated to the passed mesh
  22278. */
  22279. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  22280. private static _ExtractFrom;
  22281. /**
  22282. * Creates the VertexData for a Ribbon
  22283. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  22284. * * pathArray array of paths, each of which an array of successive Vector3
  22285. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  22286. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  22287. * * 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
  22288. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22289. * * 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)
  22290. * * 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)
  22291. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  22292. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  22293. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  22294. * @returns the VertexData of the ribbon
  22295. */
  22296. static CreateRibbon(options: {
  22297. pathArray: Vector3[][];
  22298. closeArray?: boolean;
  22299. closePath?: boolean;
  22300. offset?: number;
  22301. sideOrientation?: number;
  22302. frontUVs?: Vector4;
  22303. backUVs?: Vector4;
  22304. invertUV?: boolean;
  22305. uvs?: Vector2[];
  22306. colors?: Color4[];
  22307. }): VertexData;
  22308. /**
  22309. * Creates the VertexData for a box
  22310. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22311. * * size sets the width, height and depth of the box to the value of size, optional default 1
  22312. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  22313. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  22314. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  22315. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22316. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22317. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22318. * * 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)
  22319. * * 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)
  22320. * @returns the VertexData of the box
  22321. */
  22322. static CreateBox(options: {
  22323. size?: number;
  22324. width?: number;
  22325. height?: number;
  22326. depth?: number;
  22327. faceUV?: Vector4[];
  22328. faceColors?: Color4[];
  22329. sideOrientation?: number;
  22330. frontUVs?: Vector4;
  22331. backUVs?: Vector4;
  22332. }): VertexData;
  22333. /**
  22334. * Creates the VertexData for a tiled box
  22335. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22336. * * faceTiles sets the pattern, tile size and number of tiles for a face
  22337. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  22338. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  22339. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22340. * @returns the VertexData of the box
  22341. */
  22342. static CreateTiledBox(options: {
  22343. pattern?: number;
  22344. width?: number;
  22345. height?: number;
  22346. depth?: number;
  22347. tileSize?: number;
  22348. tileWidth?: number;
  22349. tileHeight?: number;
  22350. alignHorizontal?: number;
  22351. alignVertical?: number;
  22352. faceUV?: Vector4[];
  22353. faceColors?: Color4[];
  22354. sideOrientation?: number;
  22355. }): VertexData;
  22356. /**
  22357. * Creates the VertexData for a tiled plane
  22358. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22359. * * pattern a limited pattern arrangement depending on the number
  22360. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  22361. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  22362. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  22363. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22364. * * 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)
  22365. * * 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)
  22366. * @returns the VertexData of the tiled plane
  22367. */
  22368. static CreateTiledPlane(options: {
  22369. pattern?: number;
  22370. tileSize?: number;
  22371. tileWidth?: number;
  22372. tileHeight?: number;
  22373. size?: number;
  22374. width?: number;
  22375. height?: number;
  22376. alignHorizontal?: number;
  22377. alignVertical?: number;
  22378. sideOrientation?: number;
  22379. frontUVs?: Vector4;
  22380. backUVs?: Vector4;
  22381. }): VertexData;
  22382. /**
  22383. * Creates the VertexData for an ellipsoid, defaults to a sphere
  22384. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22385. * * segments sets the number of horizontal strips optional, default 32
  22386. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  22387. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  22388. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  22389. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  22390. * * 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
  22391. * * 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
  22392. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22393. * * 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)
  22394. * * 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)
  22395. * @returns the VertexData of the ellipsoid
  22396. */
  22397. static CreateSphere(options: {
  22398. segments?: number;
  22399. diameter?: number;
  22400. diameterX?: number;
  22401. diameterY?: number;
  22402. diameterZ?: number;
  22403. arc?: number;
  22404. slice?: number;
  22405. sideOrientation?: number;
  22406. frontUVs?: Vector4;
  22407. backUVs?: Vector4;
  22408. }): VertexData;
  22409. /**
  22410. * Creates the VertexData for a cylinder, cone or prism
  22411. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22412. * * height sets the height (y direction) of the cylinder, optional, default 2
  22413. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  22414. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  22415. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  22416. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22417. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  22418. * * 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
  22419. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22420. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22421. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  22422. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  22423. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22424. * * 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)
  22425. * * 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)
  22426. * @returns the VertexData of the cylinder, cone or prism
  22427. */
  22428. static CreateCylinder(options: {
  22429. height?: number;
  22430. diameterTop?: number;
  22431. diameterBottom?: number;
  22432. diameter?: number;
  22433. tessellation?: number;
  22434. subdivisions?: number;
  22435. arc?: number;
  22436. faceColors?: Color4[];
  22437. faceUV?: Vector4[];
  22438. hasRings?: boolean;
  22439. enclose?: boolean;
  22440. sideOrientation?: number;
  22441. frontUVs?: Vector4;
  22442. backUVs?: Vector4;
  22443. }): VertexData;
  22444. /**
  22445. * Creates the VertexData for a torus
  22446. * @param options an object used to set the following optional parameters for the box, required but can be empty
  22447. * * diameter the diameter of the torus, optional default 1
  22448. * * thickness the diameter of the tube forming the torus, optional default 0.5
  22449. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  22450. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22451. * * 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)
  22452. * * 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)
  22453. * @returns the VertexData of the torus
  22454. */
  22455. static CreateTorus(options: {
  22456. diameter?: number;
  22457. thickness?: number;
  22458. tessellation?: number;
  22459. sideOrientation?: number;
  22460. frontUVs?: Vector4;
  22461. backUVs?: Vector4;
  22462. }): VertexData;
  22463. /**
  22464. * Creates the VertexData of the LineSystem
  22465. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  22466. * - lines an array of lines, each line being an array of successive Vector3
  22467. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  22468. * @returns the VertexData of the LineSystem
  22469. */
  22470. static CreateLineSystem(options: {
  22471. lines: Vector3[][];
  22472. colors?: Nullable<Color4[][]>;
  22473. }): VertexData;
  22474. /**
  22475. * Create the VertexData for a DashedLines
  22476. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  22477. * - points an array successive Vector3
  22478. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  22479. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  22480. * - dashNb the intended total number of dashes, optional, default 200
  22481. * @returns the VertexData for the DashedLines
  22482. */
  22483. static CreateDashedLines(options: {
  22484. points: Vector3[];
  22485. dashSize?: number;
  22486. gapSize?: number;
  22487. dashNb?: number;
  22488. }): VertexData;
  22489. /**
  22490. * Creates the VertexData for a Ground
  22491. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22492. * - width the width (x direction) of the ground, optional, default 1
  22493. * - height the height (z direction) of the ground, optional, default 1
  22494. * - subdivisions the number of subdivisions per side, optional, default 1
  22495. * @returns the VertexData of the Ground
  22496. */
  22497. static CreateGround(options: {
  22498. width?: number;
  22499. height?: number;
  22500. subdivisions?: number;
  22501. subdivisionsX?: number;
  22502. subdivisionsY?: number;
  22503. }): VertexData;
  22504. /**
  22505. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  22506. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  22507. * * xmin the ground minimum X coordinate, optional, default -1
  22508. * * zmin the ground minimum Z coordinate, optional, default -1
  22509. * * xmax the ground maximum X coordinate, optional, default 1
  22510. * * zmax the ground maximum Z coordinate, optional, default 1
  22511. * * 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}
  22512. * * 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}
  22513. * @returns the VertexData of the TiledGround
  22514. */
  22515. static CreateTiledGround(options: {
  22516. xmin: number;
  22517. zmin: number;
  22518. xmax: number;
  22519. zmax: number;
  22520. subdivisions?: {
  22521. w: number;
  22522. h: number;
  22523. };
  22524. precision?: {
  22525. w: number;
  22526. h: number;
  22527. };
  22528. }): VertexData;
  22529. /**
  22530. * Creates the VertexData of the Ground designed from a heightmap
  22531. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  22532. * * width the width (x direction) of the ground
  22533. * * height the height (z direction) of the ground
  22534. * * subdivisions the number of subdivisions per side
  22535. * * minHeight the minimum altitude on the ground, optional, default 0
  22536. * * maxHeight the maximum altitude on the ground, optional default 1
  22537. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  22538. * * buffer the array holding the image color data
  22539. * * bufferWidth the width of image
  22540. * * bufferHeight the height of image
  22541. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  22542. * @returns the VertexData of the Ground designed from a heightmap
  22543. */
  22544. static CreateGroundFromHeightMap(options: {
  22545. width: number;
  22546. height: number;
  22547. subdivisions: number;
  22548. minHeight: number;
  22549. maxHeight: number;
  22550. colorFilter: Color3;
  22551. buffer: Uint8Array;
  22552. bufferWidth: number;
  22553. bufferHeight: number;
  22554. alphaFilter: number;
  22555. }): VertexData;
  22556. /**
  22557. * Creates the VertexData for a Plane
  22558. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  22559. * * size sets the width and height of the plane to the value of size, optional default 1
  22560. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  22561. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  22562. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22563. * * 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)
  22564. * * 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)
  22565. * @returns the VertexData of the box
  22566. */
  22567. static CreatePlane(options: {
  22568. size?: number;
  22569. width?: number;
  22570. height?: number;
  22571. sideOrientation?: number;
  22572. frontUVs?: Vector4;
  22573. backUVs?: Vector4;
  22574. }): VertexData;
  22575. /**
  22576. * Creates the VertexData of the Disc or regular Polygon
  22577. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  22578. * * radius the radius of the disc, optional default 0.5
  22579. * * tessellation the number of polygon sides, optional, default 64
  22580. * * 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
  22581. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22582. * * 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)
  22583. * * 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)
  22584. * @returns the VertexData of the box
  22585. */
  22586. static CreateDisc(options: {
  22587. radius?: number;
  22588. tessellation?: number;
  22589. arc?: number;
  22590. sideOrientation?: number;
  22591. frontUVs?: Vector4;
  22592. backUVs?: Vector4;
  22593. }): VertexData;
  22594. /**
  22595. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  22596. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  22597. * @param polygon a mesh built from polygonTriangulation.build()
  22598. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22599. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22600. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22601. * @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)
  22602. * @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)
  22603. * @returns the VertexData of the Polygon
  22604. */
  22605. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  22606. /**
  22607. * Creates the VertexData of the IcoSphere
  22608. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  22609. * * radius the radius of the IcoSphere, optional default 1
  22610. * * radiusX allows stretching in the x direction, optional, default radius
  22611. * * radiusY allows stretching in the y direction, optional, default radius
  22612. * * radiusZ allows stretching in the z direction, optional, default radius
  22613. * * flat when true creates a flat shaded mesh, optional, default true
  22614. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22615. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22616. * * 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)
  22617. * * 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)
  22618. * @returns the VertexData of the IcoSphere
  22619. */
  22620. static CreateIcoSphere(options: {
  22621. radius?: number;
  22622. radiusX?: number;
  22623. radiusY?: number;
  22624. radiusZ?: number;
  22625. flat?: boolean;
  22626. subdivisions?: number;
  22627. sideOrientation?: number;
  22628. frontUVs?: Vector4;
  22629. backUVs?: Vector4;
  22630. }): VertexData;
  22631. /**
  22632. * Creates the VertexData for a Polyhedron
  22633. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  22634. * * type provided types are:
  22635. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  22636. * * 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)
  22637. * * size the size of the IcoSphere, optional default 1
  22638. * * sizeX allows stretching in the x direction, optional, default size
  22639. * * sizeY allows stretching in the y direction, optional, default size
  22640. * * sizeZ allows stretching in the z direction, optional, default size
  22641. * * 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
  22642. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  22643. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  22644. * * flat when true creates a flat shaded mesh, optional, default true
  22645. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  22646. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22647. * * 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)
  22648. * * 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)
  22649. * @returns the VertexData of the Polyhedron
  22650. */
  22651. static CreatePolyhedron(options: {
  22652. type?: number;
  22653. size?: number;
  22654. sizeX?: number;
  22655. sizeY?: number;
  22656. sizeZ?: number;
  22657. custom?: any;
  22658. faceUV?: Vector4[];
  22659. faceColors?: Color4[];
  22660. flat?: boolean;
  22661. sideOrientation?: number;
  22662. frontUVs?: Vector4;
  22663. backUVs?: Vector4;
  22664. }): VertexData;
  22665. /**
  22666. * Creates the VertexData for a TorusKnot
  22667. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  22668. * * radius the radius of the torus knot, optional, default 2
  22669. * * tube the thickness of the tube, optional, default 0.5
  22670. * * radialSegments the number of sides on each tube segments, optional, default 32
  22671. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  22672. * * p the number of windings around the z axis, optional, default 2
  22673. * * q the number of windings around the x axis, optional, default 3
  22674. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22675. * * 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)
  22676. * * 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)
  22677. * @returns the VertexData of the Torus Knot
  22678. */
  22679. static CreateTorusKnot(options: {
  22680. radius?: number;
  22681. tube?: number;
  22682. radialSegments?: number;
  22683. tubularSegments?: number;
  22684. p?: number;
  22685. q?: number;
  22686. sideOrientation?: number;
  22687. frontUVs?: Vector4;
  22688. backUVs?: Vector4;
  22689. }): VertexData;
  22690. /**
  22691. * Compute normals for given positions and indices
  22692. * @param positions an array of vertex positions, [...., x, y, z, ......]
  22693. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  22694. * @param normals an array of vertex normals, [...., x, y, z, ......]
  22695. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  22696. * * facetNormals : optional array of facet normals (vector3)
  22697. * * facetPositions : optional array of facet positions (vector3)
  22698. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  22699. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  22700. * * bInfo : optional bounding info, required for facetPartitioning computation
  22701. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  22702. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  22703. * * useRightHandedSystem: optional boolean to for right handed system computation
  22704. * * depthSort : optional boolean to enable the facet depth sort computation
  22705. * * distanceTo : optional Vector3 to compute the facet depth from this location
  22706. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  22707. */
  22708. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  22709. facetNormals?: any;
  22710. facetPositions?: any;
  22711. facetPartitioning?: any;
  22712. ratio?: number;
  22713. bInfo?: any;
  22714. bbSize?: Vector3;
  22715. subDiv?: any;
  22716. useRightHandedSystem?: boolean;
  22717. depthSort?: boolean;
  22718. distanceTo?: Vector3;
  22719. depthSortedFacets?: any;
  22720. }): void;
  22721. /** @hidden */
  22722. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  22723. /**
  22724. * Applies VertexData created from the imported parameters to the geometry
  22725. * @param parsedVertexData the parsed data from an imported file
  22726. * @param geometry the geometry to apply the VertexData to
  22727. */
  22728. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  22729. }
  22730. }
  22731. declare module "babylonjs/Morph/morphTarget" {
  22732. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  22733. import { Observable } from "babylonjs/Misc/observable";
  22734. import { Nullable, FloatArray } from "babylonjs/types";
  22735. import { Scene } from "babylonjs/scene";
  22736. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22737. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  22738. /**
  22739. * Defines a target to use with MorphTargetManager
  22740. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22741. */
  22742. export class MorphTarget implements IAnimatable {
  22743. /** defines the name of the target */
  22744. name: string;
  22745. /**
  22746. * Gets or sets the list of animations
  22747. */
  22748. animations: import("babylonjs/Animations/animation").Animation[];
  22749. private _scene;
  22750. private _positions;
  22751. private _normals;
  22752. private _tangents;
  22753. private _uvs;
  22754. private _influence;
  22755. /**
  22756. * Observable raised when the influence changes
  22757. */
  22758. onInfluenceChanged: Observable<boolean>;
  22759. /** @hidden */
  22760. _onDataLayoutChanged: Observable<void>;
  22761. /**
  22762. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  22763. */
  22764. influence: number;
  22765. /**
  22766. * Gets or sets the id of the morph Target
  22767. */
  22768. id: string;
  22769. private _animationPropertiesOverride;
  22770. /**
  22771. * Gets or sets the animation properties override
  22772. */
  22773. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  22774. /**
  22775. * Creates a new MorphTarget
  22776. * @param name defines the name of the target
  22777. * @param influence defines the influence to use
  22778. * @param scene defines the scene the morphtarget belongs to
  22779. */
  22780. constructor(
  22781. /** defines the name of the target */
  22782. name: string, influence?: number, scene?: Nullable<Scene>);
  22783. /**
  22784. * Gets a boolean defining if the target contains position data
  22785. */
  22786. readonly hasPositions: boolean;
  22787. /**
  22788. * Gets a boolean defining if the target contains normal data
  22789. */
  22790. readonly hasNormals: boolean;
  22791. /**
  22792. * Gets a boolean defining if the target contains tangent data
  22793. */
  22794. readonly hasTangents: boolean;
  22795. /**
  22796. * Gets a boolean defining if the target contains texture coordinates data
  22797. */
  22798. readonly hasUVs: boolean;
  22799. /**
  22800. * Affects position data to this target
  22801. * @param data defines the position data to use
  22802. */
  22803. setPositions(data: Nullable<FloatArray>): void;
  22804. /**
  22805. * Gets the position data stored in this target
  22806. * @returns a FloatArray containing the position data (or null if not present)
  22807. */
  22808. getPositions(): Nullable<FloatArray>;
  22809. /**
  22810. * Affects normal data to this target
  22811. * @param data defines the normal data to use
  22812. */
  22813. setNormals(data: Nullable<FloatArray>): void;
  22814. /**
  22815. * Gets the normal data stored in this target
  22816. * @returns a FloatArray containing the normal data (or null if not present)
  22817. */
  22818. getNormals(): Nullable<FloatArray>;
  22819. /**
  22820. * Affects tangent data to this target
  22821. * @param data defines the tangent data to use
  22822. */
  22823. setTangents(data: Nullable<FloatArray>): void;
  22824. /**
  22825. * Gets the tangent data stored in this target
  22826. * @returns a FloatArray containing the tangent data (or null if not present)
  22827. */
  22828. getTangents(): Nullable<FloatArray>;
  22829. /**
  22830. * Affects texture coordinates data to this target
  22831. * @param data defines the texture coordinates data to use
  22832. */
  22833. setUVs(data: Nullable<FloatArray>): void;
  22834. /**
  22835. * Gets the texture coordinates data stored in this target
  22836. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  22837. */
  22838. getUVs(): Nullable<FloatArray>;
  22839. /**
  22840. * Serializes the current target into a Serialization object
  22841. * @returns the serialized object
  22842. */
  22843. serialize(): any;
  22844. /**
  22845. * Returns the string "MorphTarget"
  22846. * @returns "MorphTarget"
  22847. */
  22848. getClassName(): string;
  22849. /**
  22850. * Creates a new target from serialized data
  22851. * @param serializationObject defines the serialized data to use
  22852. * @returns a new MorphTarget
  22853. */
  22854. static Parse(serializationObject: any): MorphTarget;
  22855. /**
  22856. * Creates a MorphTarget from mesh data
  22857. * @param mesh defines the source mesh
  22858. * @param name defines the name to use for the new target
  22859. * @param influence defines the influence to attach to the target
  22860. * @returns a new MorphTarget
  22861. */
  22862. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  22863. }
  22864. }
  22865. declare module "babylonjs/Morph/morphTargetManager" {
  22866. import { Nullable } from "babylonjs/types";
  22867. import { Scene } from "babylonjs/scene";
  22868. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  22869. /**
  22870. * This class is used to deform meshes using morphing between different targets
  22871. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  22872. */
  22873. export class MorphTargetManager {
  22874. private _targets;
  22875. private _targetInfluenceChangedObservers;
  22876. private _targetDataLayoutChangedObservers;
  22877. private _activeTargets;
  22878. private _scene;
  22879. private _influences;
  22880. private _supportsNormals;
  22881. private _supportsTangents;
  22882. private _supportsUVs;
  22883. private _vertexCount;
  22884. private _uniqueId;
  22885. private _tempInfluences;
  22886. /**
  22887. * Gets or sets a boolean indicating if normals must be morphed
  22888. */
  22889. enableNormalMorphing: boolean;
  22890. /**
  22891. * Gets or sets a boolean indicating if tangents must be morphed
  22892. */
  22893. enableTangentMorphing: boolean;
  22894. /**
  22895. * Gets or sets a boolean indicating if UV must be morphed
  22896. */
  22897. enableUVMorphing: boolean;
  22898. /**
  22899. * Creates a new MorphTargetManager
  22900. * @param scene defines the current scene
  22901. */
  22902. constructor(scene?: Nullable<Scene>);
  22903. /**
  22904. * Gets the unique ID of this manager
  22905. */
  22906. readonly uniqueId: number;
  22907. /**
  22908. * Gets the number of vertices handled by this manager
  22909. */
  22910. readonly vertexCount: number;
  22911. /**
  22912. * Gets a boolean indicating if this manager supports morphing of normals
  22913. */
  22914. readonly supportsNormals: boolean;
  22915. /**
  22916. * Gets a boolean indicating if this manager supports morphing of tangents
  22917. */
  22918. readonly supportsTangents: boolean;
  22919. /**
  22920. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  22921. */
  22922. readonly supportsUVs: boolean;
  22923. /**
  22924. * Gets the number of targets stored in this manager
  22925. */
  22926. readonly numTargets: number;
  22927. /**
  22928. * Gets the number of influencers (ie. the number of targets with influences > 0)
  22929. */
  22930. readonly numInfluencers: number;
  22931. /**
  22932. * Gets the list of influences (one per target)
  22933. */
  22934. readonly influences: Float32Array;
  22935. /**
  22936. * Gets the active target at specified index. An active target is a target with an influence > 0
  22937. * @param index defines the index to check
  22938. * @returns the requested target
  22939. */
  22940. getActiveTarget(index: number): MorphTarget;
  22941. /**
  22942. * Gets the target at specified index
  22943. * @param index defines the index to check
  22944. * @returns the requested target
  22945. */
  22946. getTarget(index: number): MorphTarget;
  22947. /**
  22948. * Add a new target to this manager
  22949. * @param target defines the target to add
  22950. */
  22951. addTarget(target: MorphTarget): void;
  22952. /**
  22953. * Removes a target from the manager
  22954. * @param target defines the target to remove
  22955. */
  22956. removeTarget(target: MorphTarget): void;
  22957. /**
  22958. * Serializes the current manager into a Serialization object
  22959. * @returns the serialized object
  22960. */
  22961. serialize(): any;
  22962. private _syncActiveTargets;
  22963. /**
  22964. * Syncrhonize the targets with all the meshes using this morph target manager
  22965. */
  22966. synchronize(): void;
  22967. /**
  22968. * Creates a new MorphTargetManager from serialized data
  22969. * @param serializationObject defines the serialized data
  22970. * @param scene defines the hosting scene
  22971. * @returns the new MorphTargetManager
  22972. */
  22973. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  22974. }
  22975. }
  22976. declare module "babylonjs/Meshes/meshLODLevel" {
  22977. import { Mesh } from "babylonjs/Meshes/mesh";
  22978. import { Nullable } from "babylonjs/types";
  22979. /**
  22980. * Class used to represent a specific level of detail of a mesh
  22981. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  22982. */
  22983. export class MeshLODLevel {
  22984. /** Defines the distance where this level should start being displayed */
  22985. distance: number;
  22986. /** Defines the mesh to use to render this level */
  22987. mesh: Nullable<Mesh>;
  22988. /**
  22989. * Creates a new LOD level
  22990. * @param distance defines the distance where this level should star being displayed
  22991. * @param mesh defines the mesh to use to render this level
  22992. */
  22993. constructor(
  22994. /** Defines the distance where this level should start being displayed */
  22995. distance: number,
  22996. /** Defines the mesh to use to render this level */
  22997. mesh: Nullable<Mesh>);
  22998. }
  22999. }
  23000. declare module "babylonjs/Meshes/groundMesh" {
  23001. import { Scene } from "babylonjs/scene";
  23002. import { Vector3 } from "babylonjs/Maths/math.vector";
  23003. import { Mesh } from "babylonjs/Meshes/mesh";
  23004. /**
  23005. * Mesh representing the gorund
  23006. */
  23007. export class GroundMesh extends Mesh {
  23008. /** If octree should be generated */
  23009. generateOctree: boolean;
  23010. private _heightQuads;
  23011. /** @hidden */
  23012. _subdivisionsX: number;
  23013. /** @hidden */
  23014. _subdivisionsY: number;
  23015. /** @hidden */
  23016. _width: number;
  23017. /** @hidden */
  23018. _height: number;
  23019. /** @hidden */
  23020. _minX: number;
  23021. /** @hidden */
  23022. _maxX: number;
  23023. /** @hidden */
  23024. _minZ: number;
  23025. /** @hidden */
  23026. _maxZ: number;
  23027. constructor(name: string, scene: Scene);
  23028. /**
  23029. * "GroundMesh"
  23030. * @returns "GroundMesh"
  23031. */
  23032. getClassName(): string;
  23033. /**
  23034. * The minimum of x and y subdivisions
  23035. */
  23036. readonly subdivisions: number;
  23037. /**
  23038. * X subdivisions
  23039. */
  23040. readonly subdivisionsX: number;
  23041. /**
  23042. * Y subdivisions
  23043. */
  23044. readonly subdivisionsY: number;
  23045. /**
  23046. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  23047. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  23048. * @param chunksCount the number of subdivisions for x and y
  23049. * @param octreeBlocksSize (Default: 32)
  23050. */
  23051. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  23052. /**
  23053. * Returns a height (y) value in the Worl system :
  23054. * the ground altitude at the coordinates (x, z) expressed in the World system.
  23055. * @param x x coordinate
  23056. * @param z z coordinate
  23057. * @returns the ground y position if (x, z) are outside the ground surface.
  23058. */
  23059. getHeightAtCoordinates(x: number, z: number): number;
  23060. /**
  23061. * Returns a normalized vector (Vector3) orthogonal to the ground
  23062. * at the ground coordinates (x, z) expressed in the World system.
  23063. * @param x x coordinate
  23064. * @param z z coordinate
  23065. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  23066. */
  23067. getNormalAtCoordinates(x: number, z: number): Vector3;
  23068. /**
  23069. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  23070. * at the ground coordinates (x, z) expressed in the World system.
  23071. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  23072. * @param x x coordinate
  23073. * @param z z coordinate
  23074. * @param ref vector to store the result
  23075. * @returns the GroundMesh.
  23076. */
  23077. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  23078. /**
  23079. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  23080. * if the ground has been updated.
  23081. * This can be used in the render loop.
  23082. * @returns the GroundMesh.
  23083. */
  23084. updateCoordinateHeights(): GroundMesh;
  23085. private _getFacetAt;
  23086. private _initHeightQuads;
  23087. private _computeHeightQuads;
  23088. /**
  23089. * Serializes this ground mesh
  23090. * @param serializationObject object to write serialization to
  23091. */
  23092. serialize(serializationObject: any): void;
  23093. /**
  23094. * Parses a serialized ground mesh
  23095. * @param parsedMesh the serialized mesh
  23096. * @param scene the scene to create the ground mesh in
  23097. * @returns the created ground mesh
  23098. */
  23099. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  23100. }
  23101. }
  23102. declare module "babylonjs/Physics/physicsJoint" {
  23103. import { Vector3 } from "babylonjs/Maths/math.vector";
  23104. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  23105. /**
  23106. * Interface for Physics-Joint data
  23107. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23108. */
  23109. export interface PhysicsJointData {
  23110. /**
  23111. * The main pivot of the joint
  23112. */
  23113. mainPivot?: Vector3;
  23114. /**
  23115. * The connected pivot of the joint
  23116. */
  23117. connectedPivot?: Vector3;
  23118. /**
  23119. * The main axis of the joint
  23120. */
  23121. mainAxis?: Vector3;
  23122. /**
  23123. * The connected axis of the joint
  23124. */
  23125. connectedAxis?: Vector3;
  23126. /**
  23127. * The collision of the joint
  23128. */
  23129. collision?: boolean;
  23130. /**
  23131. * Native Oimo/Cannon/Energy data
  23132. */
  23133. nativeParams?: any;
  23134. }
  23135. /**
  23136. * This is a holder class for the physics joint created by the physics plugin
  23137. * It holds a set of functions to control the underlying joint
  23138. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23139. */
  23140. export class PhysicsJoint {
  23141. /**
  23142. * The type of the physics joint
  23143. */
  23144. type: number;
  23145. /**
  23146. * The data for the physics joint
  23147. */
  23148. jointData: PhysicsJointData;
  23149. private _physicsJoint;
  23150. protected _physicsPlugin: IPhysicsEnginePlugin;
  23151. /**
  23152. * Initializes the physics joint
  23153. * @param type The type of the physics joint
  23154. * @param jointData The data for the physics joint
  23155. */
  23156. constructor(
  23157. /**
  23158. * The type of the physics joint
  23159. */
  23160. type: number,
  23161. /**
  23162. * The data for the physics joint
  23163. */
  23164. jointData: PhysicsJointData);
  23165. /**
  23166. * Gets the physics joint
  23167. */
  23168. /**
  23169. * Sets the physics joint
  23170. */
  23171. physicsJoint: any;
  23172. /**
  23173. * Sets the physics plugin
  23174. */
  23175. physicsPlugin: IPhysicsEnginePlugin;
  23176. /**
  23177. * Execute a function that is physics-plugin specific.
  23178. * @param {Function} func the function that will be executed.
  23179. * It accepts two parameters: the physics world and the physics joint
  23180. */
  23181. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  23182. /**
  23183. * Distance-Joint type
  23184. */
  23185. static DistanceJoint: number;
  23186. /**
  23187. * Hinge-Joint type
  23188. */
  23189. static HingeJoint: number;
  23190. /**
  23191. * Ball-and-Socket joint type
  23192. */
  23193. static BallAndSocketJoint: number;
  23194. /**
  23195. * Wheel-Joint type
  23196. */
  23197. static WheelJoint: number;
  23198. /**
  23199. * Slider-Joint type
  23200. */
  23201. static SliderJoint: number;
  23202. /**
  23203. * Prismatic-Joint type
  23204. */
  23205. static PrismaticJoint: number;
  23206. /**
  23207. * Universal-Joint type
  23208. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  23209. */
  23210. static UniversalJoint: number;
  23211. /**
  23212. * Hinge-Joint 2 type
  23213. */
  23214. static Hinge2Joint: number;
  23215. /**
  23216. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  23217. */
  23218. static PointToPointJoint: number;
  23219. /**
  23220. * Spring-Joint type
  23221. */
  23222. static SpringJoint: number;
  23223. /**
  23224. * Lock-Joint type
  23225. */
  23226. static LockJoint: number;
  23227. }
  23228. /**
  23229. * A class representing a physics distance joint
  23230. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23231. */
  23232. export class DistanceJoint extends PhysicsJoint {
  23233. /**
  23234. *
  23235. * @param jointData The data for the Distance-Joint
  23236. */
  23237. constructor(jointData: DistanceJointData);
  23238. /**
  23239. * Update the predefined distance.
  23240. * @param maxDistance The maximum preferred distance
  23241. * @param minDistance The minimum preferred distance
  23242. */
  23243. updateDistance(maxDistance: number, minDistance?: number): void;
  23244. }
  23245. /**
  23246. * Represents a Motor-Enabled Joint
  23247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23248. */
  23249. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  23250. /**
  23251. * Initializes the Motor-Enabled Joint
  23252. * @param type The type of the joint
  23253. * @param jointData The physica joint data for the joint
  23254. */
  23255. constructor(type: number, jointData: PhysicsJointData);
  23256. /**
  23257. * Set the motor values.
  23258. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23259. * @param force the force to apply
  23260. * @param maxForce max force for this motor.
  23261. */
  23262. setMotor(force?: number, maxForce?: number): void;
  23263. /**
  23264. * Set the motor's limits.
  23265. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23266. * @param upperLimit The upper limit of the motor
  23267. * @param lowerLimit The lower limit of the motor
  23268. */
  23269. setLimit(upperLimit: number, lowerLimit?: number): void;
  23270. }
  23271. /**
  23272. * This class represents a single physics Hinge-Joint
  23273. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23274. */
  23275. export class HingeJoint extends MotorEnabledJoint {
  23276. /**
  23277. * Initializes the Hinge-Joint
  23278. * @param jointData The joint data for the Hinge-Joint
  23279. */
  23280. constructor(jointData: PhysicsJointData);
  23281. /**
  23282. * Set the motor values.
  23283. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23284. * @param {number} force the force to apply
  23285. * @param {number} maxForce max force for this motor.
  23286. */
  23287. setMotor(force?: number, maxForce?: number): void;
  23288. /**
  23289. * Set the motor's limits.
  23290. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23291. * @param upperLimit The upper limit of the motor
  23292. * @param lowerLimit The lower limit of the motor
  23293. */
  23294. setLimit(upperLimit: number, lowerLimit?: number): void;
  23295. }
  23296. /**
  23297. * This class represents a dual hinge physics joint (same as wheel joint)
  23298. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23299. */
  23300. export class Hinge2Joint extends MotorEnabledJoint {
  23301. /**
  23302. * Initializes the Hinge2-Joint
  23303. * @param jointData The joint data for the Hinge2-Joint
  23304. */
  23305. constructor(jointData: PhysicsJointData);
  23306. /**
  23307. * Set the motor values.
  23308. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23309. * @param {number} targetSpeed the speed the motor is to reach
  23310. * @param {number} maxForce max force for this motor.
  23311. * @param {motorIndex} the motor's index, 0 or 1.
  23312. */
  23313. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  23314. /**
  23315. * Set the motor limits.
  23316. * Attention, this function is plugin specific. Engines won't react 100% the same.
  23317. * @param {number} upperLimit the upper limit
  23318. * @param {number} lowerLimit lower limit
  23319. * @param {motorIndex} the motor's index, 0 or 1.
  23320. */
  23321. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23322. }
  23323. /**
  23324. * Interface for a motor enabled joint
  23325. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23326. */
  23327. export interface IMotorEnabledJoint {
  23328. /**
  23329. * Physics joint
  23330. */
  23331. physicsJoint: any;
  23332. /**
  23333. * Sets the motor of the motor-enabled joint
  23334. * @param force The force of the motor
  23335. * @param maxForce The maximum force of the motor
  23336. * @param motorIndex The index of the motor
  23337. */
  23338. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  23339. /**
  23340. * Sets the limit of the motor
  23341. * @param upperLimit The upper limit of the motor
  23342. * @param lowerLimit The lower limit of the motor
  23343. * @param motorIndex The index of the motor
  23344. */
  23345. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23346. }
  23347. /**
  23348. * Joint data for a Distance-Joint
  23349. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23350. */
  23351. export interface DistanceJointData extends PhysicsJointData {
  23352. /**
  23353. * Max distance the 2 joint objects can be apart
  23354. */
  23355. maxDistance: number;
  23356. }
  23357. /**
  23358. * Joint data from a spring joint
  23359. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23360. */
  23361. export interface SpringJointData extends PhysicsJointData {
  23362. /**
  23363. * Length of the spring
  23364. */
  23365. length: number;
  23366. /**
  23367. * Stiffness of the spring
  23368. */
  23369. stiffness: number;
  23370. /**
  23371. * Damping of the spring
  23372. */
  23373. damping: number;
  23374. /** this callback will be called when applying the force to the impostors. */
  23375. forceApplicationCallback: () => void;
  23376. }
  23377. }
  23378. declare module "babylonjs/Physics/physicsRaycastResult" {
  23379. import { Vector3 } from "babylonjs/Maths/math.vector";
  23380. /**
  23381. * Holds the data for the raycast result
  23382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23383. */
  23384. export class PhysicsRaycastResult {
  23385. private _hasHit;
  23386. private _hitDistance;
  23387. private _hitNormalWorld;
  23388. private _hitPointWorld;
  23389. private _rayFromWorld;
  23390. private _rayToWorld;
  23391. /**
  23392. * Gets if there was a hit
  23393. */
  23394. readonly hasHit: boolean;
  23395. /**
  23396. * Gets the distance from the hit
  23397. */
  23398. readonly hitDistance: number;
  23399. /**
  23400. * Gets the hit normal/direction in the world
  23401. */
  23402. readonly hitNormalWorld: Vector3;
  23403. /**
  23404. * Gets the hit point in the world
  23405. */
  23406. readonly hitPointWorld: Vector3;
  23407. /**
  23408. * Gets the ray "start point" of the ray in the world
  23409. */
  23410. readonly rayFromWorld: Vector3;
  23411. /**
  23412. * Gets the ray "end point" of the ray in the world
  23413. */
  23414. readonly rayToWorld: Vector3;
  23415. /**
  23416. * Sets the hit data (normal & point in world space)
  23417. * @param hitNormalWorld defines the normal in world space
  23418. * @param hitPointWorld defines the point in world space
  23419. */
  23420. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  23421. /**
  23422. * Sets the distance from the start point to the hit point
  23423. * @param distance
  23424. */
  23425. setHitDistance(distance: number): void;
  23426. /**
  23427. * Calculates the distance manually
  23428. */
  23429. calculateHitDistance(): void;
  23430. /**
  23431. * Resets all the values to default
  23432. * @param from The from point on world space
  23433. * @param to The to point on world space
  23434. */
  23435. reset(from?: Vector3, to?: Vector3): void;
  23436. }
  23437. /**
  23438. * Interface for the size containing width and height
  23439. */
  23440. interface IXYZ {
  23441. /**
  23442. * X
  23443. */
  23444. x: number;
  23445. /**
  23446. * Y
  23447. */
  23448. y: number;
  23449. /**
  23450. * Z
  23451. */
  23452. z: number;
  23453. }
  23454. }
  23455. declare module "babylonjs/Physics/IPhysicsEngine" {
  23456. import { Nullable } from "babylonjs/types";
  23457. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  23458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23459. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  23460. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  23461. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  23462. /**
  23463. * Interface used to describe a physics joint
  23464. */
  23465. export interface PhysicsImpostorJoint {
  23466. /** Defines the main impostor to which the joint is linked */
  23467. mainImpostor: PhysicsImpostor;
  23468. /** Defines the impostor that is connected to the main impostor using this joint */
  23469. connectedImpostor: PhysicsImpostor;
  23470. /** Defines the joint itself */
  23471. joint: PhysicsJoint;
  23472. }
  23473. /** @hidden */
  23474. export interface IPhysicsEnginePlugin {
  23475. world: any;
  23476. name: string;
  23477. setGravity(gravity: Vector3): void;
  23478. setTimeStep(timeStep: number): void;
  23479. getTimeStep(): number;
  23480. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  23481. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23482. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  23483. generatePhysicsBody(impostor: PhysicsImpostor): void;
  23484. removePhysicsBody(impostor: PhysicsImpostor): void;
  23485. generateJoint(joint: PhysicsImpostorJoint): void;
  23486. removeJoint(joint: PhysicsImpostorJoint): void;
  23487. isSupported(): boolean;
  23488. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  23489. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  23490. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23491. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  23492. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23493. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  23494. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  23495. getBodyMass(impostor: PhysicsImpostor): number;
  23496. getBodyFriction(impostor: PhysicsImpostor): number;
  23497. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  23498. getBodyRestitution(impostor: PhysicsImpostor): number;
  23499. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  23500. getBodyPressure?(impostor: PhysicsImpostor): number;
  23501. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  23502. getBodyStiffness?(impostor: PhysicsImpostor): number;
  23503. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  23504. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  23505. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  23506. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  23507. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  23508. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23509. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  23510. sleepBody(impostor: PhysicsImpostor): void;
  23511. wakeUpBody(impostor: PhysicsImpostor): void;
  23512. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23513. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  23514. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  23515. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  23516. getRadius(impostor: PhysicsImpostor): number;
  23517. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  23518. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  23519. dispose(): void;
  23520. }
  23521. /**
  23522. * Interface used to define a physics engine
  23523. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  23524. */
  23525. export interface IPhysicsEngine {
  23526. /**
  23527. * Gets the gravity vector used by the simulation
  23528. */
  23529. gravity: Vector3;
  23530. /**
  23531. * Sets the gravity vector used by the simulation
  23532. * @param gravity defines the gravity vector to use
  23533. */
  23534. setGravity(gravity: Vector3): void;
  23535. /**
  23536. * Set the time step of the physics engine.
  23537. * Default is 1/60.
  23538. * To slow it down, enter 1/600 for example.
  23539. * To speed it up, 1/30
  23540. * @param newTimeStep the new timestep to apply to this world.
  23541. */
  23542. setTimeStep(newTimeStep: number): void;
  23543. /**
  23544. * Get the time step of the physics engine.
  23545. * @returns the current time step
  23546. */
  23547. getTimeStep(): number;
  23548. /**
  23549. * Release all resources
  23550. */
  23551. dispose(): void;
  23552. /**
  23553. * Gets the name of the current physics plugin
  23554. * @returns the name of the plugin
  23555. */
  23556. getPhysicsPluginName(): string;
  23557. /**
  23558. * Adding a new impostor for the impostor tracking.
  23559. * This will be done by the impostor itself.
  23560. * @param impostor the impostor to add
  23561. */
  23562. addImpostor(impostor: PhysicsImpostor): void;
  23563. /**
  23564. * Remove an impostor from the engine.
  23565. * This impostor and its mesh will not longer be updated by the physics engine.
  23566. * @param impostor the impostor to remove
  23567. */
  23568. removeImpostor(impostor: PhysicsImpostor): void;
  23569. /**
  23570. * Add a joint to the physics engine
  23571. * @param mainImpostor defines the main impostor to which the joint is added.
  23572. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  23573. * @param joint defines the joint that will connect both impostors.
  23574. */
  23575. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23576. /**
  23577. * Removes a joint from the simulation
  23578. * @param mainImpostor defines the impostor used with the joint
  23579. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  23580. * @param joint defines the joint to remove
  23581. */
  23582. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  23583. /**
  23584. * Gets the current plugin used to run the simulation
  23585. * @returns current plugin
  23586. */
  23587. getPhysicsPlugin(): IPhysicsEnginePlugin;
  23588. /**
  23589. * Gets the list of physic impostors
  23590. * @returns an array of PhysicsImpostor
  23591. */
  23592. getImpostors(): Array<PhysicsImpostor>;
  23593. /**
  23594. * Gets the impostor for a physics enabled object
  23595. * @param object defines the object impersonated by the impostor
  23596. * @returns the PhysicsImpostor or null if not found
  23597. */
  23598. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  23599. /**
  23600. * Gets the impostor for a physics body object
  23601. * @param body defines physics body used by the impostor
  23602. * @returns the PhysicsImpostor or null if not found
  23603. */
  23604. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  23605. /**
  23606. * Does a raycast in the physics world
  23607. * @param from when should the ray start?
  23608. * @param to when should the ray end?
  23609. * @returns PhysicsRaycastResult
  23610. */
  23611. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  23612. /**
  23613. * Called by the scene. No need to call it.
  23614. * @param delta defines the timespam between frames
  23615. */
  23616. _step(delta: number): void;
  23617. }
  23618. }
  23619. declare module "babylonjs/Physics/physicsImpostor" {
  23620. import { Nullable, IndicesArray } from "babylonjs/types";
  23621. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  23622. import { TransformNode } from "babylonjs/Meshes/transformNode";
  23623. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23624. import { Scene } from "babylonjs/scene";
  23625. import { Bone } from "babylonjs/Bones/bone";
  23626. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23627. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  23628. import { Space } from "babylonjs/Maths/math.axis";
  23629. /**
  23630. * The interface for the physics imposter parameters
  23631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23632. */
  23633. export interface PhysicsImpostorParameters {
  23634. /**
  23635. * The mass of the physics imposter
  23636. */
  23637. mass: number;
  23638. /**
  23639. * The friction of the physics imposter
  23640. */
  23641. friction?: number;
  23642. /**
  23643. * The coefficient of restitution of the physics imposter
  23644. */
  23645. restitution?: number;
  23646. /**
  23647. * The native options of the physics imposter
  23648. */
  23649. nativeOptions?: any;
  23650. /**
  23651. * Specifies if the parent should be ignored
  23652. */
  23653. ignoreParent?: boolean;
  23654. /**
  23655. * Specifies if bi-directional transformations should be disabled
  23656. */
  23657. disableBidirectionalTransformation?: boolean;
  23658. /**
  23659. * The pressure inside the physics imposter, soft object only
  23660. */
  23661. pressure?: number;
  23662. /**
  23663. * The stiffness the physics imposter, soft object only
  23664. */
  23665. stiffness?: number;
  23666. /**
  23667. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  23668. */
  23669. velocityIterations?: number;
  23670. /**
  23671. * The number of iterations used in maintaining consistent vertex positions, soft object only
  23672. */
  23673. positionIterations?: number;
  23674. /**
  23675. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  23676. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  23677. * Add to fix multiple points
  23678. */
  23679. fixedPoints?: number;
  23680. /**
  23681. * The collision margin around a soft object
  23682. */
  23683. margin?: number;
  23684. /**
  23685. * The collision margin around a soft object
  23686. */
  23687. damping?: number;
  23688. /**
  23689. * The path for a rope based on an extrusion
  23690. */
  23691. path?: any;
  23692. /**
  23693. * The shape of an extrusion used for a rope based on an extrusion
  23694. */
  23695. shape?: any;
  23696. }
  23697. /**
  23698. * Interface for a physics-enabled object
  23699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23700. */
  23701. export interface IPhysicsEnabledObject {
  23702. /**
  23703. * The position of the physics-enabled object
  23704. */
  23705. position: Vector3;
  23706. /**
  23707. * The rotation of the physics-enabled object
  23708. */
  23709. rotationQuaternion: Nullable<Quaternion>;
  23710. /**
  23711. * The scale of the physics-enabled object
  23712. */
  23713. scaling: Vector3;
  23714. /**
  23715. * The rotation of the physics-enabled object
  23716. */
  23717. rotation?: Vector3;
  23718. /**
  23719. * The parent of the physics-enabled object
  23720. */
  23721. parent?: any;
  23722. /**
  23723. * The bounding info of the physics-enabled object
  23724. * @returns The bounding info of the physics-enabled object
  23725. */
  23726. getBoundingInfo(): BoundingInfo;
  23727. /**
  23728. * Computes the world matrix
  23729. * @param force Specifies if the world matrix should be computed by force
  23730. * @returns A world matrix
  23731. */
  23732. computeWorldMatrix(force: boolean): Matrix;
  23733. /**
  23734. * Gets the world matrix
  23735. * @returns A world matrix
  23736. */
  23737. getWorldMatrix?(): Matrix;
  23738. /**
  23739. * Gets the child meshes
  23740. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  23741. * @returns An array of abstract meshes
  23742. */
  23743. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  23744. /**
  23745. * Gets the vertex data
  23746. * @param kind The type of vertex data
  23747. * @returns A nullable array of numbers, or a float32 array
  23748. */
  23749. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  23750. /**
  23751. * Gets the indices from the mesh
  23752. * @returns A nullable array of index arrays
  23753. */
  23754. getIndices?(): Nullable<IndicesArray>;
  23755. /**
  23756. * Gets the scene from the mesh
  23757. * @returns the indices array or null
  23758. */
  23759. getScene?(): Scene;
  23760. /**
  23761. * Gets the absolute position from the mesh
  23762. * @returns the absolute position
  23763. */
  23764. getAbsolutePosition(): Vector3;
  23765. /**
  23766. * Gets the absolute pivot point from the mesh
  23767. * @returns the absolute pivot point
  23768. */
  23769. getAbsolutePivotPoint(): Vector3;
  23770. /**
  23771. * Rotates the mesh
  23772. * @param axis The axis of rotation
  23773. * @param amount The amount of rotation
  23774. * @param space The space of the rotation
  23775. * @returns The rotation transform node
  23776. */
  23777. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  23778. /**
  23779. * Translates the mesh
  23780. * @param axis The axis of translation
  23781. * @param distance The distance of translation
  23782. * @param space The space of the translation
  23783. * @returns The transform node
  23784. */
  23785. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  23786. /**
  23787. * Sets the absolute position of the mesh
  23788. * @param absolutePosition The absolute position of the mesh
  23789. * @returns The transform node
  23790. */
  23791. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  23792. /**
  23793. * Gets the class name of the mesh
  23794. * @returns The class name
  23795. */
  23796. getClassName(): string;
  23797. }
  23798. /**
  23799. * Represents a physics imposter
  23800. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  23801. */
  23802. export class PhysicsImpostor {
  23803. /**
  23804. * The physics-enabled object used as the physics imposter
  23805. */
  23806. object: IPhysicsEnabledObject;
  23807. /**
  23808. * The type of the physics imposter
  23809. */
  23810. type: number;
  23811. private _options;
  23812. private _scene?;
  23813. /**
  23814. * The default object size of the imposter
  23815. */
  23816. static DEFAULT_OBJECT_SIZE: Vector3;
  23817. /**
  23818. * The identity quaternion of the imposter
  23819. */
  23820. static IDENTITY_QUATERNION: Quaternion;
  23821. /** @hidden */
  23822. _pluginData: any;
  23823. private _physicsEngine;
  23824. private _physicsBody;
  23825. private _bodyUpdateRequired;
  23826. private _onBeforePhysicsStepCallbacks;
  23827. private _onAfterPhysicsStepCallbacks;
  23828. /** @hidden */
  23829. _onPhysicsCollideCallbacks: Array<{
  23830. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  23831. otherImpostors: Array<PhysicsImpostor>;
  23832. }>;
  23833. private _deltaPosition;
  23834. private _deltaRotation;
  23835. private _deltaRotationConjugated;
  23836. /** @hidden */
  23837. _isFromLine: boolean;
  23838. private _parent;
  23839. private _isDisposed;
  23840. private static _tmpVecs;
  23841. private static _tmpQuat;
  23842. /**
  23843. * Specifies if the physics imposter is disposed
  23844. */
  23845. readonly isDisposed: boolean;
  23846. /**
  23847. * Gets the mass of the physics imposter
  23848. */
  23849. mass: number;
  23850. /**
  23851. * Gets the coefficient of friction
  23852. */
  23853. /**
  23854. * Sets the coefficient of friction
  23855. */
  23856. friction: number;
  23857. /**
  23858. * Gets the coefficient of restitution
  23859. */
  23860. /**
  23861. * Sets the coefficient of restitution
  23862. */
  23863. restitution: number;
  23864. /**
  23865. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  23866. */
  23867. /**
  23868. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  23869. */
  23870. pressure: number;
  23871. /**
  23872. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23873. */
  23874. /**
  23875. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  23876. */
  23877. stiffness: number;
  23878. /**
  23879. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23880. */
  23881. /**
  23882. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  23883. */
  23884. velocityIterations: number;
  23885. /**
  23886. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23887. */
  23888. /**
  23889. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  23890. */
  23891. positionIterations: number;
  23892. /**
  23893. * The unique id of the physics imposter
  23894. * set by the physics engine when adding this impostor to the array
  23895. */
  23896. uniqueId: number;
  23897. /**
  23898. * @hidden
  23899. */
  23900. soft: boolean;
  23901. /**
  23902. * @hidden
  23903. */
  23904. segments: number;
  23905. private _joints;
  23906. /**
  23907. * Initializes the physics imposter
  23908. * @param object The physics-enabled object used as the physics imposter
  23909. * @param type The type of the physics imposter
  23910. * @param _options The options for the physics imposter
  23911. * @param _scene The Babylon scene
  23912. */
  23913. constructor(
  23914. /**
  23915. * The physics-enabled object used as the physics imposter
  23916. */
  23917. object: IPhysicsEnabledObject,
  23918. /**
  23919. * The type of the physics imposter
  23920. */
  23921. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  23922. /**
  23923. * This function will completly initialize this impostor.
  23924. * It will create a new body - but only if this mesh has no parent.
  23925. * If it has, this impostor will not be used other than to define the impostor
  23926. * of the child mesh.
  23927. * @hidden
  23928. */
  23929. _init(): void;
  23930. private _getPhysicsParent;
  23931. /**
  23932. * Should a new body be generated.
  23933. * @returns boolean specifying if body initialization is required
  23934. */
  23935. isBodyInitRequired(): boolean;
  23936. /**
  23937. * Sets the updated scaling
  23938. * @param updated Specifies if the scaling is updated
  23939. */
  23940. setScalingUpdated(): void;
  23941. /**
  23942. * Force a regeneration of this or the parent's impostor's body.
  23943. * Use under cautious - This will remove all joints already implemented.
  23944. */
  23945. forceUpdate(): void;
  23946. /**
  23947. * Gets the body that holds this impostor. Either its own, or its parent.
  23948. */
  23949. /**
  23950. * Set the physics body. Used mainly by the physics engine/plugin
  23951. */
  23952. physicsBody: any;
  23953. /**
  23954. * Get the parent of the physics imposter
  23955. * @returns Physics imposter or null
  23956. */
  23957. /**
  23958. * Sets the parent of the physics imposter
  23959. */
  23960. parent: Nullable<PhysicsImpostor>;
  23961. /**
  23962. * Resets the update flags
  23963. */
  23964. resetUpdateFlags(): void;
  23965. /**
  23966. * Gets the object extend size
  23967. * @returns the object extend size
  23968. */
  23969. getObjectExtendSize(): Vector3;
  23970. /**
  23971. * Gets the object center
  23972. * @returns The object center
  23973. */
  23974. getObjectCenter(): Vector3;
  23975. /**
  23976. * Get a specific parametes from the options parameter
  23977. * @param paramName The object parameter name
  23978. * @returns The object parameter
  23979. */
  23980. getParam(paramName: string): any;
  23981. /**
  23982. * Sets a specific parameter in the options given to the physics plugin
  23983. * @param paramName The parameter name
  23984. * @param value The value of the parameter
  23985. */
  23986. setParam(paramName: string, value: number): void;
  23987. /**
  23988. * Specifically change the body's mass option. Won't recreate the physics body object
  23989. * @param mass The mass of the physics imposter
  23990. */
  23991. setMass(mass: number): void;
  23992. /**
  23993. * Gets the linear velocity
  23994. * @returns linear velocity or null
  23995. */
  23996. getLinearVelocity(): Nullable<Vector3>;
  23997. /**
  23998. * Sets the linear velocity
  23999. * @param velocity linear velocity or null
  24000. */
  24001. setLinearVelocity(velocity: Nullable<Vector3>): void;
  24002. /**
  24003. * Gets the angular velocity
  24004. * @returns angular velocity or null
  24005. */
  24006. getAngularVelocity(): Nullable<Vector3>;
  24007. /**
  24008. * Sets the angular velocity
  24009. * @param velocity The velocity or null
  24010. */
  24011. setAngularVelocity(velocity: Nullable<Vector3>): void;
  24012. /**
  24013. * Execute a function with the physics plugin native code
  24014. * Provide a function the will have two variables - the world object and the physics body object
  24015. * @param func The function to execute with the physics plugin native code
  24016. */
  24017. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  24018. /**
  24019. * Register a function that will be executed before the physics world is stepping forward
  24020. * @param func The function to execute before the physics world is stepped forward
  24021. */
  24022. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24023. /**
  24024. * Unregister a function that will be executed before the physics world is stepping forward
  24025. * @param func The function to execute before the physics world is stepped forward
  24026. */
  24027. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24028. /**
  24029. * Register a function that will be executed after the physics step
  24030. * @param func The function to execute after physics step
  24031. */
  24032. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24033. /**
  24034. * Unregisters a function that will be executed after the physics step
  24035. * @param func The function to execute after physics step
  24036. */
  24037. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  24038. /**
  24039. * register a function that will be executed when this impostor collides against a different body
  24040. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  24041. * @param func Callback that is executed on collision
  24042. */
  24043. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  24044. /**
  24045. * Unregisters the physics imposter on contact
  24046. * @param collideAgainst The physics object to collide against
  24047. * @param func Callback to execute on collision
  24048. */
  24049. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  24050. private _tmpQuat;
  24051. private _tmpQuat2;
  24052. /**
  24053. * Get the parent rotation
  24054. * @returns The parent rotation
  24055. */
  24056. getParentsRotation(): Quaternion;
  24057. /**
  24058. * this function is executed by the physics engine.
  24059. */
  24060. beforeStep: () => void;
  24061. /**
  24062. * this function is executed by the physics engine
  24063. */
  24064. afterStep: () => void;
  24065. /**
  24066. * Legacy collision detection event support
  24067. */
  24068. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  24069. /**
  24070. * event and body object due to cannon's event-based architecture.
  24071. */
  24072. onCollide: (e: {
  24073. body: any;
  24074. }) => void;
  24075. /**
  24076. * Apply a force
  24077. * @param force The force to apply
  24078. * @param contactPoint The contact point for the force
  24079. * @returns The physics imposter
  24080. */
  24081. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24082. /**
  24083. * Apply an impulse
  24084. * @param force The impulse force
  24085. * @param contactPoint The contact point for the impulse force
  24086. * @returns The physics imposter
  24087. */
  24088. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  24089. /**
  24090. * A help function to create a joint
  24091. * @param otherImpostor A physics imposter used to create a joint
  24092. * @param jointType The type of joint
  24093. * @param jointData The data for the joint
  24094. * @returns The physics imposter
  24095. */
  24096. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  24097. /**
  24098. * Add a joint to this impostor with a different impostor
  24099. * @param otherImpostor A physics imposter used to add a joint
  24100. * @param joint The joint to add
  24101. * @returns The physics imposter
  24102. */
  24103. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  24104. /**
  24105. * Add an anchor to a cloth impostor
  24106. * @param otherImpostor rigid impostor to anchor to
  24107. * @param width ratio across width from 0 to 1
  24108. * @param height ratio up height from 0 to 1
  24109. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  24110. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  24111. * @returns impostor the soft imposter
  24112. */
  24113. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24114. /**
  24115. * Add a hook to a rope impostor
  24116. * @param otherImpostor rigid impostor to anchor to
  24117. * @param length ratio across rope from 0 to 1
  24118. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  24119. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  24120. * @returns impostor the rope imposter
  24121. */
  24122. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  24123. /**
  24124. * Will keep this body still, in a sleep mode.
  24125. * @returns the physics imposter
  24126. */
  24127. sleep(): PhysicsImpostor;
  24128. /**
  24129. * Wake the body up.
  24130. * @returns The physics imposter
  24131. */
  24132. wakeUp(): PhysicsImpostor;
  24133. /**
  24134. * Clones the physics imposter
  24135. * @param newObject The physics imposter clones to this physics-enabled object
  24136. * @returns A nullable physics imposter
  24137. */
  24138. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  24139. /**
  24140. * Disposes the physics imposter
  24141. */
  24142. dispose(): void;
  24143. /**
  24144. * Sets the delta position
  24145. * @param position The delta position amount
  24146. */
  24147. setDeltaPosition(position: Vector3): void;
  24148. /**
  24149. * Sets the delta rotation
  24150. * @param rotation The delta rotation amount
  24151. */
  24152. setDeltaRotation(rotation: Quaternion): void;
  24153. /**
  24154. * Gets the box size of the physics imposter and stores the result in the input parameter
  24155. * @param result Stores the box size
  24156. * @returns The physics imposter
  24157. */
  24158. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  24159. /**
  24160. * Gets the radius of the physics imposter
  24161. * @returns Radius of the physics imposter
  24162. */
  24163. getRadius(): number;
  24164. /**
  24165. * Sync a bone with this impostor
  24166. * @param bone The bone to sync to the impostor.
  24167. * @param boneMesh The mesh that the bone is influencing.
  24168. * @param jointPivot The pivot of the joint / bone in local space.
  24169. * @param distToJoint Optional distance from the impostor to the joint.
  24170. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24171. */
  24172. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  24173. /**
  24174. * Sync impostor to a bone
  24175. * @param bone The bone that the impostor will be synced to.
  24176. * @param boneMesh The mesh that the bone is influencing.
  24177. * @param jointPivot The pivot of the joint / bone in local space.
  24178. * @param distToJoint Optional distance from the impostor to the joint.
  24179. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  24180. * @param boneAxis Optional vector3 axis the bone is aligned with
  24181. */
  24182. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  24183. /**
  24184. * No-Imposter type
  24185. */
  24186. static NoImpostor: number;
  24187. /**
  24188. * Sphere-Imposter type
  24189. */
  24190. static SphereImpostor: number;
  24191. /**
  24192. * Box-Imposter type
  24193. */
  24194. static BoxImpostor: number;
  24195. /**
  24196. * Plane-Imposter type
  24197. */
  24198. static PlaneImpostor: number;
  24199. /**
  24200. * Mesh-imposter type
  24201. */
  24202. static MeshImpostor: number;
  24203. /**
  24204. * Capsule-Impostor type (Ammo.js plugin only)
  24205. */
  24206. static CapsuleImpostor: number;
  24207. /**
  24208. * Cylinder-Imposter type
  24209. */
  24210. static CylinderImpostor: number;
  24211. /**
  24212. * Particle-Imposter type
  24213. */
  24214. static ParticleImpostor: number;
  24215. /**
  24216. * Heightmap-Imposter type
  24217. */
  24218. static HeightmapImpostor: number;
  24219. /**
  24220. * ConvexHull-Impostor type (Ammo.js plugin only)
  24221. */
  24222. static ConvexHullImpostor: number;
  24223. /**
  24224. * Rope-Imposter type
  24225. */
  24226. static RopeImpostor: number;
  24227. /**
  24228. * Cloth-Imposter type
  24229. */
  24230. static ClothImpostor: number;
  24231. /**
  24232. * Softbody-Imposter type
  24233. */
  24234. static SoftbodyImpostor: number;
  24235. }
  24236. }
  24237. declare module "babylonjs/Meshes/mesh" {
  24238. import { Observable } from "babylonjs/Misc/observable";
  24239. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  24240. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  24241. import { Camera } from "babylonjs/Cameras/camera";
  24242. import { Scene } from "babylonjs/scene";
  24243. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  24244. import { Color4 } from "babylonjs/Maths/math.color";
  24245. import { Engine } from "babylonjs/Engines/engine";
  24246. import { Node } from "babylonjs/node";
  24247. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  24248. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24249. import { Buffer } from "babylonjs/Meshes/buffer";
  24250. import { Geometry } from "babylonjs/Meshes/geometry";
  24251. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24252. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24253. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  24254. import { Effect } from "babylonjs/Materials/effect";
  24255. import { Material } from "babylonjs/Materials/material";
  24256. import { Skeleton } from "babylonjs/Bones/skeleton";
  24257. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  24258. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  24259. import { Path3D } from "babylonjs/Maths/math.path";
  24260. import { Plane } from "babylonjs/Maths/math.plane";
  24261. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24262. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  24263. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  24264. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  24265. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  24266. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  24267. /**
  24268. * @hidden
  24269. **/
  24270. export class _CreationDataStorage {
  24271. closePath?: boolean;
  24272. closeArray?: boolean;
  24273. idx: number[];
  24274. dashSize: number;
  24275. gapSize: number;
  24276. path3D: Path3D;
  24277. pathArray: Vector3[][];
  24278. arc: number;
  24279. radius: number;
  24280. cap: number;
  24281. tessellation: number;
  24282. }
  24283. /**
  24284. * @hidden
  24285. **/
  24286. class _InstanceDataStorage {
  24287. visibleInstances: any;
  24288. batchCache: _InstancesBatch;
  24289. instancesBufferSize: number;
  24290. instancesBuffer: Nullable<Buffer>;
  24291. instancesData: Float32Array;
  24292. overridenInstanceCount: number;
  24293. isFrozen: boolean;
  24294. previousBatch: Nullable<_InstancesBatch>;
  24295. hardwareInstancedRendering: boolean;
  24296. sideOrientation: number;
  24297. }
  24298. /**
  24299. * @hidden
  24300. **/
  24301. export class _InstancesBatch {
  24302. mustReturn: boolean;
  24303. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  24304. renderSelf: boolean[];
  24305. hardwareInstancedRendering: boolean[];
  24306. }
  24307. /**
  24308. * Class used to represent renderable models
  24309. */
  24310. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  24311. /**
  24312. * Mesh side orientation : usually the external or front surface
  24313. */
  24314. static readonly FRONTSIDE: number;
  24315. /**
  24316. * Mesh side orientation : usually the internal or back surface
  24317. */
  24318. static readonly BACKSIDE: number;
  24319. /**
  24320. * Mesh side orientation : both internal and external or front and back surfaces
  24321. */
  24322. static readonly DOUBLESIDE: number;
  24323. /**
  24324. * Mesh side orientation : by default, `FRONTSIDE`
  24325. */
  24326. static readonly DEFAULTSIDE: number;
  24327. /**
  24328. * Mesh cap setting : no cap
  24329. */
  24330. static readonly NO_CAP: number;
  24331. /**
  24332. * Mesh cap setting : one cap at the beginning of the mesh
  24333. */
  24334. static readonly CAP_START: number;
  24335. /**
  24336. * Mesh cap setting : one cap at the end of the mesh
  24337. */
  24338. static readonly CAP_END: number;
  24339. /**
  24340. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  24341. */
  24342. static readonly CAP_ALL: number;
  24343. /**
  24344. * Mesh pattern setting : no flip or rotate
  24345. */
  24346. static readonly NO_FLIP: number;
  24347. /**
  24348. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  24349. */
  24350. static readonly FLIP_TILE: number;
  24351. /**
  24352. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  24353. */
  24354. static readonly ROTATE_TILE: number;
  24355. /**
  24356. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  24357. */
  24358. static readonly FLIP_ROW: number;
  24359. /**
  24360. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  24361. */
  24362. static readonly ROTATE_ROW: number;
  24363. /**
  24364. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  24365. */
  24366. static readonly FLIP_N_ROTATE_TILE: number;
  24367. /**
  24368. * Mesh pattern setting : rotate pattern and rotate
  24369. */
  24370. static readonly FLIP_N_ROTATE_ROW: number;
  24371. /**
  24372. * Mesh tile positioning : part tiles same on left/right or top/bottom
  24373. */
  24374. static readonly CENTER: number;
  24375. /**
  24376. * Mesh tile positioning : part tiles on left
  24377. */
  24378. static readonly LEFT: number;
  24379. /**
  24380. * Mesh tile positioning : part tiles on right
  24381. */
  24382. static readonly RIGHT: number;
  24383. /**
  24384. * Mesh tile positioning : part tiles on top
  24385. */
  24386. static readonly TOP: number;
  24387. /**
  24388. * Mesh tile positioning : part tiles on bottom
  24389. */
  24390. static readonly BOTTOM: number;
  24391. /**
  24392. * Gets the default side orientation.
  24393. * @param orientation the orientation to value to attempt to get
  24394. * @returns the default orientation
  24395. * @hidden
  24396. */
  24397. static _GetDefaultSideOrientation(orientation?: number): number;
  24398. private _internalMeshDataInfo;
  24399. /**
  24400. * An event triggered before rendering the mesh
  24401. */
  24402. readonly onBeforeRenderObservable: Observable<Mesh>;
  24403. /**
  24404. * An event triggered before binding the mesh
  24405. */
  24406. readonly onBeforeBindObservable: Observable<Mesh>;
  24407. /**
  24408. * An event triggered after rendering the mesh
  24409. */
  24410. readonly onAfterRenderObservable: Observable<Mesh>;
  24411. /**
  24412. * An event triggered before drawing the mesh
  24413. */
  24414. readonly onBeforeDrawObservable: Observable<Mesh>;
  24415. private _onBeforeDrawObserver;
  24416. /**
  24417. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  24418. */
  24419. onBeforeDraw: () => void;
  24420. readonly hasInstances: boolean;
  24421. /**
  24422. * Gets the delay loading state of the mesh (when delay loading is turned on)
  24423. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  24424. */
  24425. delayLoadState: number;
  24426. /**
  24427. * Gets the list of instances created from this mesh
  24428. * it is not supposed to be modified manually.
  24429. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  24430. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  24431. */
  24432. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  24433. /**
  24434. * Gets the file containing delay loading data for this mesh
  24435. */
  24436. delayLoadingFile: string;
  24437. /** @hidden */
  24438. _binaryInfo: any;
  24439. /**
  24440. * User defined function used to change how LOD level selection is done
  24441. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  24442. */
  24443. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  24444. /**
  24445. * Gets or sets the morph target manager
  24446. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  24447. */
  24448. morphTargetManager: Nullable<MorphTargetManager>;
  24449. /** @hidden */
  24450. _creationDataStorage: Nullable<_CreationDataStorage>;
  24451. /** @hidden */
  24452. _geometry: Nullable<Geometry>;
  24453. /** @hidden */
  24454. _delayInfo: Array<string>;
  24455. /** @hidden */
  24456. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  24457. /** @hidden */
  24458. _instanceDataStorage: _InstanceDataStorage;
  24459. private _effectiveMaterial;
  24460. /** @hidden */
  24461. _shouldGenerateFlatShading: boolean;
  24462. /** @hidden */
  24463. _originalBuilderSideOrientation: number;
  24464. /**
  24465. * Use this property to change the original side orientation defined at construction time
  24466. */
  24467. overrideMaterialSideOrientation: Nullable<number>;
  24468. /**
  24469. * Gets the source mesh (the one used to clone this one from)
  24470. */
  24471. readonly source: Nullable<Mesh>;
  24472. /**
  24473. * Gets or sets a boolean indicating that this mesh does not use index buffer
  24474. */
  24475. isUnIndexed: boolean;
  24476. /**
  24477. * @constructor
  24478. * @param name The value used by scene.getMeshByName() to do a lookup.
  24479. * @param scene The scene to add this mesh to.
  24480. * @param parent The parent of this mesh, if it has one
  24481. * @param source An optional Mesh from which geometry is shared, cloned.
  24482. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  24483. * When false, achieved by calling a clone(), also passing False.
  24484. * This will make creation of children, recursive.
  24485. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  24486. */
  24487. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  24488. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  24489. /**
  24490. * Gets the class name
  24491. * @returns the string "Mesh".
  24492. */
  24493. getClassName(): string;
  24494. /** @hidden */
  24495. readonly _isMesh: boolean;
  24496. /**
  24497. * Returns a description of this mesh
  24498. * @param fullDetails define if full details about this mesh must be used
  24499. * @returns a descriptive string representing this mesh
  24500. */
  24501. toString(fullDetails?: boolean): string;
  24502. /** @hidden */
  24503. _unBindEffect(): void;
  24504. /**
  24505. * Gets a boolean indicating if this mesh has LOD
  24506. */
  24507. readonly hasLODLevels: boolean;
  24508. /**
  24509. * Gets the list of MeshLODLevel associated with the current mesh
  24510. * @returns an array of MeshLODLevel
  24511. */
  24512. getLODLevels(): MeshLODLevel[];
  24513. private _sortLODLevels;
  24514. /**
  24515. * Add a mesh as LOD level triggered at the given distance.
  24516. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24517. * @param distance The distance from the center of the object to show this level
  24518. * @param mesh The mesh to be added as LOD level (can be null)
  24519. * @return This mesh (for chaining)
  24520. */
  24521. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  24522. /**
  24523. * Returns the LOD level mesh at the passed distance or null if not found.
  24524. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24525. * @param distance The distance from the center of the object to show this level
  24526. * @returns a Mesh or `null`
  24527. */
  24528. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  24529. /**
  24530. * Remove a mesh from the LOD array
  24531. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24532. * @param mesh defines the mesh to be removed
  24533. * @return This mesh (for chaining)
  24534. */
  24535. removeLODLevel(mesh: Mesh): Mesh;
  24536. /**
  24537. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  24538. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  24539. * @param camera defines the camera to use to compute distance
  24540. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  24541. * @return This mesh (for chaining)
  24542. */
  24543. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  24544. /**
  24545. * Gets the mesh internal Geometry object
  24546. */
  24547. readonly geometry: Nullable<Geometry>;
  24548. /**
  24549. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  24550. * @returns the total number of vertices
  24551. */
  24552. getTotalVertices(): number;
  24553. /**
  24554. * Returns the content of an associated vertex buffer
  24555. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24556. * - VertexBuffer.PositionKind
  24557. * - VertexBuffer.UVKind
  24558. * - VertexBuffer.UV2Kind
  24559. * - VertexBuffer.UV3Kind
  24560. * - VertexBuffer.UV4Kind
  24561. * - VertexBuffer.UV5Kind
  24562. * - VertexBuffer.UV6Kind
  24563. * - VertexBuffer.ColorKind
  24564. * - VertexBuffer.MatricesIndicesKind
  24565. * - VertexBuffer.MatricesIndicesExtraKind
  24566. * - VertexBuffer.MatricesWeightsKind
  24567. * - VertexBuffer.MatricesWeightsExtraKind
  24568. * @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
  24569. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  24570. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  24571. */
  24572. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  24573. /**
  24574. * Returns the mesh VertexBuffer object from the requested `kind`
  24575. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24576. * - VertexBuffer.PositionKind
  24577. * - VertexBuffer.NormalKind
  24578. * - VertexBuffer.UVKind
  24579. * - VertexBuffer.UV2Kind
  24580. * - VertexBuffer.UV3Kind
  24581. * - VertexBuffer.UV4Kind
  24582. * - VertexBuffer.UV5Kind
  24583. * - VertexBuffer.UV6Kind
  24584. * - VertexBuffer.ColorKind
  24585. * - VertexBuffer.MatricesIndicesKind
  24586. * - VertexBuffer.MatricesIndicesExtraKind
  24587. * - VertexBuffer.MatricesWeightsKind
  24588. * - VertexBuffer.MatricesWeightsExtraKind
  24589. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  24590. */
  24591. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  24592. /**
  24593. * Tests if a specific vertex buffer is associated with this mesh
  24594. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24595. * - VertexBuffer.PositionKind
  24596. * - VertexBuffer.NormalKind
  24597. * - VertexBuffer.UVKind
  24598. * - VertexBuffer.UV2Kind
  24599. * - VertexBuffer.UV3Kind
  24600. * - VertexBuffer.UV4Kind
  24601. * - VertexBuffer.UV5Kind
  24602. * - VertexBuffer.UV6Kind
  24603. * - VertexBuffer.ColorKind
  24604. * - VertexBuffer.MatricesIndicesKind
  24605. * - VertexBuffer.MatricesIndicesExtraKind
  24606. * - VertexBuffer.MatricesWeightsKind
  24607. * - VertexBuffer.MatricesWeightsExtraKind
  24608. * @returns a boolean
  24609. */
  24610. isVerticesDataPresent(kind: string): boolean;
  24611. /**
  24612. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  24613. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  24614. * - VertexBuffer.PositionKind
  24615. * - VertexBuffer.UVKind
  24616. * - VertexBuffer.UV2Kind
  24617. * - VertexBuffer.UV3Kind
  24618. * - VertexBuffer.UV4Kind
  24619. * - VertexBuffer.UV5Kind
  24620. * - VertexBuffer.UV6Kind
  24621. * - VertexBuffer.ColorKind
  24622. * - VertexBuffer.MatricesIndicesKind
  24623. * - VertexBuffer.MatricesIndicesExtraKind
  24624. * - VertexBuffer.MatricesWeightsKind
  24625. * - VertexBuffer.MatricesWeightsExtraKind
  24626. * @returns a boolean
  24627. */
  24628. isVertexBufferUpdatable(kind: string): boolean;
  24629. /**
  24630. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  24631. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  24632. * - VertexBuffer.PositionKind
  24633. * - VertexBuffer.NormalKind
  24634. * - VertexBuffer.UVKind
  24635. * - VertexBuffer.UV2Kind
  24636. * - VertexBuffer.UV3Kind
  24637. * - VertexBuffer.UV4Kind
  24638. * - VertexBuffer.UV5Kind
  24639. * - VertexBuffer.UV6Kind
  24640. * - VertexBuffer.ColorKind
  24641. * - VertexBuffer.MatricesIndicesKind
  24642. * - VertexBuffer.MatricesIndicesExtraKind
  24643. * - VertexBuffer.MatricesWeightsKind
  24644. * - VertexBuffer.MatricesWeightsExtraKind
  24645. * @returns an array of strings
  24646. */
  24647. getVerticesDataKinds(): string[];
  24648. /**
  24649. * Returns a positive integer : the total number of indices in this mesh geometry.
  24650. * @returns the numner of indices or zero if the mesh has no geometry.
  24651. */
  24652. getTotalIndices(): number;
  24653. /**
  24654. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  24655. * @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.
  24656. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  24657. * @returns the indices array or an empty array if the mesh has no geometry
  24658. */
  24659. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  24660. readonly isBlocked: boolean;
  24661. /**
  24662. * Determine if the current mesh is ready to be rendered
  24663. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  24664. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  24665. * @returns true if all associated assets are ready (material, textures, shaders)
  24666. */
  24667. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  24668. /**
  24669. * 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.
  24670. */
  24671. readonly areNormalsFrozen: boolean;
  24672. /**
  24673. * 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.
  24674. * @returns the current mesh
  24675. */
  24676. freezeNormals(): Mesh;
  24677. /**
  24678. * 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
  24679. * @returns the current mesh
  24680. */
  24681. unfreezeNormals(): Mesh;
  24682. /**
  24683. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  24684. */
  24685. overridenInstanceCount: number;
  24686. /** @hidden */
  24687. _preActivate(): Mesh;
  24688. /** @hidden */
  24689. _preActivateForIntermediateRendering(renderId: number): Mesh;
  24690. /** @hidden */
  24691. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  24692. /**
  24693. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  24694. * This means the mesh underlying bounding box and sphere are recomputed.
  24695. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  24696. * @returns the current mesh
  24697. */
  24698. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  24699. /** @hidden */
  24700. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  24701. /**
  24702. * This function will subdivide the mesh into multiple submeshes
  24703. * @param count defines the expected number of submeshes
  24704. */
  24705. subdivide(count: number): void;
  24706. /**
  24707. * Copy a FloatArray into a specific associated vertex buffer
  24708. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24709. * - VertexBuffer.PositionKind
  24710. * - VertexBuffer.UVKind
  24711. * - VertexBuffer.UV2Kind
  24712. * - VertexBuffer.UV3Kind
  24713. * - VertexBuffer.UV4Kind
  24714. * - VertexBuffer.UV5Kind
  24715. * - VertexBuffer.UV6Kind
  24716. * - VertexBuffer.ColorKind
  24717. * - VertexBuffer.MatricesIndicesKind
  24718. * - VertexBuffer.MatricesIndicesExtraKind
  24719. * - VertexBuffer.MatricesWeightsKind
  24720. * - VertexBuffer.MatricesWeightsExtraKind
  24721. * @param data defines the data source
  24722. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24723. * @param stride defines the data stride size (can be null)
  24724. * @returns the current mesh
  24725. */
  24726. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  24727. /**
  24728. * Flags an associated vertex buffer as updatable
  24729. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  24730. * - VertexBuffer.PositionKind
  24731. * - VertexBuffer.UVKind
  24732. * - VertexBuffer.UV2Kind
  24733. * - VertexBuffer.UV3Kind
  24734. * - VertexBuffer.UV4Kind
  24735. * - VertexBuffer.UV5Kind
  24736. * - VertexBuffer.UV6Kind
  24737. * - VertexBuffer.ColorKind
  24738. * - VertexBuffer.MatricesIndicesKind
  24739. * - VertexBuffer.MatricesIndicesExtraKind
  24740. * - VertexBuffer.MatricesWeightsKind
  24741. * - VertexBuffer.MatricesWeightsExtraKind
  24742. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  24743. */
  24744. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  24745. /**
  24746. * Sets the mesh global Vertex Buffer
  24747. * @param buffer defines the buffer to use
  24748. * @returns the current mesh
  24749. */
  24750. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  24751. /**
  24752. * Update a specific associated vertex buffer
  24753. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  24754. * - VertexBuffer.PositionKind
  24755. * - VertexBuffer.UVKind
  24756. * - VertexBuffer.UV2Kind
  24757. * - VertexBuffer.UV3Kind
  24758. * - VertexBuffer.UV4Kind
  24759. * - VertexBuffer.UV5Kind
  24760. * - VertexBuffer.UV6Kind
  24761. * - VertexBuffer.ColorKind
  24762. * - VertexBuffer.MatricesIndicesKind
  24763. * - VertexBuffer.MatricesIndicesExtraKind
  24764. * - VertexBuffer.MatricesWeightsKind
  24765. * - VertexBuffer.MatricesWeightsExtraKind
  24766. * @param data defines the data source
  24767. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  24768. * @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)
  24769. * @returns the current mesh
  24770. */
  24771. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  24772. /**
  24773. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  24774. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  24775. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  24776. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  24777. * @returns the current mesh
  24778. */
  24779. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  24780. /**
  24781. * Creates a un-shared specific occurence of the geometry for the mesh.
  24782. * @returns the current mesh
  24783. */
  24784. makeGeometryUnique(): Mesh;
  24785. /**
  24786. * Set the index buffer of this mesh
  24787. * @param indices defines the source data
  24788. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  24789. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  24790. * @returns the current mesh
  24791. */
  24792. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  24793. /**
  24794. * Update the current index buffer
  24795. * @param indices defines the source data
  24796. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  24797. * @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)
  24798. * @returns the current mesh
  24799. */
  24800. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  24801. /**
  24802. * Invert the geometry to move from a right handed system to a left handed one.
  24803. * @returns the current mesh
  24804. */
  24805. toLeftHanded(): Mesh;
  24806. /** @hidden */
  24807. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  24808. /** @hidden */
  24809. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  24810. /**
  24811. * Registers for this mesh a javascript function called just before the rendering process
  24812. * @param func defines the function to call before rendering this mesh
  24813. * @returns the current mesh
  24814. */
  24815. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24816. /**
  24817. * Disposes a previously registered javascript function called before the rendering
  24818. * @param func defines the function to remove
  24819. * @returns the current mesh
  24820. */
  24821. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  24822. /**
  24823. * Registers for this mesh a javascript function called just after the rendering is complete
  24824. * @param func defines the function to call after rendering this mesh
  24825. * @returns the current mesh
  24826. */
  24827. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24828. /**
  24829. * Disposes a previously registered javascript function called after the rendering.
  24830. * @param func defines the function to remove
  24831. * @returns the current mesh
  24832. */
  24833. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  24834. /** @hidden */
  24835. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  24836. /** @hidden */
  24837. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  24838. /** @hidden */
  24839. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  24840. /** @hidden */
  24841. _rebuild(): void;
  24842. /** @hidden */
  24843. _freeze(): void;
  24844. /** @hidden */
  24845. _unFreeze(): void;
  24846. /**
  24847. * 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
  24848. * @param subMesh defines the subMesh to render
  24849. * @param enableAlphaMode defines if alpha mode can be changed
  24850. * @returns the current mesh
  24851. */
  24852. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  24853. private _onBeforeDraw;
  24854. /**
  24855. * Renormalize the mesh and patch it up if there are no weights
  24856. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  24857. * However in the case of zero weights then we set just a single influence to 1.
  24858. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  24859. */
  24860. cleanMatrixWeights(): void;
  24861. private normalizeSkinFourWeights;
  24862. private normalizeSkinWeightsAndExtra;
  24863. /**
  24864. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  24865. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  24866. * the user know there was an issue with importing the mesh
  24867. * @returns a validation object with skinned, valid and report string
  24868. */
  24869. validateSkinning(): {
  24870. skinned: boolean;
  24871. valid: boolean;
  24872. report: string;
  24873. };
  24874. /** @hidden */
  24875. _checkDelayState(): Mesh;
  24876. private _queueLoad;
  24877. /**
  24878. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  24879. * A mesh is in the frustum if its bounding box intersects the frustum
  24880. * @param frustumPlanes defines the frustum to test
  24881. * @returns true if the mesh is in the frustum planes
  24882. */
  24883. isInFrustum(frustumPlanes: Plane[]): boolean;
  24884. /**
  24885. * Sets the mesh material by the material or multiMaterial `id` property
  24886. * @param id is a string identifying the material or the multiMaterial
  24887. * @returns the current mesh
  24888. */
  24889. setMaterialByID(id: string): Mesh;
  24890. /**
  24891. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  24892. * @returns an array of IAnimatable
  24893. */
  24894. getAnimatables(): IAnimatable[];
  24895. /**
  24896. * Modifies the mesh geometry according to the passed transformation matrix.
  24897. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  24898. * The mesh normals are modified using the same transformation.
  24899. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24900. * @param transform defines the transform matrix to use
  24901. * @see http://doc.babylonjs.com/resources/baking_transformations
  24902. * @returns the current mesh
  24903. */
  24904. bakeTransformIntoVertices(transform: Matrix): Mesh;
  24905. /**
  24906. * Modifies the mesh geometry according to its own current World Matrix.
  24907. * The mesh World Matrix is then reset.
  24908. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  24909. * Note that, under the hood, this method sets a new VertexBuffer each call.
  24910. * @see http://doc.babylonjs.com/resources/baking_transformations
  24911. * @returns the current mesh
  24912. */
  24913. bakeCurrentTransformIntoVertices(): Mesh;
  24914. /** @hidden */
  24915. readonly _positions: Nullable<Vector3[]>;
  24916. /** @hidden */
  24917. _resetPointsArrayCache(): Mesh;
  24918. /** @hidden */
  24919. _generatePointsArray(): boolean;
  24920. /**
  24921. * Returns a new Mesh object generated from the current mesh properties.
  24922. * This method must not get confused with createInstance()
  24923. * @param name is a string, the name given to the new mesh
  24924. * @param newParent can be any Node object (default `null`)
  24925. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  24926. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  24927. * @returns a new mesh
  24928. */
  24929. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  24930. /**
  24931. * Releases resources associated with this mesh.
  24932. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  24933. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  24934. */
  24935. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  24936. /**
  24937. * Modifies the mesh geometry according to a displacement map.
  24938. * 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.
  24939. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24940. * @param url is a string, the URL from the image file is to be downloaded.
  24941. * @param minHeight is the lower limit of the displacement.
  24942. * @param maxHeight is the upper limit of the displacement.
  24943. * @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.
  24944. * @param uvOffset is an optional vector2 used to offset UV.
  24945. * @param uvScale is an optional vector2 used to scale UV.
  24946. * @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.
  24947. * @returns the Mesh.
  24948. */
  24949. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24950. /**
  24951. * Modifies the mesh geometry according to a displacementMap buffer.
  24952. * 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.
  24953. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  24954. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  24955. * @param heightMapWidth is the width of the buffer image.
  24956. * @param heightMapHeight is the height of the buffer image.
  24957. * @param minHeight is the lower limit of the displacement.
  24958. * @param maxHeight is the upper limit of the displacement.
  24959. * @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.
  24960. * @param uvOffset is an optional vector2 used to offset UV.
  24961. * @param uvScale is an optional vector2 used to scale UV.
  24962. * @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.
  24963. * @returns the Mesh.
  24964. */
  24965. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  24966. /**
  24967. * Modify the mesh to get a flat shading rendering.
  24968. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  24969. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  24970. * @returns current mesh
  24971. */
  24972. convertToFlatShadedMesh(): Mesh;
  24973. /**
  24974. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  24975. * In other words, more vertices, no more indices and a single bigger VBO.
  24976. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  24977. * @returns current mesh
  24978. */
  24979. convertToUnIndexedMesh(): Mesh;
  24980. /**
  24981. * Inverses facet orientations.
  24982. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24983. * @param flipNormals will also inverts the normals
  24984. * @returns current mesh
  24985. */
  24986. flipFaces(flipNormals?: boolean): Mesh;
  24987. /**
  24988. * Increase the number of facets and hence vertices in a mesh
  24989. * Vertex normals are interpolated from existing vertex normals
  24990. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24991. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  24992. */
  24993. increaseVertices(numberPerEdge: number): void;
  24994. /**
  24995. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  24996. * This will undo any application of covertToFlatShadedMesh
  24997. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  24998. */
  24999. forceSharedVertices(): void;
  25000. /** @hidden */
  25001. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  25002. /** @hidden */
  25003. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  25004. /**
  25005. * Creates a new InstancedMesh object from the mesh model.
  25006. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  25007. * @param name defines the name of the new instance
  25008. * @returns a new InstancedMesh
  25009. */
  25010. createInstance(name: string): InstancedMesh;
  25011. /**
  25012. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  25013. * After this call, all the mesh instances have the same submeshes than the current mesh.
  25014. * @returns the current mesh
  25015. */
  25016. synchronizeInstances(): Mesh;
  25017. /**
  25018. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  25019. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  25020. * This should be used together with the simplification to avoid disappearing triangles.
  25021. * @param successCallback an optional success callback to be called after the optimization finished.
  25022. * @returns the current mesh
  25023. */
  25024. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  25025. /**
  25026. * Serialize current mesh
  25027. * @param serializationObject defines the object which will receive the serialization data
  25028. */
  25029. serialize(serializationObject: any): void;
  25030. /** @hidden */
  25031. _syncGeometryWithMorphTargetManager(): void;
  25032. /** @hidden */
  25033. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  25034. /**
  25035. * Returns a new Mesh object parsed from the source provided.
  25036. * @param parsedMesh is the source
  25037. * @param scene defines the hosting scene
  25038. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  25039. * @returns a new Mesh
  25040. */
  25041. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  25042. /**
  25043. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  25044. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25045. * @param name defines the name of the mesh to create
  25046. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  25047. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  25048. * @param closePath creates a seam between the first and the last points of each path of the path array
  25049. * @param offset is taken in account only if the `pathArray` is containing a single path
  25050. * @param scene defines the hosting scene
  25051. * @param updatable defines if the mesh must be flagged as updatable
  25052. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25053. * @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)
  25054. * @returns a new Mesh
  25055. */
  25056. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25057. /**
  25058. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  25059. * @param name defines the name of the mesh to create
  25060. * @param radius sets the radius size (float) of the polygon (default 0.5)
  25061. * @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
  25062. * @param scene defines the hosting scene
  25063. * @param updatable defines if the mesh must be flagged as updatable
  25064. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25065. * @returns a new Mesh
  25066. */
  25067. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25068. /**
  25069. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  25070. * @param name defines the name of the mesh to create
  25071. * @param size sets the size (float) of each box side (default 1)
  25072. * @param scene defines the hosting scene
  25073. * @param updatable defines if the mesh must be flagged as updatable
  25074. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25075. * @returns a new Mesh
  25076. */
  25077. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  25078. /**
  25079. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  25080. * @param name defines the name of the mesh to create
  25081. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25082. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25083. * @param scene defines the hosting scene
  25084. * @param updatable defines if the mesh must be flagged as updatable
  25085. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25086. * @returns a new Mesh
  25087. */
  25088. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25089. /**
  25090. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  25091. * @param name defines the name of the mesh to create
  25092. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  25093. * @param diameter sets the diameter size (float) of the sphere (default 1)
  25094. * @param scene defines the hosting scene
  25095. * @returns a new Mesh
  25096. */
  25097. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  25098. /**
  25099. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  25100. * @param name defines the name of the mesh to create
  25101. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  25102. * @param diameterTop set the top cap diameter (floats, default 1)
  25103. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  25104. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  25105. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  25106. * @param scene defines the hosting scene
  25107. * @param updatable defines if the mesh must be flagged as updatable
  25108. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25109. * @returns a new Mesh
  25110. */
  25111. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  25112. /**
  25113. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  25114. * @param name defines the name of the mesh to create
  25115. * @param diameter sets the diameter size (float) of the torus (default 1)
  25116. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  25117. * @param tessellation sets the number of torus sides (postive integer, default 16)
  25118. * @param scene defines the hosting scene
  25119. * @param updatable defines if the mesh must be flagged as updatable
  25120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25121. * @returns a new Mesh
  25122. */
  25123. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25124. /**
  25125. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  25126. * @param name defines the name of the mesh to create
  25127. * @param radius sets the global radius size (float) of the torus knot (default 2)
  25128. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  25129. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  25130. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  25131. * @param p the number of windings on X axis (positive integers, default 2)
  25132. * @param q the number of windings on Y axis (positive integers, default 3)
  25133. * @param scene defines the hosting scene
  25134. * @param updatable defines if the mesh must be flagged as updatable
  25135. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25136. * @returns a new Mesh
  25137. */
  25138. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25139. /**
  25140. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  25141. * @param name defines the name of the mesh to create
  25142. * @param points is an array successive Vector3
  25143. * @param scene defines the hosting scene
  25144. * @param updatable defines if the mesh must be flagged as updatable
  25145. * @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).
  25146. * @returns a new Mesh
  25147. */
  25148. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  25149. /**
  25150. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  25151. * @param name defines the name of the mesh to create
  25152. * @param points is an array successive Vector3
  25153. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  25154. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  25155. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  25156. * @param scene defines the hosting scene
  25157. * @param updatable defines if the mesh must be flagged as updatable
  25158. * @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)
  25159. * @returns a new Mesh
  25160. */
  25161. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  25162. /**
  25163. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  25164. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  25165. * 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.
  25166. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25167. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  25168. * Remember you can only change the shape positions, not their number when updating a polygon.
  25169. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  25170. * @param name defines the name of the mesh to create
  25171. * @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
  25172. * @param scene defines the hosting scene
  25173. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25174. * @param updatable defines if the mesh must be flagged as updatable
  25175. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25176. * @param earcutInjection can be used to inject your own earcut reference
  25177. * @returns a new Mesh
  25178. */
  25179. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25180. /**
  25181. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  25182. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  25183. * @param name defines the name of the mesh to create
  25184. * @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
  25185. * @param depth defines the height of extrusion
  25186. * @param scene defines the hosting scene
  25187. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  25188. * @param updatable defines if the mesh must be flagged as updatable
  25189. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25190. * @param earcutInjection can be used to inject your own earcut reference
  25191. * @returns a new Mesh
  25192. */
  25193. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  25194. /**
  25195. * Creates an extruded shape mesh.
  25196. * 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
  25197. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25198. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25199. * @param name defines the name of the mesh to create
  25200. * @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
  25201. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25202. * @param scale is the value to scale the shape
  25203. * @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
  25204. * @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
  25205. * @param scene defines the hosting scene
  25206. * @param updatable defines if the mesh must be flagged as updatable
  25207. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25208. * @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)
  25209. * @returns a new Mesh
  25210. */
  25211. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25212. /**
  25213. * Creates an custom extruded shape mesh.
  25214. * The custom extrusion is a parametric shape.
  25215. * It has no predefined shape. Its final shape will depend on the input parameters.
  25216. * Please consider using the same method from the MeshBuilder class instead
  25217. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  25218. * @param name defines the name of the mesh to create
  25219. * @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
  25220. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  25221. * @param scaleFunction is a custom Javascript function called on each path point
  25222. * @param rotationFunction is a custom Javascript function called on each path point
  25223. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  25224. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  25225. * @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
  25226. * @param scene defines the hosting scene
  25227. * @param updatable defines if the mesh must be flagged as updatable
  25228. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25229. * @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)
  25230. * @returns a new Mesh
  25231. */
  25232. 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;
  25233. /**
  25234. * Creates lathe mesh.
  25235. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  25236. * Please consider using the same method from the MeshBuilder class instead
  25237. * @param name defines the name of the mesh to create
  25238. * @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
  25239. * @param radius is the radius value of the lathe
  25240. * @param tessellation is the side number of the lathe.
  25241. * @param scene defines the hosting scene
  25242. * @param updatable defines if the mesh must be flagged as updatable
  25243. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25244. * @returns a new Mesh
  25245. */
  25246. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25247. /**
  25248. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  25249. * @param name defines the name of the mesh to create
  25250. * @param size sets the size (float) of both sides of the plane at once (default 1)
  25251. * @param scene defines the hosting scene
  25252. * @param updatable defines if the mesh must be flagged as updatable
  25253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25254. * @returns a new Mesh
  25255. */
  25256. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  25257. /**
  25258. * Creates a ground mesh.
  25259. * Please consider using the same method from the MeshBuilder class instead
  25260. * @param name defines the name of the mesh to create
  25261. * @param width set the width of the ground
  25262. * @param height set the height of the ground
  25263. * @param subdivisions sets the number of subdivisions per side
  25264. * @param scene defines the hosting scene
  25265. * @param updatable defines if the mesh must be flagged as updatable
  25266. * @returns a new Mesh
  25267. */
  25268. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  25269. /**
  25270. * Creates a tiled ground mesh.
  25271. * Please consider using the same method from the MeshBuilder class instead
  25272. * @param name defines the name of the mesh to create
  25273. * @param xmin set the ground minimum X coordinate
  25274. * @param zmin set the ground minimum Y coordinate
  25275. * @param xmax set the ground maximum X coordinate
  25276. * @param zmax set the ground maximum Z coordinate
  25277. * @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
  25278. * @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
  25279. * @param scene defines the hosting scene
  25280. * @param updatable defines if the mesh must be flagged as updatable
  25281. * @returns a new Mesh
  25282. */
  25283. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  25284. w: number;
  25285. h: number;
  25286. }, precision: {
  25287. w: number;
  25288. h: number;
  25289. }, scene: Scene, updatable?: boolean): Mesh;
  25290. /**
  25291. * Creates a ground mesh from a height map.
  25292. * Please consider using the same method from the MeshBuilder class instead
  25293. * @see http://doc.babylonjs.com/babylon101/height_map
  25294. * @param name defines the name of the mesh to create
  25295. * @param url sets the URL of the height map image resource
  25296. * @param width set the ground width size
  25297. * @param height set the ground height size
  25298. * @param subdivisions sets the number of subdivision per side
  25299. * @param minHeight is the minimum altitude on the ground
  25300. * @param maxHeight is the maximum altitude on the ground
  25301. * @param scene defines the hosting scene
  25302. * @param updatable defines if the mesh must be flagged as updatable
  25303. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  25304. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  25305. * @returns a new Mesh
  25306. */
  25307. 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;
  25308. /**
  25309. * Creates a tube mesh.
  25310. * The tube is a parametric shape.
  25311. * It has no predefined shape. Its final shape will depend on the input parameters.
  25312. * Please consider using the same method from the MeshBuilder class instead
  25313. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  25314. * @param name defines the name of the mesh to create
  25315. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  25316. * @param radius sets the tube radius size
  25317. * @param tessellation is the number of sides on the tubular surface
  25318. * @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
  25319. * @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
  25320. * @param scene defines the hosting scene
  25321. * @param updatable defines if the mesh must be flagged as updatable
  25322. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  25323. * @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)
  25324. * @returns a new Mesh
  25325. */
  25326. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  25327. (i: number, distance: number): number;
  25328. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  25329. /**
  25330. * Creates a polyhedron mesh.
  25331. * Please consider using the same method from the MeshBuilder class instead.
  25332. * * 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
  25333. * * The parameter `size` (positive float, default 1) sets the polygon size
  25334. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  25335. * * 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`
  25336. * * 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
  25337. * * 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)`)
  25338. * * 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
  25339. * * 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
  25340. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25341. * * If you create a double-sided mesh, you can choose what parts of 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
  25342. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25343. * @param name defines the name of the mesh to create
  25344. * @param options defines the options used to create the mesh
  25345. * @param scene defines the hosting scene
  25346. * @returns a new Mesh
  25347. */
  25348. static CreatePolyhedron(name: string, options: {
  25349. type?: number;
  25350. size?: number;
  25351. sizeX?: number;
  25352. sizeY?: number;
  25353. sizeZ?: number;
  25354. custom?: any;
  25355. faceUV?: Vector4[];
  25356. faceColors?: Color4[];
  25357. updatable?: boolean;
  25358. sideOrientation?: number;
  25359. }, scene: Scene): Mesh;
  25360. /**
  25361. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  25362. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  25363. * * 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`)
  25364. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  25365. * * 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
  25366. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  25367. * * If you create a double-sided mesh, you can choose what parts of 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
  25368. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25369. * @param name defines the name of the mesh
  25370. * @param options defines the options used to create the mesh
  25371. * @param scene defines the hosting scene
  25372. * @returns a new Mesh
  25373. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  25374. */
  25375. static CreateIcoSphere(name: string, options: {
  25376. radius?: number;
  25377. flat?: boolean;
  25378. subdivisions?: number;
  25379. sideOrientation?: number;
  25380. updatable?: boolean;
  25381. }, scene: Scene): Mesh;
  25382. /**
  25383. * Creates a decal mesh.
  25384. * Please consider using the same method from the MeshBuilder class instead.
  25385. * A decal is a mesh usually applied as a model onto the surface of another mesh
  25386. * @param name defines the name of the mesh
  25387. * @param sourceMesh defines the mesh receiving the decal
  25388. * @param position sets the position of the decal in world coordinates
  25389. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  25390. * @param size sets the decal scaling
  25391. * @param angle sets the angle to rotate the decal
  25392. * @returns a new Mesh
  25393. */
  25394. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  25395. /**
  25396. * Prepare internal position array for software CPU skinning
  25397. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  25398. */
  25399. setPositionsForCPUSkinning(): Float32Array;
  25400. /**
  25401. * Prepare internal normal array for software CPU skinning
  25402. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  25403. */
  25404. setNormalsForCPUSkinning(): Float32Array;
  25405. /**
  25406. * Updates the vertex buffer by applying transformation from the bones
  25407. * @param skeleton defines the skeleton to apply to current mesh
  25408. * @returns the current mesh
  25409. */
  25410. applySkeleton(skeleton: Skeleton): Mesh;
  25411. /**
  25412. * 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
  25413. * @param meshes defines the list of meshes to scan
  25414. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  25415. */
  25416. static MinMax(meshes: AbstractMesh[]): {
  25417. min: Vector3;
  25418. max: Vector3;
  25419. };
  25420. /**
  25421. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  25422. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  25423. * @returns a vector3
  25424. */
  25425. static Center(meshesOrMinMaxVector: {
  25426. min: Vector3;
  25427. max: Vector3;
  25428. } | AbstractMesh[]): Vector3;
  25429. /**
  25430. * Merge the array of meshes into a single mesh for performance reasons.
  25431. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  25432. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  25433. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  25434. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  25435. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  25436. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  25437. * @returns a new mesh
  25438. */
  25439. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  25440. /** @hidden */
  25441. addInstance(instance: InstancedMesh): void;
  25442. /** @hidden */
  25443. removeInstance(instance: InstancedMesh): void;
  25444. }
  25445. }
  25446. declare module "babylonjs/Cameras/camera" {
  25447. import { SmartArray } from "babylonjs/Misc/smartArray";
  25448. import { Observable } from "babylonjs/Misc/observable";
  25449. import { Nullable } from "babylonjs/types";
  25450. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  25451. import { Scene } from "babylonjs/scene";
  25452. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  25453. import { Node } from "babylonjs/node";
  25454. import { Mesh } from "babylonjs/Meshes/mesh";
  25455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25456. import { ICullable } from "babylonjs/Culling/boundingInfo";
  25457. import { Viewport } from "babylonjs/Maths/math.viewport";
  25458. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25459. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25460. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  25461. import { Ray } from "babylonjs/Culling/ray";
  25462. /**
  25463. * This is the base class of all the camera used in the application.
  25464. * @see http://doc.babylonjs.com/features/cameras
  25465. */
  25466. export class Camera extends Node {
  25467. /** @hidden */
  25468. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  25469. /**
  25470. * This is the default projection mode used by the cameras.
  25471. * It helps recreating a feeling of perspective and better appreciate depth.
  25472. * This is the best way to simulate real life cameras.
  25473. */
  25474. static readonly PERSPECTIVE_CAMERA: number;
  25475. /**
  25476. * This helps creating camera with an orthographic mode.
  25477. * 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.
  25478. */
  25479. static readonly ORTHOGRAPHIC_CAMERA: number;
  25480. /**
  25481. * This is the default FOV mode for perspective cameras.
  25482. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  25483. */
  25484. static readonly FOVMODE_VERTICAL_FIXED: number;
  25485. /**
  25486. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  25487. */
  25488. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  25489. /**
  25490. * This specifies ther is no need for a camera rig.
  25491. * Basically only one eye is rendered corresponding to the camera.
  25492. */
  25493. static readonly RIG_MODE_NONE: number;
  25494. /**
  25495. * Simulates a camera Rig with one blue eye and one red eye.
  25496. * This can be use with 3d blue and red glasses.
  25497. */
  25498. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  25499. /**
  25500. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  25501. */
  25502. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  25503. /**
  25504. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  25505. */
  25506. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  25507. /**
  25508. * Defines that both eyes of the camera will be rendered over under each other.
  25509. */
  25510. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  25511. /**
  25512. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  25513. */
  25514. static readonly RIG_MODE_VR: number;
  25515. /**
  25516. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  25517. */
  25518. static readonly RIG_MODE_WEBVR: number;
  25519. /**
  25520. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  25521. */
  25522. static readonly RIG_MODE_CUSTOM: number;
  25523. /**
  25524. * Defines if by default attaching controls should prevent the default javascript event to continue.
  25525. */
  25526. static ForceAttachControlToAlwaysPreventDefault: boolean;
  25527. /**
  25528. * Define the input manager associated with the camera.
  25529. */
  25530. inputs: CameraInputsManager<Camera>;
  25531. /** @hidden */
  25532. _position: Vector3;
  25533. /**
  25534. * Define the current local position of the camera in the scene
  25535. */
  25536. position: Vector3;
  25537. /**
  25538. * The vector the camera should consider as up.
  25539. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  25540. */
  25541. upVector: Vector3;
  25542. /**
  25543. * Define the current limit on the left side for an orthographic camera
  25544. * In scene unit
  25545. */
  25546. orthoLeft: Nullable<number>;
  25547. /**
  25548. * Define the current limit on the right side for an orthographic camera
  25549. * In scene unit
  25550. */
  25551. orthoRight: Nullable<number>;
  25552. /**
  25553. * Define the current limit on the bottom side for an orthographic camera
  25554. * In scene unit
  25555. */
  25556. orthoBottom: Nullable<number>;
  25557. /**
  25558. * Define the current limit on the top side for an orthographic camera
  25559. * In scene unit
  25560. */
  25561. orthoTop: Nullable<number>;
  25562. /**
  25563. * Field Of View is set in Radians. (default is 0.8)
  25564. */
  25565. fov: number;
  25566. /**
  25567. * Define the minimum distance the camera can see from.
  25568. * This is important to note that the depth buffer are not infinite and the closer it starts
  25569. * the more your scene might encounter depth fighting issue.
  25570. */
  25571. minZ: number;
  25572. /**
  25573. * Define the maximum distance the camera can see to.
  25574. * This is important to note that the depth buffer are not infinite and the further it end
  25575. * the more your scene might encounter depth fighting issue.
  25576. */
  25577. maxZ: number;
  25578. /**
  25579. * Define the default inertia of the camera.
  25580. * This helps giving a smooth feeling to the camera movement.
  25581. */
  25582. inertia: number;
  25583. /**
  25584. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  25585. */
  25586. mode: number;
  25587. /**
  25588. * Define wether the camera is intermediate.
  25589. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  25590. */
  25591. isIntermediate: boolean;
  25592. /**
  25593. * Define the viewport of the camera.
  25594. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  25595. */
  25596. viewport: Viewport;
  25597. /**
  25598. * Restricts the camera to viewing objects with the same layerMask.
  25599. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  25600. */
  25601. layerMask: number;
  25602. /**
  25603. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  25604. */
  25605. fovMode: number;
  25606. /**
  25607. * Rig mode of the camera.
  25608. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  25609. * This is normally controlled byt the camera themselves as internal use.
  25610. */
  25611. cameraRigMode: number;
  25612. /**
  25613. * Defines the distance between both "eyes" in case of a RIG
  25614. */
  25615. interaxialDistance: number;
  25616. /**
  25617. * Defines if stereoscopic rendering is done side by side or over under.
  25618. */
  25619. isStereoscopicSideBySide: boolean;
  25620. /**
  25621. * 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
  25622. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  25623. * else in the scene. (Eg. security camera)
  25624. *
  25625. * 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)
  25626. */
  25627. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  25628. /**
  25629. * When set, the camera will render to this render target instead of the default canvas
  25630. *
  25631. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  25632. */
  25633. outputRenderTarget: Nullable<RenderTargetTexture>;
  25634. /**
  25635. * Observable triggered when the camera view matrix has changed.
  25636. */
  25637. onViewMatrixChangedObservable: Observable<Camera>;
  25638. /**
  25639. * Observable triggered when the camera Projection matrix has changed.
  25640. */
  25641. onProjectionMatrixChangedObservable: Observable<Camera>;
  25642. /**
  25643. * Observable triggered when the inputs have been processed.
  25644. */
  25645. onAfterCheckInputsObservable: Observable<Camera>;
  25646. /**
  25647. * Observable triggered when reset has been called and applied to the camera.
  25648. */
  25649. onRestoreStateObservable: Observable<Camera>;
  25650. /** @hidden */
  25651. _cameraRigParams: any;
  25652. /** @hidden */
  25653. _rigCameras: Camera[];
  25654. /** @hidden */
  25655. _rigPostProcess: Nullable<PostProcess>;
  25656. protected _webvrViewMatrix: Matrix;
  25657. /** @hidden */
  25658. _skipRendering: boolean;
  25659. /** @hidden */
  25660. _projectionMatrix: Matrix;
  25661. /** @hidden */
  25662. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  25663. /** @hidden */
  25664. _activeMeshes: SmartArray<AbstractMesh>;
  25665. protected _globalPosition: Vector3;
  25666. /** @hidden */
  25667. _computedViewMatrix: Matrix;
  25668. private _doNotComputeProjectionMatrix;
  25669. private _transformMatrix;
  25670. private _frustumPlanes;
  25671. private _refreshFrustumPlanes;
  25672. private _storedFov;
  25673. private _stateStored;
  25674. /**
  25675. * Instantiates a new camera object.
  25676. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  25677. * @see http://doc.babylonjs.com/features/cameras
  25678. * @param name Defines the name of the camera in the scene
  25679. * @param position Defines the position of the camera
  25680. * @param scene Defines the scene the camera belongs too
  25681. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  25682. */
  25683. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  25684. /**
  25685. * Store current camera state (fov, position, etc..)
  25686. * @returns the camera
  25687. */
  25688. storeState(): Camera;
  25689. /**
  25690. * Restores the camera state values if it has been stored. You must call storeState() first
  25691. */
  25692. protected _restoreStateValues(): boolean;
  25693. /**
  25694. * Restored camera state. You must call storeState() first.
  25695. * @returns true if restored and false otherwise
  25696. */
  25697. restoreState(): boolean;
  25698. /**
  25699. * Gets the class name of the camera.
  25700. * @returns the class name
  25701. */
  25702. getClassName(): string;
  25703. /** @hidden */
  25704. readonly _isCamera: boolean;
  25705. /**
  25706. * Gets a string representation of the camera useful for debug purpose.
  25707. * @param fullDetails Defines that a more verboe level of logging is required
  25708. * @returns the string representation
  25709. */
  25710. toString(fullDetails?: boolean): string;
  25711. /**
  25712. * Gets the current world space position of the camera.
  25713. */
  25714. readonly globalPosition: Vector3;
  25715. /**
  25716. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  25717. * @returns the active meshe list
  25718. */
  25719. getActiveMeshes(): SmartArray<AbstractMesh>;
  25720. /**
  25721. * Check wether a mesh is part of the current active mesh list of the camera
  25722. * @param mesh Defines the mesh to check
  25723. * @returns true if active, false otherwise
  25724. */
  25725. isActiveMesh(mesh: Mesh): boolean;
  25726. /**
  25727. * Is this camera ready to be used/rendered
  25728. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  25729. * @return true if the camera is ready
  25730. */
  25731. isReady(completeCheck?: boolean): boolean;
  25732. /** @hidden */
  25733. _initCache(): void;
  25734. /** @hidden */
  25735. _updateCache(ignoreParentClass?: boolean): void;
  25736. /** @hidden */
  25737. _isSynchronized(): boolean;
  25738. /** @hidden */
  25739. _isSynchronizedViewMatrix(): boolean;
  25740. /** @hidden */
  25741. _isSynchronizedProjectionMatrix(): boolean;
  25742. /**
  25743. * Attach the input controls to a specific dom element to get the input from.
  25744. * @param element Defines the element the controls should be listened from
  25745. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  25746. */
  25747. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  25748. /**
  25749. * Detach the current controls from the specified dom element.
  25750. * @param element Defines the element to stop listening the inputs from
  25751. */
  25752. detachControl(element: HTMLElement): void;
  25753. /**
  25754. * Update the camera state according to the different inputs gathered during the frame.
  25755. */
  25756. update(): void;
  25757. /** @hidden */
  25758. _checkInputs(): void;
  25759. /** @hidden */
  25760. readonly rigCameras: Camera[];
  25761. /**
  25762. * Gets the post process used by the rig cameras
  25763. */
  25764. readonly rigPostProcess: Nullable<PostProcess>;
  25765. /**
  25766. * Internal, gets the first post proces.
  25767. * @returns the first post process to be run on this camera.
  25768. */
  25769. _getFirstPostProcess(): Nullable<PostProcess>;
  25770. private _cascadePostProcessesToRigCams;
  25771. /**
  25772. * Attach a post process to the camera.
  25773. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25774. * @param postProcess The post process to attach to the camera
  25775. * @param insertAt The position of the post process in case several of them are in use in the scene
  25776. * @returns the position the post process has been inserted at
  25777. */
  25778. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  25779. /**
  25780. * Detach a post process to the camera.
  25781. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  25782. * @param postProcess The post process to detach from the camera
  25783. */
  25784. detachPostProcess(postProcess: PostProcess): void;
  25785. /**
  25786. * Gets the current world matrix of the camera
  25787. */
  25788. getWorldMatrix(): Matrix;
  25789. /** @hidden */
  25790. _getViewMatrix(): Matrix;
  25791. /**
  25792. * Gets the current view matrix of the camera.
  25793. * @param force forces the camera to recompute the matrix without looking at the cached state
  25794. * @returns the view matrix
  25795. */
  25796. getViewMatrix(force?: boolean): Matrix;
  25797. /**
  25798. * Freeze the projection matrix.
  25799. * It will prevent the cache check of the camera projection compute and can speed up perf
  25800. * if no parameter of the camera are meant to change
  25801. * @param projection Defines manually a projection if necessary
  25802. */
  25803. freezeProjectionMatrix(projection?: Matrix): void;
  25804. /**
  25805. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  25806. */
  25807. unfreezeProjectionMatrix(): void;
  25808. /**
  25809. * Gets the current projection matrix of the camera.
  25810. * @param force forces the camera to recompute the matrix without looking at the cached state
  25811. * @returns the projection matrix
  25812. */
  25813. getProjectionMatrix(force?: boolean): Matrix;
  25814. /**
  25815. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  25816. * @returns a Matrix
  25817. */
  25818. getTransformationMatrix(): Matrix;
  25819. private _updateFrustumPlanes;
  25820. /**
  25821. * Checks if a cullable object (mesh...) is in the camera frustum
  25822. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  25823. * @param target The object to check
  25824. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  25825. * @returns true if the object is in frustum otherwise false
  25826. */
  25827. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  25828. /**
  25829. * Checks if a cullable object (mesh...) is in the camera frustum
  25830. * Unlike isInFrustum this cheks the full bounding box
  25831. * @param target The object to check
  25832. * @returns true if the object is in frustum otherwise false
  25833. */
  25834. isCompletelyInFrustum(target: ICullable): boolean;
  25835. /**
  25836. * Gets a ray in the forward direction from the camera.
  25837. * @param length Defines the length of the ray to create
  25838. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  25839. * @param origin Defines the start point of the ray which defaults to the camera position
  25840. * @returns the forward ray
  25841. */
  25842. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  25843. /**
  25844. * Releases resources associated with this node.
  25845. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25846. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25847. */
  25848. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25849. /** @hidden */
  25850. _isLeftCamera: boolean;
  25851. /**
  25852. * Gets the left camera of a rig setup in case of Rigged Camera
  25853. */
  25854. readonly isLeftCamera: boolean;
  25855. /** @hidden */
  25856. _isRightCamera: boolean;
  25857. /**
  25858. * Gets the right camera of a rig setup in case of Rigged Camera
  25859. */
  25860. readonly isRightCamera: boolean;
  25861. /**
  25862. * Gets the left camera of a rig setup in case of Rigged Camera
  25863. */
  25864. readonly leftCamera: Nullable<FreeCamera>;
  25865. /**
  25866. * Gets the right camera of a rig setup in case of Rigged Camera
  25867. */
  25868. readonly rightCamera: Nullable<FreeCamera>;
  25869. /**
  25870. * Gets the left camera target of a rig setup in case of Rigged Camera
  25871. * @returns the target position
  25872. */
  25873. getLeftTarget(): Nullable<Vector3>;
  25874. /**
  25875. * Gets the right camera target of a rig setup in case of Rigged Camera
  25876. * @returns the target position
  25877. */
  25878. getRightTarget(): Nullable<Vector3>;
  25879. /**
  25880. * @hidden
  25881. */
  25882. setCameraRigMode(mode: number, rigParams: any): void;
  25883. /** @hidden */
  25884. static _setStereoscopicRigMode(camera: Camera): void;
  25885. /** @hidden */
  25886. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  25887. /** @hidden */
  25888. static _setVRRigMode(camera: Camera, rigParams: any): void;
  25889. /** @hidden */
  25890. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  25891. /** @hidden */
  25892. _getVRProjectionMatrix(): Matrix;
  25893. protected _updateCameraRotationMatrix(): void;
  25894. protected _updateWebVRCameraRotationMatrix(): void;
  25895. /**
  25896. * This function MUST be overwritten by the different WebVR cameras available.
  25897. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25898. * @hidden
  25899. */
  25900. _getWebVRProjectionMatrix(): Matrix;
  25901. /**
  25902. * This function MUST be overwritten by the different WebVR cameras available.
  25903. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  25904. * @hidden
  25905. */
  25906. _getWebVRViewMatrix(): Matrix;
  25907. /** @hidden */
  25908. setCameraRigParameter(name: string, value: any): void;
  25909. /**
  25910. * needs to be overridden by children so sub has required properties to be copied
  25911. * @hidden
  25912. */
  25913. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  25914. /**
  25915. * May need to be overridden by children
  25916. * @hidden
  25917. */
  25918. _updateRigCameras(): void;
  25919. /** @hidden */
  25920. _setupInputs(): void;
  25921. /**
  25922. * Serialiaze the camera setup to a json represention
  25923. * @returns the JSON representation
  25924. */
  25925. serialize(): any;
  25926. /**
  25927. * Clones the current camera.
  25928. * @param name The cloned camera name
  25929. * @returns the cloned camera
  25930. */
  25931. clone(name: string): Camera;
  25932. /**
  25933. * Gets the direction of the camera relative to a given local axis.
  25934. * @param localAxis Defines the reference axis to provide a relative direction.
  25935. * @return the direction
  25936. */
  25937. getDirection(localAxis: Vector3): Vector3;
  25938. /**
  25939. * Returns the current camera absolute rotation
  25940. */
  25941. readonly absoluteRotation: Quaternion;
  25942. /**
  25943. * Gets the direction of the camera relative to a given local axis into a passed vector.
  25944. * @param localAxis Defines the reference axis to provide a relative direction.
  25945. * @param result Defines the vector to store the result in
  25946. */
  25947. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  25948. /**
  25949. * Gets a camera constructor for a given camera type
  25950. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  25951. * @param name The name of the camera the result will be able to instantiate
  25952. * @param scene The scene the result will construct the camera in
  25953. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  25954. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  25955. * @returns a factory method to construc the camera
  25956. */
  25957. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  25958. /**
  25959. * Compute the world matrix of the camera.
  25960. * @returns the camera workd matrix
  25961. */
  25962. computeWorldMatrix(): Matrix;
  25963. /**
  25964. * Parse a JSON and creates the camera from the parsed information
  25965. * @param parsedCamera The JSON to parse
  25966. * @param scene The scene to instantiate the camera in
  25967. * @returns the newly constructed camera
  25968. */
  25969. static Parse(parsedCamera: any, scene: Scene): Camera;
  25970. }
  25971. }
  25972. declare module "babylonjs/Meshes/Builders/discBuilder" {
  25973. import { Nullable } from "babylonjs/types";
  25974. import { Scene } from "babylonjs/scene";
  25975. import { Vector4 } from "babylonjs/Maths/math.vector";
  25976. import { Mesh } from "babylonjs/Meshes/mesh";
  25977. /**
  25978. * Class containing static functions to help procedurally build meshes
  25979. */
  25980. export class DiscBuilder {
  25981. /**
  25982. * Creates a plane polygonal mesh. By default, this is a disc
  25983. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  25984. * * 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
  25985. * * 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
  25986. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  25987. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  25988. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  25989. * @param name defines the name of the mesh
  25990. * @param options defines the options used to create the mesh
  25991. * @param scene defines the hosting scene
  25992. * @returns the plane polygonal mesh
  25993. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  25994. */
  25995. static CreateDisc(name: string, options: {
  25996. radius?: number;
  25997. tessellation?: number;
  25998. arc?: number;
  25999. updatable?: boolean;
  26000. sideOrientation?: number;
  26001. frontUVs?: Vector4;
  26002. backUVs?: Vector4;
  26003. }, scene?: Nullable<Scene>): Mesh;
  26004. }
  26005. }
  26006. declare module "babylonjs/Particles/solidParticleSystem" {
  26007. import { Vector3 } from "babylonjs/Maths/math.vector";
  26008. import { Mesh } from "babylonjs/Meshes/mesh";
  26009. import { Scene, IDisposable } from "babylonjs/scene";
  26010. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  26011. /**
  26012. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  26013. *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.
  26014. * The SPS is also a particle system. It provides some methods to manage the particles.
  26015. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  26016. *
  26017. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  26018. */
  26019. export class SolidParticleSystem implements IDisposable {
  26020. /**
  26021. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  26022. * Example : var p = SPS.particles[i];
  26023. */
  26024. particles: SolidParticle[];
  26025. /**
  26026. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  26027. */
  26028. nbParticles: number;
  26029. /**
  26030. * If the particles must ever face the camera (default false). Useful for planar particles.
  26031. */
  26032. billboard: boolean;
  26033. /**
  26034. * Recompute normals when adding a shape
  26035. */
  26036. recomputeNormals: boolean;
  26037. /**
  26038. * This a counter ofr your own usage. It's not set by any SPS functions.
  26039. */
  26040. counter: number;
  26041. /**
  26042. * The SPS name. This name is also given to the underlying mesh.
  26043. */
  26044. name: string;
  26045. /**
  26046. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  26047. */
  26048. mesh: Mesh;
  26049. /**
  26050. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  26051. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  26052. */
  26053. vars: any;
  26054. /**
  26055. * This array is populated when the SPS is set as 'pickable'.
  26056. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  26057. * Each element of this array is an object `{idx: int, faceId: int}`.
  26058. * `idx` is the picked particle index in the `SPS.particles` array
  26059. * `faceId` is the picked face index counted within this particle.
  26060. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  26061. */
  26062. pickedParticles: {
  26063. idx: number;
  26064. faceId: number;
  26065. }[];
  26066. /**
  26067. * This array is populated when `enableDepthSort` is set to true.
  26068. * Each element of this array is an instance of the class DepthSortedParticle.
  26069. */
  26070. depthSortedParticles: DepthSortedParticle[];
  26071. /**
  26072. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  26073. * @hidden
  26074. */
  26075. _bSphereOnly: boolean;
  26076. /**
  26077. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  26078. * @hidden
  26079. */
  26080. _bSphereRadiusFactor: number;
  26081. private _scene;
  26082. private _positions;
  26083. private _indices;
  26084. private _normals;
  26085. private _colors;
  26086. private _uvs;
  26087. private _indices32;
  26088. private _positions32;
  26089. private _normals32;
  26090. private _fixedNormal32;
  26091. private _colors32;
  26092. private _uvs32;
  26093. private _index;
  26094. private _updatable;
  26095. private _pickable;
  26096. private _isVisibilityBoxLocked;
  26097. private _alwaysVisible;
  26098. private _depthSort;
  26099. private _shapeCounter;
  26100. private _copy;
  26101. private _color;
  26102. private _computeParticleColor;
  26103. private _computeParticleTexture;
  26104. private _computeParticleRotation;
  26105. private _computeParticleVertex;
  26106. private _computeBoundingBox;
  26107. private _depthSortParticles;
  26108. private _camera;
  26109. private _mustUnrotateFixedNormals;
  26110. private _particlesIntersect;
  26111. private _needs32Bits;
  26112. /**
  26113. * Creates a SPS (Solid Particle System) object.
  26114. * @param name (String) is the SPS name, this will be the underlying mesh name.
  26115. * @param scene (Scene) is the scene in which the SPS is added.
  26116. * @param options defines the options of the sps e.g.
  26117. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  26118. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  26119. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  26120. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  26121. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  26122. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  26123. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  26124. */
  26125. constructor(name: string, scene: Scene, options?: {
  26126. updatable?: boolean;
  26127. isPickable?: boolean;
  26128. enableDepthSort?: boolean;
  26129. particleIntersection?: boolean;
  26130. boundingSphereOnly?: boolean;
  26131. bSphereRadiusFactor?: number;
  26132. });
  26133. /**
  26134. * Builds the SPS underlying mesh. Returns a standard Mesh.
  26135. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  26136. * @returns the created mesh
  26137. */
  26138. buildMesh(): Mesh;
  26139. /**
  26140. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  26141. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  26142. * Thus the particles generated from `digest()` have their property `position` set yet.
  26143. * @param mesh ( Mesh ) is the mesh to be digested
  26144. * @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
  26145. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  26146. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  26147. * @returns the current SPS
  26148. */
  26149. digest(mesh: Mesh, options?: {
  26150. facetNb?: number;
  26151. number?: number;
  26152. delta?: number;
  26153. }): SolidParticleSystem;
  26154. private _unrotateFixedNormals;
  26155. private _resetCopy;
  26156. private _meshBuilder;
  26157. private _posToShape;
  26158. private _uvsToShapeUV;
  26159. private _addParticle;
  26160. /**
  26161. * Adds some particles to the SPS from the model shape. Returns the shape id.
  26162. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  26163. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  26164. * @param nb (positive integer) the number of particles to be created from this model
  26165. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  26166. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  26167. * @returns the number of shapes in the system
  26168. */
  26169. addShape(mesh: Mesh, nb: number, options?: {
  26170. positionFunction?: any;
  26171. vertexFunction?: any;
  26172. }): number;
  26173. private _rebuildParticle;
  26174. /**
  26175. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  26176. * @returns the SPS.
  26177. */
  26178. rebuildMesh(): SolidParticleSystem;
  26179. /**
  26180. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  26181. * This method calls `updateParticle()` for each particle of the SPS.
  26182. * For an animated SPS, it is usually called within the render loop.
  26183. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  26184. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  26185. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  26186. * @returns the SPS.
  26187. */
  26188. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  26189. /**
  26190. * Disposes the SPS.
  26191. */
  26192. dispose(): void;
  26193. /**
  26194. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  26195. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26196. * @returns the SPS.
  26197. */
  26198. refreshVisibleSize(): SolidParticleSystem;
  26199. /**
  26200. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  26201. * @param size the size (float) of the visibility box
  26202. * note : this doesn't lock the SPS mesh bounding box.
  26203. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26204. */
  26205. setVisibilityBox(size: number): void;
  26206. /**
  26207. * Gets whether the SPS as always visible or not
  26208. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26209. */
  26210. /**
  26211. * Sets the SPS as always visible or not
  26212. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26213. */
  26214. isAlwaysVisible: boolean;
  26215. /**
  26216. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26217. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26218. */
  26219. /**
  26220. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  26221. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  26222. */
  26223. isVisibilityBoxLocked: boolean;
  26224. /**
  26225. * Tells to `setParticles()` to compute the particle rotations or not.
  26226. * Default value : true. The SPS is faster when it's set to false.
  26227. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26228. */
  26229. /**
  26230. * Gets if `setParticles()` computes the particle rotations or not.
  26231. * Default value : true. The SPS is faster when it's set to false.
  26232. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  26233. */
  26234. computeParticleRotation: boolean;
  26235. /**
  26236. * Tells to `setParticles()` to compute the particle colors or not.
  26237. * Default value : true. The SPS is faster when it's set to false.
  26238. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26239. */
  26240. /**
  26241. * Gets if `setParticles()` computes the particle colors or not.
  26242. * Default value : true. The SPS is faster when it's set to false.
  26243. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  26244. */
  26245. computeParticleColor: boolean;
  26246. /**
  26247. * Gets if `setParticles()` computes the particle textures or not.
  26248. * Default value : true. The SPS is faster when it's set to false.
  26249. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  26250. */
  26251. computeParticleTexture: boolean;
  26252. /**
  26253. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  26254. * Default value : false. The SPS is faster when it's set to false.
  26255. * Note : the particle custom vertex positions aren't stored values.
  26256. */
  26257. /**
  26258. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  26259. * Default value : false. The SPS is faster when it's set to false.
  26260. * Note : the particle custom vertex positions aren't stored values.
  26261. */
  26262. computeParticleVertex: boolean;
  26263. /**
  26264. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  26265. */
  26266. /**
  26267. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  26268. */
  26269. computeBoundingBox: boolean;
  26270. /**
  26271. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  26272. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26273. * Default : `true`
  26274. */
  26275. /**
  26276. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  26277. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  26278. * Default : `true`
  26279. */
  26280. depthSortParticles: boolean;
  26281. /**
  26282. * This function does nothing. It may be overwritten to set all the particle first values.
  26283. * The SPS doesn't call this function, you may have to call it by your own.
  26284. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26285. */
  26286. initParticles(): void;
  26287. /**
  26288. * This function does nothing. It may be overwritten to recycle a particle.
  26289. * The SPS doesn't call this function, you may have to call it by your own.
  26290. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26291. * @param particle The particle to recycle
  26292. * @returns the recycled particle
  26293. */
  26294. recycleParticle(particle: SolidParticle): SolidParticle;
  26295. /**
  26296. * Updates a particle : this function should be overwritten by the user.
  26297. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  26298. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  26299. * @example : just set a particle position or velocity and recycle conditions
  26300. * @param particle The particle to update
  26301. * @returns the updated particle
  26302. */
  26303. updateParticle(particle: SolidParticle): SolidParticle;
  26304. /**
  26305. * Updates a vertex of a particle : it can be overwritten by the user.
  26306. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  26307. * @param particle the current particle
  26308. * @param vertex the current index of the current particle
  26309. * @param pt the index of the current vertex in the particle shape
  26310. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  26311. * @example : just set a vertex particle position
  26312. * @returns the updated vertex
  26313. */
  26314. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  26315. /**
  26316. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  26317. * This does nothing and may be overwritten by the user.
  26318. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26319. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26320. * @param update the boolean update value actually passed to setParticles()
  26321. */
  26322. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26323. /**
  26324. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  26325. * This will be passed three parameters.
  26326. * This does nothing and may be overwritten by the user.
  26327. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26328. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  26329. * @param update the boolean update value actually passed to setParticles()
  26330. */
  26331. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  26332. }
  26333. }
  26334. declare module "babylonjs/Particles/solidParticle" {
  26335. import { Nullable } from "babylonjs/types";
  26336. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  26337. import { Color4 } from "babylonjs/Maths/math.color";
  26338. import { Mesh } from "babylonjs/Meshes/mesh";
  26339. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26340. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  26341. import { Plane } from "babylonjs/Maths/math.plane";
  26342. /**
  26343. * Represents one particle of a solid particle system.
  26344. */
  26345. export class SolidParticle {
  26346. /**
  26347. * particle global index
  26348. */
  26349. idx: number;
  26350. /**
  26351. * The color of the particle
  26352. */
  26353. color: Nullable<Color4>;
  26354. /**
  26355. * The world space position of the particle.
  26356. */
  26357. position: Vector3;
  26358. /**
  26359. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  26360. */
  26361. rotation: Vector3;
  26362. /**
  26363. * The world space rotation quaternion of the particle.
  26364. */
  26365. rotationQuaternion: Nullable<Quaternion>;
  26366. /**
  26367. * The scaling of the particle.
  26368. */
  26369. scaling: Vector3;
  26370. /**
  26371. * The uvs of the particle.
  26372. */
  26373. uvs: Vector4;
  26374. /**
  26375. * The current speed of the particle.
  26376. */
  26377. velocity: Vector3;
  26378. /**
  26379. * The pivot point in the particle local space.
  26380. */
  26381. pivot: Vector3;
  26382. /**
  26383. * Must the particle be translated from its pivot point in its local space ?
  26384. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  26385. * Default : false
  26386. */
  26387. translateFromPivot: boolean;
  26388. /**
  26389. * Is the particle active or not ?
  26390. */
  26391. alive: boolean;
  26392. /**
  26393. * Is the particle visible or not ?
  26394. */
  26395. isVisible: boolean;
  26396. /**
  26397. * Index of this particle in the global "positions" array (Internal use)
  26398. * @hidden
  26399. */
  26400. _pos: number;
  26401. /**
  26402. * @hidden Index of this particle in the global "indices" array (Internal use)
  26403. */
  26404. _ind: number;
  26405. /**
  26406. * @hidden ModelShape of this particle (Internal use)
  26407. */
  26408. _model: ModelShape;
  26409. /**
  26410. * ModelShape id of this particle
  26411. */
  26412. shapeId: number;
  26413. /**
  26414. * Index of the particle in its shape id
  26415. */
  26416. idxInShape: number;
  26417. /**
  26418. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  26419. */
  26420. _modelBoundingInfo: BoundingInfo;
  26421. /**
  26422. * @hidden Particle BoundingInfo object (Internal use)
  26423. */
  26424. _boundingInfo: BoundingInfo;
  26425. /**
  26426. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  26427. */
  26428. _sps: SolidParticleSystem;
  26429. /**
  26430. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  26431. */
  26432. _stillInvisible: boolean;
  26433. /**
  26434. * @hidden Last computed particle rotation matrix
  26435. */
  26436. _rotationMatrix: number[];
  26437. /**
  26438. * Parent particle Id, if any.
  26439. * Default null.
  26440. */
  26441. parentId: Nullable<number>;
  26442. /**
  26443. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  26444. * The possible values are :
  26445. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26446. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26447. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26448. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26449. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26450. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  26451. * */
  26452. cullingStrategy: number;
  26453. /**
  26454. * @hidden Internal global position in the SPS.
  26455. */
  26456. _globalPosition: Vector3;
  26457. /**
  26458. * Creates a Solid Particle object.
  26459. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  26460. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  26461. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  26462. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  26463. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  26464. * @param shapeId (integer) is the model shape identifier in the SPS.
  26465. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  26466. * @param sps defines the sps it is associated to
  26467. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  26468. */
  26469. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  26470. /**
  26471. * Legacy support, changed scale to scaling
  26472. */
  26473. /**
  26474. * Legacy support, changed scale to scaling
  26475. */
  26476. scale: Vector3;
  26477. /**
  26478. * Legacy support, changed quaternion to rotationQuaternion
  26479. */
  26480. /**
  26481. * Legacy support, changed quaternion to rotationQuaternion
  26482. */
  26483. quaternion: Nullable<Quaternion>;
  26484. /**
  26485. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  26486. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  26487. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  26488. * @returns true if it intersects
  26489. */
  26490. intersectsMesh(target: Mesh | SolidParticle): boolean;
  26491. /**
  26492. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  26493. * A particle is in the frustum if its bounding box intersects the frustum
  26494. * @param frustumPlanes defines the frustum to test
  26495. * @returns true if the particle is in the frustum planes
  26496. */
  26497. isInFrustum(frustumPlanes: Plane[]): boolean;
  26498. /**
  26499. * get the rotation matrix of the particle
  26500. * @hidden
  26501. */
  26502. getRotationMatrix(m: Matrix): void;
  26503. }
  26504. /**
  26505. * Represents the shape of the model used by one particle of a solid particle system.
  26506. * SPS internal tool, don't use it manually.
  26507. */
  26508. export class ModelShape {
  26509. /**
  26510. * The shape id
  26511. * @hidden
  26512. */
  26513. shapeID: number;
  26514. /**
  26515. * flat array of model positions (internal use)
  26516. * @hidden
  26517. */
  26518. _shape: Vector3[];
  26519. /**
  26520. * flat array of model UVs (internal use)
  26521. * @hidden
  26522. */
  26523. _shapeUV: number[];
  26524. /**
  26525. * length of the shape in the model indices array (internal use)
  26526. * @hidden
  26527. */
  26528. _indicesLength: number;
  26529. /**
  26530. * Custom position function (internal use)
  26531. * @hidden
  26532. */
  26533. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  26534. /**
  26535. * Custom vertex function (internal use)
  26536. * @hidden
  26537. */
  26538. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  26539. /**
  26540. * 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.
  26541. * SPS internal tool, don't use it manually.
  26542. * @hidden
  26543. */
  26544. 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>);
  26545. }
  26546. /**
  26547. * Represents a Depth Sorted Particle in the solid particle system.
  26548. */
  26549. export class DepthSortedParticle {
  26550. /**
  26551. * Index of the particle in the "indices" array
  26552. */
  26553. ind: number;
  26554. /**
  26555. * Length of the particle shape in the "indices" array
  26556. */
  26557. indicesLength: number;
  26558. /**
  26559. * Squared distance from the particle to the camera
  26560. */
  26561. sqDistance: number;
  26562. }
  26563. }
  26564. declare module "babylonjs/Collisions/meshCollisionData" {
  26565. import { Collider } from "babylonjs/Collisions/collider";
  26566. import { Vector3 } from "babylonjs/Maths/math.vector";
  26567. import { Nullable } from "babylonjs/types";
  26568. import { Observer } from "babylonjs/Misc/observable";
  26569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26570. /**
  26571. * @hidden
  26572. */
  26573. export class _MeshCollisionData {
  26574. _checkCollisions: boolean;
  26575. _collisionMask: number;
  26576. _collisionGroup: number;
  26577. _collider: Nullable<Collider>;
  26578. _oldPositionForCollisions: Vector3;
  26579. _diffPositionForCollisions: Vector3;
  26580. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  26581. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  26582. }
  26583. }
  26584. declare module "babylonjs/Meshes/abstractMesh" {
  26585. import { Observable } from "babylonjs/Misc/observable";
  26586. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  26587. import { Camera } from "babylonjs/Cameras/camera";
  26588. import { Scene, IDisposable } from "babylonjs/scene";
  26589. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26590. import { Node } from "babylonjs/node";
  26591. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  26592. import { TransformNode } from "babylonjs/Meshes/transformNode";
  26593. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26594. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  26595. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26596. import { Material } from "babylonjs/Materials/material";
  26597. import { Light } from "babylonjs/Lights/light";
  26598. import { Skeleton } from "babylonjs/Bones/skeleton";
  26599. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  26600. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  26601. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  26602. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  26603. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  26604. import { Plane } from "babylonjs/Maths/math.plane";
  26605. import { Ray } from "babylonjs/Culling/ray";
  26606. import { Collider } from "babylonjs/Collisions/collider";
  26607. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26608. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  26609. /** @hidden */
  26610. class _FacetDataStorage {
  26611. facetPositions: Vector3[];
  26612. facetNormals: Vector3[];
  26613. facetPartitioning: number[][];
  26614. facetNb: number;
  26615. partitioningSubdivisions: number;
  26616. partitioningBBoxRatio: number;
  26617. facetDataEnabled: boolean;
  26618. facetParameters: any;
  26619. bbSize: Vector3;
  26620. subDiv: {
  26621. max: number;
  26622. X: number;
  26623. Y: number;
  26624. Z: number;
  26625. };
  26626. facetDepthSort: boolean;
  26627. facetDepthSortEnabled: boolean;
  26628. depthSortedIndices: IndicesArray;
  26629. depthSortedFacets: {
  26630. ind: number;
  26631. sqDistance: number;
  26632. }[];
  26633. facetDepthSortFunction: (f1: {
  26634. ind: number;
  26635. sqDistance: number;
  26636. }, f2: {
  26637. ind: number;
  26638. sqDistance: number;
  26639. }) => number;
  26640. facetDepthSortFrom: Vector3;
  26641. facetDepthSortOrigin: Vector3;
  26642. invertedMatrix: Matrix;
  26643. }
  26644. /**
  26645. * @hidden
  26646. **/
  26647. class _InternalAbstractMeshDataInfo {
  26648. _hasVertexAlpha: boolean;
  26649. _useVertexColors: boolean;
  26650. _numBoneInfluencers: number;
  26651. _applyFog: boolean;
  26652. _receiveShadows: boolean;
  26653. _facetData: _FacetDataStorage;
  26654. _visibility: number;
  26655. _skeleton: Nullable<Skeleton>;
  26656. _layerMask: number;
  26657. _computeBonesUsingShaders: boolean;
  26658. _isActive: boolean;
  26659. _onlyForInstances: boolean;
  26660. _isActiveIntermediate: boolean;
  26661. _onlyForInstancesIntermediate: boolean;
  26662. }
  26663. /**
  26664. * Class used to store all common mesh properties
  26665. */
  26666. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  26667. /** No occlusion */
  26668. static OCCLUSION_TYPE_NONE: number;
  26669. /** Occlusion set to optimisitic */
  26670. static OCCLUSION_TYPE_OPTIMISTIC: number;
  26671. /** Occlusion set to strict */
  26672. static OCCLUSION_TYPE_STRICT: number;
  26673. /** Use an accurante occlusion algorithm */
  26674. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  26675. /** Use a conservative occlusion algorithm */
  26676. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  26677. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  26678. * Test order :
  26679. * Is the bounding sphere outside the frustum ?
  26680. * If not, are the bounding box vertices outside the frustum ?
  26681. * It not, then the cullable object is in the frustum.
  26682. */
  26683. static readonly CULLINGSTRATEGY_STANDARD: number;
  26684. /** Culling strategy : Bounding Sphere Only.
  26685. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  26686. * It's also less accurate than the standard because some not visible objects can still be selected.
  26687. * Test : is the bounding sphere outside the frustum ?
  26688. * If not, then the cullable object is in the frustum.
  26689. */
  26690. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  26691. /** Culling strategy : Optimistic Inclusion.
  26692. * This in an inclusion test first, then the standard exclusion test.
  26693. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  26694. * 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.
  26695. * Anyway, it's as accurate as the standard strategy.
  26696. * Test :
  26697. * Is the cullable object bounding sphere center in the frustum ?
  26698. * If not, apply the default culling strategy.
  26699. */
  26700. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  26701. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  26702. * This in an inclusion test first, then the bounding sphere only exclusion test.
  26703. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  26704. * 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.
  26705. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  26706. * Test :
  26707. * Is the cullable object bounding sphere center in the frustum ?
  26708. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  26709. */
  26710. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  26711. /**
  26712. * No billboard
  26713. */
  26714. static readonly BILLBOARDMODE_NONE: number;
  26715. /** Billboard on X axis */
  26716. static readonly BILLBOARDMODE_X: number;
  26717. /** Billboard on Y axis */
  26718. static readonly BILLBOARDMODE_Y: number;
  26719. /** Billboard on Z axis */
  26720. static readonly BILLBOARDMODE_Z: number;
  26721. /** Billboard on all axes */
  26722. static readonly BILLBOARDMODE_ALL: number;
  26723. /** Billboard on using position instead of orientation */
  26724. static readonly BILLBOARDMODE_USE_POSITION: number;
  26725. /** @hidden */
  26726. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  26727. /**
  26728. * The culling strategy to use to check whether the mesh must be rendered or not.
  26729. * This value can be changed at any time and will be used on the next render mesh selection.
  26730. * The possible values are :
  26731. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  26732. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  26733. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  26734. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  26735. * Please read each static variable documentation to get details about the culling process.
  26736. * */
  26737. cullingStrategy: number;
  26738. /**
  26739. * Gets the number of facets in the mesh
  26740. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26741. */
  26742. readonly facetNb: number;
  26743. /**
  26744. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  26745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26746. */
  26747. partitioningSubdivisions: number;
  26748. /**
  26749. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  26750. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  26751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  26752. */
  26753. partitioningBBoxRatio: number;
  26754. /**
  26755. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  26756. * Works only for updatable meshes.
  26757. * Doesn't work with multi-materials
  26758. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26759. */
  26760. mustDepthSortFacets: boolean;
  26761. /**
  26762. * The location (Vector3) where the facet depth sort must be computed from.
  26763. * By default, the active camera position.
  26764. * Used only when facet depth sort is enabled
  26765. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  26766. */
  26767. facetDepthSortFrom: Vector3;
  26768. /**
  26769. * gets a boolean indicating if facetData is enabled
  26770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  26771. */
  26772. readonly isFacetDataEnabled: boolean;
  26773. /** @hidden */
  26774. _updateNonUniformScalingState(value: boolean): boolean;
  26775. /**
  26776. * An event triggered when this mesh collides with another one
  26777. */
  26778. onCollideObservable: Observable<AbstractMesh>;
  26779. /** Set a function to call when this mesh collides with another one */
  26780. onCollide: () => void;
  26781. /**
  26782. * An event triggered when the collision's position changes
  26783. */
  26784. onCollisionPositionChangeObservable: Observable<Vector3>;
  26785. /** Set a function to call when the collision's position changes */
  26786. onCollisionPositionChange: () => void;
  26787. /**
  26788. * An event triggered when material is changed
  26789. */
  26790. onMaterialChangedObservable: Observable<AbstractMesh>;
  26791. /**
  26792. * Gets or sets the orientation for POV movement & rotation
  26793. */
  26794. definedFacingForward: boolean;
  26795. /** @hidden */
  26796. _occlusionQuery: Nullable<WebGLQuery>;
  26797. /** @hidden */
  26798. _renderingGroup: Nullable<RenderingGroup>;
  26799. /**
  26800. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26801. */
  26802. /**
  26803. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  26804. */
  26805. visibility: number;
  26806. /** Gets or sets the alpha index used to sort transparent meshes
  26807. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  26808. */
  26809. alphaIndex: number;
  26810. /**
  26811. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  26812. */
  26813. isVisible: boolean;
  26814. /**
  26815. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  26816. */
  26817. isPickable: boolean;
  26818. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  26819. showSubMeshesBoundingBox: boolean;
  26820. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  26821. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  26822. */
  26823. isBlocker: boolean;
  26824. /**
  26825. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  26826. */
  26827. enablePointerMoveEvents: boolean;
  26828. /**
  26829. * Specifies the rendering group id for this mesh (0 by default)
  26830. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  26831. */
  26832. renderingGroupId: number;
  26833. private _material;
  26834. /** Gets or sets current material */
  26835. material: Nullable<Material>;
  26836. /**
  26837. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  26838. * @see http://doc.babylonjs.com/babylon101/shadows
  26839. */
  26840. receiveShadows: boolean;
  26841. /** Defines color to use when rendering outline */
  26842. outlineColor: Color3;
  26843. /** Define width to use when rendering outline */
  26844. outlineWidth: number;
  26845. /** Defines color to use when rendering overlay */
  26846. overlayColor: Color3;
  26847. /** Defines alpha to use when rendering overlay */
  26848. overlayAlpha: number;
  26849. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  26850. hasVertexAlpha: boolean;
  26851. /** 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) */
  26852. useVertexColors: boolean;
  26853. /**
  26854. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  26855. */
  26856. computeBonesUsingShaders: boolean;
  26857. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  26858. numBoneInfluencers: number;
  26859. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  26860. applyFog: boolean;
  26861. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  26862. useOctreeForRenderingSelection: boolean;
  26863. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  26864. useOctreeForPicking: boolean;
  26865. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  26866. useOctreeForCollisions: boolean;
  26867. /**
  26868. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  26869. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  26870. */
  26871. layerMask: number;
  26872. /**
  26873. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  26874. */
  26875. alwaysSelectAsActiveMesh: boolean;
  26876. /**
  26877. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  26878. */
  26879. doNotSyncBoundingInfo: boolean;
  26880. /**
  26881. * Gets or sets the current action manager
  26882. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  26883. */
  26884. actionManager: Nullable<AbstractActionManager>;
  26885. private _meshCollisionData;
  26886. /**
  26887. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  26888. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26889. */
  26890. ellipsoid: Vector3;
  26891. /**
  26892. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  26893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  26894. */
  26895. ellipsoidOffset: Vector3;
  26896. /**
  26897. * Gets or sets a collision mask used to mask collisions (default is -1).
  26898. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26899. */
  26900. collisionMask: number;
  26901. /**
  26902. * Gets or sets the current collision group mask (-1 by default).
  26903. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  26904. */
  26905. collisionGroup: number;
  26906. /**
  26907. * Defines edge width used when edgesRenderer is enabled
  26908. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26909. */
  26910. edgesWidth: number;
  26911. /**
  26912. * Defines edge color used when edgesRenderer is enabled
  26913. * @see https://www.babylonjs-playground.com/#10OJSG#13
  26914. */
  26915. edgesColor: Color4;
  26916. /** @hidden */
  26917. _edgesRenderer: Nullable<IEdgesRenderer>;
  26918. /** @hidden */
  26919. _masterMesh: Nullable<AbstractMesh>;
  26920. /** @hidden */
  26921. _boundingInfo: Nullable<BoundingInfo>;
  26922. /** @hidden */
  26923. _renderId: number;
  26924. /**
  26925. * Gets or sets the list of subMeshes
  26926. * @see http://doc.babylonjs.com/how_to/multi_materials
  26927. */
  26928. subMeshes: SubMesh[];
  26929. /** @hidden */
  26930. _intersectionsInProgress: AbstractMesh[];
  26931. /** @hidden */
  26932. _unIndexed: boolean;
  26933. /** @hidden */
  26934. _lightSources: Light[];
  26935. /** Gets the list of lights affecting that mesh */
  26936. readonly lightSources: Light[];
  26937. /** @hidden */
  26938. readonly _positions: Nullable<Vector3[]>;
  26939. /** @hidden */
  26940. _waitingData: {
  26941. lods: Nullable<any>;
  26942. actions: Nullable<any>;
  26943. freezeWorldMatrix: Nullable<boolean>;
  26944. };
  26945. /** @hidden */
  26946. _bonesTransformMatrices: Nullable<Float32Array>;
  26947. /** @hidden */
  26948. _transformMatrixTexture: Nullable<RawTexture>;
  26949. /**
  26950. * Gets or sets a skeleton to apply skining transformations
  26951. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  26952. */
  26953. skeleton: Nullable<Skeleton>;
  26954. /**
  26955. * An event triggered when the mesh is rebuilt.
  26956. */
  26957. onRebuildObservable: Observable<AbstractMesh>;
  26958. /**
  26959. * Creates a new AbstractMesh
  26960. * @param name defines the name of the mesh
  26961. * @param scene defines the hosting scene
  26962. */
  26963. constructor(name: string, scene?: Nullable<Scene>);
  26964. /**
  26965. * Returns the string "AbstractMesh"
  26966. * @returns "AbstractMesh"
  26967. */
  26968. getClassName(): string;
  26969. /**
  26970. * Gets a string representation of the current mesh
  26971. * @param fullDetails defines a boolean indicating if full details must be included
  26972. * @returns a string representation of the current mesh
  26973. */
  26974. toString(fullDetails?: boolean): string;
  26975. /**
  26976. * @hidden
  26977. */
  26978. protected _getEffectiveParent(): Nullable<Node>;
  26979. /** @hidden */
  26980. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  26981. /** @hidden */
  26982. _rebuild(): void;
  26983. /** @hidden */
  26984. _resyncLightSources(): void;
  26985. /** @hidden */
  26986. _resyncLighSource(light: Light): void;
  26987. /** @hidden */
  26988. _unBindEffect(): void;
  26989. /** @hidden */
  26990. _removeLightSource(light: Light, dispose: boolean): void;
  26991. private _markSubMeshesAsDirty;
  26992. /** @hidden */
  26993. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  26994. /** @hidden */
  26995. _markSubMeshesAsAttributesDirty(): void;
  26996. /** @hidden */
  26997. _markSubMeshesAsMiscDirty(): void;
  26998. /**
  26999. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  27000. */
  27001. scaling: Vector3;
  27002. /**
  27003. * Returns true if the mesh is blocked. Implemented by child classes
  27004. */
  27005. readonly isBlocked: boolean;
  27006. /**
  27007. * Returns the mesh itself by default. Implemented by child classes
  27008. * @param camera defines the camera to use to pick the right LOD level
  27009. * @returns the currentAbstractMesh
  27010. */
  27011. getLOD(camera: Camera): Nullable<AbstractMesh>;
  27012. /**
  27013. * Returns 0 by default. Implemented by child classes
  27014. * @returns an integer
  27015. */
  27016. getTotalVertices(): number;
  27017. /**
  27018. * Returns a positive integer : the total number of indices in this mesh geometry.
  27019. * @returns the numner of indices or zero if the mesh has no geometry.
  27020. */
  27021. getTotalIndices(): number;
  27022. /**
  27023. * Returns null by default. Implemented by child classes
  27024. * @returns null
  27025. */
  27026. getIndices(): Nullable<IndicesArray>;
  27027. /**
  27028. * Returns the array of the requested vertex data kind. Implemented by child classes
  27029. * @param kind defines the vertex data kind to use
  27030. * @returns null
  27031. */
  27032. getVerticesData(kind: string): Nullable<FloatArray>;
  27033. /**
  27034. * Sets the vertex data of the mesh geometry for the requested `kind`.
  27035. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  27036. * Note that a new underlying VertexBuffer object is created each call.
  27037. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  27038. * @param kind defines vertex data kind:
  27039. * * VertexBuffer.PositionKind
  27040. * * VertexBuffer.UVKind
  27041. * * VertexBuffer.UV2Kind
  27042. * * VertexBuffer.UV3Kind
  27043. * * VertexBuffer.UV4Kind
  27044. * * VertexBuffer.UV5Kind
  27045. * * VertexBuffer.UV6Kind
  27046. * * VertexBuffer.ColorKind
  27047. * * VertexBuffer.MatricesIndicesKind
  27048. * * VertexBuffer.MatricesIndicesExtraKind
  27049. * * VertexBuffer.MatricesWeightsKind
  27050. * * VertexBuffer.MatricesWeightsExtraKind
  27051. * @param data defines the data source
  27052. * @param updatable defines if the data must be flagged as updatable (or static)
  27053. * @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
  27054. * @returns the current mesh
  27055. */
  27056. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  27057. /**
  27058. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  27059. * If the mesh has no geometry, it is simply returned as it is.
  27060. * @param kind defines vertex data kind:
  27061. * * VertexBuffer.PositionKind
  27062. * * VertexBuffer.UVKind
  27063. * * VertexBuffer.UV2Kind
  27064. * * VertexBuffer.UV3Kind
  27065. * * VertexBuffer.UV4Kind
  27066. * * VertexBuffer.UV5Kind
  27067. * * VertexBuffer.UV6Kind
  27068. * * VertexBuffer.ColorKind
  27069. * * VertexBuffer.MatricesIndicesKind
  27070. * * VertexBuffer.MatricesIndicesExtraKind
  27071. * * VertexBuffer.MatricesWeightsKind
  27072. * * VertexBuffer.MatricesWeightsExtraKind
  27073. * @param data defines the data source
  27074. * @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
  27075. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  27076. * @returns the current mesh
  27077. */
  27078. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  27079. /**
  27080. * Sets the mesh indices,
  27081. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  27082. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  27083. * @param totalVertices Defines the total number of vertices
  27084. * @returns the current mesh
  27085. */
  27086. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  27087. /**
  27088. * Gets a boolean indicating if specific vertex data is present
  27089. * @param kind defines the vertex data kind to use
  27090. * @returns true is data kind is present
  27091. */
  27092. isVerticesDataPresent(kind: string): boolean;
  27093. /**
  27094. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  27095. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  27096. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  27097. * @returns a BoundingInfo
  27098. */
  27099. getBoundingInfo(): BoundingInfo;
  27100. /**
  27101. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  27102. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  27103. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  27104. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  27105. * @returns the current mesh
  27106. */
  27107. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  27108. /**
  27109. * Overwrite the current bounding info
  27110. * @param boundingInfo defines the new bounding info
  27111. * @returns the current mesh
  27112. */
  27113. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  27114. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  27115. readonly useBones: boolean;
  27116. /** @hidden */
  27117. _preActivate(): void;
  27118. /** @hidden */
  27119. _preActivateForIntermediateRendering(renderId: number): void;
  27120. /** @hidden */
  27121. _activate(renderId: number, intermediateRendering: boolean): boolean;
  27122. /** @hidden */
  27123. _postActivate(): void;
  27124. /** @hidden */
  27125. _freeze(): void;
  27126. /** @hidden */
  27127. _unFreeze(): void;
  27128. /**
  27129. * Gets the current world matrix
  27130. * @returns a Matrix
  27131. */
  27132. getWorldMatrix(): Matrix;
  27133. /** @hidden */
  27134. _getWorldMatrixDeterminant(): number;
  27135. /**
  27136. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  27137. */
  27138. readonly isAnInstance: boolean;
  27139. /**
  27140. * Gets a boolean indicating if this mesh has instances
  27141. */
  27142. readonly hasInstances: boolean;
  27143. /**
  27144. * Perform relative position change from the point of view of behind the front of the mesh.
  27145. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27146. * Supports definition of mesh facing forward or backward
  27147. * @param amountRight defines the distance on the right axis
  27148. * @param amountUp defines the distance on the up axis
  27149. * @param amountForward defines the distance on the forward axis
  27150. * @returns the current mesh
  27151. */
  27152. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  27153. /**
  27154. * Calculate relative position change from the point of view of behind the front of the mesh.
  27155. * This is performed taking into account the meshes current rotation, so you do not have to care.
  27156. * Supports definition of mesh facing forward or backward
  27157. * @param amountRight defines the distance on the right axis
  27158. * @param amountUp defines the distance on the up axis
  27159. * @param amountForward defines the distance on the forward axis
  27160. * @returns the new displacement vector
  27161. */
  27162. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  27163. /**
  27164. * Perform relative rotation change from the point of view of behind the front of the mesh.
  27165. * Supports definition of mesh facing forward or backward
  27166. * @param flipBack defines the flip
  27167. * @param twirlClockwise defines the twirl
  27168. * @param tiltRight defines the tilt
  27169. * @returns the current mesh
  27170. */
  27171. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  27172. /**
  27173. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  27174. * Supports definition of mesh facing forward or backward.
  27175. * @param flipBack defines the flip
  27176. * @param twirlClockwise defines the twirl
  27177. * @param tiltRight defines the tilt
  27178. * @returns the new rotation vector
  27179. */
  27180. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  27181. /**
  27182. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  27183. * This means the mesh underlying bounding box and sphere are recomputed.
  27184. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  27185. * @returns the current mesh
  27186. */
  27187. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  27188. /** @hidden */
  27189. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  27190. /** @hidden */
  27191. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  27192. /** @hidden */
  27193. _updateBoundingInfo(): AbstractMesh;
  27194. /** @hidden */
  27195. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  27196. /** @hidden */
  27197. protected _afterComputeWorldMatrix(): void;
  27198. /** @hidden */
  27199. readonly _effectiveMesh: AbstractMesh;
  27200. /**
  27201. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  27202. * A mesh is in the frustum if its bounding box intersects the frustum
  27203. * @param frustumPlanes defines the frustum to test
  27204. * @returns true if the mesh is in the frustum planes
  27205. */
  27206. isInFrustum(frustumPlanes: Plane[]): boolean;
  27207. /**
  27208. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  27209. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  27210. * @param frustumPlanes defines the frustum to test
  27211. * @returns true if the mesh is completely in the frustum planes
  27212. */
  27213. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  27214. /**
  27215. * True if the mesh intersects another mesh or a SolidParticle object
  27216. * @param mesh defines a target mesh or SolidParticle to test
  27217. * @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)
  27218. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  27219. * @returns true if there is an intersection
  27220. */
  27221. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  27222. /**
  27223. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  27224. * @param point defines the point to test
  27225. * @returns true if there is an intersection
  27226. */
  27227. intersectsPoint(point: Vector3): boolean;
  27228. /**
  27229. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  27230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27231. */
  27232. checkCollisions: boolean;
  27233. /**
  27234. * Gets Collider object used to compute collisions (not physics)
  27235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27236. */
  27237. readonly collider: Nullable<Collider>;
  27238. /**
  27239. * Move the mesh using collision engine
  27240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  27241. * @param displacement defines the requested displacement vector
  27242. * @returns the current mesh
  27243. */
  27244. moveWithCollisions(displacement: Vector3): AbstractMesh;
  27245. private _onCollisionPositionChange;
  27246. /** @hidden */
  27247. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  27248. /** @hidden */
  27249. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  27250. /** @hidden */
  27251. _checkCollision(collider: Collider): AbstractMesh;
  27252. /** @hidden */
  27253. _generatePointsArray(): boolean;
  27254. /**
  27255. * Checks if the passed Ray intersects with the mesh
  27256. * @param ray defines the ray to use
  27257. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  27258. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  27259. * @returns the picking info
  27260. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  27261. */
  27262. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  27263. /**
  27264. * Clones the current mesh
  27265. * @param name defines the mesh name
  27266. * @param newParent defines the new mesh parent
  27267. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  27268. * @returns the new mesh
  27269. */
  27270. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  27271. /**
  27272. * Disposes all the submeshes of the current meshnp
  27273. * @returns the current mesh
  27274. */
  27275. releaseSubMeshes(): AbstractMesh;
  27276. /**
  27277. * Releases resources associated with this abstract mesh.
  27278. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27279. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27280. */
  27281. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27282. /**
  27283. * Adds the passed mesh as a child to the current mesh
  27284. * @param mesh defines the child mesh
  27285. * @returns the current mesh
  27286. */
  27287. addChild(mesh: AbstractMesh): AbstractMesh;
  27288. /**
  27289. * Removes the passed mesh from the current mesh children list
  27290. * @param mesh defines the child mesh
  27291. * @returns the current mesh
  27292. */
  27293. removeChild(mesh: AbstractMesh): AbstractMesh;
  27294. /** @hidden */
  27295. private _initFacetData;
  27296. /**
  27297. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  27298. * This method can be called within the render loop.
  27299. * 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
  27300. * @returns the current mesh
  27301. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27302. */
  27303. updateFacetData(): AbstractMesh;
  27304. /**
  27305. * Returns the facetLocalNormals array.
  27306. * The normals are expressed in the mesh local spac
  27307. * @returns an array of Vector3
  27308. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27309. */
  27310. getFacetLocalNormals(): Vector3[];
  27311. /**
  27312. * Returns the facetLocalPositions array.
  27313. * The facet positions are expressed in the mesh local space
  27314. * @returns an array of Vector3
  27315. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27316. */
  27317. getFacetLocalPositions(): Vector3[];
  27318. /**
  27319. * Returns the facetLocalPartioning array
  27320. * @returns an array of array of numbers
  27321. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27322. */
  27323. getFacetLocalPartitioning(): number[][];
  27324. /**
  27325. * Returns the i-th facet position in the world system.
  27326. * This method allocates a new Vector3 per call
  27327. * @param i defines the facet index
  27328. * @returns a new Vector3
  27329. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27330. */
  27331. getFacetPosition(i: number): Vector3;
  27332. /**
  27333. * Sets the reference Vector3 with the i-th facet position in the world system
  27334. * @param i defines the facet index
  27335. * @param ref defines the target vector
  27336. * @returns the current mesh
  27337. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27338. */
  27339. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  27340. /**
  27341. * Returns the i-th facet normal in the world system.
  27342. * This method allocates a new Vector3 per call
  27343. * @param i defines the facet index
  27344. * @returns a new Vector3
  27345. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27346. */
  27347. getFacetNormal(i: number): Vector3;
  27348. /**
  27349. * Sets the reference Vector3 with the i-th facet normal in the world system
  27350. * @param i defines the facet index
  27351. * @param ref defines the target vector
  27352. * @returns the current mesh
  27353. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27354. */
  27355. getFacetNormalToRef(i: number, ref: Vector3): this;
  27356. /**
  27357. * 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)
  27358. * @param x defines x coordinate
  27359. * @param y defines y coordinate
  27360. * @param z defines z coordinate
  27361. * @returns the array of facet indexes
  27362. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27363. */
  27364. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  27365. /**
  27366. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  27367. * @param projected sets as the (x,y,z) world projection on the facet
  27368. * @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
  27369. * @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
  27370. * @param x defines x coordinate
  27371. * @param y defines y coordinate
  27372. * @param z defines z coordinate
  27373. * @returns the face index if found (or null instead)
  27374. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27375. */
  27376. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27377. /**
  27378. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  27379. * @param projected sets as the (x,y,z) local projection on the facet
  27380. * @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
  27381. * @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
  27382. * @param x defines x coordinate
  27383. * @param y defines y coordinate
  27384. * @param z defines z coordinate
  27385. * @returns the face index if found (or null instead)
  27386. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27387. */
  27388. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  27389. /**
  27390. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  27391. * @returns the parameters
  27392. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27393. */
  27394. getFacetDataParameters(): any;
  27395. /**
  27396. * Disables the feature FacetData and frees the related memory
  27397. * @returns the current mesh
  27398. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  27399. */
  27400. disableFacetData(): AbstractMesh;
  27401. /**
  27402. * Updates the AbstractMesh indices array
  27403. * @param indices defines the data source
  27404. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  27405. * @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)
  27406. * @returns the current mesh
  27407. */
  27408. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  27409. /**
  27410. * Creates new normals data for the mesh
  27411. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  27412. * @returns the current mesh
  27413. */
  27414. createNormals(updatable: boolean): AbstractMesh;
  27415. /**
  27416. * Align the mesh with a normal
  27417. * @param normal defines the normal to use
  27418. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  27419. * @returns the current mesh
  27420. */
  27421. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  27422. /** @hidden */
  27423. _checkOcclusionQuery(): boolean;
  27424. /**
  27425. * Disables the mesh edge rendering mode
  27426. * @returns the currentAbstractMesh
  27427. */
  27428. disableEdgesRendering(): AbstractMesh;
  27429. /**
  27430. * Enables the edge rendering mode on the mesh.
  27431. * This mode makes the mesh edges visible
  27432. * @param epsilon defines the maximal distance between two angles to detect a face
  27433. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  27434. * @returns the currentAbstractMesh
  27435. * @see https://www.babylonjs-playground.com/#19O9TU#0
  27436. */
  27437. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  27438. }
  27439. }
  27440. declare module "babylonjs/Actions/actionEvent" {
  27441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27442. import { Nullable } from "babylonjs/types";
  27443. import { Sprite } from "babylonjs/Sprites/sprite";
  27444. import { Scene } from "babylonjs/scene";
  27445. import { Vector2 } from "babylonjs/Maths/math.vector";
  27446. /**
  27447. * Interface used to define ActionEvent
  27448. */
  27449. export interface IActionEvent {
  27450. /** The mesh or sprite that triggered the action */
  27451. source: any;
  27452. /** The X mouse cursor position at the time of the event */
  27453. pointerX: number;
  27454. /** The Y mouse cursor position at the time of the event */
  27455. pointerY: number;
  27456. /** The mesh that is currently pointed at (can be null) */
  27457. meshUnderPointer: Nullable<AbstractMesh>;
  27458. /** the original (browser) event that triggered the ActionEvent */
  27459. sourceEvent?: any;
  27460. /** additional data for the event */
  27461. additionalData?: any;
  27462. }
  27463. /**
  27464. * ActionEvent is the event being sent when an action is triggered.
  27465. */
  27466. export class ActionEvent implements IActionEvent {
  27467. /** The mesh or sprite that triggered the action */
  27468. source: any;
  27469. /** The X mouse cursor position at the time of the event */
  27470. pointerX: number;
  27471. /** The Y mouse cursor position at the time of the event */
  27472. pointerY: number;
  27473. /** The mesh that is currently pointed at (can be null) */
  27474. meshUnderPointer: Nullable<AbstractMesh>;
  27475. /** the original (browser) event that triggered the ActionEvent */
  27476. sourceEvent?: any;
  27477. /** additional data for the event */
  27478. additionalData?: any;
  27479. /**
  27480. * Creates a new ActionEvent
  27481. * @param source The mesh or sprite that triggered the action
  27482. * @param pointerX The X mouse cursor position at the time of the event
  27483. * @param pointerY The Y mouse cursor position at the time of the event
  27484. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  27485. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  27486. * @param additionalData additional data for the event
  27487. */
  27488. constructor(
  27489. /** The mesh or sprite that triggered the action */
  27490. source: any,
  27491. /** The X mouse cursor position at the time of the event */
  27492. pointerX: number,
  27493. /** The Y mouse cursor position at the time of the event */
  27494. pointerY: number,
  27495. /** The mesh that is currently pointed at (can be null) */
  27496. meshUnderPointer: Nullable<AbstractMesh>,
  27497. /** the original (browser) event that triggered the ActionEvent */
  27498. sourceEvent?: any,
  27499. /** additional data for the event */
  27500. additionalData?: any);
  27501. /**
  27502. * Helper function to auto-create an ActionEvent from a source mesh.
  27503. * @param source The source mesh that triggered the event
  27504. * @param evt The original (browser) event
  27505. * @param additionalData additional data for the event
  27506. * @returns the new ActionEvent
  27507. */
  27508. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  27509. /**
  27510. * Helper function to auto-create an ActionEvent from a source sprite
  27511. * @param source The source sprite that triggered the event
  27512. * @param scene Scene associated with the sprite
  27513. * @param evt The original (browser) event
  27514. * @param additionalData additional data for the event
  27515. * @returns the new ActionEvent
  27516. */
  27517. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  27518. /**
  27519. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  27520. * @param scene the scene where the event occurred
  27521. * @param evt The original (browser) event
  27522. * @returns the new ActionEvent
  27523. */
  27524. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  27525. /**
  27526. * Helper function to auto-create an ActionEvent from a primitive
  27527. * @param prim defines the target primitive
  27528. * @param pointerPos defines the pointer position
  27529. * @param evt The original (browser) event
  27530. * @param additionalData additional data for the event
  27531. * @returns the new ActionEvent
  27532. */
  27533. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  27534. }
  27535. }
  27536. declare module "babylonjs/Actions/abstractActionManager" {
  27537. import { IDisposable } from "babylonjs/scene";
  27538. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  27539. import { IAction } from "babylonjs/Actions/action";
  27540. import { Nullable } from "babylonjs/types";
  27541. /**
  27542. * Abstract class used to decouple action Manager from scene and meshes.
  27543. * Do not instantiate.
  27544. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  27545. */
  27546. export abstract class AbstractActionManager implements IDisposable {
  27547. /** Gets the list of active triggers */
  27548. static Triggers: {
  27549. [key: string]: number;
  27550. };
  27551. /** Gets the cursor to use when hovering items */
  27552. hoverCursor: string;
  27553. /** Gets the list of actions */
  27554. actions: IAction[];
  27555. /**
  27556. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  27557. */
  27558. isRecursive: boolean;
  27559. /**
  27560. * Releases all associated resources
  27561. */
  27562. abstract dispose(): void;
  27563. /**
  27564. * Does this action manager has pointer triggers
  27565. */
  27566. abstract readonly hasPointerTriggers: boolean;
  27567. /**
  27568. * Does this action manager has pick triggers
  27569. */
  27570. abstract readonly hasPickTriggers: boolean;
  27571. /**
  27572. * Process a specific trigger
  27573. * @param trigger defines the trigger to process
  27574. * @param evt defines the event details to be processed
  27575. */
  27576. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  27577. /**
  27578. * Does this action manager handles actions of any of the given triggers
  27579. * @param triggers defines the triggers to be tested
  27580. * @return a boolean indicating whether one (or more) of the triggers is handled
  27581. */
  27582. abstract hasSpecificTriggers(triggers: number[]): boolean;
  27583. /**
  27584. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  27585. * speed.
  27586. * @param triggerA defines the trigger to be tested
  27587. * @param triggerB defines the trigger to be tested
  27588. * @return a boolean indicating whether one (or more) of the triggers is handled
  27589. */
  27590. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  27591. /**
  27592. * Does this action manager handles actions of a given trigger
  27593. * @param trigger defines the trigger to be tested
  27594. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  27595. * @return whether the trigger is handled
  27596. */
  27597. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  27598. /**
  27599. * Serialize this manager to a JSON object
  27600. * @param name defines the property name to store this manager
  27601. * @returns a JSON representation of this manager
  27602. */
  27603. abstract serialize(name: string): any;
  27604. /**
  27605. * Registers an action to this action manager
  27606. * @param action defines the action to be registered
  27607. * @return the action amended (prepared) after registration
  27608. */
  27609. abstract registerAction(action: IAction): Nullable<IAction>;
  27610. /**
  27611. * Unregisters an action to this action manager
  27612. * @param action defines the action to be unregistered
  27613. * @return a boolean indicating whether the action has been unregistered
  27614. */
  27615. abstract unregisterAction(action: IAction): Boolean;
  27616. /**
  27617. * Does exist one action manager with at least one trigger
  27618. **/
  27619. static readonly HasTriggers: boolean;
  27620. /**
  27621. * Does exist one action manager with at least one pick trigger
  27622. **/
  27623. static readonly HasPickTriggers: boolean;
  27624. /**
  27625. * Does exist one action manager that handles actions of a given trigger
  27626. * @param trigger defines the trigger to be tested
  27627. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  27628. **/
  27629. static HasSpecificTrigger(trigger: number): boolean;
  27630. }
  27631. }
  27632. declare module "babylonjs/node" {
  27633. import { Scene } from "babylonjs/scene";
  27634. import { Nullable } from "babylonjs/types";
  27635. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  27636. import { Engine } from "babylonjs/Engines/engine";
  27637. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  27638. import { Observable } from "babylonjs/Misc/observable";
  27639. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  27640. import { IInspectable } from "babylonjs/Misc/iInspectable";
  27641. import { Animatable } from "babylonjs/Animations/animatable";
  27642. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27643. import { Animation } from "babylonjs/Animations/animation";
  27644. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27646. /**
  27647. * Defines how a node can be built from a string name.
  27648. */
  27649. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  27650. /**
  27651. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  27652. */
  27653. export class Node implements IBehaviorAware<Node> {
  27654. /** @hidden */
  27655. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  27656. private static _NodeConstructors;
  27657. /**
  27658. * Add a new node constructor
  27659. * @param type defines the type name of the node to construct
  27660. * @param constructorFunc defines the constructor function
  27661. */
  27662. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  27663. /**
  27664. * Returns a node constructor based on type name
  27665. * @param type defines the type name
  27666. * @param name defines the new node name
  27667. * @param scene defines the hosting scene
  27668. * @param options defines optional options to transmit to constructors
  27669. * @returns the new constructor or null
  27670. */
  27671. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  27672. /**
  27673. * Gets or sets the name of the node
  27674. */
  27675. name: string;
  27676. /**
  27677. * Gets or sets the id of the node
  27678. */
  27679. id: string;
  27680. /**
  27681. * Gets or sets the unique id of the node
  27682. */
  27683. uniqueId: number;
  27684. /**
  27685. * Gets or sets a string used to store user defined state for the node
  27686. */
  27687. state: string;
  27688. /**
  27689. * Gets or sets an object used to store user defined information for the node
  27690. */
  27691. metadata: any;
  27692. /**
  27693. * For internal use only. Please do not use.
  27694. */
  27695. reservedDataStore: any;
  27696. /**
  27697. * List of inspectable custom properties (used by the Inspector)
  27698. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  27699. */
  27700. inspectableCustomProperties: IInspectable[];
  27701. private _doNotSerialize;
  27702. /**
  27703. * Gets or sets a boolean used to define if the node must be serialized
  27704. */
  27705. doNotSerialize: boolean;
  27706. /** @hidden */
  27707. _isDisposed: boolean;
  27708. /**
  27709. * Gets a list of Animations associated with the node
  27710. */
  27711. animations: import("babylonjs/Animations/animation").Animation[];
  27712. protected _ranges: {
  27713. [name: string]: Nullable<AnimationRange>;
  27714. };
  27715. /**
  27716. * Callback raised when the node is ready to be used
  27717. */
  27718. onReady: Nullable<(node: Node) => void>;
  27719. private _isEnabled;
  27720. private _isParentEnabled;
  27721. private _isReady;
  27722. /** @hidden */
  27723. _currentRenderId: number;
  27724. private _parentUpdateId;
  27725. /** @hidden */
  27726. _childUpdateId: number;
  27727. /** @hidden */
  27728. _waitingParentId: Nullable<string>;
  27729. /** @hidden */
  27730. _scene: Scene;
  27731. /** @hidden */
  27732. _cache: any;
  27733. private _parentNode;
  27734. private _children;
  27735. /** @hidden */
  27736. _worldMatrix: Matrix;
  27737. /** @hidden */
  27738. _worldMatrixDeterminant: number;
  27739. /** @hidden */
  27740. _worldMatrixDeterminantIsDirty: boolean;
  27741. /** @hidden */
  27742. private _sceneRootNodesIndex;
  27743. /**
  27744. * Gets a boolean indicating if the node has been disposed
  27745. * @returns true if the node was disposed
  27746. */
  27747. isDisposed(): boolean;
  27748. /**
  27749. * Gets or sets the parent of the node (without keeping the current position in the scene)
  27750. * @see https://doc.babylonjs.com/how_to/parenting
  27751. */
  27752. parent: Nullable<Node>;
  27753. private addToSceneRootNodes;
  27754. private removeFromSceneRootNodes;
  27755. private _animationPropertiesOverride;
  27756. /**
  27757. * Gets or sets the animation properties override
  27758. */
  27759. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  27760. /**
  27761. * Gets a string idenfifying the name of the class
  27762. * @returns "Node" string
  27763. */
  27764. getClassName(): string;
  27765. /** @hidden */
  27766. readonly _isNode: boolean;
  27767. /**
  27768. * An event triggered when the mesh is disposed
  27769. */
  27770. onDisposeObservable: Observable<Node>;
  27771. private _onDisposeObserver;
  27772. /**
  27773. * Sets a callback that will be raised when the node will be disposed
  27774. */
  27775. onDispose: () => void;
  27776. /**
  27777. * Creates a new Node
  27778. * @param name the name and id to be given to this node
  27779. * @param scene the scene this node will be added to
  27780. * @param addToRootNodes the node will be added to scene.rootNodes
  27781. */
  27782. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  27783. /**
  27784. * Gets the scene of the node
  27785. * @returns a scene
  27786. */
  27787. getScene(): Scene;
  27788. /**
  27789. * Gets the engine of the node
  27790. * @returns a Engine
  27791. */
  27792. getEngine(): Engine;
  27793. private _behaviors;
  27794. /**
  27795. * Attach a behavior to the node
  27796. * @see http://doc.babylonjs.com/features/behaviour
  27797. * @param behavior defines the behavior to attach
  27798. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  27799. * @returns the current Node
  27800. */
  27801. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  27802. /**
  27803. * Remove an attached behavior
  27804. * @see http://doc.babylonjs.com/features/behaviour
  27805. * @param behavior defines the behavior to attach
  27806. * @returns the current Node
  27807. */
  27808. removeBehavior(behavior: Behavior<Node>): Node;
  27809. /**
  27810. * Gets the list of attached behaviors
  27811. * @see http://doc.babylonjs.com/features/behaviour
  27812. */
  27813. readonly behaviors: Behavior<Node>[];
  27814. /**
  27815. * Gets an attached behavior by name
  27816. * @param name defines the name of the behavior to look for
  27817. * @see http://doc.babylonjs.com/features/behaviour
  27818. * @returns null if behavior was not found else the requested behavior
  27819. */
  27820. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  27821. /**
  27822. * Returns the latest update of the World matrix
  27823. * @returns a Matrix
  27824. */
  27825. getWorldMatrix(): Matrix;
  27826. /** @hidden */
  27827. _getWorldMatrixDeterminant(): number;
  27828. /**
  27829. * Returns directly the latest state of the mesh World matrix.
  27830. * A Matrix is returned.
  27831. */
  27832. readonly worldMatrixFromCache: Matrix;
  27833. /** @hidden */
  27834. _initCache(): void;
  27835. /** @hidden */
  27836. updateCache(force?: boolean): void;
  27837. /** @hidden */
  27838. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  27839. /** @hidden */
  27840. _updateCache(ignoreParentClass?: boolean): void;
  27841. /** @hidden */
  27842. _isSynchronized(): boolean;
  27843. /** @hidden */
  27844. _markSyncedWithParent(): void;
  27845. /** @hidden */
  27846. isSynchronizedWithParent(): boolean;
  27847. /** @hidden */
  27848. isSynchronized(): boolean;
  27849. /**
  27850. * Is this node ready to be used/rendered
  27851. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  27852. * @return true if the node is ready
  27853. */
  27854. isReady(completeCheck?: boolean): boolean;
  27855. /**
  27856. * Is this node enabled?
  27857. * 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
  27858. * @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
  27859. * @return whether this node (and its parent) is enabled
  27860. */
  27861. isEnabled(checkAncestors?: boolean): boolean;
  27862. /** @hidden */
  27863. protected _syncParentEnabledState(): void;
  27864. /**
  27865. * Set the enabled state of this node
  27866. * @param value defines the new enabled state
  27867. */
  27868. setEnabled(value: boolean): void;
  27869. /**
  27870. * Is this node a descendant of the given node?
  27871. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  27872. * @param ancestor defines the parent node to inspect
  27873. * @returns a boolean indicating if this node is a descendant of the given node
  27874. */
  27875. isDescendantOf(ancestor: Node): boolean;
  27876. /** @hidden */
  27877. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  27878. /**
  27879. * Will return all nodes that have this node as ascendant
  27880. * @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
  27881. * @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
  27882. * @return all children nodes of all types
  27883. */
  27884. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  27885. /**
  27886. * Get all child-meshes of this node
  27887. * @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)
  27888. * @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
  27889. * @returns an array of AbstractMesh
  27890. */
  27891. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  27892. /**
  27893. * Get all direct children of this node
  27894. * @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
  27895. * @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)
  27896. * @returns an array of Node
  27897. */
  27898. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  27899. /** @hidden */
  27900. _setReady(state: boolean): void;
  27901. /**
  27902. * Get an animation by name
  27903. * @param name defines the name of the animation to look for
  27904. * @returns null if not found else the requested animation
  27905. */
  27906. getAnimationByName(name: string): Nullable<Animation>;
  27907. /**
  27908. * Creates an animation range for this node
  27909. * @param name defines the name of the range
  27910. * @param from defines the starting key
  27911. * @param to defines the end key
  27912. */
  27913. createAnimationRange(name: string, from: number, to: number): void;
  27914. /**
  27915. * Delete a specific animation range
  27916. * @param name defines the name of the range to delete
  27917. * @param deleteFrames defines if animation frames from the range must be deleted as well
  27918. */
  27919. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  27920. /**
  27921. * Get an animation range by name
  27922. * @param name defines the name of the animation range to look for
  27923. * @returns null if not found else the requested animation range
  27924. */
  27925. getAnimationRange(name: string): Nullable<AnimationRange>;
  27926. /**
  27927. * Gets the list of all animation ranges defined on this node
  27928. * @returns an array
  27929. */
  27930. getAnimationRanges(): Nullable<AnimationRange>[];
  27931. /**
  27932. * Will start the animation sequence
  27933. * @param name defines the range frames for animation sequence
  27934. * @param loop defines if the animation should loop (false by default)
  27935. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  27936. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  27937. * @returns the object created for this animation. If range does not exist, it will return null
  27938. */
  27939. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  27940. /**
  27941. * Serialize animation ranges into a JSON compatible object
  27942. * @returns serialization object
  27943. */
  27944. serializeAnimationRanges(): any;
  27945. /**
  27946. * Computes the world matrix of the node
  27947. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  27948. * @returns the world matrix
  27949. */
  27950. computeWorldMatrix(force?: boolean): Matrix;
  27951. /**
  27952. * Releases resources associated with this node.
  27953. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  27954. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  27955. */
  27956. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  27957. /**
  27958. * Parse animation range data from a serialization object and store them into a given node
  27959. * @param node defines where to store the animation ranges
  27960. * @param parsedNode defines the serialization object to read data from
  27961. * @param scene defines the hosting scene
  27962. */
  27963. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  27964. /**
  27965. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  27966. * @param includeDescendants Include bounding info from descendants as well (true by default)
  27967. * @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
  27968. * @returns the new bounding vectors
  27969. */
  27970. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  27971. min: Vector3;
  27972. max: Vector3;
  27973. };
  27974. }
  27975. }
  27976. declare module "babylonjs/Animations/animation" {
  27977. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  27978. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  27979. import { Color3 } from "babylonjs/Maths/math.color";
  27980. import { Nullable } from "babylonjs/types";
  27981. import { Scene } from "babylonjs/scene";
  27982. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  27983. import { AnimationRange } from "babylonjs/Animations/animationRange";
  27984. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  27985. import { Node } from "babylonjs/node";
  27986. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27987. import { Size } from "babylonjs/Maths/math.size";
  27988. import { Animatable } from "babylonjs/Animations/animatable";
  27989. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  27990. /**
  27991. * @hidden
  27992. */
  27993. export class _IAnimationState {
  27994. key: number;
  27995. repeatCount: number;
  27996. workValue?: any;
  27997. loopMode?: number;
  27998. offsetValue?: any;
  27999. highLimitValue?: any;
  28000. }
  28001. /**
  28002. * Class used to store any kind of animation
  28003. */
  28004. export class Animation {
  28005. /**Name of the animation */
  28006. name: string;
  28007. /**Property to animate */
  28008. targetProperty: string;
  28009. /**The frames per second of the animation */
  28010. framePerSecond: number;
  28011. /**The data type of the animation */
  28012. dataType: number;
  28013. /**The loop mode of the animation */
  28014. loopMode?: number | undefined;
  28015. /**Specifies if blending should be enabled */
  28016. enableBlending?: boolean | undefined;
  28017. /**
  28018. * Use matrix interpolation instead of using direct key value when animating matrices
  28019. */
  28020. static AllowMatricesInterpolation: boolean;
  28021. /**
  28022. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  28023. */
  28024. static AllowMatrixDecomposeForInterpolation: boolean;
  28025. /**
  28026. * Stores the key frames of the animation
  28027. */
  28028. private _keys;
  28029. /**
  28030. * Stores the easing function of the animation
  28031. */
  28032. private _easingFunction;
  28033. /**
  28034. * @hidden Internal use only
  28035. */
  28036. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  28037. /**
  28038. * The set of event that will be linked to this animation
  28039. */
  28040. private _events;
  28041. /**
  28042. * Stores an array of target property paths
  28043. */
  28044. targetPropertyPath: string[];
  28045. /**
  28046. * Stores the blending speed of the animation
  28047. */
  28048. blendingSpeed: number;
  28049. /**
  28050. * Stores the animation ranges for the animation
  28051. */
  28052. private _ranges;
  28053. /**
  28054. * @hidden Internal use
  28055. */
  28056. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  28057. /**
  28058. * Sets up an animation
  28059. * @param property The property to animate
  28060. * @param animationType The animation type to apply
  28061. * @param framePerSecond The frames per second of the animation
  28062. * @param easingFunction The easing function used in the animation
  28063. * @returns The created animation
  28064. */
  28065. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  28066. /**
  28067. * Create and start an animation on a node
  28068. * @param name defines the name of the global animation that will be run on all nodes
  28069. * @param node defines the root node where the animation will take place
  28070. * @param targetProperty defines property to animate
  28071. * @param framePerSecond defines the number of frame per second yo use
  28072. * @param totalFrame defines the number of frames in total
  28073. * @param from defines the initial value
  28074. * @param to defines the final value
  28075. * @param loopMode defines which loop mode you want to use (off by default)
  28076. * @param easingFunction defines the easing function to use (linear by default)
  28077. * @param onAnimationEnd defines the callback to call when animation end
  28078. * @returns the animatable created for this animation
  28079. */
  28080. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28081. /**
  28082. * Create and start an animation on a node and its descendants
  28083. * @param name defines the name of the global animation that will be run on all nodes
  28084. * @param node defines the root node where the animation will take place
  28085. * @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
  28086. * @param targetProperty defines property to animate
  28087. * @param framePerSecond defines the number of frame per second to use
  28088. * @param totalFrame defines the number of frames in total
  28089. * @param from defines the initial value
  28090. * @param to defines the final value
  28091. * @param loopMode defines which loop mode you want to use (off by default)
  28092. * @param easingFunction defines the easing function to use (linear by default)
  28093. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  28094. * @returns the list of animatables created for all nodes
  28095. * @example https://www.babylonjs-playground.com/#MH0VLI
  28096. */
  28097. 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[]>;
  28098. /**
  28099. * Creates a new animation, merges it with the existing animations and starts it
  28100. * @param name Name of the animation
  28101. * @param node Node which contains the scene that begins the animations
  28102. * @param targetProperty Specifies which property to animate
  28103. * @param framePerSecond The frames per second of the animation
  28104. * @param totalFrame The total number of frames
  28105. * @param from The frame at the beginning of the animation
  28106. * @param to The frame at the end of the animation
  28107. * @param loopMode Specifies the loop mode of the animation
  28108. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  28109. * @param onAnimationEnd Callback to run once the animation is complete
  28110. * @returns Nullable animation
  28111. */
  28112. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  28113. /**
  28114. * Transition property of an host to the target Value
  28115. * @param property The property to transition
  28116. * @param targetValue The target Value of the property
  28117. * @param host The object where the property to animate belongs
  28118. * @param scene Scene used to run the animation
  28119. * @param frameRate Framerate (in frame/s) to use
  28120. * @param transition The transition type we want to use
  28121. * @param duration The duration of the animation, in milliseconds
  28122. * @param onAnimationEnd Callback trigger at the end of the animation
  28123. * @returns Nullable animation
  28124. */
  28125. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  28126. /**
  28127. * Return the array of runtime animations currently using this animation
  28128. */
  28129. readonly runtimeAnimations: RuntimeAnimation[];
  28130. /**
  28131. * Specifies if any of the runtime animations are currently running
  28132. */
  28133. readonly hasRunningRuntimeAnimations: boolean;
  28134. /**
  28135. * Initializes the animation
  28136. * @param name Name of the animation
  28137. * @param targetProperty Property to animate
  28138. * @param framePerSecond The frames per second of the animation
  28139. * @param dataType The data type of the animation
  28140. * @param loopMode The loop mode of the animation
  28141. * @param enableBlending Specifies if blending should be enabled
  28142. */
  28143. constructor(
  28144. /**Name of the animation */
  28145. name: string,
  28146. /**Property to animate */
  28147. targetProperty: string,
  28148. /**The frames per second of the animation */
  28149. framePerSecond: number,
  28150. /**The data type of the animation */
  28151. dataType: number,
  28152. /**The loop mode of the animation */
  28153. loopMode?: number | undefined,
  28154. /**Specifies if blending should be enabled */
  28155. enableBlending?: boolean | undefined);
  28156. /**
  28157. * Converts the animation to a string
  28158. * @param fullDetails support for multiple levels of logging within scene loading
  28159. * @returns String form of the animation
  28160. */
  28161. toString(fullDetails?: boolean): string;
  28162. /**
  28163. * Add an event to this animation
  28164. * @param event Event to add
  28165. */
  28166. addEvent(event: AnimationEvent): void;
  28167. /**
  28168. * Remove all events found at the given frame
  28169. * @param frame The frame to remove events from
  28170. */
  28171. removeEvents(frame: number): void;
  28172. /**
  28173. * Retrieves all the events from the animation
  28174. * @returns Events from the animation
  28175. */
  28176. getEvents(): AnimationEvent[];
  28177. /**
  28178. * Creates an animation range
  28179. * @param name Name of the animation range
  28180. * @param from Starting frame of the animation range
  28181. * @param to Ending frame of the animation
  28182. */
  28183. createRange(name: string, from: number, to: number): void;
  28184. /**
  28185. * Deletes an animation range by name
  28186. * @param name Name of the animation range to delete
  28187. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  28188. */
  28189. deleteRange(name: string, deleteFrames?: boolean): void;
  28190. /**
  28191. * Gets the animation range by name, or null if not defined
  28192. * @param name Name of the animation range
  28193. * @returns Nullable animation range
  28194. */
  28195. getRange(name: string): Nullable<AnimationRange>;
  28196. /**
  28197. * Gets the key frames from the animation
  28198. * @returns The key frames of the animation
  28199. */
  28200. getKeys(): Array<IAnimationKey>;
  28201. /**
  28202. * Gets the highest frame rate of the animation
  28203. * @returns Highest frame rate of the animation
  28204. */
  28205. getHighestFrame(): number;
  28206. /**
  28207. * Gets the easing function of the animation
  28208. * @returns Easing function of the animation
  28209. */
  28210. getEasingFunction(): IEasingFunction;
  28211. /**
  28212. * Sets the easing function of the animation
  28213. * @param easingFunction A custom mathematical formula for animation
  28214. */
  28215. setEasingFunction(easingFunction: EasingFunction): void;
  28216. /**
  28217. * Interpolates a scalar linearly
  28218. * @param startValue Start value of the animation curve
  28219. * @param endValue End value of the animation curve
  28220. * @param gradient Scalar amount to interpolate
  28221. * @returns Interpolated scalar value
  28222. */
  28223. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  28224. /**
  28225. * Interpolates a scalar cubically
  28226. * @param startValue Start value of the animation curve
  28227. * @param outTangent End tangent of the animation
  28228. * @param endValue End value of the animation curve
  28229. * @param inTangent Start tangent of the animation curve
  28230. * @param gradient Scalar amount to interpolate
  28231. * @returns Interpolated scalar value
  28232. */
  28233. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  28234. /**
  28235. * Interpolates a quaternion using a spherical linear interpolation
  28236. * @param startValue Start value of the animation curve
  28237. * @param endValue End value of the animation curve
  28238. * @param gradient Scalar amount to interpolate
  28239. * @returns Interpolated quaternion value
  28240. */
  28241. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  28242. /**
  28243. * Interpolates a quaternion cubically
  28244. * @param startValue Start value of the animation curve
  28245. * @param outTangent End tangent of the animation curve
  28246. * @param endValue End value of the animation curve
  28247. * @param inTangent Start tangent of the animation curve
  28248. * @param gradient Scalar amount to interpolate
  28249. * @returns Interpolated quaternion value
  28250. */
  28251. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  28252. /**
  28253. * Interpolates a Vector3 linearl
  28254. * @param startValue Start value of the animation curve
  28255. * @param endValue End value of the animation curve
  28256. * @param gradient Scalar amount to interpolate
  28257. * @returns Interpolated scalar value
  28258. */
  28259. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  28260. /**
  28261. * Interpolates a Vector3 cubically
  28262. * @param startValue Start value of the animation curve
  28263. * @param outTangent End tangent of the animation
  28264. * @param endValue End value of the animation curve
  28265. * @param inTangent Start tangent of the animation curve
  28266. * @param gradient Scalar amount to interpolate
  28267. * @returns InterpolatedVector3 value
  28268. */
  28269. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  28270. /**
  28271. * Interpolates a Vector2 linearly
  28272. * @param startValue Start value of the animation curve
  28273. * @param endValue End value of the animation curve
  28274. * @param gradient Scalar amount to interpolate
  28275. * @returns Interpolated Vector2 value
  28276. */
  28277. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  28278. /**
  28279. * Interpolates a Vector2 cubically
  28280. * @param startValue Start value of the animation curve
  28281. * @param outTangent End tangent of the animation
  28282. * @param endValue End value of the animation curve
  28283. * @param inTangent Start tangent of the animation curve
  28284. * @param gradient Scalar amount to interpolate
  28285. * @returns Interpolated Vector2 value
  28286. */
  28287. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  28288. /**
  28289. * Interpolates a size linearly
  28290. * @param startValue Start value of the animation curve
  28291. * @param endValue End value of the animation curve
  28292. * @param gradient Scalar amount to interpolate
  28293. * @returns Interpolated Size value
  28294. */
  28295. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  28296. /**
  28297. * Interpolates a Color3 linearly
  28298. * @param startValue Start value of the animation curve
  28299. * @param endValue End value of the animation curve
  28300. * @param gradient Scalar amount to interpolate
  28301. * @returns Interpolated Color3 value
  28302. */
  28303. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  28304. /**
  28305. * @hidden Internal use only
  28306. */
  28307. _getKeyValue(value: any): any;
  28308. /**
  28309. * @hidden Internal use only
  28310. */
  28311. _interpolate(currentFrame: number, state: _IAnimationState): any;
  28312. /**
  28313. * Defines the function to use to interpolate matrices
  28314. * @param startValue defines the start matrix
  28315. * @param endValue defines the end matrix
  28316. * @param gradient defines the gradient between both matrices
  28317. * @param result defines an optional target matrix where to store the interpolation
  28318. * @returns the interpolated matrix
  28319. */
  28320. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  28321. /**
  28322. * Makes a copy of the animation
  28323. * @returns Cloned animation
  28324. */
  28325. clone(): Animation;
  28326. /**
  28327. * Sets the key frames of the animation
  28328. * @param values The animation key frames to set
  28329. */
  28330. setKeys(values: Array<IAnimationKey>): void;
  28331. /**
  28332. * Serializes the animation to an object
  28333. * @returns Serialized object
  28334. */
  28335. serialize(): any;
  28336. /**
  28337. * Float animation type
  28338. */
  28339. private static _ANIMATIONTYPE_FLOAT;
  28340. /**
  28341. * Vector3 animation type
  28342. */
  28343. private static _ANIMATIONTYPE_VECTOR3;
  28344. /**
  28345. * Quaternion animation type
  28346. */
  28347. private static _ANIMATIONTYPE_QUATERNION;
  28348. /**
  28349. * Matrix animation type
  28350. */
  28351. private static _ANIMATIONTYPE_MATRIX;
  28352. /**
  28353. * Color3 animation type
  28354. */
  28355. private static _ANIMATIONTYPE_COLOR3;
  28356. /**
  28357. * Vector2 animation type
  28358. */
  28359. private static _ANIMATIONTYPE_VECTOR2;
  28360. /**
  28361. * Size animation type
  28362. */
  28363. private static _ANIMATIONTYPE_SIZE;
  28364. /**
  28365. * Relative Loop Mode
  28366. */
  28367. private static _ANIMATIONLOOPMODE_RELATIVE;
  28368. /**
  28369. * Cycle Loop Mode
  28370. */
  28371. private static _ANIMATIONLOOPMODE_CYCLE;
  28372. /**
  28373. * Constant Loop Mode
  28374. */
  28375. private static _ANIMATIONLOOPMODE_CONSTANT;
  28376. /**
  28377. * Get the float animation type
  28378. */
  28379. static readonly ANIMATIONTYPE_FLOAT: number;
  28380. /**
  28381. * Get the Vector3 animation type
  28382. */
  28383. static readonly ANIMATIONTYPE_VECTOR3: number;
  28384. /**
  28385. * Get the Vector2 animation type
  28386. */
  28387. static readonly ANIMATIONTYPE_VECTOR2: number;
  28388. /**
  28389. * Get the Size animation type
  28390. */
  28391. static readonly ANIMATIONTYPE_SIZE: number;
  28392. /**
  28393. * Get the Quaternion animation type
  28394. */
  28395. static readonly ANIMATIONTYPE_QUATERNION: number;
  28396. /**
  28397. * Get the Matrix animation type
  28398. */
  28399. static readonly ANIMATIONTYPE_MATRIX: number;
  28400. /**
  28401. * Get the Color3 animation type
  28402. */
  28403. static readonly ANIMATIONTYPE_COLOR3: number;
  28404. /**
  28405. * Get the Relative Loop Mode
  28406. */
  28407. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  28408. /**
  28409. * Get the Cycle Loop Mode
  28410. */
  28411. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  28412. /**
  28413. * Get the Constant Loop Mode
  28414. */
  28415. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  28416. /** @hidden */
  28417. static _UniversalLerp(left: any, right: any, amount: number): any;
  28418. /**
  28419. * Parses an animation object and creates an animation
  28420. * @param parsedAnimation Parsed animation object
  28421. * @returns Animation object
  28422. */
  28423. static Parse(parsedAnimation: any): Animation;
  28424. /**
  28425. * Appends the serialized animations from the source animations
  28426. * @param source Source containing the animations
  28427. * @param destination Target to store the animations
  28428. */
  28429. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28430. }
  28431. }
  28432. declare module "babylonjs/Animations/animatable.interface" {
  28433. import { Nullable } from "babylonjs/types";
  28434. import { Animation } from "babylonjs/Animations/animation";
  28435. /**
  28436. * Interface containing an array of animations
  28437. */
  28438. export interface IAnimatable {
  28439. /**
  28440. * Array of animations
  28441. */
  28442. animations: Nullable<Array<Animation>>;
  28443. }
  28444. }
  28445. declare module "babylonjs/Materials/fresnelParameters" {
  28446. import { Color3 } from "babylonjs/Maths/math.color";
  28447. /**
  28448. * This represents all the required information to add a fresnel effect on a material:
  28449. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  28450. */
  28451. export class FresnelParameters {
  28452. private _isEnabled;
  28453. /**
  28454. * Define if the fresnel effect is enable or not.
  28455. */
  28456. isEnabled: boolean;
  28457. /**
  28458. * Define the color used on edges (grazing angle)
  28459. */
  28460. leftColor: Color3;
  28461. /**
  28462. * Define the color used on center
  28463. */
  28464. rightColor: Color3;
  28465. /**
  28466. * Define bias applied to computed fresnel term
  28467. */
  28468. bias: number;
  28469. /**
  28470. * Defined the power exponent applied to fresnel term
  28471. */
  28472. power: number;
  28473. /**
  28474. * Clones the current fresnel and its valuues
  28475. * @returns a clone fresnel configuration
  28476. */
  28477. clone(): FresnelParameters;
  28478. /**
  28479. * Serializes the current fresnel parameters to a JSON representation.
  28480. * @return the JSON serialization
  28481. */
  28482. serialize(): any;
  28483. /**
  28484. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  28485. * @param parsedFresnelParameters Define the JSON representation
  28486. * @returns the parsed parameters
  28487. */
  28488. static Parse(parsedFresnelParameters: any): FresnelParameters;
  28489. }
  28490. }
  28491. declare module "babylonjs/Misc/decorators" {
  28492. import { Nullable } from "babylonjs/types";
  28493. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28494. import { Scene } from "babylonjs/scene";
  28495. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  28496. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28497. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28498. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28499. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28500. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28501. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28502. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28503. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28504. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28505. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28506. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28507. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28508. /**
  28509. * Decorator used to define property that can be serialized as reference to a camera
  28510. * @param sourceName defines the name of the property to decorate
  28511. */
  28512. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  28513. /**
  28514. * Class used to help serialization objects
  28515. */
  28516. export class SerializationHelper {
  28517. /** @hidden */
  28518. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  28519. /** @hidden */
  28520. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  28521. /** @hidden */
  28522. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  28523. /** @hidden */
  28524. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  28525. /**
  28526. * Appends the serialized animations from the source animations
  28527. * @param source Source containing the animations
  28528. * @param destination Target to store the animations
  28529. */
  28530. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  28531. /**
  28532. * Static function used to serialized a specific entity
  28533. * @param entity defines the entity to serialize
  28534. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  28535. * @returns a JSON compatible object representing the serialization of the entity
  28536. */
  28537. static Serialize<T>(entity: T, serializationObject?: any): any;
  28538. /**
  28539. * Creates a new entity from a serialization data object
  28540. * @param creationFunction defines a function used to instanciated the new entity
  28541. * @param source defines the source serialization data
  28542. * @param scene defines the hosting scene
  28543. * @param rootUrl defines the root url for resources
  28544. * @returns a new entity
  28545. */
  28546. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  28547. /**
  28548. * Clones an object
  28549. * @param creationFunction defines the function used to instanciate the new object
  28550. * @param source defines the source object
  28551. * @returns the cloned object
  28552. */
  28553. static Clone<T>(creationFunction: () => T, source: T): T;
  28554. /**
  28555. * Instanciates a new object based on a source one (some data will be shared between both object)
  28556. * @param creationFunction defines the function used to instanciate the new object
  28557. * @param source defines the source object
  28558. * @returns the new object
  28559. */
  28560. static Instanciate<T>(creationFunction: () => T, source: T): T;
  28561. }
  28562. }
  28563. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  28564. import { Nullable } from "babylonjs/types";
  28565. /**
  28566. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  28567. */
  28568. export interface CubeMapInfo {
  28569. /**
  28570. * The pixel array for the front face.
  28571. * This is stored in format, left to right, up to down format.
  28572. */
  28573. front: Nullable<ArrayBufferView>;
  28574. /**
  28575. * The pixel array for the back face.
  28576. * This is stored in format, left to right, up to down format.
  28577. */
  28578. back: Nullable<ArrayBufferView>;
  28579. /**
  28580. * The pixel array for the left face.
  28581. * This is stored in format, left to right, up to down format.
  28582. */
  28583. left: Nullable<ArrayBufferView>;
  28584. /**
  28585. * The pixel array for the right face.
  28586. * This is stored in format, left to right, up to down format.
  28587. */
  28588. right: Nullable<ArrayBufferView>;
  28589. /**
  28590. * The pixel array for the up face.
  28591. * This is stored in format, left to right, up to down format.
  28592. */
  28593. up: Nullable<ArrayBufferView>;
  28594. /**
  28595. * The pixel array for the down face.
  28596. * This is stored in format, left to right, up to down format.
  28597. */
  28598. down: Nullable<ArrayBufferView>;
  28599. /**
  28600. * The size of the cubemap stored.
  28601. *
  28602. * Each faces will be size * size pixels.
  28603. */
  28604. size: number;
  28605. /**
  28606. * The format of the texture.
  28607. *
  28608. * RGBA, RGB.
  28609. */
  28610. format: number;
  28611. /**
  28612. * The type of the texture data.
  28613. *
  28614. * UNSIGNED_INT, FLOAT.
  28615. */
  28616. type: number;
  28617. /**
  28618. * Specifies whether the texture is in gamma space.
  28619. */
  28620. gammaSpace: boolean;
  28621. }
  28622. /**
  28623. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  28624. */
  28625. export class PanoramaToCubeMapTools {
  28626. private static FACE_FRONT;
  28627. private static FACE_BACK;
  28628. private static FACE_RIGHT;
  28629. private static FACE_LEFT;
  28630. private static FACE_DOWN;
  28631. private static FACE_UP;
  28632. /**
  28633. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  28634. *
  28635. * @param float32Array The source data.
  28636. * @param inputWidth The width of the input panorama.
  28637. * @param inputHeight The height of the input panorama.
  28638. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  28639. * @return The cubemap data
  28640. */
  28641. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  28642. private static CreateCubemapTexture;
  28643. private static CalcProjectionSpherical;
  28644. }
  28645. }
  28646. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  28647. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28648. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  28649. import { Nullable } from "babylonjs/types";
  28650. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  28651. /**
  28652. * Helper class dealing with the extraction of spherical polynomial dataArray
  28653. * from a cube map.
  28654. */
  28655. export class CubeMapToSphericalPolynomialTools {
  28656. private static FileFaces;
  28657. /**
  28658. * Converts a texture to the according Spherical Polynomial data.
  28659. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28660. *
  28661. * @param texture The texture to extract the information from.
  28662. * @return The Spherical Polynomial data.
  28663. */
  28664. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  28665. /**
  28666. * Converts a cubemap to the according Spherical Polynomial data.
  28667. * This extracts the first 3 orders only as they are the only one used in the lighting.
  28668. *
  28669. * @param cubeInfo The Cube map to extract the information from.
  28670. * @return The Spherical Polynomial data.
  28671. */
  28672. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  28673. }
  28674. }
  28675. declare module "babylonjs/Misc/guid" {
  28676. /**
  28677. * Class used to manipulate GUIDs
  28678. */
  28679. export class GUID {
  28680. /**
  28681. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  28682. * Be aware Math.random() could cause collisions, but:
  28683. * "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"
  28684. * @returns a pseudo random id
  28685. */
  28686. static RandomId(): string;
  28687. }
  28688. }
  28689. declare module "babylonjs/Materials/Textures/baseTexture" {
  28690. import { Observable } from "babylonjs/Misc/observable";
  28691. import { Nullable } from "babylonjs/types";
  28692. import { Scene } from "babylonjs/scene";
  28693. import { Matrix } from "babylonjs/Maths/math.vector";
  28694. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  28695. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  28696. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  28697. import { ISize } from "babylonjs/Maths/math.size";
  28698. /**
  28699. * Base class of all the textures in babylon.
  28700. * It groups all the common properties the materials, post process, lights... might need
  28701. * in order to make a correct use of the texture.
  28702. */
  28703. export class BaseTexture implements IAnimatable {
  28704. /**
  28705. * Default anisotropic filtering level for the application.
  28706. * It is set to 4 as a good tradeoff between perf and quality.
  28707. */
  28708. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  28709. /**
  28710. * Gets or sets the unique id of the texture
  28711. */
  28712. uniqueId: number;
  28713. /**
  28714. * Define the name of the texture.
  28715. */
  28716. name: string;
  28717. /**
  28718. * Gets or sets an object used to store user defined information.
  28719. */
  28720. metadata: any;
  28721. /**
  28722. * For internal use only. Please do not use.
  28723. */
  28724. reservedDataStore: any;
  28725. private _hasAlpha;
  28726. /**
  28727. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  28728. */
  28729. hasAlpha: boolean;
  28730. /**
  28731. * Defines if the alpha value should be determined via the rgb values.
  28732. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  28733. */
  28734. getAlphaFromRGB: boolean;
  28735. /**
  28736. * Intensity or strength of the texture.
  28737. * It is commonly used by materials to fine tune the intensity of the texture
  28738. */
  28739. level: number;
  28740. /**
  28741. * Define the UV chanel to use starting from 0 and defaulting to 0.
  28742. * This is part of the texture as textures usually maps to one uv set.
  28743. */
  28744. coordinatesIndex: number;
  28745. private _coordinatesMode;
  28746. /**
  28747. * How a texture is mapped.
  28748. *
  28749. * | Value | Type | Description |
  28750. * | ----- | ----------------------------------- | ----------- |
  28751. * | 0 | EXPLICIT_MODE | |
  28752. * | 1 | SPHERICAL_MODE | |
  28753. * | 2 | PLANAR_MODE | |
  28754. * | 3 | CUBIC_MODE | |
  28755. * | 4 | PROJECTION_MODE | |
  28756. * | 5 | SKYBOX_MODE | |
  28757. * | 6 | INVCUBIC_MODE | |
  28758. * | 7 | EQUIRECTANGULAR_MODE | |
  28759. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  28760. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  28761. */
  28762. coordinatesMode: number;
  28763. /**
  28764. * | Value | Type | Description |
  28765. * | ----- | ------------------ | ----------- |
  28766. * | 0 | CLAMP_ADDRESSMODE | |
  28767. * | 1 | WRAP_ADDRESSMODE | |
  28768. * | 2 | MIRROR_ADDRESSMODE | |
  28769. */
  28770. wrapU: number;
  28771. /**
  28772. * | Value | Type | Description |
  28773. * | ----- | ------------------ | ----------- |
  28774. * | 0 | CLAMP_ADDRESSMODE | |
  28775. * | 1 | WRAP_ADDRESSMODE | |
  28776. * | 2 | MIRROR_ADDRESSMODE | |
  28777. */
  28778. wrapV: number;
  28779. /**
  28780. * | Value | Type | Description |
  28781. * | ----- | ------------------ | ----------- |
  28782. * | 0 | CLAMP_ADDRESSMODE | |
  28783. * | 1 | WRAP_ADDRESSMODE | |
  28784. * | 2 | MIRROR_ADDRESSMODE | |
  28785. */
  28786. wrapR: number;
  28787. /**
  28788. * With compliant hardware and browser (supporting anisotropic filtering)
  28789. * this defines the level of anisotropic filtering in the texture.
  28790. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  28791. */
  28792. anisotropicFilteringLevel: number;
  28793. /**
  28794. * Define if the texture is a cube texture or if false a 2d texture.
  28795. */
  28796. isCube: boolean;
  28797. /**
  28798. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  28799. */
  28800. is3D: boolean;
  28801. /**
  28802. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  28803. * HDR texture are usually stored in linear space.
  28804. * This only impacts the PBR and Background materials
  28805. */
  28806. gammaSpace: boolean;
  28807. /**
  28808. * Gets or sets whether or not the texture contains RGBD data.
  28809. */
  28810. isRGBD: boolean;
  28811. /**
  28812. * Is Z inverted in the texture (useful in a cube texture).
  28813. */
  28814. invertZ: boolean;
  28815. /**
  28816. * Are mip maps generated for this texture or not.
  28817. */
  28818. readonly noMipmap: boolean;
  28819. /**
  28820. * @hidden
  28821. */
  28822. lodLevelInAlpha: boolean;
  28823. /**
  28824. * With prefiltered texture, defined the offset used during the prefiltering steps.
  28825. */
  28826. lodGenerationOffset: number;
  28827. /**
  28828. * With prefiltered texture, defined the scale used during the prefiltering steps.
  28829. */
  28830. lodGenerationScale: number;
  28831. /**
  28832. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  28833. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  28834. * average roughness values.
  28835. */
  28836. linearSpecularLOD: boolean;
  28837. /**
  28838. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  28839. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  28840. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  28841. */
  28842. irradianceTexture: Nullable<BaseTexture>;
  28843. /**
  28844. * Define if the texture is a render target.
  28845. */
  28846. isRenderTarget: boolean;
  28847. /**
  28848. * Define the unique id of the texture in the scene.
  28849. */
  28850. readonly uid: string;
  28851. /**
  28852. * Return a string representation of the texture.
  28853. * @returns the texture as a string
  28854. */
  28855. toString(): string;
  28856. /**
  28857. * Get the class name of the texture.
  28858. * @returns "BaseTexture"
  28859. */
  28860. getClassName(): string;
  28861. /**
  28862. * Define the list of animation attached to the texture.
  28863. */
  28864. animations: import("babylonjs/Animations/animation").Animation[];
  28865. /**
  28866. * An event triggered when the texture is disposed.
  28867. */
  28868. onDisposeObservable: Observable<BaseTexture>;
  28869. private _onDisposeObserver;
  28870. /**
  28871. * Callback triggered when the texture has been disposed.
  28872. * Kept for back compatibility, you can use the onDisposeObservable instead.
  28873. */
  28874. onDispose: () => void;
  28875. /**
  28876. * Define the current state of the loading sequence when in delayed load mode.
  28877. */
  28878. delayLoadState: number;
  28879. private _scene;
  28880. /** @hidden */
  28881. _texture: Nullable<InternalTexture>;
  28882. private _uid;
  28883. /**
  28884. * Define if the texture is preventinga material to render or not.
  28885. * If not and the texture is not ready, the engine will use a default black texture instead.
  28886. */
  28887. readonly isBlocking: boolean;
  28888. /**
  28889. * Instantiates a new BaseTexture.
  28890. * Base class of all the textures in babylon.
  28891. * It groups all the common properties the materials, post process, lights... might need
  28892. * in order to make a correct use of the texture.
  28893. * @param scene Define the scene the texture blongs to
  28894. */
  28895. constructor(scene: Nullable<Scene>);
  28896. /**
  28897. * Get the scene the texture belongs to.
  28898. * @returns the scene or null if undefined
  28899. */
  28900. getScene(): Nullable<Scene>;
  28901. /**
  28902. * Get the texture transform matrix used to offset tile the texture for istance.
  28903. * @returns the transformation matrix
  28904. */
  28905. getTextureMatrix(): Matrix;
  28906. /**
  28907. * Get the texture reflection matrix used to rotate/transform the reflection.
  28908. * @returns the reflection matrix
  28909. */
  28910. getReflectionTextureMatrix(): Matrix;
  28911. /**
  28912. * Get the underlying lower level texture from Babylon.
  28913. * @returns the insternal texture
  28914. */
  28915. getInternalTexture(): Nullable<InternalTexture>;
  28916. /**
  28917. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  28918. * @returns true if ready or not blocking
  28919. */
  28920. isReadyOrNotBlocking(): boolean;
  28921. /**
  28922. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  28923. * @returns true if fully ready
  28924. */
  28925. isReady(): boolean;
  28926. private _cachedSize;
  28927. /**
  28928. * Get the size of the texture.
  28929. * @returns the texture size.
  28930. */
  28931. getSize(): ISize;
  28932. /**
  28933. * Get the base size of the texture.
  28934. * It can be different from the size if the texture has been resized for POT for instance
  28935. * @returns the base size
  28936. */
  28937. getBaseSize(): ISize;
  28938. /**
  28939. * Update the sampling mode of the texture.
  28940. * Default is Trilinear mode.
  28941. *
  28942. * | Value | Type | Description |
  28943. * | ----- | ------------------ | ----------- |
  28944. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  28945. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  28946. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  28947. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  28948. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  28949. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  28950. * | 7 | NEAREST_LINEAR | |
  28951. * | 8 | NEAREST_NEAREST | |
  28952. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  28953. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  28954. * | 11 | LINEAR_LINEAR | |
  28955. * | 12 | LINEAR_NEAREST | |
  28956. *
  28957. * > _mag_: magnification filter (close to the viewer)
  28958. * > _min_: minification filter (far from the viewer)
  28959. * > _mip_: filter used between mip map levels
  28960. *@param samplingMode Define the new sampling mode of the texture
  28961. */
  28962. updateSamplingMode(samplingMode: number): void;
  28963. /**
  28964. * Scales the texture if is `canRescale()`
  28965. * @param ratio the resize factor we want to use to rescale
  28966. */
  28967. scale(ratio: number): void;
  28968. /**
  28969. * Get if the texture can rescale.
  28970. */
  28971. readonly canRescale: boolean;
  28972. /** @hidden */
  28973. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  28974. /** @hidden */
  28975. _rebuild(): void;
  28976. /**
  28977. * Triggers the load sequence in delayed load mode.
  28978. */
  28979. delayLoad(): void;
  28980. /**
  28981. * Clones the texture.
  28982. * @returns the cloned texture
  28983. */
  28984. clone(): Nullable<BaseTexture>;
  28985. /**
  28986. * Get the texture underlying type (INT, FLOAT...)
  28987. */
  28988. readonly textureType: number;
  28989. /**
  28990. * Get the texture underlying format (RGB, RGBA...)
  28991. */
  28992. readonly textureFormat: number;
  28993. /**
  28994. * Indicates that textures need to be re-calculated for all materials
  28995. */
  28996. protected _markAllSubMeshesAsTexturesDirty(): void;
  28997. /**
  28998. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  28999. * This will returns an RGBA array buffer containing either in values (0-255) or
  29000. * float values (0-1) depending of the underlying buffer type.
  29001. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  29002. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  29003. * @param buffer defines a user defined buffer to fill with data (can be null)
  29004. * @returns The Array buffer containing the pixels data.
  29005. */
  29006. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  29007. /**
  29008. * Release and destroy the underlying lower level texture aka internalTexture.
  29009. */
  29010. releaseInternalTexture(): void;
  29011. /**
  29012. * Get the polynomial representation of the texture data.
  29013. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  29014. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  29015. */
  29016. sphericalPolynomial: Nullable<SphericalPolynomial>;
  29017. /** @hidden */
  29018. readonly _lodTextureHigh: Nullable<BaseTexture>;
  29019. /** @hidden */
  29020. readonly _lodTextureMid: Nullable<BaseTexture>;
  29021. /** @hidden */
  29022. readonly _lodTextureLow: Nullable<BaseTexture>;
  29023. /**
  29024. * Dispose the texture and release its associated resources.
  29025. */
  29026. dispose(): void;
  29027. /**
  29028. * Serialize the texture into a JSON representation that can be parsed later on.
  29029. * @returns the JSON representation of the texture
  29030. */
  29031. serialize(): any;
  29032. /**
  29033. * Helper function to be called back once a list of texture contains only ready textures.
  29034. * @param textures Define the list of textures to wait for
  29035. * @param callback Define the callback triggered once the entire list will be ready
  29036. */
  29037. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  29038. }
  29039. }
  29040. declare module "babylonjs/Materials/effect" {
  29041. import { Observable } from "babylonjs/Misc/observable";
  29042. import { Nullable } from "babylonjs/types";
  29043. import { IDisposable } from "babylonjs/scene";
  29044. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29045. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29046. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  29047. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  29048. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29049. import { Engine } from "babylonjs/Engines/engine";
  29050. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29051. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29052. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29053. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29054. /**
  29055. * Options to be used when creating an effect.
  29056. */
  29057. export class EffectCreationOptions {
  29058. /**
  29059. * Atrributes that will be used in the shader.
  29060. */
  29061. attributes: string[];
  29062. /**
  29063. * Uniform varible names that will be set in the shader.
  29064. */
  29065. uniformsNames: string[];
  29066. /**
  29067. * Uniform buffer varible names that will be set in the shader.
  29068. */
  29069. uniformBuffersNames: string[];
  29070. /**
  29071. * Sampler texture variable names that will be set in the shader.
  29072. */
  29073. samplers: string[];
  29074. /**
  29075. * Define statements that will be set in the shader.
  29076. */
  29077. defines: any;
  29078. /**
  29079. * Possible fallbacks for this effect to improve performance when needed.
  29080. */
  29081. fallbacks: Nullable<IEffectFallbacks>;
  29082. /**
  29083. * Callback that will be called when the shader is compiled.
  29084. */
  29085. onCompiled: Nullable<(effect: Effect) => void>;
  29086. /**
  29087. * Callback that will be called if an error occurs during shader compilation.
  29088. */
  29089. onError: Nullable<(effect: Effect, errors: string) => void>;
  29090. /**
  29091. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29092. */
  29093. indexParameters?: any;
  29094. /**
  29095. * Max number of lights that can be used in the shader.
  29096. */
  29097. maxSimultaneousLights?: number;
  29098. /**
  29099. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29100. */
  29101. transformFeedbackVaryings?: Nullable<string[]>;
  29102. }
  29103. /**
  29104. * Effect containing vertex and fragment shader that can be executed on an object.
  29105. */
  29106. export class Effect implements IDisposable {
  29107. /**
  29108. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29109. */
  29110. static ShadersRepository: string;
  29111. /**
  29112. * Name of the effect.
  29113. */
  29114. name: any;
  29115. /**
  29116. * String container all the define statements that should be set on the shader.
  29117. */
  29118. defines: string;
  29119. /**
  29120. * Callback that will be called when the shader is compiled.
  29121. */
  29122. onCompiled: Nullable<(effect: Effect) => void>;
  29123. /**
  29124. * Callback that will be called if an error occurs during shader compilation.
  29125. */
  29126. onError: Nullable<(effect: Effect, errors: string) => void>;
  29127. /**
  29128. * Callback that will be called when effect is bound.
  29129. */
  29130. onBind: Nullable<(effect: Effect) => void>;
  29131. /**
  29132. * Unique ID of the effect.
  29133. */
  29134. uniqueId: number;
  29135. /**
  29136. * Observable that will be called when the shader is compiled.
  29137. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29138. */
  29139. onCompileObservable: Observable<Effect>;
  29140. /**
  29141. * Observable that will be called if an error occurs during shader compilation.
  29142. */
  29143. onErrorObservable: Observable<Effect>;
  29144. /** @hidden */
  29145. _onBindObservable: Nullable<Observable<Effect>>;
  29146. /**
  29147. * Observable that will be called when effect is bound.
  29148. */
  29149. readonly onBindObservable: Observable<Effect>;
  29150. /** @hidden */
  29151. _bonesComputationForcedToCPU: boolean;
  29152. private static _uniqueIdSeed;
  29153. private _engine;
  29154. private _uniformBuffersNames;
  29155. private _uniformsNames;
  29156. private _samplerList;
  29157. private _samplers;
  29158. private _isReady;
  29159. private _compilationError;
  29160. private _attributesNames;
  29161. private _attributes;
  29162. private _uniforms;
  29163. /**
  29164. * Key for the effect.
  29165. * @hidden
  29166. */
  29167. _key: string;
  29168. private _indexParameters;
  29169. private _fallbacks;
  29170. private _vertexSourceCode;
  29171. private _fragmentSourceCode;
  29172. private _vertexSourceCodeOverride;
  29173. private _fragmentSourceCodeOverride;
  29174. private _transformFeedbackVaryings;
  29175. /**
  29176. * Compiled shader to webGL program.
  29177. * @hidden
  29178. */
  29179. _pipelineContext: Nullable<IPipelineContext>;
  29180. private _valueCache;
  29181. private static _baseCache;
  29182. /**
  29183. * Instantiates an effect.
  29184. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29185. * @param baseName Name of the effect.
  29186. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29187. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29188. * @param samplers List of sampler variables that will be passed to the shader.
  29189. * @param engine Engine to be used to render the effect
  29190. * @param defines Define statements to be added to the shader.
  29191. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29192. * @param onCompiled Callback that will be called when the shader is compiled.
  29193. * @param onError Callback that will be called if an error occurs during shader compilation.
  29194. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29195. */
  29196. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  29197. private _useFinalCode;
  29198. /**
  29199. * Unique key for this effect
  29200. */
  29201. readonly key: string;
  29202. /**
  29203. * If the effect has been compiled and prepared.
  29204. * @returns if the effect is compiled and prepared.
  29205. */
  29206. isReady(): boolean;
  29207. private _isReadyInternal;
  29208. /**
  29209. * The engine the effect was initialized with.
  29210. * @returns the engine.
  29211. */
  29212. getEngine(): Engine;
  29213. /**
  29214. * The pipeline context for this effect
  29215. * @returns the associated pipeline context
  29216. */
  29217. getPipelineContext(): Nullable<IPipelineContext>;
  29218. /**
  29219. * The set of names of attribute variables for the shader.
  29220. * @returns An array of attribute names.
  29221. */
  29222. getAttributesNames(): string[];
  29223. /**
  29224. * Returns the attribute at the given index.
  29225. * @param index The index of the attribute.
  29226. * @returns The location of the attribute.
  29227. */
  29228. getAttributeLocation(index: number): number;
  29229. /**
  29230. * Returns the attribute based on the name of the variable.
  29231. * @param name of the attribute to look up.
  29232. * @returns the attribute location.
  29233. */
  29234. getAttributeLocationByName(name: string): number;
  29235. /**
  29236. * The number of attributes.
  29237. * @returns the numnber of attributes.
  29238. */
  29239. getAttributesCount(): number;
  29240. /**
  29241. * Gets the index of a uniform variable.
  29242. * @param uniformName of the uniform to look up.
  29243. * @returns the index.
  29244. */
  29245. getUniformIndex(uniformName: string): number;
  29246. /**
  29247. * Returns the attribute based on the name of the variable.
  29248. * @param uniformName of the uniform to look up.
  29249. * @returns the location of the uniform.
  29250. */
  29251. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29252. /**
  29253. * Returns an array of sampler variable names
  29254. * @returns The array of sampler variable neames.
  29255. */
  29256. getSamplers(): string[];
  29257. /**
  29258. * The error from the last compilation.
  29259. * @returns the error string.
  29260. */
  29261. getCompilationError(): string;
  29262. /**
  29263. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29264. * @param func The callback to be used.
  29265. */
  29266. executeWhenCompiled(func: (effect: Effect) => void): void;
  29267. private _checkIsReady;
  29268. /** @hidden */
  29269. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29270. /** @hidden */
  29271. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29272. /** @hidden */
  29273. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29274. /**
  29275. * Recompiles the webGL program
  29276. * @param vertexSourceCode The source code for the vertex shader.
  29277. * @param fragmentSourceCode The source code for the fragment shader.
  29278. * @param onCompiled Callback called when completed.
  29279. * @param onError Callback called on error.
  29280. * @hidden
  29281. */
  29282. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  29283. /**
  29284. * Prepares the effect
  29285. * @hidden
  29286. */
  29287. _prepareEffect(): void;
  29288. private _processCompilationErrors;
  29289. /**
  29290. * Checks if the effect is supported. (Must be called after compilation)
  29291. */
  29292. readonly isSupported: boolean;
  29293. /**
  29294. * Binds a texture to the engine to be used as output of the shader.
  29295. * @param channel Name of the output variable.
  29296. * @param texture Texture to bind.
  29297. * @hidden
  29298. */
  29299. _bindTexture(channel: string, texture: InternalTexture): void;
  29300. /**
  29301. * Sets a texture on the engine to be used in the shader.
  29302. * @param channel Name of the sampler variable.
  29303. * @param texture Texture to set.
  29304. */
  29305. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29306. /**
  29307. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29308. * @param channel Name of the sampler variable.
  29309. * @param texture Texture to set.
  29310. */
  29311. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29312. /**
  29313. * Sets an array of textures on the engine to be used in the shader.
  29314. * @param channel Name of the variable.
  29315. * @param textures Textures to set.
  29316. */
  29317. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29318. /**
  29319. * 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)
  29320. * @param channel Name of the sampler variable.
  29321. * @param postProcess Post process to get the input texture from.
  29322. */
  29323. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29324. /**
  29325. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29326. * 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)
  29327. * @param channel Name of the sampler variable.
  29328. * @param postProcess Post process to get the output texture from.
  29329. */
  29330. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29331. /** @hidden */
  29332. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  29333. /** @hidden */
  29334. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29335. /** @hidden */
  29336. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29337. /** @hidden */
  29338. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29339. /**
  29340. * Binds a buffer to a uniform.
  29341. * @param buffer Buffer to bind.
  29342. * @param name Name of the uniform variable to bind to.
  29343. */
  29344. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  29345. /**
  29346. * Binds block to a uniform.
  29347. * @param blockName Name of the block to bind.
  29348. * @param index Index to bind.
  29349. */
  29350. bindUniformBlock(blockName: string, index: number): void;
  29351. /**
  29352. * Sets an interger value on a uniform variable.
  29353. * @param uniformName Name of the variable.
  29354. * @param value Value to be set.
  29355. * @returns this effect.
  29356. */
  29357. setInt(uniformName: string, value: number): Effect;
  29358. /**
  29359. * Sets an int array on a uniform variable.
  29360. * @param uniformName Name of the variable.
  29361. * @param array array to be set.
  29362. * @returns this effect.
  29363. */
  29364. setIntArray(uniformName: string, array: Int32Array): Effect;
  29365. /**
  29366. * 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)
  29367. * @param uniformName Name of the variable.
  29368. * @param array array to be set.
  29369. * @returns this effect.
  29370. */
  29371. setIntArray2(uniformName: string, array: Int32Array): Effect;
  29372. /**
  29373. * 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)
  29374. * @param uniformName Name of the variable.
  29375. * @param array array to be set.
  29376. * @returns this effect.
  29377. */
  29378. setIntArray3(uniformName: string, array: Int32Array): Effect;
  29379. /**
  29380. * 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)
  29381. * @param uniformName Name of the variable.
  29382. * @param array array to be set.
  29383. * @returns this effect.
  29384. */
  29385. setIntArray4(uniformName: string, array: Int32Array): Effect;
  29386. /**
  29387. * Sets an float array on a uniform variable.
  29388. * @param uniformName Name of the variable.
  29389. * @param array array to be set.
  29390. * @returns this effect.
  29391. */
  29392. setFloatArray(uniformName: string, array: Float32Array): Effect;
  29393. /**
  29394. * 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)
  29395. * @param uniformName Name of the variable.
  29396. * @param array array to be set.
  29397. * @returns this effect.
  29398. */
  29399. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  29400. /**
  29401. * 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)
  29402. * @param uniformName Name of the variable.
  29403. * @param array array to be set.
  29404. * @returns this effect.
  29405. */
  29406. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  29407. /**
  29408. * 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)
  29409. * @param uniformName Name of the variable.
  29410. * @param array array to be set.
  29411. * @returns this effect.
  29412. */
  29413. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  29414. /**
  29415. * Sets an array on a uniform variable.
  29416. * @param uniformName Name of the variable.
  29417. * @param array array to be set.
  29418. * @returns this effect.
  29419. */
  29420. setArray(uniformName: string, array: number[]): Effect;
  29421. /**
  29422. * 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)
  29423. * @param uniformName Name of the variable.
  29424. * @param array array to be set.
  29425. * @returns this effect.
  29426. */
  29427. setArray2(uniformName: string, array: number[]): Effect;
  29428. /**
  29429. * 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)
  29430. * @param uniformName Name of the variable.
  29431. * @param array array to be set.
  29432. * @returns this effect.
  29433. */
  29434. setArray3(uniformName: string, array: number[]): Effect;
  29435. /**
  29436. * 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)
  29437. * @param uniformName Name of the variable.
  29438. * @param array array to be set.
  29439. * @returns this effect.
  29440. */
  29441. setArray4(uniformName: string, array: number[]): Effect;
  29442. /**
  29443. * Sets matrices on a uniform variable.
  29444. * @param uniformName Name of the variable.
  29445. * @param matrices matrices to be set.
  29446. * @returns this effect.
  29447. */
  29448. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  29449. /**
  29450. * Sets matrix on a uniform variable.
  29451. * @param uniformName Name of the variable.
  29452. * @param matrix matrix to be set.
  29453. * @returns this effect.
  29454. */
  29455. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  29456. /**
  29457. * 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)
  29458. * @param uniformName Name of the variable.
  29459. * @param matrix matrix to be set.
  29460. * @returns this effect.
  29461. */
  29462. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  29463. /**
  29464. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  29465. * @param uniformName Name of the variable.
  29466. * @param matrix matrix to be set.
  29467. * @returns this effect.
  29468. */
  29469. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  29470. /**
  29471. * Sets a float on a uniform variable.
  29472. * @param uniformName Name of the variable.
  29473. * @param value value to be set.
  29474. * @returns this effect.
  29475. */
  29476. setFloat(uniformName: string, value: number): Effect;
  29477. /**
  29478. * Sets a boolean on a uniform variable.
  29479. * @param uniformName Name of the variable.
  29480. * @param bool value to be set.
  29481. * @returns this effect.
  29482. */
  29483. setBool(uniformName: string, bool: boolean): Effect;
  29484. /**
  29485. * Sets a Vector2 on a uniform variable.
  29486. * @param uniformName Name of the variable.
  29487. * @param vector2 vector2 to be set.
  29488. * @returns this effect.
  29489. */
  29490. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  29491. /**
  29492. * Sets a float2 on a uniform variable.
  29493. * @param uniformName Name of the variable.
  29494. * @param x First float in float2.
  29495. * @param y Second float in float2.
  29496. * @returns this effect.
  29497. */
  29498. setFloat2(uniformName: string, x: number, y: number): Effect;
  29499. /**
  29500. * Sets a Vector3 on a uniform variable.
  29501. * @param uniformName Name of the variable.
  29502. * @param vector3 Value to be set.
  29503. * @returns this effect.
  29504. */
  29505. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  29506. /**
  29507. * Sets a float3 on a uniform variable.
  29508. * @param uniformName Name of the variable.
  29509. * @param x First float in float3.
  29510. * @param y Second float in float3.
  29511. * @param z Third float in float3.
  29512. * @returns this effect.
  29513. */
  29514. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  29515. /**
  29516. * Sets a Vector4 on a uniform variable.
  29517. * @param uniformName Name of the variable.
  29518. * @param vector4 Value to be set.
  29519. * @returns this effect.
  29520. */
  29521. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  29522. /**
  29523. * Sets a float4 on a uniform variable.
  29524. * @param uniformName Name of the variable.
  29525. * @param x First float in float4.
  29526. * @param y Second float in float4.
  29527. * @param z Third float in float4.
  29528. * @param w Fourth float in float4.
  29529. * @returns this effect.
  29530. */
  29531. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  29532. /**
  29533. * Sets a Color3 on a uniform variable.
  29534. * @param uniformName Name of the variable.
  29535. * @param color3 Value to be set.
  29536. * @returns this effect.
  29537. */
  29538. setColor3(uniformName: string, color3: IColor3Like): Effect;
  29539. /**
  29540. * Sets a Color4 on a uniform variable.
  29541. * @param uniformName Name of the variable.
  29542. * @param color3 Value to be set.
  29543. * @param alpha Alpha value to be set.
  29544. * @returns this effect.
  29545. */
  29546. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  29547. /**
  29548. * Sets a Color4 on a uniform variable
  29549. * @param uniformName defines the name of the variable
  29550. * @param color4 defines the value to be set
  29551. * @returns this effect.
  29552. */
  29553. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  29554. /** Release all associated resources */
  29555. dispose(): void;
  29556. /**
  29557. * This function will add a new shader to the shader store
  29558. * @param name the name of the shader
  29559. * @param pixelShader optional pixel shader content
  29560. * @param vertexShader optional vertex shader content
  29561. */
  29562. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  29563. /**
  29564. * Store of each shader (The can be looked up using effect.key)
  29565. */
  29566. static ShadersStore: {
  29567. [key: string]: string;
  29568. };
  29569. /**
  29570. * Store of each included file for a shader (The can be looked up using effect.key)
  29571. */
  29572. static IncludesShadersStore: {
  29573. [key: string]: string;
  29574. };
  29575. /**
  29576. * Resets the cache of effects.
  29577. */
  29578. static ResetCache(): void;
  29579. }
  29580. }
  29581. declare module "babylonjs/Engines/engineCapabilities" {
  29582. import { Nullable } from "babylonjs/types";
  29583. /**
  29584. * Class used to describe the capabilities of the engine relatively to the current browser
  29585. */
  29586. export class EngineCapabilities {
  29587. /** Maximum textures units per fragment shader */
  29588. maxTexturesImageUnits: number;
  29589. /** Maximum texture units per vertex shader */
  29590. maxVertexTextureImageUnits: number;
  29591. /** Maximum textures units in the entire pipeline */
  29592. maxCombinedTexturesImageUnits: number;
  29593. /** Maximum texture size */
  29594. maxTextureSize: number;
  29595. /** Maximum cube texture size */
  29596. maxCubemapTextureSize: number;
  29597. /** Maximum render texture size */
  29598. maxRenderTextureSize: number;
  29599. /** Maximum number of vertex attributes */
  29600. maxVertexAttribs: number;
  29601. /** Maximum number of varyings */
  29602. maxVaryingVectors: number;
  29603. /** Maximum number of uniforms per vertex shader */
  29604. maxVertexUniformVectors: number;
  29605. /** Maximum number of uniforms per fragment shader */
  29606. maxFragmentUniformVectors: number;
  29607. /** Defines if standard derivates (dx/dy) are supported */
  29608. standardDerivatives: boolean;
  29609. /** Defines if s3tc texture compression is supported */
  29610. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  29611. /** Defines if pvrtc texture compression is supported */
  29612. pvrtc: any;
  29613. /** Defines if etc1 texture compression is supported */
  29614. etc1: any;
  29615. /** Defines if etc2 texture compression is supported */
  29616. etc2: any;
  29617. /** Defines if astc texture compression is supported */
  29618. astc: any;
  29619. /** Defines if float textures are supported */
  29620. textureFloat: boolean;
  29621. /** Defines if vertex array objects are supported */
  29622. vertexArrayObject: boolean;
  29623. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  29624. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  29625. /** Gets the maximum level of anisotropy supported */
  29626. maxAnisotropy: number;
  29627. /** Defines if instancing is supported */
  29628. instancedArrays: boolean;
  29629. /** Defines if 32 bits indices are supported */
  29630. uintIndices: boolean;
  29631. /** Defines if high precision shaders are supported */
  29632. highPrecisionShaderSupported: boolean;
  29633. /** Defines if depth reading in the fragment shader is supported */
  29634. fragmentDepthSupported: boolean;
  29635. /** Defines if float texture linear filtering is supported*/
  29636. textureFloatLinearFiltering: boolean;
  29637. /** Defines if rendering to float textures is supported */
  29638. textureFloatRender: boolean;
  29639. /** Defines if half float textures are supported*/
  29640. textureHalfFloat: boolean;
  29641. /** Defines if half float texture linear filtering is supported*/
  29642. textureHalfFloatLinearFiltering: boolean;
  29643. /** Defines if rendering to half float textures is supported */
  29644. textureHalfFloatRender: boolean;
  29645. /** Defines if textureLOD shader command is supported */
  29646. textureLOD: boolean;
  29647. /** Defines if draw buffers extension is supported */
  29648. drawBuffersExtension: boolean;
  29649. /** Defines if depth textures are supported */
  29650. depthTextureExtension: boolean;
  29651. /** Defines if float color buffer are supported */
  29652. colorBufferFloat: boolean;
  29653. /** Gets disjoint timer query extension (null if not supported) */
  29654. timerQuery: EXT_disjoint_timer_query;
  29655. /** Defines if timestamp can be used with timer query */
  29656. canUseTimestampForTimerQuery: boolean;
  29657. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  29658. multiview: any;
  29659. /** Function used to let the system compiles shaders in background */
  29660. parallelShaderCompile: {
  29661. COMPLETION_STATUS_KHR: number;
  29662. };
  29663. /** Max number of texture samples for MSAA */
  29664. maxMSAASamples: number;
  29665. /** Defines if the blend min max extension is supported */
  29666. blendMinMax: boolean;
  29667. }
  29668. }
  29669. declare module "babylonjs/States/depthCullingState" {
  29670. import { Nullable } from "babylonjs/types";
  29671. /**
  29672. * @hidden
  29673. **/
  29674. export class DepthCullingState {
  29675. private _isDepthTestDirty;
  29676. private _isDepthMaskDirty;
  29677. private _isDepthFuncDirty;
  29678. private _isCullFaceDirty;
  29679. private _isCullDirty;
  29680. private _isZOffsetDirty;
  29681. private _isFrontFaceDirty;
  29682. private _depthTest;
  29683. private _depthMask;
  29684. private _depthFunc;
  29685. private _cull;
  29686. private _cullFace;
  29687. private _zOffset;
  29688. private _frontFace;
  29689. /**
  29690. * Initializes the state.
  29691. */
  29692. constructor();
  29693. readonly isDirty: boolean;
  29694. zOffset: number;
  29695. cullFace: Nullable<number>;
  29696. cull: Nullable<boolean>;
  29697. depthFunc: Nullable<number>;
  29698. depthMask: boolean;
  29699. depthTest: boolean;
  29700. frontFace: Nullable<number>;
  29701. reset(): void;
  29702. apply(gl: WebGLRenderingContext): void;
  29703. }
  29704. }
  29705. declare module "babylonjs/States/stencilState" {
  29706. /**
  29707. * @hidden
  29708. **/
  29709. export class StencilState {
  29710. /** 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 */
  29711. static readonly ALWAYS: number;
  29712. /** Passed to stencilOperation to specify that stencil value must be kept */
  29713. static readonly KEEP: number;
  29714. /** Passed to stencilOperation to specify that stencil value must be replaced */
  29715. static readonly REPLACE: number;
  29716. private _isStencilTestDirty;
  29717. private _isStencilMaskDirty;
  29718. private _isStencilFuncDirty;
  29719. private _isStencilOpDirty;
  29720. private _stencilTest;
  29721. private _stencilMask;
  29722. private _stencilFunc;
  29723. private _stencilFuncRef;
  29724. private _stencilFuncMask;
  29725. private _stencilOpStencilFail;
  29726. private _stencilOpDepthFail;
  29727. private _stencilOpStencilDepthPass;
  29728. readonly isDirty: boolean;
  29729. stencilFunc: number;
  29730. stencilFuncRef: number;
  29731. stencilFuncMask: number;
  29732. stencilOpStencilFail: number;
  29733. stencilOpDepthFail: number;
  29734. stencilOpStencilDepthPass: number;
  29735. stencilMask: number;
  29736. stencilTest: boolean;
  29737. constructor();
  29738. reset(): void;
  29739. apply(gl: WebGLRenderingContext): void;
  29740. }
  29741. }
  29742. declare module "babylonjs/States/alphaCullingState" {
  29743. /**
  29744. * @hidden
  29745. **/
  29746. export class AlphaState {
  29747. private _isAlphaBlendDirty;
  29748. private _isBlendFunctionParametersDirty;
  29749. private _isBlendEquationParametersDirty;
  29750. private _isBlendConstantsDirty;
  29751. private _alphaBlend;
  29752. private _blendFunctionParameters;
  29753. private _blendEquationParameters;
  29754. private _blendConstants;
  29755. /**
  29756. * Initializes the state.
  29757. */
  29758. constructor();
  29759. readonly isDirty: boolean;
  29760. alphaBlend: boolean;
  29761. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  29762. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  29763. setAlphaEquationParameters(rgb: number, alpha: number): void;
  29764. reset(): void;
  29765. apply(gl: WebGLRenderingContext): void;
  29766. }
  29767. }
  29768. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  29769. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29770. /** @hidden */
  29771. export class WebGL2ShaderProcessor implements IShaderProcessor {
  29772. attributeProcessor(attribute: string): string;
  29773. varyingProcessor(varying: string, isFragment: boolean): string;
  29774. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  29775. }
  29776. }
  29777. declare module "babylonjs/Engines/instancingAttributeInfo" {
  29778. /**
  29779. * Interface for attribute information associated with buffer instanciation
  29780. */
  29781. export class InstancingAttributeInfo {
  29782. /**
  29783. * Index/offset of the attribute in the vertex shader
  29784. */
  29785. index: number;
  29786. /**
  29787. * size of the attribute, 1, 2, 3 or 4
  29788. */
  29789. attributeSize: number;
  29790. /**
  29791. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  29792. * default is FLOAT
  29793. */
  29794. attribyteType: number;
  29795. /**
  29796. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  29797. */
  29798. normalized: boolean;
  29799. /**
  29800. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  29801. */
  29802. offset: number;
  29803. /**
  29804. * Name of the GLSL attribute, for debugging purpose only
  29805. */
  29806. attributeName: string;
  29807. }
  29808. }
  29809. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  29810. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29811. import { Nullable } from "babylonjs/types";
  29812. module "babylonjs/Engines/thinEngine" {
  29813. interface ThinEngine {
  29814. /**
  29815. * Update a video texture
  29816. * @param texture defines the texture to update
  29817. * @param video defines the video element to use
  29818. * @param invertY defines if data must be stored with Y axis inverted
  29819. */
  29820. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29821. }
  29822. }
  29823. }
  29824. declare module "babylonjs/Materials/Textures/videoTexture" {
  29825. import { Observable } from "babylonjs/Misc/observable";
  29826. import { Nullable } from "babylonjs/types";
  29827. import { Scene } from "babylonjs/scene";
  29828. import { Texture } from "babylonjs/Materials/Textures/texture";
  29829. import "babylonjs/Engines/Extensions/engine.videoTexture";
  29830. /**
  29831. * Settings for finer control over video usage
  29832. */
  29833. export interface VideoTextureSettings {
  29834. /**
  29835. * Applies `autoplay` to video, if specified
  29836. */
  29837. autoPlay?: boolean;
  29838. /**
  29839. * Applies `loop` to video, if specified
  29840. */
  29841. loop?: boolean;
  29842. /**
  29843. * Automatically updates internal texture from video at every frame in the render loop
  29844. */
  29845. autoUpdateTexture: boolean;
  29846. /**
  29847. * Image src displayed during the video loading or until the user interacts with the video.
  29848. */
  29849. poster?: string;
  29850. }
  29851. /**
  29852. * If you want to display a video in your scene, this is the special texture for that.
  29853. * This special texture works similar to other textures, with the exception of a few parameters.
  29854. * @see https://doc.babylonjs.com/how_to/video_texture
  29855. */
  29856. export class VideoTexture extends Texture {
  29857. /**
  29858. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  29859. */
  29860. readonly autoUpdateTexture: boolean;
  29861. /**
  29862. * The video instance used by the texture internally
  29863. */
  29864. readonly video: HTMLVideoElement;
  29865. private _onUserActionRequestedObservable;
  29866. /**
  29867. * Event triggerd when a dom action is required by the user to play the video.
  29868. * This happens due to recent changes in browser policies preventing video to auto start.
  29869. */
  29870. readonly onUserActionRequestedObservable: Observable<Texture>;
  29871. private _generateMipMaps;
  29872. private _engine;
  29873. private _stillImageCaptured;
  29874. private _displayingPosterTexture;
  29875. private _settings;
  29876. private _createInternalTextureOnEvent;
  29877. private _frameId;
  29878. /**
  29879. * Creates a video texture.
  29880. * If you want to display a video in your scene, this is the special texture for that.
  29881. * This special texture works similar to other textures, with the exception of a few parameters.
  29882. * @see https://doc.babylonjs.com/how_to/video_texture
  29883. * @param name optional name, will detect from video source, if not defined
  29884. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  29885. * @param scene is obviously the current scene.
  29886. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  29887. * @param invertY is false by default but can be used to invert video on Y axis
  29888. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  29889. * @param settings allows finer control over video usage
  29890. */
  29891. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  29892. private _getName;
  29893. private _getVideo;
  29894. private _createInternalTexture;
  29895. private reset;
  29896. /**
  29897. * @hidden Internal method to initiate `update`.
  29898. */
  29899. _rebuild(): void;
  29900. /**
  29901. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  29902. */
  29903. update(): void;
  29904. /**
  29905. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  29906. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  29907. */
  29908. updateTexture(isVisible: boolean): void;
  29909. protected _updateInternalTexture: () => void;
  29910. /**
  29911. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  29912. * @param url New url.
  29913. */
  29914. updateURL(url: string): void;
  29915. /**
  29916. * Dispose the texture and release its associated resources.
  29917. */
  29918. dispose(): void;
  29919. /**
  29920. * Creates a video texture straight from a stream.
  29921. * @param scene Define the scene the texture should be created in
  29922. * @param stream Define the stream the texture should be created from
  29923. * @returns The created video texture as a promise
  29924. */
  29925. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  29926. /**
  29927. * Creates a video texture straight from your WebCam video feed.
  29928. * @param scene Define the scene the texture should be created in
  29929. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29930. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29931. * @returns The created video texture as a promise
  29932. */
  29933. static CreateFromWebCamAsync(scene: Scene, constraints: {
  29934. minWidth: number;
  29935. maxWidth: number;
  29936. minHeight: number;
  29937. maxHeight: number;
  29938. deviceId: string;
  29939. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  29940. /**
  29941. * Creates a video texture straight from your WebCam video feed.
  29942. * @param scene Define the scene the texture should be created in
  29943. * @param onReady Define a callback to triggered once the texture will be ready
  29944. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  29945. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  29946. */
  29947. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  29948. minWidth: number;
  29949. maxWidth: number;
  29950. minHeight: number;
  29951. maxHeight: number;
  29952. deviceId: string;
  29953. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  29954. }
  29955. }
  29956. declare module "babylonjs/Engines/thinEngine" {
  29957. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  29958. import { Effect, EffectCreationOptions } from "babylonjs/Materials/effect";
  29959. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  29960. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  29961. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  29962. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  29963. import { Observable } from "babylonjs/Misc/observable";
  29964. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  29965. import { StencilState } from "babylonjs/States/stencilState";
  29966. import { AlphaState } from "babylonjs/States/alphaCullingState";
  29967. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29968. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  29969. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  29970. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  29971. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  29972. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  29973. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29974. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  29975. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  29976. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29977. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  29978. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  29979. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  29980. /**
  29981. * Defines the interface used by objects working like Scene
  29982. * @hidden
  29983. */
  29984. interface ISceneLike {
  29985. _addPendingData(data: any): void;
  29986. _removePendingData(data: any): void;
  29987. offlineProvider: IOfflineProvider;
  29988. }
  29989. /** Interface defining initialization parameters for Engine class */
  29990. export interface EngineOptions extends WebGLContextAttributes {
  29991. /**
  29992. * Defines if the engine should no exceed a specified device ratio
  29993. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  29994. */
  29995. limitDeviceRatio?: number;
  29996. /**
  29997. * Defines if webvr should be enabled automatically
  29998. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29999. */
  30000. autoEnableWebVR?: boolean;
  30001. /**
  30002. * Defines if webgl2 should be turned off even if supported
  30003. * @see http://doc.babylonjs.com/features/webgl2
  30004. */
  30005. disableWebGL2Support?: boolean;
  30006. /**
  30007. * Defines if webaudio should be initialized as well
  30008. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  30009. */
  30010. audioEngine?: boolean;
  30011. /**
  30012. * Defines if animations should run using a deterministic lock step
  30013. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  30014. */
  30015. deterministicLockstep?: boolean;
  30016. /** Defines the maximum steps to use with deterministic lock step mode */
  30017. lockstepMaxSteps?: number;
  30018. /**
  30019. * Defines that engine should ignore context lost events
  30020. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  30021. */
  30022. doNotHandleContextLost?: boolean;
  30023. /**
  30024. * Defines that engine should ignore modifying touch action attribute and style
  30025. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  30026. */
  30027. doNotHandleTouchAction?: boolean;
  30028. /**
  30029. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  30030. */
  30031. useHighPrecisionFloats?: boolean;
  30032. }
  30033. /**
  30034. * The base engine class (root of all engines)
  30035. */
  30036. export class ThinEngine {
  30037. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  30038. static ExceptionList: ({
  30039. key: string;
  30040. capture: string;
  30041. captureConstraint: number;
  30042. targets: string[];
  30043. } | {
  30044. key: string;
  30045. capture: null;
  30046. captureConstraint: null;
  30047. targets: string[];
  30048. })[];
  30049. /** @hidden */
  30050. static _TextureLoaders: IInternalTextureLoader[];
  30051. /**
  30052. * Returns the current npm package of the sdk
  30053. */
  30054. static readonly NpmPackage: string;
  30055. /**
  30056. * Returns the current version of the framework
  30057. */
  30058. static readonly Version: string;
  30059. /**
  30060. * Returns a string describing the current engine
  30061. */
  30062. readonly description: string;
  30063. /**
  30064. * Gets or sets the epsilon value used by collision engine
  30065. */
  30066. static CollisionsEpsilon: number;
  30067. /**
  30068. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  30069. */
  30070. static ShadersRepository: string;
  30071. /** @hidden */
  30072. _shaderProcessor: IShaderProcessor;
  30073. /**
  30074. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  30075. */
  30076. forcePOTTextures: boolean;
  30077. /**
  30078. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  30079. */
  30080. isFullscreen: boolean;
  30081. /**
  30082. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  30083. */
  30084. cullBackFaces: boolean;
  30085. /**
  30086. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  30087. */
  30088. renderEvenInBackground: boolean;
  30089. /**
  30090. * Gets or sets a boolean indicating that cache can be kept between frames
  30091. */
  30092. preventCacheWipeBetweenFrames: boolean;
  30093. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  30094. validateShaderPrograms: boolean;
  30095. /**
  30096. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  30097. */
  30098. disableUniformBuffers: boolean;
  30099. /** @hidden */
  30100. _uniformBuffers: UniformBuffer[];
  30101. /**
  30102. * Gets a boolean indicating that the engine supports uniform buffers
  30103. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  30104. */
  30105. readonly supportsUniformBuffers: boolean;
  30106. /** @hidden */
  30107. _gl: WebGLRenderingContext;
  30108. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  30109. protected _windowIsBackground: boolean;
  30110. protected _webGLVersion: number;
  30111. protected _highPrecisionShadersAllowed: boolean;
  30112. /** @hidden */
  30113. readonly _shouldUseHighPrecisionShader: boolean;
  30114. /**
  30115. * Gets a boolean indicating that only power of 2 textures are supported
  30116. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  30117. */
  30118. readonly needPOTTextures: boolean;
  30119. /** @hidden */
  30120. _badOS: boolean;
  30121. /** @hidden */
  30122. _badDesktopOS: boolean;
  30123. private _hardwareScalingLevel;
  30124. /** @hidden */
  30125. _caps: EngineCapabilities;
  30126. private _isStencilEnable;
  30127. protected _colorWrite: boolean;
  30128. private _glVersion;
  30129. private _glRenderer;
  30130. private _glVendor;
  30131. /** @hidden */
  30132. _videoTextureSupported: boolean;
  30133. protected _renderingQueueLaunched: boolean;
  30134. protected _activeRenderLoops: (() => void)[];
  30135. /**
  30136. * Observable signaled when a context lost event is raised
  30137. */
  30138. onContextLostObservable: Observable<ThinEngine>;
  30139. /**
  30140. * Observable signaled when a context restored event is raised
  30141. */
  30142. onContextRestoredObservable: Observable<ThinEngine>;
  30143. private _onContextLost;
  30144. private _onContextRestored;
  30145. protected _contextWasLost: boolean;
  30146. /** @hidden */
  30147. _doNotHandleContextLost: boolean;
  30148. /**
  30149. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  30150. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  30151. */
  30152. doNotHandleContextLost: boolean;
  30153. /**
  30154. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  30155. */
  30156. disableVertexArrayObjects: boolean;
  30157. /** @hidden */
  30158. protected _depthCullingState: DepthCullingState;
  30159. /** @hidden */
  30160. protected _stencilState: StencilState;
  30161. /** @hidden */
  30162. protected _alphaState: AlphaState;
  30163. /** @hidden */
  30164. _internalTexturesCache: InternalTexture[];
  30165. /** @hidden */
  30166. protected _activeChannel: number;
  30167. private _currentTextureChannel;
  30168. /** @hidden */
  30169. protected _boundTexturesCache: {
  30170. [key: string]: Nullable<InternalTexture>;
  30171. };
  30172. /** @hidden */
  30173. protected _currentEffect: Nullable<Effect>;
  30174. /** @hidden */
  30175. protected _currentProgram: Nullable<WebGLProgram>;
  30176. private _compiledEffects;
  30177. private _vertexAttribArraysEnabled;
  30178. /** @hidden */
  30179. protected _cachedViewport: Nullable<IViewportLike>;
  30180. private _cachedVertexArrayObject;
  30181. /** @hidden */
  30182. protected _cachedVertexBuffers: any;
  30183. /** @hidden */
  30184. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  30185. /** @hidden */
  30186. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  30187. /** @hidden */
  30188. _currentRenderTarget: Nullable<InternalTexture>;
  30189. private _uintIndicesCurrentlySet;
  30190. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  30191. /** @hidden */
  30192. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  30193. private _currentBufferPointers;
  30194. private _currentInstanceLocations;
  30195. private _currentInstanceBuffers;
  30196. private _textureUnits;
  30197. /** @hidden */
  30198. _workingCanvas: Nullable<HTMLCanvasElement>;
  30199. /** @hidden */
  30200. _workingContext: Nullable<CanvasRenderingContext2D>;
  30201. /** @hidden */
  30202. _bindedRenderFunction: any;
  30203. private _vaoRecordInProgress;
  30204. private _mustWipeVertexAttributes;
  30205. private _emptyTexture;
  30206. private _emptyCubeTexture;
  30207. private _emptyTexture3D;
  30208. /** @hidden */
  30209. _frameHandler: number;
  30210. private _nextFreeTextureSlots;
  30211. private _maxSimultaneousTextures;
  30212. private _activeRequests;
  30213. protected _texturesSupported: string[];
  30214. /** @hidden */
  30215. _textureFormatInUse: Nullable<string>;
  30216. protected readonly _supportsHardwareTextureRescaling: boolean;
  30217. /**
  30218. * Gets the list of texture formats supported
  30219. */
  30220. readonly texturesSupported: Array<string>;
  30221. /**
  30222. * Gets the list of texture formats in use
  30223. */
  30224. readonly textureFormatInUse: Nullable<string>;
  30225. /**
  30226. * Gets the current viewport
  30227. */
  30228. readonly currentViewport: Nullable<IViewportLike>;
  30229. /**
  30230. * Gets the default empty texture
  30231. */
  30232. readonly emptyTexture: InternalTexture;
  30233. /**
  30234. * Gets the default empty 3D texture
  30235. */
  30236. readonly emptyTexture3D: InternalTexture;
  30237. /**
  30238. * Gets the default empty cube texture
  30239. */
  30240. readonly emptyCubeTexture: InternalTexture;
  30241. /**
  30242. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  30243. */
  30244. readonly premultipliedAlpha: boolean;
  30245. /**
  30246. * Creates a new engine
  30247. * @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
  30248. * @param antialias defines enable antialiasing (default: false)
  30249. * @param options defines further options to be sent to the getContext() function
  30250. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  30251. */
  30252. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  30253. private _rebuildInternalTextures;
  30254. private _rebuildEffects;
  30255. /**
  30256. * Gets a boolean indicating if all created effects are ready
  30257. * @returns true if all effects are ready
  30258. */
  30259. areAllEffectsReady(): boolean;
  30260. protected _rebuildBuffers(): void;
  30261. private _initGLContext;
  30262. /**
  30263. * Gets version of the current webGL context
  30264. */
  30265. readonly webGLVersion: number;
  30266. /**
  30267. * Gets a string idenfifying the name of the class
  30268. * @returns "Engine" string
  30269. */
  30270. getClassName(): string;
  30271. /**
  30272. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  30273. */
  30274. readonly isStencilEnable: boolean;
  30275. /** @hidden */
  30276. _prepareWorkingCanvas(): void;
  30277. /**
  30278. * Reset the texture cache to empty state
  30279. */
  30280. resetTextureCache(): void;
  30281. /**
  30282. * Gets an object containing information about the current webGL context
  30283. * @returns an object containing the vender, the renderer and the version of the current webGL context
  30284. */
  30285. getGlInfo(): {
  30286. vendor: string;
  30287. renderer: string;
  30288. version: string;
  30289. };
  30290. /**
  30291. * Defines the hardware scaling level.
  30292. * By default the hardware scaling level is computed from the window device ratio.
  30293. * 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.
  30294. * @param level defines the level to use
  30295. */
  30296. setHardwareScalingLevel(level: number): void;
  30297. /**
  30298. * Gets the current hardware scaling level.
  30299. * By default the hardware scaling level is computed from the window device ratio.
  30300. * 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.
  30301. * @returns a number indicating the current hardware scaling level
  30302. */
  30303. getHardwareScalingLevel(): number;
  30304. /**
  30305. * Gets the list of loaded textures
  30306. * @returns an array containing all loaded textures
  30307. */
  30308. getLoadedTexturesCache(): InternalTexture[];
  30309. /**
  30310. * Gets the object containing all engine capabilities
  30311. * @returns the EngineCapabilities object
  30312. */
  30313. getCaps(): EngineCapabilities;
  30314. /**
  30315. * stop executing a render loop function and remove it from the execution array
  30316. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  30317. */
  30318. stopRenderLoop(renderFunction?: () => void): void;
  30319. /** @hidden */
  30320. _renderLoop(): void;
  30321. /**
  30322. * Gets the HTML canvas attached with the current webGL context
  30323. * @returns a HTML canvas
  30324. */
  30325. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  30326. /**
  30327. * Gets host window
  30328. * @returns the host window object
  30329. */
  30330. getHostWindow(): Window;
  30331. /**
  30332. * Gets the current render width
  30333. * @param useScreen defines if screen size must be used (or the current render target if any)
  30334. * @returns a number defining the current render width
  30335. */
  30336. getRenderWidth(useScreen?: boolean): number;
  30337. /**
  30338. * Gets the current render height
  30339. * @param useScreen defines if screen size must be used (or the current render target if any)
  30340. * @returns a number defining the current render height
  30341. */
  30342. getRenderHeight(useScreen?: boolean): number;
  30343. /**
  30344. * Can be used to override the current requestAnimationFrame requester.
  30345. * @hidden
  30346. */
  30347. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  30348. /**
  30349. * Register and execute a render loop. The engine can have more than one render function
  30350. * @param renderFunction defines the function to continuously execute
  30351. */
  30352. runRenderLoop(renderFunction: () => void): void;
  30353. /**
  30354. * Clear the current render buffer or the current render target (if any is set up)
  30355. * @param color defines the color to use
  30356. * @param backBuffer defines if the back buffer must be cleared
  30357. * @param depth defines if the depth buffer must be cleared
  30358. * @param stencil defines if the stencil buffer must be cleared
  30359. */
  30360. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  30361. private _viewportCached;
  30362. /** @hidden */
  30363. _viewport(x: number, y: number, width: number, height: number): void;
  30364. /**
  30365. * Set the WebGL's viewport
  30366. * @param viewport defines the viewport element to be used
  30367. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  30368. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  30369. */
  30370. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  30371. /**
  30372. * Begin a new frame
  30373. */
  30374. beginFrame(): void;
  30375. /**
  30376. * Enf the current frame
  30377. */
  30378. endFrame(): void;
  30379. /**
  30380. * Resize the view according to the canvas' size
  30381. */
  30382. resize(): void;
  30383. /**
  30384. * Force a specific size of the canvas
  30385. * @param width defines the new canvas' width
  30386. * @param height defines the new canvas' height
  30387. */
  30388. setSize(width: number, height: number): void;
  30389. /**
  30390. * Binds the frame buffer to the specified texture.
  30391. * @param texture The texture to render to or null for the default canvas
  30392. * @param faceIndex The face of the texture to render to in case of cube texture
  30393. * @param requiredWidth The width of the target to render to
  30394. * @param requiredHeight The height of the target to render to
  30395. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  30396. * @param depthStencilTexture The depth stencil texture to use to render
  30397. * @param lodLevel defines le lod level to bind to the frame buffer
  30398. */
  30399. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  30400. /** @hidden */
  30401. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  30402. /**
  30403. * Unbind the current render target texture from the webGL context
  30404. * @param texture defines the render target texture to unbind
  30405. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  30406. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  30407. */
  30408. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  30409. /**
  30410. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  30411. */
  30412. flushFramebuffer(): void;
  30413. /**
  30414. * Unbind the current render target and bind the default framebuffer
  30415. */
  30416. restoreDefaultFramebuffer(): void;
  30417. private _resetVertexBufferBinding;
  30418. /**
  30419. * Creates a vertex buffer
  30420. * @param data the data for the vertex buffer
  30421. * @returns the new WebGL static buffer
  30422. */
  30423. createVertexBuffer(data: DataArray): DataBuffer;
  30424. private _createVertexBuffer;
  30425. /**
  30426. * Creates a dynamic vertex buffer
  30427. * @param data the data for the dynamic vertex buffer
  30428. * @returns the new WebGL dynamic buffer
  30429. */
  30430. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  30431. /**
  30432. * Updates a dynamic vertex buffer.
  30433. * @param vertexBuffer the vertex buffer to update
  30434. * @param data the data used to update the vertex buffer
  30435. * @param byteOffset the byte offset of the data
  30436. * @param byteLength the byte length of the data
  30437. */
  30438. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  30439. protected _resetIndexBufferBinding(): void;
  30440. /**
  30441. * Creates a new index buffer
  30442. * @param indices defines the content of the index buffer
  30443. * @param updatable defines if the index buffer must be updatable
  30444. * @returns a new webGL buffer
  30445. */
  30446. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  30447. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  30448. /**
  30449. * Bind a webGL buffer to the webGL context
  30450. * @param buffer defines the buffer to bind
  30451. */
  30452. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  30453. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  30454. private bindBuffer;
  30455. /**
  30456. * update the bound buffer with the given data
  30457. * @param data defines the data to update
  30458. */
  30459. updateArrayBuffer(data: Float32Array): void;
  30460. private _vertexAttribPointer;
  30461. private _bindIndexBufferWithCache;
  30462. private _bindVertexBuffersAttributes;
  30463. /**
  30464. * Records a vertex array object
  30465. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30466. * @param vertexBuffers defines the list of vertex buffers to store
  30467. * @param indexBuffer defines the index buffer to store
  30468. * @param effect defines the effect to store
  30469. * @returns the new vertex array object
  30470. */
  30471. recordVertexArrayObject(vertexBuffers: {
  30472. [key: string]: VertexBuffer;
  30473. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  30474. /**
  30475. * Bind a specific vertex array object
  30476. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  30477. * @param vertexArrayObject defines the vertex array object to bind
  30478. * @param indexBuffer defines the index buffer to bind
  30479. */
  30480. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  30481. /**
  30482. * Bind webGl buffers directly to the webGL context
  30483. * @param vertexBuffer defines the vertex buffer to bind
  30484. * @param indexBuffer defines the index buffer to bind
  30485. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  30486. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  30487. * @param effect defines the effect associated with the vertex buffer
  30488. */
  30489. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  30490. private _unbindVertexArrayObject;
  30491. /**
  30492. * Bind a list of vertex buffers to the webGL context
  30493. * @param vertexBuffers defines the list of vertex buffers to bind
  30494. * @param indexBuffer defines the index buffer to bind
  30495. * @param effect defines the effect associated with the vertex buffers
  30496. */
  30497. bindBuffers(vertexBuffers: {
  30498. [key: string]: Nullable<VertexBuffer>;
  30499. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  30500. /**
  30501. * Unbind all instance attributes
  30502. */
  30503. unbindInstanceAttributes(): void;
  30504. /**
  30505. * Release and free the memory of a vertex array object
  30506. * @param vao defines the vertex array object to delete
  30507. */
  30508. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  30509. /** @hidden */
  30510. _releaseBuffer(buffer: DataBuffer): boolean;
  30511. protected _deleteBuffer(buffer: DataBuffer): void;
  30512. /**
  30513. * Creates a webGL buffer to use with instanciation
  30514. * @param capacity defines the size of the buffer
  30515. * @returns the webGL buffer
  30516. */
  30517. createInstancesBuffer(capacity: number): DataBuffer;
  30518. /**
  30519. * Delete a webGL buffer used with instanciation
  30520. * @param buffer defines the webGL buffer to delete
  30521. */
  30522. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  30523. /**
  30524. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  30525. * @param instancesBuffer defines the webGL buffer to update and bind
  30526. * @param data defines the data to store in the buffer
  30527. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  30528. */
  30529. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  30530. /**
  30531. * Apply all cached states (depth, culling, stencil and alpha)
  30532. */
  30533. applyStates(): void;
  30534. /**
  30535. * Send a draw order
  30536. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30537. * @param indexStart defines the starting index
  30538. * @param indexCount defines the number of index to draw
  30539. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30540. */
  30541. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  30542. /**
  30543. * Draw a list of points
  30544. * @param verticesStart defines the index of first vertex to draw
  30545. * @param verticesCount defines the count of vertices to draw
  30546. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30547. */
  30548. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30549. /**
  30550. * Draw a list of unindexed primitives
  30551. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  30552. * @param verticesStart defines the index of first vertex to draw
  30553. * @param verticesCount defines the count of vertices to draw
  30554. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30555. */
  30556. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30557. /**
  30558. * Draw a list of indexed primitives
  30559. * @param fillMode defines the primitive to use
  30560. * @param indexStart defines the starting index
  30561. * @param indexCount defines the number of index to draw
  30562. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30563. */
  30564. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  30565. /**
  30566. * Draw a list of unindexed primitives
  30567. * @param fillMode defines the primitive to use
  30568. * @param verticesStart defines the index of first vertex to draw
  30569. * @param verticesCount defines the count of vertices to draw
  30570. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  30571. */
  30572. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  30573. private _drawMode;
  30574. /** @hidden */
  30575. protected _reportDrawCall(): void;
  30576. /** @hidden */
  30577. _releaseEffect(effect: Effect): void;
  30578. /** @hidden */
  30579. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  30580. /**
  30581. * Create a new effect (used to store vertex/fragment shaders)
  30582. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  30583. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  30584. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  30585. * @param samplers defines an array of string used to represent textures
  30586. * @param defines defines the string containing the defines to use to compile the shaders
  30587. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  30588. * @param onCompiled defines a function to call when the effect creation is successful
  30589. * @param onError defines a function to call when the effect creation has failed
  30590. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  30591. * @returns the new Effect
  30592. */
  30593. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  30594. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  30595. private _compileShader;
  30596. private _compileRawShader;
  30597. /**
  30598. * Directly creates a webGL program
  30599. * @param pipelineContext defines the pipeline context to attach to
  30600. * @param vertexCode defines the vertex shader code to use
  30601. * @param fragmentCode defines the fragment shader code to use
  30602. * @param context defines the webGL context to use (if not set, the current one will be used)
  30603. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30604. * @returns the new webGL program
  30605. */
  30606. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30607. /**
  30608. * Creates a webGL program
  30609. * @param pipelineContext defines the pipeline context to attach to
  30610. * @param vertexCode defines the vertex shader code to use
  30611. * @param fragmentCode defines the fragment shader code to use
  30612. * @param defines defines the string containing the defines to use to compile the shaders
  30613. * @param context defines the webGL context to use (if not set, the current one will be used)
  30614. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30615. * @returns the new webGL program
  30616. */
  30617. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30618. /**
  30619. * Creates a new pipeline context
  30620. * @returns the new pipeline
  30621. */
  30622. createPipelineContext(): IPipelineContext;
  30623. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  30624. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  30625. /** @hidden */
  30626. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  30627. /** @hidden */
  30628. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  30629. /** @hidden */
  30630. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  30631. /**
  30632. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30633. * @param pipelineContext defines the pipeline context to use
  30634. * @param uniformsNames defines the list of uniform names
  30635. * @returns an array of webGL uniform locations
  30636. */
  30637. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  30638. /**
  30639. * Gets the lsit of active attributes for a given webGL program
  30640. * @param pipelineContext defines the pipeline context to use
  30641. * @param attributesNames defines the list of attribute names to get
  30642. * @returns an array of indices indicating the offset of each attribute
  30643. */
  30644. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  30645. /**
  30646. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30647. * @param effect defines the effect to activate
  30648. */
  30649. enableEffect(effect: Nullable<Effect>): void;
  30650. /**
  30651. * Set the value of an uniform to an array of int32
  30652. * @param uniform defines the webGL uniform location where to store the value
  30653. * @param array defines the array of int32 to store
  30654. */
  30655. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30656. /**
  30657. * Set the value of an uniform to an array of int32 (stored as vec2)
  30658. * @param uniform defines the webGL uniform location where to store the value
  30659. * @param array defines the array of int32 to store
  30660. */
  30661. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30662. /**
  30663. * Set the value of an uniform to an array of int32 (stored as vec3)
  30664. * @param uniform defines the webGL uniform location where to store the value
  30665. * @param array defines the array of int32 to store
  30666. */
  30667. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30668. /**
  30669. * Set the value of an uniform to an array of int32 (stored as vec4)
  30670. * @param uniform defines the webGL uniform location where to store the value
  30671. * @param array defines the array of int32 to store
  30672. */
  30673. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  30674. /**
  30675. * Set the value of an uniform to an array of float32
  30676. * @param uniform defines the webGL uniform location where to store the value
  30677. * @param array defines the array of float32 to store
  30678. */
  30679. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30680. /**
  30681. * Set the value of an uniform to an array of float32 (stored as vec2)
  30682. * @param uniform defines the webGL uniform location where to store the value
  30683. * @param array defines the array of float32 to store
  30684. */
  30685. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30686. /**
  30687. * Set the value of an uniform to an array of float32 (stored as vec3)
  30688. * @param uniform defines the webGL uniform location where to store the value
  30689. * @param array defines the array of float32 to store
  30690. */
  30691. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30692. /**
  30693. * Set the value of an uniform to an array of float32 (stored as vec4)
  30694. * @param uniform defines the webGL uniform location where to store the value
  30695. * @param array defines the array of float32 to store
  30696. */
  30697. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  30698. /**
  30699. * Set the value of an uniform to an array of number
  30700. * @param uniform defines the webGL uniform location where to store the value
  30701. * @param array defines the array of number to store
  30702. */
  30703. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30704. /**
  30705. * Set the value of an uniform to an array of number (stored as vec2)
  30706. * @param uniform defines the webGL uniform location where to store the value
  30707. * @param array defines the array of number to store
  30708. */
  30709. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30710. /**
  30711. * Set the value of an uniform to an array of number (stored as vec3)
  30712. * @param uniform defines the webGL uniform location where to store the value
  30713. * @param array defines the array of number to store
  30714. */
  30715. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30716. /**
  30717. * Set the value of an uniform to an array of number (stored as vec4)
  30718. * @param uniform defines the webGL uniform location where to store the value
  30719. * @param array defines the array of number to store
  30720. */
  30721. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  30722. /**
  30723. * Set the value of an uniform to an array of float32 (stored as matrices)
  30724. * @param uniform defines the webGL uniform location where to store the value
  30725. * @param matrices defines the array of float32 to store
  30726. */
  30727. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  30728. /**
  30729. * Set the value of an uniform to a matrix (3x3)
  30730. * @param uniform defines the webGL uniform location where to store the value
  30731. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30732. */
  30733. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30734. /**
  30735. * Set the value of an uniform to a matrix (2x2)
  30736. * @param uniform defines the webGL uniform location where to store the value
  30737. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30738. */
  30739. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  30740. /**
  30741. * Set the value of an uniform to a number (int)
  30742. * @param uniform defines the webGL uniform location where to store the value
  30743. * @param value defines the int number to store
  30744. */
  30745. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30746. /**
  30747. * Set the value of an uniform to a number (float)
  30748. * @param uniform defines the webGL uniform location where to store the value
  30749. * @param value defines the float number to store
  30750. */
  30751. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  30752. /**
  30753. * Set the value of an uniform to a vec2
  30754. * @param uniform defines the webGL uniform location where to store the value
  30755. * @param x defines the 1st component of the value
  30756. * @param y defines the 2nd component of the value
  30757. */
  30758. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  30759. /**
  30760. * Set the value of an uniform to a vec3
  30761. * @param uniform defines the webGL uniform location where to store the value
  30762. * @param x defines the 1st component of the value
  30763. * @param y defines the 2nd component of the value
  30764. * @param z defines the 3rd component of the value
  30765. */
  30766. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  30767. /**
  30768. * Set the value of an uniform to a boolean
  30769. * @param uniform defines the webGL uniform location where to store the value
  30770. * @param bool defines the boolean to store
  30771. */
  30772. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  30773. /**
  30774. * Set the value of an uniform to a vec4
  30775. * @param uniform defines the webGL uniform location where to store the value
  30776. * @param x defines the 1st component of the value
  30777. * @param y defines the 2nd component of the value
  30778. * @param z defines the 3rd component of the value
  30779. * @param w defines the 4th component of the value
  30780. */
  30781. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  30782. /**
  30783. * Sets a Color4 on a uniform variable
  30784. * @param uniform defines the uniform location
  30785. * @param color4 defines the value to be set
  30786. */
  30787. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  30788. /**
  30789. * Gets the depth culling state manager
  30790. */
  30791. readonly depthCullingState: DepthCullingState;
  30792. /**
  30793. * Gets the alpha state manager
  30794. */
  30795. readonly alphaState: AlphaState;
  30796. /**
  30797. * Gets the stencil state manager
  30798. */
  30799. readonly stencilState: StencilState;
  30800. /**
  30801. * Clears the list of texture accessible through engine.
  30802. * This can help preventing texture load conflict due to name collision.
  30803. */
  30804. clearInternalTexturesCache(): void;
  30805. /**
  30806. * Force the entire cache to be cleared
  30807. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30808. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30809. */
  30810. wipeCaches(bruteForce?: boolean): void;
  30811. /** @hidden */
  30812. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  30813. min: number;
  30814. mag: number;
  30815. };
  30816. /** @hidden */
  30817. _createTexture(): WebGLTexture;
  30818. /**
  30819. * Usually called from Texture.ts.
  30820. * Passed information to create a WebGLTexture
  30821. * @param urlArg defines a value which contains one of the following:
  30822. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30823. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30824. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30825. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30826. * @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)
  30827. * @param scene needed for loading to the correct scene
  30828. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30829. * @param onLoad optional callback to be called upon successful completion
  30830. * @param onError optional callback to be called upon failure
  30831. * @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
  30832. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30833. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30834. * @param forcedExtension defines the extension to use to pick the right loader
  30835. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30836. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30837. */
  30838. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  30839. /**
  30840. * @hidden
  30841. */
  30842. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  30843. /**
  30844. * Creates a raw texture
  30845. * @param data defines the data to store in the texture
  30846. * @param width defines the width of the texture
  30847. * @param height defines the height of the texture
  30848. * @param format defines the format of the data
  30849. * @param generateMipMaps defines if the engine should generate the mip levels
  30850. * @param invertY defines if data must be stored with Y axis inverted
  30851. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  30852. * @param compression defines the compression used (null by default)
  30853. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  30854. * @returns the raw texture inside an InternalTexture
  30855. */
  30856. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  30857. /**
  30858. * Creates a new raw cube texture
  30859. * @param data defines the array of data to use to create each face
  30860. * @param size defines the size of the textures
  30861. * @param format defines the format of the data
  30862. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  30863. * @param generateMipMaps defines if the engine should generate the mip levels
  30864. * @param invertY defines if data must be stored with Y axis inverted
  30865. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30866. * @param compression defines the compression used (null by default)
  30867. * @returns the cube texture as an InternalTexture
  30868. */
  30869. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  30870. /**
  30871. * Creates a new raw 3D texture
  30872. * @param data defines the data used to create the texture
  30873. * @param width defines the width of the texture
  30874. * @param height defines the height of the texture
  30875. * @param depth defines the depth of the texture
  30876. * @param format defines the format of the texture
  30877. * @param generateMipMaps defines if the engine must generate mip levels
  30878. * @param invertY defines if data must be stored with Y axis inverted
  30879. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  30880. * @param compression defines the compressed used (can be null)
  30881. * @param textureType defines the compressed used (can be null)
  30882. * @returns a new raw 3D texture (stored in an InternalTexture)
  30883. */
  30884. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  30885. private _unpackFlipYCached;
  30886. /**
  30887. * In case you are sharing the context with other applications, it might
  30888. * be interested to not cache the unpack flip y state to ensure a consistent
  30889. * value would be set.
  30890. */
  30891. enableUnpackFlipYCached: boolean;
  30892. /** @hidden */
  30893. _unpackFlipY(value: boolean): void;
  30894. /** @hidden */
  30895. _getUnpackAlignement(): number;
  30896. /**
  30897. * Update the sampling mode of a given texture
  30898. * @param samplingMode defines the required sampling mode
  30899. * @param texture defines the texture to update
  30900. */
  30901. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  30902. /**
  30903. * Updates a depth texture Comparison Mode and Function.
  30904. * If the comparison Function is equal to 0, the mode will be set to none.
  30905. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  30906. * @param texture The texture to set the comparison function for
  30907. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  30908. */
  30909. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  30910. /** @hidden */
  30911. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  30912. width: number;
  30913. height: number;
  30914. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  30915. /**
  30916. * Creates a depth stencil texture.
  30917. * This is only available in WebGL 2 or with the depth texture extension available.
  30918. * @param size The size of face edge in the texture.
  30919. * @param options The options defining the texture.
  30920. * @returns The texture
  30921. */
  30922. createDepthStencilTexture(size: number | {
  30923. width: number;
  30924. height: number;
  30925. }, options: DepthTextureCreationOptions): InternalTexture;
  30926. /**
  30927. * Creates a depth stencil texture.
  30928. * This is only available in WebGL 2 or with the depth texture extension available.
  30929. * @param size The size of face edge in the texture.
  30930. * @param options The options defining the texture.
  30931. * @returns The texture
  30932. */
  30933. private _createDepthStencilTexture;
  30934. /** @hidden */
  30935. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30936. /** @hidden */
  30937. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  30938. /** @hidden */
  30939. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  30940. /** @hidden */
  30941. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  30942. /**
  30943. * @hidden
  30944. */
  30945. _setCubeMapTextureParams(loadMipmap: boolean): void;
  30946. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  30947. private _prepareWebGLTexture;
  30948. /** @hidden */
  30949. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  30950. /** @hidden */
  30951. _releaseFramebufferObjects(texture: InternalTexture): void;
  30952. /** @hidden */
  30953. _releaseTexture(texture: InternalTexture): void;
  30954. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  30955. protected _setProgram(program: WebGLProgram): void;
  30956. protected _boundUniforms: {
  30957. [key: number]: WebGLUniformLocation;
  30958. };
  30959. /**
  30960. * Binds an effect to the webGL context
  30961. * @param effect defines the effect to bind
  30962. */
  30963. bindSamplers(effect: Effect): void;
  30964. private _activateCurrentTexture;
  30965. /** @hidden */
  30966. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  30967. /** @hidden */
  30968. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  30969. /**
  30970. * Unbind all textures from the webGL context
  30971. */
  30972. unbindAllTextures(): void;
  30973. /**
  30974. * Sets a texture to the according uniform.
  30975. * @param channel The texture channel
  30976. * @param uniform The uniform to set
  30977. * @param texture The texture to apply
  30978. */
  30979. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  30980. private _bindSamplerUniformToChannel;
  30981. private _getTextureWrapMode;
  30982. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  30983. /**
  30984. * Sets an array of texture to the webGL context
  30985. * @param channel defines the channel where the texture array must be set
  30986. * @param uniform defines the associated uniform location
  30987. * @param textures defines the array of textures to bind
  30988. */
  30989. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  30990. /** @hidden */
  30991. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  30992. private _setTextureParameterFloat;
  30993. private _setTextureParameterInteger;
  30994. /**
  30995. * Unbind all vertex attributes from the webGL context
  30996. */
  30997. unbindAllAttributes(): void;
  30998. /**
  30999. * 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
  31000. */
  31001. releaseEffects(): void;
  31002. /**
  31003. * Dispose and release all associated resources
  31004. */
  31005. dispose(): void;
  31006. /**
  31007. * Attach a new callback raised when context lost event is fired
  31008. * @param callback defines the callback to call
  31009. */
  31010. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31011. /**
  31012. * Attach a new callback raised when context restored event is fired
  31013. * @param callback defines the callback to call
  31014. */
  31015. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  31016. /**
  31017. * Get the current error code of the webGL context
  31018. * @returns the error code
  31019. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  31020. */
  31021. getError(): number;
  31022. private _canRenderToFloatFramebuffer;
  31023. private _canRenderToHalfFloatFramebuffer;
  31024. private _canRenderToFramebuffer;
  31025. /** @hidden */
  31026. _getWebGLTextureType(type: number): number;
  31027. /** @hidden */
  31028. _getInternalFormat(format: number): number;
  31029. /** @hidden */
  31030. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  31031. /** @hidden */
  31032. _getRGBAMultiSampleBufferFormat(type: number): number;
  31033. /** @hidden */
  31034. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  31035. /**
  31036. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  31037. * @returns true if the engine can be created
  31038. * @ignorenaming
  31039. */
  31040. static isSupported(): boolean;
  31041. /**
  31042. * Find the next highest power of two.
  31043. * @param x Number to start search from.
  31044. * @return Next highest power of two.
  31045. */
  31046. static CeilingPOT(x: number): number;
  31047. /**
  31048. * Find the next lowest power of two.
  31049. * @param x Number to start search from.
  31050. * @return Next lowest power of two.
  31051. */
  31052. static FloorPOT(x: number): number;
  31053. /**
  31054. * Find the nearest power of two.
  31055. * @param x Number to start search from.
  31056. * @return Next nearest power of two.
  31057. */
  31058. static NearestPOT(x: number): number;
  31059. /**
  31060. * Get the closest exponent of two
  31061. * @param value defines the value to approximate
  31062. * @param max defines the maximum value to return
  31063. * @param mode defines how to define the closest value
  31064. * @returns closest exponent of two of the given value
  31065. */
  31066. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31067. /**
  31068. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31069. * @param func - the function to be called
  31070. * @param requester - the object that will request the next frame. Falls back to window.
  31071. * @returns frame number
  31072. */
  31073. static QueueNewFrame(func: () => void, requester?: any): number;
  31074. }
  31075. }
  31076. declare module "babylonjs/Materials/Textures/internalTexture" {
  31077. import { Observable } from "babylonjs/Misc/observable";
  31078. import { Nullable, int } from "babylonjs/types";
  31079. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  31080. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31082. /**
  31083. * Defines the source of the internal texture
  31084. */
  31085. export enum InternalTextureSource {
  31086. /**
  31087. * The source of the texture data is unknown
  31088. */
  31089. Unknown = 0,
  31090. /**
  31091. * Texture data comes from an URL
  31092. */
  31093. Url = 1,
  31094. /**
  31095. * Texture data is only used for temporary storage
  31096. */
  31097. Temp = 2,
  31098. /**
  31099. * Texture data comes from raw data (ArrayBuffer)
  31100. */
  31101. Raw = 3,
  31102. /**
  31103. * Texture content is dynamic (video or dynamic texture)
  31104. */
  31105. Dynamic = 4,
  31106. /**
  31107. * Texture content is generated by rendering to it
  31108. */
  31109. RenderTarget = 5,
  31110. /**
  31111. * Texture content is part of a multi render target process
  31112. */
  31113. MultiRenderTarget = 6,
  31114. /**
  31115. * Texture data comes from a cube data file
  31116. */
  31117. Cube = 7,
  31118. /**
  31119. * Texture data comes from a raw cube data
  31120. */
  31121. CubeRaw = 8,
  31122. /**
  31123. * Texture data come from a prefiltered cube data file
  31124. */
  31125. CubePrefiltered = 9,
  31126. /**
  31127. * Texture content is raw 3D data
  31128. */
  31129. Raw3D = 10,
  31130. /**
  31131. * Texture content is a depth texture
  31132. */
  31133. Depth = 11,
  31134. /**
  31135. * Texture data comes from a raw cube data encoded with RGBD
  31136. */
  31137. CubeRawRGBD = 12
  31138. }
  31139. /**
  31140. * Class used to store data associated with WebGL texture data for the engine
  31141. * This class should not be used directly
  31142. */
  31143. export class InternalTexture {
  31144. /** @hidden */
  31145. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  31146. /**
  31147. * Defines if the texture is ready
  31148. */
  31149. isReady: boolean;
  31150. /**
  31151. * Defines if the texture is a cube texture
  31152. */
  31153. isCube: boolean;
  31154. /**
  31155. * Defines if the texture contains 3D data
  31156. */
  31157. is3D: boolean;
  31158. /**
  31159. * Defines if the texture contains multiview data
  31160. */
  31161. isMultiview: boolean;
  31162. /**
  31163. * Gets the URL used to load this texture
  31164. */
  31165. url: string;
  31166. /**
  31167. * Gets the sampling mode of the texture
  31168. */
  31169. samplingMode: number;
  31170. /**
  31171. * Gets a boolean indicating if the texture needs mipmaps generation
  31172. */
  31173. generateMipMaps: boolean;
  31174. /**
  31175. * Gets the number of samples used by the texture (WebGL2+ only)
  31176. */
  31177. samples: number;
  31178. /**
  31179. * Gets the type of the texture (int, float...)
  31180. */
  31181. type: number;
  31182. /**
  31183. * Gets the format of the texture (RGB, RGBA...)
  31184. */
  31185. format: number;
  31186. /**
  31187. * Observable called when the texture is loaded
  31188. */
  31189. onLoadedObservable: Observable<InternalTexture>;
  31190. /**
  31191. * Gets the width of the texture
  31192. */
  31193. width: number;
  31194. /**
  31195. * Gets the height of the texture
  31196. */
  31197. height: number;
  31198. /**
  31199. * Gets the depth of the texture
  31200. */
  31201. depth: number;
  31202. /**
  31203. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  31204. */
  31205. baseWidth: number;
  31206. /**
  31207. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  31208. */
  31209. baseHeight: number;
  31210. /**
  31211. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  31212. */
  31213. baseDepth: number;
  31214. /**
  31215. * Gets a boolean indicating if the texture is inverted on Y axis
  31216. */
  31217. invertY: boolean;
  31218. /** @hidden */
  31219. _invertVScale: boolean;
  31220. /** @hidden */
  31221. _associatedChannel: number;
  31222. /** @hidden */
  31223. _source: InternalTextureSource;
  31224. /** @hidden */
  31225. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  31226. /** @hidden */
  31227. _bufferView: Nullable<ArrayBufferView>;
  31228. /** @hidden */
  31229. _bufferViewArray: Nullable<ArrayBufferView[]>;
  31230. /** @hidden */
  31231. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  31232. /** @hidden */
  31233. _size: number;
  31234. /** @hidden */
  31235. _extension: string;
  31236. /** @hidden */
  31237. _files: Nullable<string[]>;
  31238. /** @hidden */
  31239. _workingCanvas: Nullable<HTMLCanvasElement>;
  31240. /** @hidden */
  31241. _workingContext: Nullable<CanvasRenderingContext2D>;
  31242. /** @hidden */
  31243. _framebuffer: Nullable<WebGLFramebuffer>;
  31244. /** @hidden */
  31245. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  31246. /** @hidden */
  31247. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  31248. /** @hidden */
  31249. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  31250. /** @hidden */
  31251. _attachments: Nullable<number[]>;
  31252. /** @hidden */
  31253. _cachedCoordinatesMode: Nullable<number>;
  31254. /** @hidden */
  31255. _cachedWrapU: Nullable<number>;
  31256. /** @hidden */
  31257. _cachedWrapV: Nullable<number>;
  31258. /** @hidden */
  31259. _cachedWrapR: Nullable<number>;
  31260. /** @hidden */
  31261. _cachedAnisotropicFilteringLevel: Nullable<number>;
  31262. /** @hidden */
  31263. _isDisabled: boolean;
  31264. /** @hidden */
  31265. _compression: Nullable<string>;
  31266. /** @hidden */
  31267. _generateStencilBuffer: boolean;
  31268. /** @hidden */
  31269. _generateDepthBuffer: boolean;
  31270. /** @hidden */
  31271. _comparisonFunction: number;
  31272. /** @hidden */
  31273. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  31274. /** @hidden */
  31275. _lodGenerationScale: number;
  31276. /** @hidden */
  31277. _lodGenerationOffset: number;
  31278. /** @hidden */
  31279. _colorTextureArray: Nullable<WebGLTexture>;
  31280. /** @hidden */
  31281. _depthStencilTextureArray: Nullable<WebGLTexture>;
  31282. /** @hidden */
  31283. _lodTextureHigh: Nullable<BaseTexture>;
  31284. /** @hidden */
  31285. _lodTextureMid: Nullable<BaseTexture>;
  31286. /** @hidden */
  31287. _lodTextureLow: Nullable<BaseTexture>;
  31288. /** @hidden */
  31289. _isRGBD: boolean;
  31290. /** @hidden */
  31291. _linearSpecularLOD: boolean;
  31292. /** @hidden */
  31293. _irradianceTexture: Nullable<BaseTexture>;
  31294. /** @hidden */
  31295. _webGLTexture: Nullable<WebGLTexture>;
  31296. /** @hidden */
  31297. _references: number;
  31298. private _engine;
  31299. /**
  31300. * Gets the Engine the texture belongs to.
  31301. * @returns The babylon engine
  31302. */
  31303. getEngine(): ThinEngine;
  31304. /**
  31305. * Gets the data source type of the texture
  31306. */
  31307. readonly source: InternalTextureSource;
  31308. /**
  31309. * Creates a new InternalTexture
  31310. * @param engine defines the engine to use
  31311. * @param source defines the type of data that will be used
  31312. * @param delayAllocation if the texture allocation should be delayed (default: false)
  31313. */
  31314. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  31315. /**
  31316. * Increments the number of references (ie. the number of Texture that point to it)
  31317. */
  31318. incrementReferences(): void;
  31319. /**
  31320. * Change the size of the texture (not the size of the content)
  31321. * @param width defines the new width
  31322. * @param height defines the new height
  31323. * @param depth defines the new depth (1 by default)
  31324. */
  31325. updateSize(width: int, height: int, depth?: int): void;
  31326. /** @hidden */
  31327. _rebuild(): void;
  31328. /** @hidden */
  31329. _swapAndDie(target: InternalTexture): void;
  31330. /**
  31331. * Dispose the current allocated resources
  31332. */
  31333. dispose(): void;
  31334. }
  31335. }
  31336. declare module "babylonjs/Audio/analyser" {
  31337. import { Scene } from "babylonjs/scene";
  31338. /**
  31339. * Class used to work with sound analyzer using fast fourier transform (FFT)
  31340. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31341. */
  31342. export class Analyser {
  31343. /**
  31344. * Gets or sets the smoothing
  31345. * @ignorenaming
  31346. */
  31347. SMOOTHING: number;
  31348. /**
  31349. * Gets or sets the FFT table size
  31350. * @ignorenaming
  31351. */
  31352. FFT_SIZE: number;
  31353. /**
  31354. * Gets or sets the bar graph amplitude
  31355. * @ignorenaming
  31356. */
  31357. BARGRAPHAMPLITUDE: number;
  31358. /**
  31359. * Gets or sets the position of the debug canvas
  31360. * @ignorenaming
  31361. */
  31362. DEBUGCANVASPOS: {
  31363. x: number;
  31364. y: number;
  31365. };
  31366. /**
  31367. * Gets or sets the debug canvas size
  31368. * @ignorenaming
  31369. */
  31370. DEBUGCANVASSIZE: {
  31371. width: number;
  31372. height: number;
  31373. };
  31374. private _byteFreqs;
  31375. private _byteTime;
  31376. private _floatFreqs;
  31377. private _webAudioAnalyser;
  31378. private _debugCanvas;
  31379. private _debugCanvasContext;
  31380. private _scene;
  31381. private _registerFunc;
  31382. private _audioEngine;
  31383. /**
  31384. * Creates a new analyser
  31385. * @param scene defines hosting scene
  31386. */
  31387. constructor(scene: Scene);
  31388. /**
  31389. * Get the number of data values you will have to play with for the visualization
  31390. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  31391. * @returns a number
  31392. */
  31393. getFrequencyBinCount(): number;
  31394. /**
  31395. * Gets the current frequency data as a byte array
  31396. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31397. * @returns a Uint8Array
  31398. */
  31399. getByteFrequencyData(): Uint8Array;
  31400. /**
  31401. * Gets the current waveform as a byte array
  31402. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  31403. * @returns a Uint8Array
  31404. */
  31405. getByteTimeDomainData(): Uint8Array;
  31406. /**
  31407. * Gets the current frequency data as a float array
  31408. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  31409. * @returns a Float32Array
  31410. */
  31411. getFloatFrequencyData(): Float32Array;
  31412. /**
  31413. * Renders the debug canvas
  31414. */
  31415. drawDebugCanvas(): void;
  31416. /**
  31417. * Stops rendering the debug canvas and removes it
  31418. */
  31419. stopDebugCanvas(): void;
  31420. /**
  31421. * Connects two audio nodes
  31422. * @param inputAudioNode defines first node to connect
  31423. * @param outputAudioNode defines second node to connect
  31424. */
  31425. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  31426. /**
  31427. * Releases all associated resources
  31428. */
  31429. dispose(): void;
  31430. }
  31431. }
  31432. declare module "babylonjs/Audio/audioEngine" {
  31433. import { IDisposable } from "babylonjs/scene";
  31434. import { Analyser } from "babylonjs/Audio/analyser";
  31435. import { Nullable } from "babylonjs/types";
  31436. import { Observable } from "babylonjs/Misc/observable";
  31437. /**
  31438. * This represents an audio engine and it is responsible
  31439. * to play, synchronize and analyse sounds throughout the application.
  31440. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31441. */
  31442. export interface IAudioEngine extends IDisposable {
  31443. /**
  31444. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31445. */
  31446. readonly canUseWebAudio: boolean;
  31447. /**
  31448. * Gets the current AudioContext if available.
  31449. */
  31450. readonly audioContext: Nullable<AudioContext>;
  31451. /**
  31452. * The master gain node defines the global audio volume of your audio engine.
  31453. */
  31454. readonly masterGain: GainNode;
  31455. /**
  31456. * Gets whether or not mp3 are supported by your browser.
  31457. */
  31458. readonly isMP3supported: boolean;
  31459. /**
  31460. * Gets whether or not ogg are supported by your browser.
  31461. */
  31462. readonly isOGGsupported: boolean;
  31463. /**
  31464. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31465. * @ignoreNaming
  31466. */
  31467. WarnedWebAudioUnsupported: boolean;
  31468. /**
  31469. * Defines if the audio engine relies on a custom unlocked button.
  31470. * In this case, the embedded button will not be displayed.
  31471. */
  31472. useCustomUnlockedButton: boolean;
  31473. /**
  31474. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  31475. */
  31476. readonly unlocked: boolean;
  31477. /**
  31478. * Event raised when audio has been unlocked on the browser.
  31479. */
  31480. onAudioUnlockedObservable: Observable<AudioEngine>;
  31481. /**
  31482. * Event raised when audio has been locked on the browser.
  31483. */
  31484. onAudioLockedObservable: Observable<AudioEngine>;
  31485. /**
  31486. * Flags the audio engine in Locked state.
  31487. * This happens due to new browser policies preventing audio to autoplay.
  31488. */
  31489. lock(): void;
  31490. /**
  31491. * Unlocks the audio engine once a user action has been done on the dom.
  31492. * This is helpful to resume play once browser policies have been satisfied.
  31493. */
  31494. unlock(): void;
  31495. }
  31496. /**
  31497. * This represents the default audio engine used in babylon.
  31498. * It is responsible to play, synchronize and analyse sounds throughout the application.
  31499. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  31500. */
  31501. export class AudioEngine implements IAudioEngine {
  31502. private _audioContext;
  31503. private _audioContextInitialized;
  31504. private _muteButton;
  31505. private _hostElement;
  31506. /**
  31507. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  31508. */
  31509. canUseWebAudio: boolean;
  31510. /**
  31511. * The master gain node defines the global audio volume of your audio engine.
  31512. */
  31513. masterGain: GainNode;
  31514. /**
  31515. * Defines if Babylon should emit a warning if WebAudio is not supported.
  31516. * @ignoreNaming
  31517. */
  31518. WarnedWebAudioUnsupported: boolean;
  31519. /**
  31520. * Gets whether or not mp3 are supported by your browser.
  31521. */
  31522. isMP3supported: boolean;
  31523. /**
  31524. * Gets whether or not ogg are supported by your browser.
  31525. */
  31526. isOGGsupported: boolean;
  31527. /**
  31528. * Gets whether audio has been unlocked on the device.
  31529. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  31530. * a user interaction has happened.
  31531. */
  31532. unlocked: boolean;
  31533. /**
  31534. * Defines if the audio engine relies on a custom unlocked button.
  31535. * In this case, the embedded button will not be displayed.
  31536. */
  31537. useCustomUnlockedButton: boolean;
  31538. /**
  31539. * Event raised when audio has been unlocked on the browser.
  31540. */
  31541. onAudioUnlockedObservable: Observable<AudioEngine>;
  31542. /**
  31543. * Event raised when audio has been locked on the browser.
  31544. */
  31545. onAudioLockedObservable: Observable<AudioEngine>;
  31546. /**
  31547. * Gets the current AudioContext if available.
  31548. */
  31549. readonly audioContext: Nullable<AudioContext>;
  31550. private _connectedAnalyser;
  31551. /**
  31552. * Instantiates a new audio engine.
  31553. *
  31554. * There should be only one per page as some browsers restrict the number
  31555. * of audio contexts you can create.
  31556. * @param hostElement defines the host element where to display the mute icon if necessary
  31557. */
  31558. constructor(hostElement?: Nullable<HTMLElement>);
  31559. /**
  31560. * Flags the audio engine in Locked state.
  31561. * This happens due to new browser policies preventing audio to autoplay.
  31562. */
  31563. lock(): void;
  31564. /**
  31565. * Unlocks the audio engine once a user action has been done on the dom.
  31566. * This is helpful to resume play once browser policies have been satisfied.
  31567. */
  31568. unlock(): void;
  31569. private _resumeAudioContext;
  31570. private _initializeAudioContext;
  31571. private _tryToRun;
  31572. private _triggerRunningState;
  31573. private _triggerSuspendedState;
  31574. private _displayMuteButton;
  31575. private _moveButtonToTopLeft;
  31576. private _onResize;
  31577. private _hideMuteButton;
  31578. /**
  31579. * Destroy and release the resources associated with the audio ccontext.
  31580. */
  31581. dispose(): void;
  31582. /**
  31583. * Gets the global volume sets on the master gain.
  31584. * @returns the global volume if set or -1 otherwise
  31585. */
  31586. getGlobalVolume(): number;
  31587. /**
  31588. * Sets the global volume of your experience (sets on the master gain).
  31589. * @param newVolume Defines the new global volume of the application
  31590. */
  31591. setGlobalVolume(newVolume: number): void;
  31592. /**
  31593. * Connect the audio engine to an audio analyser allowing some amazing
  31594. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  31595. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  31596. * @param analyser The analyser to connect to the engine
  31597. */
  31598. connectToAnalyser(analyser: Analyser): void;
  31599. }
  31600. }
  31601. declare module "babylonjs/Loading/loadingScreen" {
  31602. /**
  31603. * Interface used to present a loading screen while loading a scene
  31604. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31605. */
  31606. export interface ILoadingScreen {
  31607. /**
  31608. * Function called to display the loading screen
  31609. */
  31610. displayLoadingUI: () => void;
  31611. /**
  31612. * Function called to hide the loading screen
  31613. */
  31614. hideLoadingUI: () => void;
  31615. /**
  31616. * Gets or sets the color to use for the background
  31617. */
  31618. loadingUIBackgroundColor: string;
  31619. /**
  31620. * Gets or sets the text to display while loading
  31621. */
  31622. loadingUIText: string;
  31623. }
  31624. /**
  31625. * Class used for the default loading screen
  31626. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  31627. */
  31628. export class DefaultLoadingScreen implements ILoadingScreen {
  31629. private _renderingCanvas;
  31630. private _loadingText;
  31631. private _loadingDivBackgroundColor;
  31632. private _loadingDiv;
  31633. private _loadingTextDiv;
  31634. /** Gets or sets the logo url to use for the default loading screen */
  31635. static DefaultLogoUrl: string;
  31636. /** Gets or sets the spinner url to use for the default loading screen */
  31637. static DefaultSpinnerUrl: string;
  31638. /**
  31639. * Creates a new default loading screen
  31640. * @param _renderingCanvas defines the canvas used to render the scene
  31641. * @param _loadingText defines the default text to display
  31642. * @param _loadingDivBackgroundColor defines the default background color
  31643. */
  31644. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  31645. /**
  31646. * Function called to display the loading screen
  31647. */
  31648. displayLoadingUI(): void;
  31649. /**
  31650. * Function called to hide the loading screen
  31651. */
  31652. hideLoadingUI(): void;
  31653. /**
  31654. * Gets or sets the text to display while loading
  31655. */
  31656. loadingUIText: string;
  31657. /**
  31658. * Gets or sets the color to use for the background
  31659. */
  31660. loadingUIBackgroundColor: string;
  31661. private _resizeLoadingUI;
  31662. }
  31663. }
  31664. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  31665. /**
  31666. * Interface for any object that can request an animation frame
  31667. */
  31668. export interface ICustomAnimationFrameRequester {
  31669. /**
  31670. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31671. */
  31672. renderFunction?: Function;
  31673. /**
  31674. * Called to request the next frame to render to
  31675. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31676. */
  31677. requestAnimationFrame: Function;
  31678. /**
  31679. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31680. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31681. */
  31682. requestID?: number;
  31683. }
  31684. }
  31685. declare module "babylonjs/Misc/performanceMonitor" {
  31686. /**
  31687. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  31688. */
  31689. export class PerformanceMonitor {
  31690. private _enabled;
  31691. private _rollingFrameTime;
  31692. private _lastFrameTimeMs;
  31693. /**
  31694. * constructor
  31695. * @param frameSampleSize The number of samples required to saturate the sliding window
  31696. */
  31697. constructor(frameSampleSize?: number);
  31698. /**
  31699. * Samples current frame
  31700. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  31701. */
  31702. sampleFrame(timeMs?: number): void;
  31703. /**
  31704. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31705. */
  31706. readonly averageFrameTime: number;
  31707. /**
  31708. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  31709. */
  31710. readonly averageFrameTimeVariance: number;
  31711. /**
  31712. * Returns the frame time of the most recent frame
  31713. */
  31714. readonly instantaneousFrameTime: number;
  31715. /**
  31716. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  31717. */
  31718. readonly averageFPS: number;
  31719. /**
  31720. * Returns the average framerate in frames per second using the most recent frame time
  31721. */
  31722. readonly instantaneousFPS: number;
  31723. /**
  31724. * Returns true if enough samples have been taken to completely fill the sliding window
  31725. */
  31726. readonly isSaturated: boolean;
  31727. /**
  31728. * Enables contributions to the sliding window sample set
  31729. */
  31730. enable(): void;
  31731. /**
  31732. * Disables contributions to the sliding window sample set
  31733. * Samples will not be interpolated over the disabled period
  31734. */
  31735. disable(): void;
  31736. /**
  31737. * Returns true if sampling is enabled
  31738. */
  31739. readonly isEnabled: boolean;
  31740. /**
  31741. * Resets performance monitor
  31742. */
  31743. reset(): void;
  31744. }
  31745. /**
  31746. * RollingAverage
  31747. *
  31748. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  31749. */
  31750. export class RollingAverage {
  31751. /**
  31752. * Current average
  31753. */
  31754. average: number;
  31755. /**
  31756. * Current variance
  31757. */
  31758. variance: number;
  31759. protected _samples: Array<number>;
  31760. protected _sampleCount: number;
  31761. protected _pos: number;
  31762. protected _m2: number;
  31763. /**
  31764. * constructor
  31765. * @param length The number of samples required to saturate the sliding window
  31766. */
  31767. constructor(length: number);
  31768. /**
  31769. * Adds a sample to the sample set
  31770. * @param v The sample value
  31771. */
  31772. add(v: number): void;
  31773. /**
  31774. * Returns previously added values or null if outside of history or outside the sliding window domain
  31775. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  31776. * @return Value previously recorded with add() or null if outside of range
  31777. */
  31778. history(i: number): number;
  31779. /**
  31780. * Returns true if enough samples have been taken to completely fill the sliding window
  31781. * @return true if sample-set saturated
  31782. */
  31783. isSaturated(): boolean;
  31784. /**
  31785. * Resets the rolling average (equivalent to 0 samples taken so far)
  31786. */
  31787. reset(): void;
  31788. /**
  31789. * Wraps a value around the sample range boundaries
  31790. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  31791. * @return Wrapped position in sample range
  31792. */
  31793. protected _wrapPosition(i: number): number;
  31794. }
  31795. }
  31796. declare module "babylonjs/Misc/perfCounter" {
  31797. /**
  31798. * This class is used to track a performance counter which is number based.
  31799. * The user has access to many properties which give statistics of different nature.
  31800. *
  31801. * The implementer can track two kinds of Performance Counter: time and count.
  31802. * 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.
  31803. * 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.
  31804. */
  31805. export class PerfCounter {
  31806. /**
  31807. * Gets or sets a global boolean to turn on and off all the counters
  31808. */
  31809. static Enabled: boolean;
  31810. /**
  31811. * Returns the smallest value ever
  31812. */
  31813. readonly min: number;
  31814. /**
  31815. * Returns the biggest value ever
  31816. */
  31817. readonly max: number;
  31818. /**
  31819. * Returns the average value since the performance counter is running
  31820. */
  31821. readonly average: number;
  31822. /**
  31823. * Returns the average value of the last second the counter was monitored
  31824. */
  31825. readonly lastSecAverage: number;
  31826. /**
  31827. * Returns the current value
  31828. */
  31829. readonly current: number;
  31830. /**
  31831. * Gets the accumulated total
  31832. */
  31833. readonly total: number;
  31834. /**
  31835. * Gets the total value count
  31836. */
  31837. readonly count: number;
  31838. /**
  31839. * Creates a new counter
  31840. */
  31841. constructor();
  31842. /**
  31843. * Call this method to start monitoring a new frame.
  31844. * 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.
  31845. */
  31846. fetchNewFrame(): void;
  31847. /**
  31848. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  31849. * @param newCount the count value to add to the monitored count
  31850. * @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.
  31851. */
  31852. addCount(newCount: number, fetchResult: boolean): void;
  31853. /**
  31854. * Start monitoring this performance counter
  31855. */
  31856. beginMonitoring(): void;
  31857. /**
  31858. * Compute the time lapsed since the previous beginMonitoring() call.
  31859. * @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
  31860. */
  31861. endMonitoring(newFrame?: boolean): void;
  31862. private _fetchResult;
  31863. private _startMonitoringTime;
  31864. private _min;
  31865. private _max;
  31866. private _average;
  31867. private _current;
  31868. private _totalValueCount;
  31869. private _totalAccumulated;
  31870. private _lastSecAverage;
  31871. private _lastSecAccumulated;
  31872. private _lastSecTime;
  31873. private _lastSecValueCount;
  31874. }
  31875. }
  31876. declare module "babylonjs/Engines/engine" {
  31877. import { Observable } from "babylonjs/Misc/observable";
  31878. import { Nullable, IndicesArray } from "babylonjs/types";
  31879. import { Scene } from "babylonjs/scene";
  31880. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31881. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  31882. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31883. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  31884. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  31885. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31886. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  31887. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  31888. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  31889. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  31890. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31891. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  31892. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31893. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  31894. import { Material } from "babylonjs/Materials/material";
  31895. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31896. /**
  31897. * Defines the interface used by display changed events
  31898. */
  31899. export interface IDisplayChangedEventArgs {
  31900. /** Gets the vrDisplay object (if any) */
  31901. vrDisplay: Nullable<any>;
  31902. /** Gets a boolean indicating if webVR is supported */
  31903. vrSupported: boolean;
  31904. }
  31905. /**
  31906. * Defines the interface used by objects containing a viewport (like a camera)
  31907. */
  31908. interface IViewportOwnerLike {
  31909. /**
  31910. * Gets or sets the viewport
  31911. */
  31912. viewport: IViewportLike;
  31913. }
  31914. /**
  31915. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  31916. */
  31917. export class Engine extends ThinEngine {
  31918. /** Defines that alpha blending is disabled */
  31919. static readonly ALPHA_DISABLE: number;
  31920. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  31921. static readonly ALPHA_ADD: number;
  31922. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  31923. static readonly ALPHA_COMBINE: number;
  31924. /** Defines that alpha blending to DEST - SRC * DEST */
  31925. static readonly ALPHA_SUBTRACT: number;
  31926. /** Defines that alpha blending to SRC * DEST */
  31927. static readonly ALPHA_MULTIPLY: number;
  31928. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  31929. static readonly ALPHA_MAXIMIZED: number;
  31930. /** Defines that alpha blending to SRC + DEST */
  31931. static readonly ALPHA_ONEONE: number;
  31932. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  31933. static readonly ALPHA_PREMULTIPLIED: number;
  31934. /**
  31935. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  31936. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  31937. */
  31938. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  31939. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  31940. static readonly ALPHA_INTERPOLATE: number;
  31941. /**
  31942. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  31943. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  31944. */
  31945. static readonly ALPHA_SCREENMODE: number;
  31946. /** Defines that the ressource is not delayed*/
  31947. static readonly DELAYLOADSTATE_NONE: number;
  31948. /** Defines that the ressource was successfully delay loaded */
  31949. static readonly DELAYLOADSTATE_LOADED: number;
  31950. /** Defines that the ressource is currently delay loading */
  31951. static readonly DELAYLOADSTATE_LOADING: number;
  31952. /** Defines that the ressource is delayed and has not started loading */
  31953. static readonly DELAYLOADSTATE_NOTLOADED: number;
  31954. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  31955. static readonly NEVER: number;
  31956. /** 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 */
  31957. static readonly ALWAYS: number;
  31958. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  31959. static readonly LESS: number;
  31960. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  31961. static readonly EQUAL: number;
  31962. /** 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 */
  31963. static readonly LEQUAL: number;
  31964. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  31965. static readonly GREATER: number;
  31966. /** 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 */
  31967. static readonly GEQUAL: number;
  31968. /** 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 */
  31969. static readonly NOTEQUAL: number;
  31970. /** Passed to stencilOperation to specify that stencil value must be kept */
  31971. static readonly KEEP: number;
  31972. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31973. static readonly REPLACE: number;
  31974. /** Passed to stencilOperation to specify that stencil value must be incremented */
  31975. static readonly INCR: number;
  31976. /** Passed to stencilOperation to specify that stencil value must be decremented */
  31977. static readonly DECR: number;
  31978. /** Passed to stencilOperation to specify that stencil value must be inverted */
  31979. static readonly INVERT: number;
  31980. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  31981. static readonly INCR_WRAP: number;
  31982. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  31983. static readonly DECR_WRAP: number;
  31984. /** Texture is not repeating outside of 0..1 UVs */
  31985. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  31986. /** Texture is repeating outside of 0..1 UVs */
  31987. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  31988. /** Texture is repeating and mirrored */
  31989. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  31990. /** ALPHA */
  31991. static readonly TEXTUREFORMAT_ALPHA: number;
  31992. /** LUMINANCE */
  31993. static readonly TEXTUREFORMAT_LUMINANCE: number;
  31994. /** LUMINANCE_ALPHA */
  31995. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  31996. /** RGB */
  31997. static readonly TEXTUREFORMAT_RGB: number;
  31998. /** RGBA */
  31999. static readonly TEXTUREFORMAT_RGBA: number;
  32000. /** RED */
  32001. static readonly TEXTUREFORMAT_RED: number;
  32002. /** RED (2nd reference) */
  32003. static readonly TEXTUREFORMAT_R: number;
  32004. /** RG */
  32005. static readonly TEXTUREFORMAT_RG: number;
  32006. /** RED_INTEGER */
  32007. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  32008. /** RED_INTEGER (2nd reference) */
  32009. static readonly TEXTUREFORMAT_R_INTEGER: number;
  32010. /** RG_INTEGER */
  32011. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  32012. /** RGB_INTEGER */
  32013. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  32014. /** RGBA_INTEGER */
  32015. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  32016. /** UNSIGNED_BYTE */
  32017. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  32018. /** UNSIGNED_BYTE (2nd reference) */
  32019. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  32020. /** FLOAT */
  32021. static readonly TEXTURETYPE_FLOAT: number;
  32022. /** HALF_FLOAT */
  32023. static readonly TEXTURETYPE_HALF_FLOAT: number;
  32024. /** BYTE */
  32025. static readonly TEXTURETYPE_BYTE: number;
  32026. /** SHORT */
  32027. static readonly TEXTURETYPE_SHORT: number;
  32028. /** UNSIGNED_SHORT */
  32029. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  32030. /** INT */
  32031. static readonly TEXTURETYPE_INT: number;
  32032. /** UNSIGNED_INT */
  32033. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  32034. /** UNSIGNED_SHORT_4_4_4_4 */
  32035. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  32036. /** UNSIGNED_SHORT_5_5_5_1 */
  32037. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  32038. /** UNSIGNED_SHORT_5_6_5 */
  32039. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  32040. /** UNSIGNED_INT_2_10_10_10_REV */
  32041. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  32042. /** UNSIGNED_INT_24_8 */
  32043. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  32044. /** UNSIGNED_INT_10F_11F_11F_REV */
  32045. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  32046. /** UNSIGNED_INT_5_9_9_9_REV */
  32047. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  32048. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  32049. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  32050. /** nearest is mag = nearest and min = nearest and mip = linear */
  32051. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  32052. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32053. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  32054. /** Trilinear is mag = linear and min = linear and mip = linear */
  32055. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  32056. /** nearest is mag = nearest and min = nearest and mip = linear */
  32057. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  32058. /** Bilinear is mag = linear and min = linear and mip = nearest */
  32059. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  32060. /** Trilinear is mag = linear and min = linear and mip = linear */
  32061. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  32062. /** mag = nearest and min = nearest and mip = nearest */
  32063. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  32064. /** mag = nearest and min = linear and mip = nearest */
  32065. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  32066. /** mag = nearest and min = linear and mip = linear */
  32067. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  32068. /** mag = nearest and min = linear and mip = none */
  32069. static readonly TEXTURE_NEAREST_LINEAR: number;
  32070. /** mag = nearest and min = nearest and mip = none */
  32071. static readonly TEXTURE_NEAREST_NEAREST: number;
  32072. /** mag = linear and min = nearest and mip = nearest */
  32073. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  32074. /** mag = linear and min = nearest and mip = linear */
  32075. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  32076. /** mag = linear and min = linear and mip = none */
  32077. static readonly TEXTURE_LINEAR_LINEAR: number;
  32078. /** mag = linear and min = nearest and mip = none */
  32079. static readonly TEXTURE_LINEAR_NEAREST: number;
  32080. /** Explicit coordinates mode */
  32081. static readonly TEXTURE_EXPLICIT_MODE: number;
  32082. /** Spherical coordinates mode */
  32083. static readonly TEXTURE_SPHERICAL_MODE: number;
  32084. /** Planar coordinates mode */
  32085. static readonly TEXTURE_PLANAR_MODE: number;
  32086. /** Cubic coordinates mode */
  32087. static readonly TEXTURE_CUBIC_MODE: number;
  32088. /** Projection coordinates mode */
  32089. static readonly TEXTURE_PROJECTION_MODE: number;
  32090. /** Skybox coordinates mode */
  32091. static readonly TEXTURE_SKYBOX_MODE: number;
  32092. /** Inverse Cubic coordinates mode */
  32093. static readonly TEXTURE_INVCUBIC_MODE: number;
  32094. /** Equirectangular coordinates mode */
  32095. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  32096. /** Equirectangular Fixed coordinates mode */
  32097. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  32098. /** Equirectangular Fixed Mirrored coordinates mode */
  32099. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  32100. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  32101. static readonly SCALEMODE_FLOOR: number;
  32102. /** Defines that texture rescaling will look for the nearest power of 2 size */
  32103. static readonly SCALEMODE_NEAREST: number;
  32104. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  32105. static readonly SCALEMODE_CEILING: number;
  32106. /**
  32107. * Returns the current npm package of the sdk
  32108. */
  32109. static readonly NpmPackage: string;
  32110. /**
  32111. * Returns the current version of the framework
  32112. */
  32113. static readonly Version: string;
  32114. /** Gets the list of created engines */
  32115. static readonly Instances: Engine[];
  32116. /**
  32117. * Gets the latest created engine
  32118. */
  32119. static readonly LastCreatedEngine: Nullable<Engine>;
  32120. /**
  32121. * Gets the latest created scene
  32122. */
  32123. static readonly LastCreatedScene: Nullable<Scene>;
  32124. /**
  32125. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  32126. * @param flag defines which part of the materials must be marked as dirty
  32127. * @param predicate defines a predicate used to filter which materials should be affected
  32128. */
  32129. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  32130. /**
  32131. * Method called to create the default loading screen.
  32132. * This can be overriden in your own app.
  32133. * @param canvas The rendering canvas element
  32134. * @returns The loading screen
  32135. */
  32136. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  32137. /**
  32138. * Method called to create the default rescale post process on each engine.
  32139. */
  32140. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  32141. /**
  32142. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  32143. **/
  32144. enableOfflineSupport: boolean;
  32145. /**
  32146. * 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)
  32147. **/
  32148. disableManifestCheck: boolean;
  32149. /**
  32150. * Gets the list of created scenes
  32151. */
  32152. scenes: Scene[];
  32153. /**
  32154. * Event raised when a new scene is created
  32155. */
  32156. onNewSceneAddedObservable: Observable<Scene>;
  32157. /**
  32158. * Gets the list of created postprocesses
  32159. */
  32160. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  32161. /**
  32162. * Gets a boolean indicating if the pointer is currently locked
  32163. */
  32164. isPointerLock: boolean;
  32165. /**
  32166. * Observable event triggered each time the rendering canvas is resized
  32167. */
  32168. onResizeObservable: Observable<Engine>;
  32169. /**
  32170. * Observable event triggered each time the canvas loses focus
  32171. */
  32172. onCanvasBlurObservable: Observable<Engine>;
  32173. /**
  32174. * Observable event triggered each time the canvas gains focus
  32175. */
  32176. onCanvasFocusObservable: Observable<Engine>;
  32177. /**
  32178. * Observable event triggered each time the canvas receives pointerout event
  32179. */
  32180. onCanvasPointerOutObservable: Observable<PointerEvent>;
  32181. /**
  32182. * Observable event triggered before each texture is initialized
  32183. */
  32184. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32185. /**
  32186. * Observable raised when the engine begins a new frame
  32187. */
  32188. onBeginFrameObservable: Observable<Engine>;
  32189. /**
  32190. * If set, will be used to request the next animation frame for the render loop
  32191. */
  32192. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  32193. /**
  32194. * Observable raised when the engine ends the current frame
  32195. */
  32196. onEndFrameObservable: Observable<Engine>;
  32197. /**
  32198. * Observable raised when the engine is about to compile a shader
  32199. */
  32200. onBeforeShaderCompilationObservable: Observable<Engine>;
  32201. /**
  32202. * Observable raised when the engine has jsut compiled a shader
  32203. */
  32204. onAfterShaderCompilationObservable: Observable<Engine>;
  32205. /**
  32206. * Gets the audio engine
  32207. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32208. * @ignorenaming
  32209. */
  32210. static audioEngine: IAudioEngine;
  32211. /**
  32212. * Default AudioEngine factory responsible of creating the Audio Engine.
  32213. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  32214. */
  32215. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  32216. /**
  32217. * Default offline support factory responsible of creating a tool used to store data locally.
  32218. * By default, this will create a Database object if the workload has been embedded.
  32219. */
  32220. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  32221. private _loadingScreen;
  32222. private _pointerLockRequested;
  32223. private _dummyFramebuffer;
  32224. private _rescalePostProcess;
  32225. /** @hidden */
  32226. protected _alphaMode: number;
  32227. /** @hidden */
  32228. protected _alphaEquation: number;
  32229. private _deterministicLockstep;
  32230. private _lockstepMaxSteps;
  32231. protected readonly _supportsHardwareTextureRescaling: boolean;
  32232. private _fps;
  32233. private _deltaTime;
  32234. /** @hidden */
  32235. _drawCalls: PerfCounter;
  32236. /**
  32237. * Turn this value on if you want to pause FPS computation when in background
  32238. */
  32239. disablePerformanceMonitorInBackground: boolean;
  32240. private _performanceMonitor;
  32241. /**
  32242. * Gets the performance monitor attached to this engine
  32243. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  32244. */
  32245. readonly performanceMonitor: PerformanceMonitor;
  32246. private _onFocus;
  32247. private _onBlur;
  32248. private _onCanvasPointerOut;
  32249. private _onCanvasBlur;
  32250. private _onCanvasFocus;
  32251. private _onFullscreenChange;
  32252. private _onPointerLockChange;
  32253. /**
  32254. * Creates a new engine
  32255. * @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
  32256. * @param antialias defines enable antialiasing (default: false)
  32257. * @param options defines further options to be sent to the getContext() function
  32258. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32259. */
  32260. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32261. /**
  32262. * Gets current aspect ratio
  32263. * @param viewportOwner defines the camera to use to get the aspect ratio
  32264. * @param useScreen defines if screen size must be used (or the current render target if any)
  32265. * @returns a number defining the aspect ratio
  32266. */
  32267. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  32268. /**
  32269. * Gets current screen aspect ratio
  32270. * @returns a number defining the aspect ratio
  32271. */
  32272. getScreenAspectRatio(): number;
  32273. /**
  32274. * Gets host document
  32275. * @returns the host document object
  32276. */
  32277. getHostDocument(): Document;
  32278. /**
  32279. * Gets the client rect of the HTML canvas attached with the current webGL context
  32280. * @returns a client rectanglee
  32281. */
  32282. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  32283. /**
  32284. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  32285. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32286. * @returns true if engine is in deterministic lock step mode
  32287. */
  32288. isDeterministicLockStep(): boolean;
  32289. /**
  32290. * Gets the max steps when engine is running in deterministic lock step
  32291. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32292. * @returns the max steps
  32293. */
  32294. getLockstepMaxSteps(): number;
  32295. /**
  32296. * Force the mipmap generation for the given render target texture
  32297. * @param texture defines the render target texture to use
  32298. */
  32299. generateMipMapsForCubemap(texture: InternalTexture): void;
  32300. /** States */
  32301. /**
  32302. * Set various states to the webGL context
  32303. * @param culling defines backface culling state
  32304. * @param zOffset defines the value to apply to zOffset (0 by default)
  32305. * @param force defines if states must be applied even if cache is up to date
  32306. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  32307. */
  32308. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  32309. /**
  32310. * Set the z offset to apply to current rendering
  32311. * @param value defines the offset to apply
  32312. */
  32313. setZOffset(value: number): void;
  32314. /**
  32315. * Gets the current value of the zOffset
  32316. * @returns the current zOffset state
  32317. */
  32318. getZOffset(): number;
  32319. /**
  32320. * Enable or disable depth buffering
  32321. * @param enable defines the state to set
  32322. */
  32323. setDepthBuffer(enable: boolean): void;
  32324. /**
  32325. * Gets a boolean indicating if depth writing is enabled
  32326. * @returns the current depth writing state
  32327. */
  32328. getDepthWrite(): boolean;
  32329. /**
  32330. * Enable or disable depth writing
  32331. * @param enable defines the state to set
  32332. */
  32333. setDepthWrite(enable: boolean): void;
  32334. /**
  32335. * Enable or disable color writing
  32336. * @param enable defines the state to set
  32337. */
  32338. setColorWrite(enable: boolean): void;
  32339. /**
  32340. * Gets a boolean indicating if color writing is enabled
  32341. * @returns the current color writing state
  32342. */
  32343. getColorWrite(): boolean;
  32344. /**
  32345. * Sets alpha constants used by some alpha blending modes
  32346. * @param r defines the red component
  32347. * @param g defines the green component
  32348. * @param b defines the blue component
  32349. * @param a defines the alpha component
  32350. */
  32351. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  32352. /**
  32353. * Sets the current alpha mode
  32354. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  32355. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  32356. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32357. */
  32358. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  32359. /**
  32360. * Gets the current alpha mode
  32361. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  32362. * @returns the current alpha mode
  32363. */
  32364. getAlphaMode(): number;
  32365. /**
  32366. * Sets the current alpha equation
  32367. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  32368. */
  32369. setAlphaEquation(equation: number): void;
  32370. /**
  32371. * Gets the current alpha equation.
  32372. * @returns the current alpha equation
  32373. */
  32374. getAlphaEquation(): number;
  32375. /**
  32376. * Gets a boolean indicating if stencil buffer is enabled
  32377. * @returns the current stencil buffer state
  32378. */
  32379. getStencilBuffer(): boolean;
  32380. /**
  32381. * Enable or disable the stencil buffer
  32382. * @param enable defines if the stencil buffer must be enabled or disabled
  32383. */
  32384. setStencilBuffer(enable: boolean): void;
  32385. /**
  32386. * Gets the current stencil mask
  32387. * @returns a number defining the new stencil mask to use
  32388. */
  32389. getStencilMask(): number;
  32390. /**
  32391. * Sets the current stencil mask
  32392. * @param mask defines the new stencil mask to use
  32393. */
  32394. setStencilMask(mask: number): void;
  32395. /**
  32396. * Gets the current stencil function
  32397. * @returns a number defining the stencil function to use
  32398. */
  32399. getStencilFunction(): number;
  32400. /**
  32401. * Gets the current stencil reference value
  32402. * @returns a number defining the stencil reference value to use
  32403. */
  32404. getStencilFunctionReference(): number;
  32405. /**
  32406. * Gets the current stencil mask
  32407. * @returns a number defining the stencil mask to use
  32408. */
  32409. getStencilFunctionMask(): number;
  32410. /**
  32411. * Sets the current stencil function
  32412. * @param stencilFunc defines the new stencil function to use
  32413. */
  32414. setStencilFunction(stencilFunc: number): void;
  32415. /**
  32416. * Sets the current stencil reference
  32417. * @param reference defines the new stencil reference to use
  32418. */
  32419. setStencilFunctionReference(reference: number): void;
  32420. /**
  32421. * Sets the current stencil mask
  32422. * @param mask defines the new stencil mask to use
  32423. */
  32424. setStencilFunctionMask(mask: number): void;
  32425. /**
  32426. * Gets the current stencil operation when stencil fails
  32427. * @returns a number defining stencil operation to use when stencil fails
  32428. */
  32429. getStencilOperationFail(): number;
  32430. /**
  32431. * Gets the current stencil operation when depth fails
  32432. * @returns a number defining stencil operation to use when depth fails
  32433. */
  32434. getStencilOperationDepthFail(): number;
  32435. /**
  32436. * Gets the current stencil operation when stencil passes
  32437. * @returns a number defining stencil operation to use when stencil passes
  32438. */
  32439. getStencilOperationPass(): number;
  32440. /**
  32441. * Sets the stencil operation to use when stencil fails
  32442. * @param operation defines the stencil operation to use when stencil fails
  32443. */
  32444. setStencilOperationFail(operation: number): void;
  32445. /**
  32446. * Sets the stencil operation to use when depth fails
  32447. * @param operation defines the stencil operation to use when depth fails
  32448. */
  32449. setStencilOperationDepthFail(operation: number): void;
  32450. /**
  32451. * Sets the stencil operation to use when stencil passes
  32452. * @param operation defines the stencil operation to use when stencil passes
  32453. */
  32454. setStencilOperationPass(operation: number): void;
  32455. /**
  32456. * Sets a boolean indicating if the dithering state is enabled or disabled
  32457. * @param value defines the dithering state
  32458. */
  32459. setDitheringState(value: boolean): void;
  32460. /**
  32461. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  32462. * @param value defines the rasterizer state
  32463. */
  32464. setRasterizerState(value: boolean): void;
  32465. /**
  32466. * Gets the current depth function
  32467. * @returns a number defining the depth function
  32468. */
  32469. getDepthFunction(): Nullable<number>;
  32470. /**
  32471. * Sets the current depth function
  32472. * @param depthFunc defines the function to use
  32473. */
  32474. setDepthFunction(depthFunc: number): void;
  32475. /**
  32476. * Sets the current depth function to GREATER
  32477. */
  32478. setDepthFunctionToGreater(): void;
  32479. /**
  32480. * Sets the current depth function to GEQUAL
  32481. */
  32482. setDepthFunctionToGreaterOrEqual(): void;
  32483. /**
  32484. * Sets the current depth function to LESS
  32485. */
  32486. setDepthFunctionToLess(): void;
  32487. /**
  32488. * Sets the current depth function to LEQUAL
  32489. */
  32490. setDepthFunctionToLessOrEqual(): void;
  32491. private _cachedStencilBuffer;
  32492. private _cachedStencilFunction;
  32493. private _cachedStencilMask;
  32494. private _cachedStencilOperationPass;
  32495. private _cachedStencilOperationFail;
  32496. private _cachedStencilOperationDepthFail;
  32497. private _cachedStencilReference;
  32498. /**
  32499. * Caches the the state of the stencil buffer
  32500. */
  32501. cacheStencilState(): void;
  32502. /**
  32503. * Restores the state of the stencil buffer
  32504. */
  32505. restoreStencilState(): void;
  32506. /**
  32507. * Directly set the WebGL Viewport
  32508. * @param x defines the x coordinate of the viewport (in screen space)
  32509. * @param y defines the y coordinate of the viewport (in screen space)
  32510. * @param width defines the width of the viewport (in screen space)
  32511. * @param height defines the height of the viewport (in screen space)
  32512. * @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
  32513. */
  32514. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  32515. /**
  32516. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  32517. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32518. * @param y defines the y-coordinate of the corner of the clear rectangle
  32519. * @param width defines the width of the clear rectangle
  32520. * @param height defines the height of the clear rectangle
  32521. * @param clearColor defines the clear color
  32522. */
  32523. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  32524. /**
  32525. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  32526. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  32527. * @param y defines the y-coordinate of the corner of the clear rectangle
  32528. * @param width defines the width of the clear rectangle
  32529. * @param height defines the height of the clear rectangle
  32530. */
  32531. enableScissor(x: number, y: number, width: number, height: number): void;
  32532. /**
  32533. * Disable previously set scissor test rectangle
  32534. */
  32535. disableScissor(): void;
  32536. protected _reportDrawCall(): void;
  32537. /**
  32538. * Initializes a webVR display and starts listening to display change events
  32539. * The onVRDisplayChangedObservable will be notified upon these changes
  32540. * @returns The onVRDisplayChangedObservable
  32541. */
  32542. initWebVR(): Observable<IDisplayChangedEventArgs>;
  32543. /** @hidden */
  32544. _prepareVRComponent(): void;
  32545. /** @hidden */
  32546. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  32547. /** @hidden */
  32548. _submitVRFrame(): void;
  32549. /**
  32550. * Call this function to leave webVR mode
  32551. * Will do nothing if webVR is not supported or if there is no webVR device
  32552. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32553. */
  32554. disableVR(): void;
  32555. /**
  32556. * Gets a boolean indicating that the system is in VR mode and is presenting
  32557. * @returns true if VR mode is engaged
  32558. */
  32559. isVRPresenting(): boolean;
  32560. /** @hidden */
  32561. _requestVRFrame(): void;
  32562. /** @hidden */
  32563. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  32564. /**
  32565. * Gets the source code of the vertex shader associated with a specific webGL program
  32566. * @param program defines the program to use
  32567. * @returns a string containing the source code of the vertex shader associated with the program
  32568. */
  32569. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  32570. /**
  32571. * Gets the source code of the fragment shader associated with a specific webGL program
  32572. * @param program defines the program to use
  32573. * @returns a string containing the source code of the fragment shader associated with the program
  32574. */
  32575. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  32576. /**
  32577. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32578. * @param x defines the x coordinate of the rectangle where pixels must be read
  32579. * @param y defines the y coordinate of the rectangle where pixels must be read
  32580. * @param width defines the width of the rectangle where pixels must be read
  32581. * @param height defines the height of the rectangle where pixels must be read
  32582. * @returns a Uint8Array containing RGBA colors
  32583. */
  32584. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  32585. /**
  32586. * Sets a depth stencil texture from a render target to the according uniform.
  32587. * @param channel The texture channel
  32588. * @param uniform The uniform to set
  32589. * @param texture The render target texture containing the depth stencil texture to apply
  32590. */
  32591. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  32592. /**
  32593. * Sets a texture to the webGL context from a postprocess
  32594. * @param channel defines the channel to use
  32595. * @param postProcess defines the source postprocess
  32596. */
  32597. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  32598. /**
  32599. * Binds the output of the passed in post process to the texture channel specified
  32600. * @param channel The channel the texture should be bound to
  32601. * @param postProcess The post process which's output should be bound
  32602. */
  32603. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  32604. /** @hidden */
  32605. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  32606. protected _rebuildBuffers(): void;
  32607. _renderLoop(): void;
  32608. /**
  32609. * Toggle full screen mode
  32610. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32611. */
  32612. switchFullscreen(requestPointerLock: boolean): void;
  32613. /**
  32614. * Enters full screen mode
  32615. * @param requestPointerLock defines if a pointer lock should be requested from the user
  32616. */
  32617. enterFullscreen(requestPointerLock: boolean): void;
  32618. /**
  32619. * Exits full screen mode
  32620. */
  32621. exitFullscreen(): void;
  32622. /**
  32623. * Enters Pointerlock mode
  32624. */
  32625. enterPointerlock(): void;
  32626. /**
  32627. * Exits Pointerlock mode
  32628. */
  32629. exitPointerlock(): void;
  32630. /**
  32631. * Begin a new frame
  32632. */
  32633. beginFrame(): void;
  32634. /**
  32635. * Enf the current frame
  32636. */
  32637. endFrame(): void;
  32638. resize(): void;
  32639. /**
  32640. * Set the compressed texture format to use, based on the formats you have, and the formats
  32641. * supported by the hardware / browser.
  32642. *
  32643. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  32644. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  32645. * to API arguments needed to compressed textures. This puts the burden on the container
  32646. * generator to house the arcane code for determining these for current & future formats.
  32647. *
  32648. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  32649. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  32650. *
  32651. * Note: The result of this call is not taken into account when a texture is base64.
  32652. *
  32653. * @param formatsAvailable defines the list of those format families you have created
  32654. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  32655. *
  32656. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  32657. * @returns The extension selected.
  32658. */
  32659. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  32660. /**
  32661. * Force a specific size of the canvas
  32662. * @param width defines the new canvas' width
  32663. * @param height defines the new canvas' height
  32664. */
  32665. setSize(width: number, height: number): void;
  32666. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32667. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32668. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32669. _releaseTexture(texture: InternalTexture): void;
  32670. /**
  32671. * @hidden
  32672. * Rescales a texture
  32673. * @param source input texutre
  32674. * @param destination destination texture
  32675. * @param scene scene to use to render the resize
  32676. * @param internalFormat format to use when resizing
  32677. * @param onComplete callback to be called when resize has completed
  32678. */
  32679. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  32680. /**
  32681. * Gets the current framerate
  32682. * @returns a number representing the framerate
  32683. */
  32684. getFps(): number;
  32685. /**
  32686. * Gets the time spent between current and previous frame
  32687. * @returns a number representing the delta time in ms
  32688. */
  32689. getDeltaTime(): number;
  32690. private _measureFps;
  32691. /**
  32692. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  32693. * @param renderTarget The render target to set the frame buffer for
  32694. */
  32695. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  32696. /**
  32697. * Update a dynamic index buffer
  32698. * @param indexBuffer defines the target index buffer
  32699. * @param indices defines the data to update
  32700. * @param offset defines the offset in the target index buffer where update should start
  32701. */
  32702. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  32703. /**
  32704. * Creates a new render target texture
  32705. * @param size defines the size of the texture
  32706. * @param options defines the options used to create the texture
  32707. * @returns a new render target texture stored in an InternalTexture
  32708. */
  32709. createRenderTargetTexture(size: number | {
  32710. width: number;
  32711. height: number;
  32712. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  32713. /**
  32714. * Updates the sample count of a render target texture
  32715. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  32716. * @param texture defines the texture to update
  32717. * @param samples defines the sample count to set
  32718. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  32719. */
  32720. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  32721. /** @hidden */
  32722. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  32723. dispose(): void;
  32724. private _disableTouchAction;
  32725. /**
  32726. * Display the loading screen
  32727. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32728. */
  32729. displayLoadingUI(): void;
  32730. /**
  32731. * Hide the loading screen
  32732. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32733. */
  32734. hideLoadingUI(): void;
  32735. /**
  32736. * Gets the current loading screen object
  32737. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32738. */
  32739. /**
  32740. * Sets the current loading screen object
  32741. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32742. */
  32743. loadingScreen: ILoadingScreen;
  32744. /**
  32745. * Sets the current loading screen text
  32746. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32747. */
  32748. loadingUIText: string;
  32749. /**
  32750. * Sets the current loading screen background color
  32751. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  32752. */
  32753. loadingUIBackgroundColor: string;
  32754. /** Pointerlock and fullscreen */
  32755. /**
  32756. * Ask the browser to promote the current element to pointerlock mode
  32757. * @param element defines the DOM element to promote
  32758. */
  32759. static _RequestPointerlock(element: HTMLElement): void;
  32760. /**
  32761. * Asks the browser to exit pointerlock mode
  32762. */
  32763. static _ExitPointerlock(): void;
  32764. /**
  32765. * Ask the browser to promote the current element to fullscreen rendering mode
  32766. * @param element defines the DOM element to promote
  32767. */
  32768. static _RequestFullscreen(element: HTMLElement): void;
  32769. /**
  32770. * Asks the browser to exit fullscreen mode
  32771. */
  32772. static _ExitFullscreen(): void;
  32773. }
  32774. }
  32775. declare module "babylonjs/Engines/engineStore" {
  32776. import { Nullable } from "babylonjs/types";
  32777. import { Engine } from "babylonjs/Engines/engine";
  32778. import { Scene } from "babylonjs/scene";
  32779. /**
  32780. * The engine store class is responsible to hold all the instances of Engine and Scene created
  32781. * during the life time of the application.
  32782. */
  32783. export class EngineStore {
  32784. /** Gets the list of created engines */
  32785. static Instances: import("babylonjs/Engines/engine").Engine[];
  32786. /** @hidden */
  32787. static _LastCreatedScene: Nullable<Scene>;
  32788. /**
  32789. * Gets the latest created engine
  32790. */
  32791. static readonly LastCreatedEngine: Nullable<Engine>;
  32792. /**
  32793. * Gets the latest created scene
  32794. */
  32795. static readonly LastCreatedScene: Nullable<Scene>;
  32796. /**
  32797. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32798. * @ignorenaming
  32799. */
  32800. static UseFallbackTexture: boolean;
  32801. /**
  32802. * Texture content used if a texture cannot loaded
  32803. * @ignorenaming
  32804. */
  32805. static FallbackTexture: string;
  32806. }
  32807. }
  32808. declare module "babylonjs/Misc/promise" {
  32809. /**
  32810. * Helper class that provides a small promise polyfill
  32811. */
  32812. export class PromisePolyfill {
  32813. /**
  32814. * Static function used to check if the polyfill is required
  32815. * If this is the case then the function will inject the polyfill to window.Promise
  32816. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  32817. */
  32818. static Apply(force?: boolean): void;
  32819. }
  32820. }
  32821. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  32822. /**
  32823. * Interface for screenshot methods with describe argument called `size` as object with options
  32824. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  32825. */
  32826. export interface IScreenshotSize {
  32827. /**
  32828. * number in pixels for canvas height
  32829. */
  32830. height?: number;
  32831. /**
  32832. * multiplier allowing render at a higher or lower resolution
  32833. * If value is defined then height and width will be ignored and taken from camera
  32834. */
  32835. precision?: number;
  32836. /**
  32837. * number in pixels for canvas width
  32838. */
  32839. width?: number;
  32840. }
  32841. }
  32842. declare module "babylonjs/Misc/tools" {
  32843. import { Nullable, float } from "babylonjs/types";
  32844. import { DomManagement } from "babylonjs/Misc/domManagement";
  32845. import { WebRequest } from "babylonjs/Misc/webRequest";
  32846. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32847. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32848. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  32849. import { Camera } from "babylonjs/Cameras/camera";
  32850. import { Engine } from "babylonjs/Engines/engine";
  32851. interface IColor4Like {
  32852. r: float;
  32853. g: float;
  32854. b: float;
  32855. a: float;
  32856. }
  32857. /**
  32858. * Class containing a set of static utilities functions
  32859. */
  32860. export class Tools {
  32861. /**
  32862. * Gets or sets the base URL to use to load assets
  32863. */
  32864. static BaseUrl: string;
  32865. /**
  32866. * Enable/Disable Custom HTTP Request Headers globally.
  32867. * default = false
  32868. * @see CustomRequestHeaders
  32869. */
  32870. static UseCustomRequestHeaders: boolean;
  32871. /**
  32872. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  32873. * i.e. when loading files, where the server/service expects an Authorization header
  32874. */
  32875. static CustomRequestHeaders: {
  32876. [key: string]: string;
  32877. };
  32878. /**
  32879. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  32880. */
  32881. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  32882. /**
  32883. * Default behaviour for cors in the application.
  32884. * It can be a string if the expected behavior is identical in the entire app.
  32885. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  32886. */
  32887. static CorsBehavior: string | ((url: string | string[]) => string);
  32888. /**
  32889. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  32890. * @ignorenaming
  32891. */
  32892. static UseFallbackTexture: boolean;
  32893. /**
  32894. * Use this object to register external classes like custom textures or material
  32895. * to allow the laoders to instantiate them
  32896. */
  32897. static RegisteredExternalClasses: {
  32898. [key: string]: Object;
  32899. };
  32900. /**
  32901. * Texture content used if a texture cannot loaded
  32902. * @ignorenaming
  32903. */
  32904. static fallbackTexture: string;
  32905. /**
  32906. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  32907. * @param u defines the coordinate on X axis
  32908. * @param v defines the coordinate on Y axis
  32909. * @param width defines the width of the source data
  32910. * @param height defines the height of the source data
  32911. * @param pixels defines the source byte array
  32912. * @param color defines the output color
  32913. */
  32914. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  32915. /**
  32916. * Interpolates between a and b via alpha
  32917. * @param a The lower value (returned when alpha = 0)
  32918. * @param b The upper value (returned when alpha = 1)
  32919. * @param alpha The interpolation-factor
  32920. * @return The mixed value
  32921. */
  32922. static Mix(a: number, b: number, alpha: number): number;
  32923. /**
  32924. * Tries to instantiate a new object from a given class name
  32925. * @param className defines the class name to instantiate
  32926. * @returns the new object or null if the system was not able to do the instantiation
  32927. */
  32928. static Instantiate(className: string): any;
  32929. /**
  32930. * Provides a slice function that will work even on IE
  32931. * @param data defines the array to slice
  32932. * @param start defines the start of the data (optional)
  32933. * @param end defines the end of the data (optional)
  32934. * @returns the new sliced array
  32935. */
  32936. static Slice<T>(data: T, start?: number, end?: number): T;
  32937. /**
  32938. * Polyfill for setImmediate
  32939. * @param action defines the action to execute after the current execution block
  32940. */
  32941. static SetImmediate(action: () => void): void;
  32942. /**
  32943. * Function indicating if a number is an exponent of 2
  32944. * @param value defines the value to test
  32945. * @returns true if the value is an exponent of 2
  32946. */
  32947. static IsExponentOfTwo(value: number): boolean;
  32948. private static _tmpFloatArray;
  32949. /**
  32950. * Returns the nearest 32-bit single precision float representation of a Number
  32951. * @param value A Number. If the parameter is of a different type, it will get converted
  32952. * to a number or to NaN if it cannot be converted
  32953. * @returns number
  32954. */
  32955. static FloatRound(value: number): number;
  32956. /**
  32957. * Extracts the filename from a path
  32958. * @param path defines the path to use
  32959. * @returns the filename
  32960. */
  32961. static GetFilename(path: string): string;
  32962. /**
  32963. * Extracts the "folder" part of a path (everything before the filename).
  32964. * @param uri The URI to extract the info from
  32965. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  32966. * @returns The "folder" part of the path
  32967. */
  32968. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  32969. /**
  32970. * Extracts text content from a DOM element hierarchy
  32971. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  32972. */
  32973. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  32974. /**
  32975. * Convert an angle in radians to degrees
  32976. * @param angle defines the angle to convert
  32977. * @returns the angle in degrees
  32978. */
  32979. static ToDegrees(angle: number): number;
  32980. /**
  32981. * Convert an angle in degrees to radians
  32982. * @param angle defines the angle to convert
  32983. * @returns the angle in radians
  32984. */
  32985. static ToRadians(angle: number): number;
  32986. /**
  32987. * Encode a buffer to a base64 string
  32988. * @param buffer defines the buffer to encode
  32989. * @returns the encoded string
  32990. */
  32991. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  32992. /**
  32993. * Returns an array if obj is not an array
  32994. * @param obj defines the object to evaluate as an array
  32995. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  32996. * @returns either obj directly if obj is an array or a new array containing obj
  32997. */
  32998. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  32999. /**
  33000. * Gets the pointer prefix to use
  33001. * @returns "pointer" if touch is enabled. Else returns "mouse"
  33002. */
  33003. static GetPointerPrefix(): string;
  33004. /**
  33005. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  33006. * @param url define the url we are trying
  33007. * @param element define the dom element where to configure the cors policy
  33008. */
  33009. static SetCorsBehavior(url: string | string[], element: {
  33010. crossOrigin: string | null;
  33011. }): void;
  33012. /**
  33013. * Removes unwanted characters from an url
  33014. * @param url defines the url to clean
  33015. * @returns the cleaned url
  33016. */
  33017. static CleanUrl(url: string): string;
  33018. /**
  33019. * Gets or sets a function used to pre-process url before using them to load assets
  33020. */
  33021. static PreprocessUrl: (url: string) => string;
  33022. /**
  33023. * Loads an image as an HTMLImageElement.
  33024. * @param input url string, ArrayBuffer, or Blob to load
  33025. * @param onLoad callback called when the image successfully loads
  33026. * @param onError callback called when the image fails to load
  33027. * @param offlineProvider offline provider for caching
  33028. * @returns the HTMLImageElement of the loaded image
  33029. */
  33030. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  33031. /**
  33032. * Loads a file
  33033. * @param url url string, ArrayBuffer, or Blob to load
  33034. * @param onSuccess callback called when the file successfully loads
  33035. * @param onProgress callback called while file is loading (if the server supports this mode)
  33036. * @param offlineProvider defines the offline provider for caching
  33037. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33038. * @param onError callback called when the file fails to load
  33039. * @returns a file request object
  33040. */
  33041. 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;
  33042. /**
  33043. * Loads a file from a url
  33044. * @param url the file url to load
  33045. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  33046. */
  33047. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  33048. /**
  33049. * Load a script (identified by an url). When the url returns, the
  33050. * content of this file is added into a new script element, attached to the DOM (body element)
  33051. * @param scriptUrl defines the url of the script to laod
  33052. * @param onSuccess defines the callback called when the script is loaded
  33053. * @param onError defines the callback to call if an error occurs
  33054. * @param scriptId defines the id of the script element
  33055. */
  33056. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  33057. /**
  33058. * Load an asynchronous script (identified by an url). When the url returns, the
  33059. * content of this file is added into a new script element, attached to the DOM (body element)
  33060. * @param scriptUrl defines the url of the script to laod
  33061. * @param scriptId defines the id of the script element
  33062. * @returns a promise request object
  33063. */
  33064. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  33065. /**
  33066. * Loads a file from a blob
  33067. * @param fileToLoad defines the blob to use
  33068. * @param callback defines the callback to call when data is loaded
  33069. * @param progressCallback defines the callback to call during loading process
  33070. * @returns a file request object
  33071. */
  33072. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  33073. /**
  33074. * Loads a file
  33075. * @param fileToLoad defines the file to load
  33076. * @param callback defines the callback to call when data is loaded
  33077. * @param progressCallBack defines the callback to call during loading process
  33078. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  33079. * @returns a file request object
  33080. */
  33081. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  33082. /**
  33083. * Creates a data url from a given string content
  33084. * @param content defines the content to convert
  33085. * @returns the new data url link
  33086. */
  33087. static FileAsURL(content: string): string;
  33088. /**
  33089. * Format the given number to a specific decimal format
  33090. * @param value defines the number to format
  33091. * @param decimals defines the number of decimals to use
  33092. * @returns the formatted string
  33093. */
  33094. static Format(value: number, decimals?: number): string;
  33095. /**
  33096. * Tries to copy an object by duplicating every property
  33097. * @param source defines the source object
  33098. * @param destination defines the target object
  33099. * @param doNotCopyList defines a list of properties to avoid
  33100. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  33101. */
  33102. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  33103. /**
  33104. * Gets a boolean indicating if the given object has no own property
  33105. * @param obj defines the object to test
  33106. * @returns true if object has no own property
  33107. */
  33108. static IsEmpty(obj: any): boolean;
  33109. /**
  33110. * Function used to register events at window level
  33111. * @param windowElement defines the Window object to use
  33112. * @param events defines the events to register
  33113. */
  33114. static RegisterTopRootEvents(windowElement: Window, events: {
  33115. name: string;
  33116. handler: Nullable<(e: FocusEvent) => any>;
  33117. }[]): void;
  33118. /**
  33119. * Function used to unregister events from window level
  33120. * @param windowElement defines the Window object to use
  33121. * @param events defines the events to unregister
  33122. */
  33123. static UnregisterTopRootEvents(windowElement: Window, events: {
  33124. name: string;
  33125. handler: Nullable<(e: FocusEvent) => any>;
  33126. }[]): void;
  33127. /**
  33128. * @ignore
  33129. */
  33130. static _ScreenshotCanvas: HTMLCanvasElement;
  33131. /**
  33132. * Dumps the current bound framebuffer
  33133. * @param width defines the rendering width
  33134. * @param height defines the rendering height
  33135. * @param engine defines the hosting engine
  33136. * @param successCallback defines the callback triggered once the data are available
  33137. * @param mimeType defines the mime type of the result
  33138. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  33139. */
  33140. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33141. /**
  33142. * Converts the canvas data to blob.
  33143. * This acts as a polyfill for browsers not supporting the to blob function.
  33144. * @param canvas Defines the canvas to extract the data from
  33145. * @param successCallback Defines the callback triggered once the data are available
  33146. * @param mimeType Defines the mime type of the result
  33147. */
  33148. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  33149. /**
  33150. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  33151. * @param successCallback defines the callback triggered once the data are available
  33152. * @param mimeType defines the mime type of the result
  33153. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  33154. */
  33155. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  33156. /**
  33157. * Downloads a blob in the browser
  33158. * @param blob defines the blob to download
  33159. * @param fileName defines the name of the downloaded file
  33160. */
  33161. static Download(blob: Blob, fileName: string): void;
  33162. /**
  33163. * Captures a screenshot of the current rendering
  33164. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33165. * @param engine defines the rendering engine
  33166. * @param camera defines the source camera
  33167. * @param size This parameter can be set to a single number or to an object with the
  33168. * following (optional) properties: precision, width, height. If a single number is passed,
  33169. * it will be used for both width and height. If an object is passed, the screenshot size
  33170. * will be derived from the parameters. The precision property is a multiplier allowing
  33171. * rendering at a higher or lower resolution
  33172. * @param successCallback defines the callback receives a single parameter which contains the
  33173. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33174. * src parameter of an <img> to display it
  33175. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33176. * Check your browser for supported MIME types
  33177. */
  33178. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  33179. /**
  33180. * Captures a screenshot of the current rendering
  33181. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33182. * @param engine defines the rendering engine
  33183. * @param camera defines the source camera
  33184. * @param size This parameter can be set to a single number or to an object with the
  33185. * following (optional) properties: precision, width, height. If a single number is passed,
  33186. * it will be used for both width and height. If an object is passed, the screenshot size
  33187. * will be derived from the parameters. The precision property is a multiplier allowing
  33188. * rendering at a higher or lower resolution
  33189. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  33190. * Check your browser for supported MIME types
  33191. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33192. * to the src parameter of an <img> to display it
  33193. */
  33194. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  33195. /**
  33196. * Generates an image screenshot from the specified camera.
  33197. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33198. * @param engine The engine to use for rendering
  33199. * @param camera The camera to use for rendering
  33200. * @param size This parameter can be set to a single number or to an object with the
  33201. * following (optional) properties: precision, width, height. If a single number is passed,
  33202. * it will be used for both width and height. If an object is passed, the screenshot size
  33203. * will be derived from the parameters. The precision property is a multiplier allowing
  33204. * rendering at a higher or lower resolution
  33205. * @param successCallback The callback receives a single parameter which contains the
  33206. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  33207. * src parameter of an <img> to display it
  33208. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33209. * Check your browser for supported MIME types
  33210. * @param samples Texture samples (default: 1)
  33211. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33212. * @param fileName A name for for the downloaded file.
  33213. */
  33214. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  33215. /**
  33216. * Generates an image screenshot from the specified camera.
  33217. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  33218. * @param engine The engine to use for rendering
  33219. * @param camera The camera to use for rendering
  33220. * @param size This parameter can be set to a single number or to an object with the
  33221. * following (optional) properties: precision, width, height. If a single number is passed,
  33222. * it will be used for both width and height. If an object is passed, the screenshot size
  33223. * will be derived from the parameters. The precision property is a multiplier allowing
  33224. * rendering at a higher or lower resolution
  33225. * @param mimeType The MIME type of the screenshot image (default: image/png).
  33226. * Check your browser for supported MIME types
  33227. * @param samples Texture samples (default: 1)
  33228. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  33229. * @param fileName A name for for the downloaded file.
  33230. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  33231. * to the src parameter of an <img> to display it
  33232. */
  33233. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  33234. /**
  33235. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  33236. * Be aware Math.random() could cause collisions, but:
  33237. * "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"
  33238. * @returns a pseudo random id
  33239. */
  33240. static RandomId(): string;
  33241. /**
  33242. * Test if the given uri is a base64 string
  33243. * @param uri The uri to test
  33244. * @return True if the uri is a base64 string or false otherwise
  33245. */
  33246. static IsBase64(uri: string): boolean;
  33247. /**
  33248. * Decode the given base64 uri.
  33249. * @param uri The uri to decode
  33250. * @return The decoded base64 data.
  33251. */
  33252. static DecodeBase64(uri: string): ArrayBuffer;
  33253. /**
  33254. * Gets the absolute url.
  33255. * @param url the input url
  33256. * @return the absolute url
  33257. */
  33258. static GetAbsoluteUrl(url: string): string;
  33259. /**
  33260. * No log
  33261. */
  33262. static readonly NoneLogLevel: number;
  33263. /**
  33264. * Only message logs
  33265. */
  33266. static readonly MessageLogLevel: number;
  33267. /**
  33268. * Only warning logs
  33269. */
  33270. static readonly WarningLogLevel: number;
  33271. /**
  33272. * Only error logs
  33273. */
  33274. static readonly ErrorLogLevel: number;
  33275. /**
  33276. * All logs
  33277. */
  33278. static readonly AllLogLevel: number;
  33279. /**
  33280. * Gets a value indicating the number of loading errors
  33281. * @ignorenaming
  33282. */
  33283. static readonly errorsCount: number;
  33284. /**
  33285. * Callback called when a new log is added
  33286. */
  33287. static OnNewCacheEntry: (entry: string) => void;
  33288. /**
  33289. * Log a message to the console
  33290. * @param message defines the message to log
  33291. */
  33292. static Log(message: string): void;
  33293. /**
  33294. * Write a warning message to the console
  33295. * @param message defines the message to log
  33296. */
  33297. static Warn(message: string): void;
  33298. /**
  33299. * Write an error message to the console
  33300. * @param message defines the message to log
  33301. */
  33302. static Error(message: string): void;
  33303. /**
  33304. * Gets current log cache (list of logs)
  33305. */
  33306. static readonly LogCache: string;
  33307. /**
  33308. * Clears the log cache
  33309. */
  33310. static ClearLogCache(): void;
  33311. /**
  33312. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  33313. */
  33314. static LogLevels: number;
  33315. /**
  33316. * Checks if the window object exists
  33317. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  33318. */
  33319. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  33320. /**
  33321. * No performance log
  33322. */
  33323. static readonly PerformanceNoneLogLevel: number;
  33324. /**
  33325. * Use user marks to log performance
  33326. */
  33327. static readonly PerformanceUserMarkLogLevel: number;
  33328. /**
  33329. * Log performance to the console
  33330. */
  33331. static readonly PerformanceConsoleLogLevel: number;
  33332. private static _performance;
  33333. /**
  33334. * Sets the current performance log level
  33335. */
  33336. static PerformanceLogLevel: number;
  33337. private static _StartPerformanceCounterDisabled;
  33338. private static _EndPerformanceCounterDisabled;
  33339. private static _StartUserMark;
  33340. private static _EndUserMark;
  33341. private static _StartPerformanceConsole;
  33342. private static _EndPerformanceConsole;
  33343. /**
  33344. * Starts a performance counter
  33345. */
  33346. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33347. /**
  33348. * Ends a specific performance coutner
  33349. */
  33350. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  33351. /**
  33352. * Gets either window.performance.now() if supported or Date.now() else
  33353. */
  33354. static readonly Now: number;
  33355. /**
  33356. * This method will return the name of the class used to create the instance of the given object.
  33357. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  33358. * @param object the object to get the class name from
  33359. * @param isType defines if the object is actually a type
  33360. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  33361. */
  33362. static GetClassName(object: any, isType?: boolean): string;
  33363. /**
  33364. * Gets the first element of an array satisfying a given predicate
  33365. * @param array defines the array to browse
  33366. * @param predicate defines the predicate to use
  33367. * @returns null if not found or the element
  33368. */
  33369. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  33370. /**
  33371. * This method will return the name of the full name of the class, including its owning module (if any).
  33372. * 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).
  33373. * @param object the object to get the class name from
  33374. * @param isType defines if the object is actually a type
  33375. * @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.
  33376. * @ignorenaming
  33377. */
  33378. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  33379. /**
  33380. * Returns a promise that resolves after the given amount of time.
  33381. * @param delay Number of milliseconds to delay
  33382. * @returns Promise that resolves after the given amount of time
  33383. */
  33384. static DelayAsync(delay: number): Promise<void>;
  33385. }
  33386. /**
  33387. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  33388. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  33389. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  33390. * @param name The name of the class, case should be preserved
  33391. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  33392. */
  33393. export function className(name: string, module?: string): (target: Object) => void;
  33394. /**
  33395. * An implementation of a loop for asynchronous functions.
  33396. */
  33397. export class AsyncLoop {
  33398. /**
  33399. * Defines the number of iterations for the loop
  33400. */
  33401. iterations: number;
  33402. /**
  33403. * Defines the current index of the loop.
  33404. */
  33405. index: number;
  33406. private _done;
  33407. private _fn;
  33408. private _successCallback;
  33409. /**
  33410. * Constructor.
  33411. * @param iterations the number of iterations.
  33412. * @param func the function to run each iteration
  33413. * @param successCallback the callback that will be called upon succesful execution
  33414. * @param offset starting offset.
  33415. */
  33416. constructor(
  33417. /**
  33418. * Defines the number of iterations for the loop
  33419. */
  33420. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  33421. /**
  33422. * Execute the next iteration. Must be called after the last iteration was finished.
  33423. */
  33424. executeNext(): void;
  33425. /**
  33426. * Break the loop and run the success callback.
  33427. */
  33428. breakLoop(): void;
  33429. /**
  33430. * Create and run an async loop.
  33431. * @param iterations the number of iterations.
  33432. * @param fn the function to run each iteration
  33433. * @param successCallback the callback that will be called upon succesful execution
  33434. * @param offset starting offset.
  33435. * @returns the created async loop object
  33436. */
  33437. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  33438. /**
  33439. * A for-loop that will run a given number of iterations synchronous and the rest async.
  33440. * @param iterations total number of iterations
  33441. * @param syncedIterations number of synchronous iterations in each async iteration.
  33442. * @param fn the function to call each iteration.
  33443. * @param callback a success call back that will be called when iterating stops.
  33444. * @param breakFunction a break condition (optional)
  33445. * @param timeout timeout settings for the setTimeout function. default - 0.
  33446. * @returns the created async loop object
  33447. */
  33448. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  33449. }
  33450. }
  33451. declare module "babylonjs/Misc/stringDictionary" {
  33452. import { Nullable } from "babylonjs/types";
  33453. /**
  33454. * This class implement a typical dictionary using a string as key and the generic type T as value.
  33455. * The underlying implementation relies on an associative array to ensure the best performances.
  33456. * The value can be anything including 'null' but except 'undefined'
  33457. */
  33458. export class StringDictionary<T> {
  33459. /**
  33460. * This will clear this dictionary and copy the content from the 'source' one.
  33461. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  33462. * @param source the dictionary to take the content from and copy to this dictionary
  33463. */
  33464. copyFrom(source: StringDictionary<T>): void;
  33465. /**
  33466. * Get a value based from its key
  33467. * @param key the given key to get the matching value from
  33468. * @return the value if found, otherwise undefined is returned
  33469. */
  33470. get(key: string): T | undefined;
  33471. /**
  33472. * Get a value from its key or add it if it doesn't exist.
  33473. * This method will ensure you that a given key/data will be present in the dictionary.
  33474. * @param key the given key to get the matching value from
  33475. * @param factory the factory that will create the value if the key is not present in the dictionary.
  33476. * The factory will only be invoked if there's no data for the given key.
  33477. * @return the value corresponding to the key.
  33478. */
  33479. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  33480. /**
  33481. * Get a value from its key if present in the dictionary otherwise add it
  33482. * @param key the key to get the value from
  33483. * @param val if there's no such key/value pair in the dictionary add it with this value
  33484. * @return the value corresponding to the key
  33485. */
  33486. getOrAdd(key: string, val: T): T;
  33487. /**
  33488. * Check if there's a given key in the dictionary
  33489. * @param key the key to check for
  33490. * @return true if the key is present, false otherwise
  33491. */
  33492. contains(key: string): boolean;
  33493. /**
  33494. * Add a new key and its corresponding value
  33495. * @param key the key to add
  33496. * @param value the value corresponding to the key
  33497. * @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
  33498. */
  33499. add(key: string, value: T): boolean;
  33500. /**
  33501. * Update a specific value associated to a key
  33502. * @param key defines the key to use
  33503. * @param value defines the value to store
  33504. * @returns true if the value was updated (or false if the key was not found)
  33505. */
  33506. set(key: string, value: T): boolean;
  33507. /**
  33508. * Get the element of the given key and remove it from the dictionary
  33509. * @param key defines the key to search
  33510. * @returns the value associated with the key or null if not found
  33511. */
  33512. getAndRemove(key: string): Nullable<T>;
  33513. /**
  33514. * Remove a key/value from the dictionary.
  33515. * @param key the key to remove
  33516. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  33517. */
  33518. remove(key: string): boolean;
  33519. /**
  33520. * Clear the whole content of the dictionary
  33521. */
  33522. clear(): void;
  33523. /**
  33524. * Gets the current count
  33525. */
  33526. readonly count: number;
  33527. /**
  33528. * Execute a callback on each key/val of the dictionary.
  33529. * Note that you can remove any element in this dictionary in the callback implementation
  33530. * @param callback the callback to execute on a given key/value pair
  33531. */
  33532. forEach(callback: (key: string, val: T) => void): void;
  33533. /**
  33534. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  33535. * If the callback returns null or undefined the method will iterate to the next key/value pair
  33536. * Note that you can remove any element in this dictionary in the callback implementation
  33537. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  33538. * @returns the first item
  33539. */
  33540. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  33541. private _count;
  33542. private _data;
  33543. }
  33544. }
  33545. declare module "babylonjs/Collisions/collisionCoordinator" {
  33546. import { Nullable } from "babylonjs/types";
  33547. import { Scene } from "babylonjs/scene";
  33548. import { Vector3 } from "babylonjs/Maths/math.vector";
  33549. import { Collider } from "babylonjs/Collisions/collider";
  33550. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33551. /** @hidden */
  33552. export interface ICollisionCoordinator {
  33553. createCollider(): Collider;
  33554. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33555. init(scene: Scene): void;
  33556. }
  33557. /** @hidden */
  33558. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  33559. private _scene;
  33560. private _scaledPosition;
  33561. private _scaledVelocity;
  33562. private _finalPosition;
  33563. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  33564. createCollider(): Collider;
  33565. init(scene: Scene): void;
  33566. private _collideWithWorld;
  33567. }
  33568. }
  33569. declare module "babylonjs/Inputs/scene.inputManager" {
  33570. import { Nullable } from "babylonjs/types";
  33571. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33572. import { Vector2 } from "babylonjs/Maths/math.vector";
  33573. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33574. import { Scene } from "babylonjs/scene";
  33575. /**
  33576. * Class used to manage all inputs for the scene.
  33577. */
  33578. export class InputManager {
  33579. /** The distance in pixel that you have to move to prevent some events */
  33580. static DragMovementThreshold: number;
  33581. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  33582. static LongPressDelay: number;
  33583. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  33584. static DoubleClickDelay: number;
  33585. /** If you need to check double click without raising a single click at first click, enable this flag */
  33586. static ExclusiveDoubleClickMode: boolean;
  33587. private _wheelEventName;
  33588. private _onPointerMove;
  33589. private _onPointerDown;
  33590. private _onPointerUp;
  33591. private _initClickEvent;
  33592. private _initActionManager;
  33593. private _delayedSimpleClick;
  33594. private _delayedSimpleClickTimeout;
  33595. private _previousDelayedSimpleClickTimeout;
  33596. private _meshPickProceed;
  33597. private _previousButtonPressed;
  33598. private _currentPickResult;
  33599. private _previousPickResult;
  33600. private _totalPointersPressed;
  33601. private _doubleClickOccured;
  33602. private _pointerOverMesh;
  33603. private _pickedDownMesh;
  33604. private _pickedUpMesh;
  33605. private _pointerX;
  33606. private _pointerY;
  33607. private _unTranslatedPointerX;
  33608. private _unTranslatedPointerY;
  33609. private _startingPointerPosition;
  33610. private _previousStartingPointerPosition;
  33611. private _startingPointerTime;
  33612. private _previousStartingPointerTime;
  33613. private _pointerCaptures;
  33614. private _onKeyDown;
  33615. private _onKeyUp;
  33616. private _onCanvasFocusObserver;
  33617. private _onCanvasBlurObserver;
  33618. private _scene;
  33619. /**
  33620. * Creates a new InputManager
  33621. * @param scene defines the hosting scene
  33622. */
  33623. constructor(scene: Scene);
  33624. /**
  33625. * Gets the mesh that is currently under the pointer
  33626. */
  33627. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33628. /**
  33629. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  33630. */
  33631. readonly unTranslatedPointer: Vector2;
  33632. /**
  33633. * Gets or sets the current on-screen X position of the pointer
  33634. */
  33635. pointerX: number;
  33636. /**
  33637. * Gets or sets the current on-screen Y position of the pointer
  33638. */
  33639. pointerY: number;
  33640. private _updatePointerPosition;
  33641. private _processPointerMove;
  33642. private _setRayOnPointerInfo;
  33643. private _checkPrePointerObservable;
  33644. /**
  33645. * Use this method to simulate a pointer move on a mesh
  33646. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33647. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33648. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33649. */
  33650. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33651. /**
  33652. * Use this method to simulate a pointer down on a mesh
  33653. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33654. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33655. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33656. */
  33657. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  33658. private _processPointerDown;
  33659. /** @hidden */
  33660. _isPointerSwiping(): boolean;
  33661. /**
  33662. * Use this method to simulate a pointer up on a mesh
  33663. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33664. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33665. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33666. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33667. */
  33668. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  33669. private _processPointerUp;
  33670. /**
  33671. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33672. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33673. * @returns true if the pointer was captured
  33674. */
  33675. isPointerCaptured(pointerId?: number): boolean;
  33676. /**
  33677. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33678. * @param attachUp defines if you want to attach events to pointerup
  33679. * @param attachDown defines if you want to attach events to pointerdown
  33680. * @param attachMove defines if you want to attach events to pointermove
  33681. */
  33682. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33683. /**
  33684. * Detaches all event handlers
  33685. */
  33686. detachControl(): void;
  33687. /**
  33688. * Force the value of meshUnderPointer
  33689. * @param mesh defines the mesh to use
  33690. */
  33691. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  33692. /**
  33693. * Gets the mesh under the pointer
  33694. * @returns a Mesh or null if no mesh is under the pointer
  33695. */
  33696. getPointerOverMesh(): Nullable<AbstractMesh>;
  33697. }
  33698. }
  33699. declare module "babylonjs/Misc/uniqueIdGenerator" {
  33700. /**
  33701. * Helper class used to generate session unique ID
  33702. */
  33703. export class UniqueIdGenerator {
  33704. private static _UniqueIdCounter;
  33705. /**
  33706. * Gets an unique (relatively to the current scene) Id
  33707. */
  33708. static readonly UniqueId: number;
  33709. }
  33710. }
  33711. declare module "babylonjs/Animations/animationGroup" {
  33712. import { Animatable } from "babylonjs/Animations/animatable";
  33713. import { Animation } from "babylonjs/Animations/animation";
  33714. import { Scene, IDisposable } from "babylonjs/scene";
  33715. import { Observable } from "babylonjs/Misc/observable";
  33716. import { Nullable } from "babylonjs/types";
  33717. import "babylonjs/Animations/animatable";
  33718. /**
  33719. * This class defines the direct association between an animation and a target
  33720. */
  33721. export class TargetedAnimation {
  33722. /**
  33723. * Animation to perform
  33724. */
  33725. animation: Animation;
  33726. /**
  33727. * Target to animate
  33728. */
  33729. target: any;
  33730. /**
  33731. * Serialize the object
  33732. * @returns the JSON object representing the current entity
  33733. */
  33734. serialize(): any;
  33735. }
  33736. /**
  33737. * Use this class to create coordinated animations on multiple targets
  33738. */
  33739. export class AnimationGroup implements IDisposable {
  33740. /** The name of the animation group */
  33741. name: string;
  33742. private _scene;
  33743. private _targetedAnimations;
  33744. private _animatables;
  33745. private _from;
  33746. private _to;
  33747. private _isStarted;
  33748. private _isPaused;
  33749. private _speedRatio;
  33750. private _loopAnimation;
  33751. /**
  33752. * Gets or sets the unique id of the node
  33753. */
  33754. uniqueId: number;
  33755. /**
  33756. * This observable will notify when one animation have ended
  33757. */
  33758. onAnimationEndObservable: Observable<TargetedAnimation>;
  33759. /**
  33760. * Observer raised when one animation loops
  33761. */
  33762. onAnimationLoopObservable: Observable<TargetedAnimation>;
  33763. /**
  33764. * This observable will notify when all animations have ended.
  33765. */
  33766. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  33767. /**
  33768. * This observable will notify when all animations have paused.
  33769. */
  33770. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  33771. /**
  33772. * This observable will notify when all animations are playing.
  33773. */
  33774. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  33775. /**
  33776. * Gets the first frame
  33777. */
  33778. readonly from: number;
  33779. /**
  33780. * Gets the last frame
  33781. */
  33782. readonly to: number;
  33783. /**
  33784. * Define if the animations are started
  33785. */
  33786. readonly isStarted: boolean;
  33787. /**
  33788. * Gets a value indicating that the current group is playing
  33789. */
  33790. readonly isPlaying: boolean;
  33791. /**
  33792. * Gets or sets the speed ratio to use for all animations
  33793. */
  33794. /**
  33795. * Gets or sets the speed ratio to use for all animations
  33796. */
  33797. speedRatio: number;
  33798. /**
  33799. * Gets or sets if all animations should loop or not
  33800. */
  33801. loopAnimation: boolean;
  33802. /**
  33803. * Gets the targeted animations for this animation group
  33804. */
  33805. readonly targetedAnimations: Array<TargetedAnimation>;
  33806. /**
  33807. * returning the list of animatables controlled by this animation group.
  33808. */
  33809. readonly animatables: Array<Animatable>;
  33810. /**
  33811. * Instantiates a new Animation Group.
  33812. * This helps managing several animations at once.
  33813. * @see http://doc.babylonjs.com/how_to/group
  33814. * @param name Defines the name of the group
  33815. * @param scene Defines the scene the group belongs to
  33816. */
  33817. constructor(
  33818. /** The name of the animation group */
  33819. name: string, scene?: Nullable<Scene>);
  33820. /**
  33821. * Add an animation (with its target) in the group
  33822. * @param animation defines the animation we want to add
  33823. * @param target defines the target of the animation
  33824. * @returns the TargetedAnimation object
  33825. */
  33826. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  33827. /**
  33828. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  33829. * It can add constant keys at begin or end
  33830. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  33831. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  33832. * @returns the animation group
  33833. */
  33834. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  33835. /**
  33836. * Start all animations on given targets
  33837. * @param loop defines if animations must loop
  33838. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  33839. * @param from defines the from key (optional)
  33840. * @param to defines the to key (optional)
  33841. * @returns the current animation group
  33842. */
  33843. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  33844. /**
  33845. * Pause all animations
  33846. * @returns the animation group
  33847. */
  33848. pause(): AnimationGroup;
  33849. /**
  33850. * Play all animations to initial state
  33851. * This function will start() the animations if they were not started or will restart() them if they were paused
  33852. * @param loop defines if animations must loop
  33853. * @returns the animation group
  33854. */
  33855. play(loop?: boolean): AnimationGroup;
  33856. /**
  33857. * Reset all animations to initial state
  33858. * @returns the animation group
  33859. */
  33860. reset(): AnimationGroup;
  33861. /**
  33862. * Restart animations from key 0
  33863. * @returns the animation group
  33864. */
  33865. restart(): AnimationGroup;
  33866. /**
  33867. * Stop all animations
  33868. * @returns the animation group
  33869. */
  33870. stop(): AnimationGroup;
  33871. /**
  33872. * Set animation weight for all animatables
  33873. * @param weight defines the weight to use
  33874. * @return the animationGroup
  33875. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33876. */
  33877. setWeightForAllAnimatables(weight: number): AnimationGroup;
  33878. /**
  33879. * Synchronize and normalize all animatables with a source animatable
  33880. * @param root defines the root animatable to synchronize with
  33881. * @return the animationGroup
  33882. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  33883. */
  33884. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  33885. /**
  33886. * Goes to a specific frame in this animation group
  33887. * @param frame the frame number to go to
  33888. * @return the animationGroup
  33889. */
  33890. goToFrame(frame: number): AnimationGroup;
  33891. /**
  33892. * Dispose all associated resources
  33893. */
  33894. dispose(): void;
  33895. private _checkAnimationGroupEnded;
  33896. /**
  33897. * Clone the current animation group and returns a copy
  33898. * @param newName defines the name of the new group
  33899. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  33900. * @returns the new aniamtion group
  33901. */
  33902. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  33903. /**
  33904. * Serializes the animationGroup to an object
  33905. * @returns Serialized object
  33906. */
  33907. serialize(): any;
  33908. /**
  33909. * Returns a new AnimationGroup object parsed from the source provided.
  33910. * @param parsedAnimationGroup defines the source
  33911. * @param scene defines the scene that will receive the animationGroup
  33912. * @returns a new AnimationGroup
  33913. */
  33914. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  33915. /**
  33916. * Returns the string "AnimationGroup"
  33917. * @returns "AnimationGroup"
  33918. */
  33919. getClassName(): string;
  33920. /**
  33921. * Creates a detailled string about the object
  33922. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  33923. * @returns a string representing the object
  33924. */
  33925. toString(fullDetails?: boolean): string;
  33926. }
  33927. }
  33928. declare module "babylonjs/scene" {
  33929. import { Nullable } from "babylonjs/types";
  33930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  33931. import { Observable } from "babylonjs/Misc/observable";
  33932. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  33933. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  33934. import { Geometry } from "babylonjs/Meshes/geometry";
  33935. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33936. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33937. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33938. import { Mesh } from "babylonjs/Meshes/mesh";
  33939. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33940. import { Bone } from "babylonjs/Bones/bone";
  33941. import { Skeleton } from "babylonjs/Bones/skeleton";
  33942. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  33943. import { Camera } from "babylonjs/Cameras/camera";
  33944. import { AbstractScene } from "babylonjs/abstractScene";
  33945. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33946. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  33947. import { Material } from "babylonjs/Materials/material";
  33948. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  33949. import { Effect } from "babylonjs/Materials/effect";
  33950. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  33951. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  33952. import { Light } from "babylonjs/Lights/light";
  33953. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33954. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  33955. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  33956. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  33957. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  33958. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  33959. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  33960. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  33961. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  33962. import { Engine } from "babylonjs/Engines/engine";
  33963. import { Node } from "babylonjs/node";
  33964. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  33965. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33966. import { WebRequest } from "babylonjs/Misc/webRequest";
  33967. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  33968. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  33969. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  33970. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  33971. import { Plane } from "babylonjs/Maths/math.plane";
  33972. import { Ray } from "babylonjs/Culling/ray";
  33973. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33974. import { Animation } from "babylonjs/Animations/animation";
  33975. import { Animatable } from "babylonjs/Animations/animatable";
  33976. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  33977. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  33978. import { Collider } from "babylonjs/Collisions/collider";
  33979. /**
  33980. * Define an interface for all classes that will hold resources
  33981. */
  33982. export interface IDisposable {
  33983. /**
  33984. * Releases all held resources
  33985. */
  33986. dispose(): void;
  33987. }
  33988. /** Interface defining initialization parameters for Scene class */
  33989. export interface SceneOptions {
  33990. /**
  33991. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  33992. * It will improve performance when the number of geometries becomes important.
  33993. */
  33994. useGeometryUniqueIdsMap?: boolean;
  33995. /**
  33996. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  33997. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  33998. */
  33999. useMaterialMeshMap?: boolean;
  34000. /**
  34001. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  34002. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  34003. */
  34004. useClonedMeshhMap?: boolean;
  34005. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  34006. virtual?: boolean;
  34007. }
  34008. /**
  34009. * Represents a scene to be rendered by the engine.
  34010. * @see http://doc.babylonjs.com/features/scene
  34011. */
  34012. export class Scene extends AbstractScene implements IAnimatable {
  34013. /** The fog is deactivated */
  34014. static readonly FOGMODE_NONE: number;
  34015. /** The fog density is following an exponential function */
  34016. static readonly FOGMODE_EXP: number;
  34017. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  34018. static readonly FOGMODE_EXP2: number;
  34019. /** The fog density is following a linear function. */
  34020. static readonly FOGMODE_LINEAR: number;
  34021. /**
  34022. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  34023. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34024. */
  34025. static MinDeltaTime: number;
  34026. /**
  34027. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  34028. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34029. */
  34030. static MaxDeltaTime: number;
  34031. /**
  34032. * Factory used to create the default material.
  34033. * @param name The name of the material to create
  34034. * @param scene The scene to create the material for
  34035. * @returns The default material
  34036. */
  34037. static DefaultMaterialFactory(scene: Scene): Material;
  34038. /**
  34039. * Factory used to create the a collision coordinator.
  34040. * @returns The collision coordinator
  34041. */
  34042. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  34043. /** @hidden */
  34044. _inputManager: InputManager;
  34045. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  34046. cameraToUseForPointers: Nullable<Camera>;
  34047. /** @hidden */
  34048. readonly _isScene: boolean;
  34049. /**
  34050. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  34051. */
  34052. autoClear: boolean;
  34053. /**
  34054. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  34055. */
  34056. autoClearDepthAndStencil: boolean;
  34057. /**
  34058. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  34059. */
  34060. clearColor: Color4;
  34061. /**
  34062. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  34063. */
  34064. ambientColor: Color3;
  34065. /**
  34066. * This is use to store the default BRDF lookup for PBR materials in your scene.
  34067. * It should only be one of the following (if not the default embedded one):
  34068. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  34069. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  34070. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  34071. * The material properties need to be setup according to the type of texture in use.
  34072. */
  34073. environmentBRDFTexture: BaseTexture;
  34074. /** @hidden */
  34075. protected _environmentTexture: Nullable<BaseTexture>;
  34076. /**
  34077. * Texture used in all pbr material as the reflection texture.
  34078. * As in the majority of the scene they are the same (exception for multi room and so on),
  34079. * this is easier to reference from here than from all the materials.
  34080. */
  34081. /**
  34082. * Texture used in all pbr material as the reflection texture.
  34083. * As in the majority of the scene they are the same (exception for multi room and so on),
  34084. * this is easier to set here than in all the materials.
  34085. */
  34086. environmentTexture: Nullable<BaseTexture>;
  34087. /** @hidden */
  34088. protected _environmentIntensity: number;
  34089. /**
  34090. * Intensity of the environment in all pbr material.
  34091. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34092. * As in the majority of the scene they are the same (exception for multi room and so on),
  34093. * this is easier to reference from here than from all the materials.
  34094. */
  34095. /**
  34096. * Intensity of the environment in all pbr material.
  34097. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  34098. * As in the majority of the scene they are the same (exception for multi room and so on),
  34099. * this is easier to set here than in all the materials.
  34100. */
  34101. environmentIntensity: number;
  34102. /** @hidden */
  34103. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  34104. /**
  34105. * Default image processing configuration used either in the rendering
  34106. * Forward main pass or through the imageProcessingPostProcess if present.
  34107. * As in the majority of the scene they are the same (exception for multi camera),
  34108. * this is easier to reference from here than from all the materials and post process.
  34109. *
  34110. * No setter as we it is a shared configuration, you can set the values instead.
  34111. */
  34112. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  34113. private _forceWireframe;
  34114. /**
  34115. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  34116. */
  34117. forceWireframe: boolean;
  34118. private _forcePointsCloud;
  34119. /**
  34120. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  34121. */
  34122. forcePointsCloud: boolean;
  34123. /**
  34124. * Gets or sets the active clipplane 1
  34125. */
  34126. clipPlane: Nullable<Plane>;
  34127. /**
  34128. * Gets or sets the active clipplane 2
  34129. */
  34130. clipPlane2: Nullable<Plane>;
  34131. /**
  34132. * Gets or sets the active clipplane 3
  34133. */
  34134. clipPlane3: Nullable<Plane>;
  34135. /**
  34136. * Gets or sets the active clipplane 4
  34137. */
  34138. clipPlane4: Nullable<Plane>;
  34139. /**
  34140. * Gets or sets a boolean indicating if animations are enabled
  34141. */
  34142. animationsEnabled: boolean;
  34143. private _animationPropertiesOverride;
  34144. /**
  34145. * Gets or sets the animation properties override
  34146. */
  34147. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  34148. /**
  34149. * Gets or sets a boolean indicating if a constant deltatime has to be used
  34150. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  34151. */
  34152. useConstantAnimationDeltaTime: boolean;
  34153. /**
  34154. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  34155. * Please note that it requires to run a ray cast through the scene on every frame
  34156. */
  34157. constantlyUpdateMeshUnderPointer: boolean;
  34158. /**
  34159. * Defines the HTML cursor to use when hovering over interactive elements
  34160. */
  34161. hoverCursor: string;
  34162. /**
  34163. * Defines the HTML default cursor to use (empty by default)
  34164. */
  34165. defaultCursor: string;
  34166. /**
  34167. * This is used to call preventDefault() on pointer down
  34168. * in order to block unwanted artifacts like system double clicks
  34169. */
  34170. preventDefaultOnPointerDown: boolean;
  34171. /**
  34172. * This is used to call preventDefault() on pointer up
  34173. * in order to block unwanted artifacts like system double clicks
  34174. */
  34175. preventDefaultOnPointerUp: boolean;
  34176. /**
  34177. * Gets or sets user defined metadata
  34178. */
  34179. metadata: any;
  34180. /**
  34181. * For internal use only. Please do not use.
  34182. */
  34183. reservedDataStore: any;
  34184. /**
  34185. * Gets the name of the plugin used to load this scene (null by default)
  34186. */
  34187. loadingPluginName: string;
  34188. /**
  34189. * Use this array to add regular expressions used to disable offline support for specific urls
  34190. */
  34191. disableOfflineSupportExceptionRules: RegExp[];
  34192. /**
  34193. * An event triggered when the scene is disposed.
  34194. */
  34195. onDisposeObservable: Observable<Scene>;
  34196. private _onDisposeObserver;
  34197. /** Sets a function to be executed when this scene is disposed. */
  34198. onDispose: () => void;
  34199. /**
  34200. * An event triggered before rendering the scene (right after animations and physics)
  34201. */
  34202. onBeforeRenderObservable: Observable<Scene>;
  34203. private _onBeforeRenderObserver;
  34204. /** Sets a function to be executed before rendering this scene */
  34205. beforeRender: Nullable<() => void>;
  34206. /**
  34207. * An event triggered after rendering the scene
  34208. */
  34209. onAfterRenderObservable: Observable<Scene>;
  34210. /**
  34211. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  34212. */
  34213. onAfterRenderCameraObservable: Observable<Camera>;
  34214. private _onAfterRenderObserver;
  34215. /** Sets a function to be executed after rendering this scene */
  34216. afterRender: Nullable<() => void>;
  34217. /**
  34218. * An event triggered before animating the scene
  34219. */
  34220. onBeforeAnimationsObservable: Observable<Scene>;
  34221. /**
  34222. * An event triggered after animations processing
  34223. */
  34224. onAfterAnimationsObservable: Observable<Scene>;
  34225. /**
  34226. * An event triggered before draw calls are ready to be sent
  34227. */
  34228. onBeforeDrawPhaseObservable: Observable<Scene>;
  34229. /**
  34230. * An event triggered after draw calls have been sent
  34231. */
  34232. onAfterDrawPhaseObservable: Observable<Scene>;
  34233. /**
  34234. * An event triggered when the scene is ready
  34235. */
  34236. onReadyObservable: Observable<Scene>;
  34237. /**
  34238. * An event triggered before rendering a camera
  34239. */
  34240. onBeforeCameraRenderObservable: Observable<Camera>;
  34241. private _onBeforeCameraRenderObserver;
  34242. /** Sets a function to be executed before rendering a camera*/
  34243. beforeCameraRender: () => void;
  34244. /**
  34245. * An event triggered after rendering a camera
  34246. */
  34247. onAfterCameraRenderObservable: Observable<Camera>;
  34248. private _onAfterCameraRenderObserver;
  34249. /** Sets a function to be executed after rendering a camera*/
  34250. afterCameraRender: () => void;
  34251. /**
  34252. * An event triggered when active meshes evaluation is about to start
  34253. */
  34254. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  34255. /**
  34256. * An event triggered when active meshes evaluation is done
  34257. */
  34258. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  34259. /**
  34260. * An event triggered when particles rendering is about to start
  34261. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34262. */
  34263. onBeforeParticlesRenderingObservable: Observable<Scene>;
  34264. /**
  34265. * An event triggered when particles rendering is done
  34266. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  34267. */
  34268. onAfterParticlesRenderingObservable: Observable<Scene>;
  34269. /**
  34270. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  34271. */
  34272. onDataLoadedObservable: Observable<Scene>;
  34273. /**
  34274. * An event triggered when a camera is created
  34275. */
  34276. onNewCameraAddedObservable: Observable<Camera>;
  34277. /**
  34278. * An event triggered when a camera is removed
  34279. */
  34280. onCameraRemovedObservable: Observable<Camera>;
  34281. /**
  34282. * An event triggered when a light is created
  34283. */
  34284. onNewLightAddedObservable: Observable<Light>;
  34285. /**
  34286. * An event triggered when a light is removed
  34287. */
  34288. onLightRemovedObservable: Observable<Light>;
  34289. /**
  34290. * An event triggered when a geometry is created
  34291. */
  34292. onNewGeometryAddedObservable: Observable<Geometry>;
  34293. /**
  34294. * An event triggered when a geometry is removed
  34295. */
  34296. onGeometryRemovedObservable: Observable<Geometry>;
  34297. /**
  34298. * An event triggered when a transform node is created
  34299. */
  34300. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  34301. /**
  34302. * An event triggered when a transform node is removed
  34303. */
  34304. onTransformNodeRemovedObservable: Observable<TransformNode>;
  34305. /**
  34306. * An event triggered when a mesh is created
  34307. */
  34308. onNewMeshAddedObservable: Observable<AbstractMesh>;
  34309. /**
  34310. * An event triggered when a mesh is removed
  34311. */
  34312. onMeshRemovedObservable: Observable<AbstractMesh>;
  34313. /**
  34314. * An event triggered when a skeleton is created
  34315. */
  34316. onNewSkeletonAddedObservable: Observable<Skeleton>;
  34317. /**
  34318. * An event triggered when a skeleton is removed
  34319. */
  34320. onSkeletonRemovedObservable: Observable<Skeleton>;
  34321. /**
  34322. * An event triggered when a material is created
  34323. */
  34324. onNewMaterialAddedObservable: Observable<Material>;
  34325. /**
  34326. * An event triggered when a material is removed
  34327. */
  34328. onMaterialRemovedObservable: Observable<Material>;
  34329. /**
  34330. * An event triggered when a texture is created
  34331. */
  34332. onNewTextureAddedObservable: Observable<BaseTexture>;
  34333. /**
  34334. * An event triggered when a texture is removed
  34335. */
  34336. onTextureRemovedObservable: Observable<BaseTexture>;
  34337. /**
  34338. * An event triggered when render targets are about to be rendered
  34339. * Can happen multiple times per frame.
  34340. */
  34341. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  34342. /**
  34343. * An event triggered when render targets were rendered.
  34344. * Can happen multiple times per frame.
  34345. */
  34346. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  34347. /**
  34348. * An event triggered before calculating deterministic simulation step
  34349. */
  34350. onBeforeStepObservable: Observable<Scene>;
  34351. /**
  34352. * An event triggered after calculating deterministic simulation step
  34353. */
  34354. onAfterStepObservable: Observable<Scene>;
  34355. /**
  34356. * An event triggered when the activeCamera property is updated
  34357. */
  34358. onActiveCameraChanged: Observable<Scene>;
  34359. /**
  34360. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  34361. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34362. * 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)
  34363. */
  34364. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34365. /**
  34366. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  34367. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  34368. * 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)
  34369. */
  34370. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  34371. /**
  34372. * This Observable will when a mesh has been imported into the scene.
  34373. */
  34374. onMeshImportedObservable: Observable<AbstractMesh>;
  34375. /**
  34376. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  34377. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  34378. */
  34379. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  34380. /** @hidden */
  34381. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  34382. /**
  34383. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  34384. */
  34385. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  34386. /**
  34387. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  34388. */
  34389. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  34390. /**
  34391. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  34392. */
  34393. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  34394. /** Callback called when a pointer move is detected */
  34395. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34396. /** Callback called when a pointer down is detected */
  34397. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  34398. /** Callback called when a pointer up is detected */
  34399. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  34400. /** Callback called when a pointer pick is detected */
  34401. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  34402. /**
  34403. * 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).
  34404. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  34405. */
  34406. onPrePointerObservable: Observable<PointerInfoPre>;
  34407. /**
  34408. * Observable event triggered each time an input event is received from the rendering canvas
  34409. */
  34410. onPointerObservable: Observable<PointerInfo>;
  34411. /**
  34412. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  34413. */
  34414. readonly unTranslatedPointer: Vector2;
  34415. /**
  34416. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  34417. */
  34418. static DragMovementThreshold: number;
  34419. /**
  34420. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  34421. */
  34422. static LongPressDelay: number;
  34423. /**
  34424. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  34425. */
  34426. static DoubleClickDelay: number;
  34427. /** If you need to check double click without raising a single click at first click, enable this flag */
  34428. static ExclusiveDoubleClickMode: boolean;
  34429. /** @hidden */
  34430. _mirroredCameraPosition: Nullable<Vector3>;
  34431. /**
  34432. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  34433. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  34434. */
  34435. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  34436. /**
  34437. * Observable event triggered each time an keyboard event is received from the hosting window
  34438. */
  34439. onKeyboardObservable: Observable<KeyboardInfo>;
  34440. private _useRightHandedSystem;
  34441. /**
  34442. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  34443. */
  34444. useRightHandedSystem: boolean;
  34445. private _timeAccumulator;
  34446. private _currentStepId;
  34447. private _currentInternalStep;
  34448. /**
  34449. * Sets the step Id used by deterministic lock step
  34450. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34451. * @param newStepId defines the step Id
  34452. */
  34453. setStepId(newStepId: number): void;
  34454. /**
  34455. * Gets the step Id used by deterministic lock step
  34456. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34457. * @returns the step Id
  34458. */
  34459. getStepId(): number;
  34460. /**
  34461. * Gets the internal step used by deterministic lock step
  34462. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34463. * @returns the internal step
  34464. */
  34465. getInternalStep(): number;
  34466. private _fogEnabled;
  34467. /**
  34468. * Gets or sets a boolean indicating if fog is enabled on this scene
  34469. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34470. * (Default is true)
  34471. */
  34472. fogEnabled: boolean;
  34473. private _fogMode;
  34474. /**
  34475. * Gets or sets the fog mode to use
  34476. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34477. * | mode | value |
  34478. * | --- | --- |
  34479. * | FOGMODE_NONE | 0 |
  34480. * | FOGMODE_EXP | 1 |
  34481. * | FOGMODE_EXP2 | 2 |
  34482. * | FOGMODE_LINEAR | 3 |
  34483. */
  34484. fogMode: number;
  34485. /**
  34486. * Gets or sets the fog color to use
  34487. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34488. * (Default is Color3(0.2, 0.2, 0.3))
  34489. */
  34490. fogColor: Color3;
  34491. /**
  34492. * Gets or sets the fog density to use
  34493. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34494. * (Default is 0.1)
  34495. */
  34496. fogDensity: number;
  34497. /**
  34498. * Gets or sets the fog start distance to use
  34499. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34500. * (Default is 0)
  34501. */
  34502. fogStart: number;
  34503. /**
  34504. * Gets or sets the fog end distance to use
  34505. * @see http://doc.babylonjs.com/babylon101/environment#fog
  34506. * (Default is 1000)
  34507. */
  34508. fogEnd: number;
  34509. private _shadowsEnabled;
  34510. /**
  34511. * Gets or sets a boolean indicating if shadows are enabled on this scene
  34512. */
  34513. shadowsEnabled: boolean;
  34514. private _lightsEnabled;
  34515. /**
  34516. * Gets or sets a boolean indicating if lights are enabled on this scene
  34517. */
  34518. lightsEnabled: boolean;
  34519. /** All of the active cameras added to this scene. */
  34520. activeCameras: Camera[];
  34521. /** @hidden */
  34522. _activeCamera: Nullable<Camera>;
  34523. /** Gets or sets the current active camera */
  34524. activeCamera: Nullable<Camera>;
  34525. private _defaultMaterial;
  34526. /** The default material used on meshes when no material is affected */
  34527. /** The default material used on meshes when no material is affected */
  34528. defaultMaterial: Material;
  34529. private _texturesEnabled;
  34530. /**
  34531. * Gets or sets a boolean indicating if textures are enabled on this scene
  34532. */
  34533. texturesEnabled: boolean;
  34534. /**
  34535. * Gets or sets a boolean indicating if particles are enabled on this scene
  34536. */
  34537. particlesEnabled: boolean;
  34538. /**
  34539. * Gets or sets a boolean indicating if sprites are enabled on this scene
  34540. */
  34541. spritesEnabled: boolean;
  34542. private _skeletonsEnabled;
  34543. /**
  34544. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  34545. */
  34546. skeletonsEnabled: boolean;
  34547. /**
  34548. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  34549. */
  34550. lensFlaresEnabled: boolean;
  34551. /**
  34552. * Gets or sets a boolean indicating if collisions are enabled on this scene
  34553. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34554. */
  34555. collisionsEnabled: boolean;
  34556. private _collisionCoordinator;
  34557. /** @hidden */
  34558. readonly collisionCoordinator: ICollisionCoordinator;
  34559. /**
  34560. * Defines the gravity applied to this scene (used only for collisions)
  34561. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  34562. */
  34563. gravity: Vector3;
  34564. /**
  34565. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  34566. */
  34567. postProcessesEnabled: boolean;
  34568. /**
  34569. * The list of postprocesses added to the scene
  34570. */
  34571. postProcesses: PostProcess[];
  34572. /**
  34573. * Gets the current postprocess manager
  34574. */
  34575. postProcessManager: PostProcessManager;
  34576. /**
  34577. * Gets or sets a boolean indicating if render targets are enabled on this scene
  34578. */
  34579. renderTargetsEnabled: boolean;
  34580. /**
  34581. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  34582. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  34583. */
  34584. dumpNextRenderTargets: boolean;
  34585. /**
  34586. * The list of user defined render targets added to the scene
  34587. */
  34588. customRenderTargets: RenderTargetTexture[];
  34589. /**
  34590. * Defines if texture loading must be delayed
  34591. * If true, textures will only be loaded when they need to be rendered
  34592. */
  34593. useDelayedTextureLoading: boolean;
  34594. /**
  34595. * Gets the list of meshes imported to the scene through SceneLoader
  34596. */
  34597. importedMeshesFiles: String[];
  34598. /**
  34599. * Gets or sets a boolean indicating if probes are enabled on this scene
  34600. */
  34601. probesEnabled: boolean;
  34602. /**
  34603. * Gets or sets the current offline provider to use to store scene data
  34604. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  34605. */
  34606. offlineProvider: IOfflineProvider;
  34607. /**
  34608. * Gets or sets the action manager associated with the scene
  34609. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34610. */
  34611. actionManager: AbstractActionManager;
  34612. private _meshesForIntersections;
  34613. /**
  34614. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  34615. */
  34616. proceduralTexturesEnabled: boolean;
  34617. private _engine;
  34618. private _totalVertices;
  34619. /** @hidden */
  34620. _activeIndices: PerfCounter;
  34621. /** @hidden */
  34622. _activeParticles: PerfCounter;
  34623. /** @hidden */
  34624. _activeBones: PerfCounter;
  34625. private _animationRatio;
  34626. /** @hidden */
  34627. _animationTimeLast: number;
  34628. /** @hidden */
  34629. _animationTime: number;
  34630. /**
  34631. * Gets or sets a general scale for animation speed
  34632. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  34633. */
  34634. animationTimeScale: number;
  34635. /** @hidden */
  34636. _cachedMaterial: Nullable<Material>;
  34637. /** @hidden */
  34638. _cachedEffect: Nullable<Effect>;
  34639. /** @hidden */
  34640. _cachedVisibility: Nullable<number>;
  34641. private _renderId;
  34642. private _frameId;
  34643. private _executeWhenReadyTimeoutId;
  34644. private _intermediateRendering;
  34645. private _viewUpdateFlag;
  34646. private _projectionUpdateFlag;
  34647. /** @hidden */
  34648. _toBeDisposed: Nullable<IDisposable>[];
  34649. private _activeRequests;
  34650. /** @hidden */
  34651. _pendingData: any[];
  34652. private _isDisposed;
  34653. /**
  34654. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  34655. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  34656. */
  34657. dispatchAllSubMeshesOfActiveMeshes: boolean;
  34658. private _activeMeshes;
  34659. private _processedMaterials;
  34660. private _renderTargets;
  34661. /** @hidden */
  34662. _activeParticleSystems: SmartArray<IParticleSystem>;
  34663. private _activeSkeletons;
  34664. private _softwareSkinnedMeshes;
  34665. private _renderingManager;
  34666. /** @hidden */
  34667. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  34668. private _transformMatrix;
  34669. private _sceneUbo;
  34670. /** @hidden */
  34671. _viewMatrix: Matrix;
  34672. private _projectionMatrix;
  34673. /** @hidden */
  34674. _forcedViewPosition: Nullable<Vector3>;
  34675. /** @hidden */
  34676. _frustumPlanes: Plane[];
  34677. /**
  34678. * Gets the list of frustum planes (built from the active camera)
  34679. */
  34680. readonly frustumPlanes: Plane[];
  34681. /**
  34682. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  34683. * This is useful if there are more lights that the maximum simulteanous authorized
  34684. */
  34685. requireLightSorting: boolean;
  34686. /** @hidden */
  34687. readonly useMaterialMeshMap: boolean;
  34688. /** @hidden */
  34689. readonly useClonedMeshhMap: boolean;
  34690. private _externalData;
  34691. private _uid;
  34692. /**
  34693. * @hidden
  34694. * Backing store of defined scene components.
  34695. */
  34696. _components: ISceneComponent[];
  34697. /**
  34698. * @hidden
  34699. * Backing store of defined scene components.
  34700. */
  34701. _serializableComponents: ISceneSerializableComponent[];
  34702. /**
  34703. * List of components to register on the next registration step.
  34704. */
  34705. private _transientComponents;
  34706. /**
  34707. * Registers the transient components if needed.
  34708. */
  34709. private _registerTransientComponents;
  34710. /**
  34711. * @hidden
  34712. * Add a component to the scene.
  34713. * Note that the ccomponent could be registered on th next frame if this is called after
  34714. * the register component stage.
  34715. * @param component Defines the component to add to the scene
  34716. */
  34717. _addComponent(component: ISceneComponent): void;
  34718. /**
  34719. * @hidden
  34720. * Gets a component from the scene.
  34721. * @param name defines the name of the component to retrieve
  34722. * @returns the component or null if not present
  34723. */
  34724. _getComponent(name: string): Nullable<ISceneComponent>;
  34725. /**
  34726. * @hidden
  34727. * Defines the actions happening before camera updates.
  34728. */
  34729. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  34730. /**
  34731. * @hidden
  34732. * Defines the actions happening before clear the canvas.
  34733. */
  34734. _beforeClearStage: Stage<SimpleStageAction>;
  34735. /**
  34736. * @hidden
  34737. * Defines the actions when collecting render targets for the frame.
  34738. */
  34739. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34740. /**
  34741. * @hidden
  34742. * Defines the actions happening for one camera in the frame.
  34743. */
  34744. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  34745. /**
  34746. * @hidden
  34747. * Defines the actions happening during the per mesh ready checks.
  34748. */
  34749. _isReadyForMeshStage: Stage<MeshStageAction>;
  34750. /**
  34751. * @hidden
  34752. * Defines the actions happening before evaluate active mesh checks.
  34753. */
  34754. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  34755. /**
  34756. * @hidden
  34757. * Defines the actions happening during the evaluate sub mesh checks.
  34758. */
  34759. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  34760. /**
  34761. * @hidden
  34762. * Defines the actions happening during the active mesh stage.
  34763. */
  34764. _activeMeshStage: Stage<ActiveMeshStageAction>;
  34765. /**
  34766. * @hidden
  34767. * Defines the actions happening during the per camera render target step.
  34768. */
  34769. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  34770. /**
  34771. * @hidden
  34772. * Defines the actions happening just before the active camera is drawing.
  34773. */
  34774. _beforeCameraDrawStage: Stage<CameraStageAction>;
  34775. /**
  34776. * @hidden
  34777. * Defines the actions happening just before a render target is drawing.
  34778. */
  34779. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34780. /**
  34781. * @hidden
  34782. * Defines the actions happening just before a rendering group is drawing.
  34783. */
  34784. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34785. /**
  34786. * @hidden
  34787. * Defines the actions happening just before a mesh is drawing.
  34788. */
  34789. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34790. /**
  34791. * @hidden
  34792. * Defines the actions happening just after a mesh has been drawn.
  34793. */
  34794. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  34795. /**
  34796. * @hidden
  34797. * Defines the actions happening just after a rendering group has been drawn.
  34798. */
  34799. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  34800. /**
  34801. * @hidden
  34802. * Defines the actions happening just after the active camera has been drawn.
  34803. */
  34804. _afterCameraDrawStage: Stage<CameraStageAction>;
  34805. /**
  34806. * @hidden
  34807. * Defines the actions happening just after a render target has been drawn.
  34808. */
  34809. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  34810. /**
  34811. * @hidden
  34812. * Defines the actions happening just after rendering all cameras and computing intersections.
  34813. */
  34814. _afterRenderStage: Stage<SimpleStageAction>;
  34815. /**
  34816. * @hidden
  34817. * Defines the actions happening when a pointer move event happens.
  34818. */
  34819. _pointerMoveStage: Stage<PointerMoveStageAction>;
  34820. /**
  34821. * @hidden
  34822. * Defines the actions happening when a pointer down event happens.
  34823. */
  34824. _pointerDownStage: Stage<PointerUpDownStageAction>;
  34825. /**
  34826. * @hidden
  34827. * Defines the actions happening when a pointer up event happens.
  34828. */
  34829. _pointerUpStage: Stage<PointerUpDownStageAction>;
  34830. /**
  34831. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  34832. */
  34833. private geometriesByUniqueId;
  34834. /**
  34835. * Creates a new Scene
  34836. * @param engine defines the engine to use to render this scene
  34837. * @param options defines the scene options
  34838. */
  34839. constructor(engine: Engine, options?: SceneOptions);
  34840. /**
  34841. * Gets a string idenfifying the name of the class
  34842. * @returns "Scene" string
  34843. */
  34844. getClassName(): string;
  34845. private _defaultMeshCandidates;
  34846. /**
  34847. * @hidden
  34848. */
  34849. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  34850. private _defaultSubMeshCandidates;
  34851. /**
  34852. * @hidden
  34853. */
  34854. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  34855. /**
  34856. * Sets the default candidate providers for the scene.
  34857. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  34858. * and getCollidingSubMeshCandidates to their default function
  34859. */
  34860. setDefaultCandidateProviders(): void;
  34861. /**
  34862. * Gets the mesh that is currently under the pointer
  34863. */
  34864. readonly meshUnderPointer: Nullable<AbstractMesh>;
  34865. /**
  34866. * Gets or sets the current on-screen X position of the pointer
  34867. */
  34868. pointerX: number;
  34869. /**
  34870. * Gets or sets the current on-screen Y position of the pointer
  34871. */
  34872. pointerY: number;
  34873. /**
  34874. * Gets the cached material (ie. the latest rendered one)
  34875. * @returns the cached material
  34876. */
  34877. getCachedMaterial(): Nullable<Material>;
  34878. /**
  34879. * Gets the cached effect (ie. the latest rendered one)
  34880. * @returns the cached effect
  34881. */
  34882. getCachedEffect(): Nullable<Effect>;
  34883. /**
  34884. * Gets the cached visibility state (ie. the latest rendered one)
  34885. * @returns the cached visibility state
  34886. */
  34887. getCachedVisibility(): Nullable<number>;
  34888. /**
  34889. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  34890. * @param material defines the current material
  34891. * @param effect defines the current effect
  34892. * @param visibility defines the current visibility state
  34893. * @returns true if one parameter is not cached
  34894. */
  34895. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  34896. /**
  34897. * Gets the engine associated with the scene
  34898. * @returns an Engine
  34899. */
  34900. getEngine(): Engine;
  34901. /**
  34902. * Gets the total number of vertices rendered per frame
  34903. * @returns the total number of vertices rendered per frame
  34904. */
  34905. getTotalVertices(): number;
  34906. /**
  34907. * Gets the performance counter for total vertices
  34908. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34909. */
  34910. readonly totalVerticesPerfCounter: PerfCounter;
  34911. /**
  34912. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  34913. * @returns the total number of active indices rendered per frame
  34914. */
  34915. getActiveIndices(): number;
  34916. /**
  34917. * Gets the performance counter for active indices
  34918. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34919. */
  34920. readonly totalActiveIndicesPerfCounter: PerfCounter;
  34921. /**
  34922. * Gets the total number of active particles rendered per frame
  34923. * @returns the total number of active particles rendered per frame
  34924. */
  34925. getActiveParticles(): number;
  34926. /**
  34927. * Gets the performance counter for active particles
  34928. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34929. */
  34930. readonly activeParticlesPerfCounter: PerfCounter;
  34931. /**
  34932. * Gets the total number of active bones rendered per frame
  34933. * @returns the total number of active bones rendered per frame
  34934. */
  34935. getActiveBones(): number;
  34936. /**
  34937. * Gets the performance counter for active bones
  34938. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  34939. */
  34940. readonly activeBonesPerfCounter: PerfCounter;
  34941. /**
  34942. * Gets the array of active meshes
  34943. * @returns an array of AbstractMesh
  34944. */
  34945. getActiveMeshes(): SmartArray<AbstractMesh>;
  34946. /**
  34947. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  34948. * @returns a number
  34949. */
  34950. getAnimationRatio(): number;
  34951. /**
  34952. * Gets an unique Id for the current render phase
  34953. * @returns a number
  34954. */
  34955. getRenderId(): number;
  34956. /**
  34957. * Gets an unique Id for the current frame
  34958. * @returns a number
  34959. */
  34960. getFrameId(): number;
  34961. /** Call this function if you want to manually increment the render Id*/
  34962. incrementRenderId(): void;
  34963. private _createUbo;
  34964. /**
  34965. * Use this method to simulate a pointer move on a mesh
  34966. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34967. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34968. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34969. * @returns the current scene
  34970. */
  34971. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34972. /**
  34973. * Use this method to simulate a pointer down on a mesh
  34974. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34975. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34976. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34977. * @returns the current scene
  34978. */
  34979. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  34980. /**
  34981. * Use this method to simulate a pointer up on a mesh
  34982. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  34983. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  34984. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  34985. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  34986. * @returns the current scene
  34987. */
  34988. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  34989. /**
  34990. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  34991. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  34992. * @returns true if the pointer was captured
  34993. */
  34994. isPointerCaptured(pointerId?: number): boolean;
  34995. /**
  34996. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  34997. * @param attachUp defines if you want to attach events to pointerup
  34998. * @param attachDown defines if you want to attach events to pointerdown
  34999. * @param attachMove defines if you want to attach events to pointermove
  35000. */
  35001. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  35002. /** Detaches all event handlers*/
  35003. detachControl(): void;
  35004. /**
  35005. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  35006. * Delay loaded resources are not taking in account
  35007. * @return true if all required resources are ready
  35008. */
  35009. isReady(): boolean;
  35010. /** Resets all cached information relative to material (including effect and visibility) */
  35011. resetCachedMaterial(): void;
  35012. /**
  35013. * Registers a function to be called before every frame render
  35014. * @param func defines the function to register
  35015. */
  35016. registerBeforeRender(func: () => void): void;
  35017. /**
  35018. * Unregisters a function called before every frame render
  35019. * @param func defines the function to unregister
  35020. */
  35021. unregisterBeforeRender(func: () => void): void;
  35022. /**
  35023. * Registers a function to be called after every frame render
  35024. * @param func defines the function to register
  35025. */
  35026. registerAfterRender(func: () => void): void;
  35027. /**
  35028. * Unregisters a function called after every frame render
  35029. * @param func defines the function to unregister
  35030. */
  35031. unregisterAfterRender(func: () => void): void;
  35032. private _executeOnceBeforeRender;
  35033. /**
  35034. * The provided function will run before render once and will be disposed afterwards.
  35035. * A timeout delay can be provided so that the function will be executed in N ms.
  35036. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  35037. * @param func The function to be executed.
  35038. * @param timeout optional delay in ms
  35039. */
  35040. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  35041. /** @hidden */
  35042. _addPendingData(data: any): void;
  35043. /** @hidden */
  35044. _removePendingData(data: any): void;
  35045. /**
  35046. * Returns the number of items waiting to be loaded
  35047. * @returns the number of items waiting to be loaded
  35048. */
  35049. getWaitingItemsCount(): number;
  35050. /**
  35051. * Returns a boolean indicating if the scene is still loading data
  35052. */
  35053. readonly isLoading: boolean;
  35054. /**
  35055. * Registers a function to be executed when the scene is ready
  35056. * @param {Function} func - the function to be executed
  35057. */
  35058. executeWhenReady(func: () => void): void;
  35059. /**
  35060. * Returns a promise that resolves when the scene is ready
  35061. * @returns A promise that resolves when the scene is ready
  35062. */
  35063. whenReadyAsync(): Promise<void>;
  35064. /** @hidden */
  35065. _checkIsReady(): void;
  35066. /**
  35067. * Gets all animatable attached to the scene
  35068. */
  35069. readonly animatables: Animatable[];
  35070. /**
  35071. * Resets the last animation time frame.
  35072. * Useful to override when animations start running when loading a scene for the first time.
  35073. */
  35074. resetLastAnimationTimeFrame(): void;
  35075. /**
  35076. * Gets the current view matrix
  35077. * @returns a Matrix
  35078. */
  35079. getViewMatrix(): Matrix;
  35080. /**
  35081. * Gets the current projection matrix
  35082. * @returns a Matrix
  35083. */
  35084. getProjectionMatrix(): Matrix;
  35085. /**
  35086. * Gets the current transform matrix
  35087. * @returns a Matrix made of View * Projection
  35088. */
  35089. getTransformMatrix(): Matrix;
  35090. /**
  35091. * Sets the current transform matrix
  35092. * @param viewL defines the View matrix to use
  35093. * @param projectionL defines the Projection matrix to use
  35094. * @param viewR defines the right View matrix to use (if provided)
  35095. * @param projectionR defines the right Projection matrix to use (if provided)
  35096. */
  35097. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  35098. /**
  35099. * Gets the uniform buffer used to store scene data
  35100. * @returns a UniformBuffer
  35101. */
  35102. getSceneUniformBuffer(): UniformBuffer;
  35103. /**
  35104. * Gets an unique (relatively to the current scene) Id
  35105. * @returns an unique number for the scene
  35106. */
  35107. getUniqueId(): number;
  35108. /**
  35109. * Add a mesh to the list of scene's meshes
  35110. * @param newMesh defines the mesh to add
  35111. * @param recursive if all child meshes should also be added to the scene
  35112. */
  35113. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  35114. /**
  35115. * Remove a mesh for the list of scene's meshes
  35116. * @param toRemove defines the mesh to remove
  35117. * @param recursive if all child meshes should also be removed from the scene
  35118. * @returns the index where the mesh was in the mesh list
  35119. */
  35120. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  35121. /**
  35122. * Add a transform node to the list of scene's transform nodes
  35123. * @param newTransformNode defines the transform node to add
  35124. */
  35125. addTransformNode(newTransformNode: TransformNode): void;
  35126. /**
  35127. * Remove a transform node for the list of scene's transform nodes
  35128. * @param toRemove defines the transform node to remove
  35129. * @returns the index where the transform node was in the transform node list
  35130. */
  35131. removeTransformNode(toRemove: TransformNode): number;
  35132. /**
  35133. * Remove a skeleton for the list of scene's skeletons
  35134. * @param toRemove defines the skeleton to remove
  35135. * @returns the index where the skeleton was in the skeleton list
  35136. */
  35137. removeSkeleton(toRemove: Skeleton): number;
  35138. /**
  35139. * Remove a morph target for the list of scene's morph targets
  35140. * @param toRemove defines the morph target to remove
  35141. * @returns the index where the morph target was in the morph target list
  35142. */
  35143. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  35144. /**
  35145. * Remove a light for the list of scene's lights
  35146. * @param toRemove defines the light to remove
  35147. * @returns the index where the light was in the light list
  35148. */
  35149. removeLight(toRemove: Light): number;
  35150. /**
  35151. * Remove a camera for the list of scene's cameras
  35152. * @param toRemove defines the camera to remove
  35153. * @returns the index where the camera was in the camera list
  35154. */
  35155. removeCamera(toRemove: Camera): number;
  35156. /**
  35157. * Remove a particle system for the list of scene's particle systems
  35158. * @param toRemove defines the particle system to remove
  35159. * @returns the index where the particle system was in the particle system list
  35160. */
  35161. removeParticleSystem(toRemove: IParticleSystem): number;
  35162. /**
  35163. * Remove a animation for the list of scene's animations
  35164. * @param toRemove defines the animation to remove
  35165. * @returns the index where the animation was in the animation list
  35166. */
  35167. removeAnimation(toRemove: Animation): number;
  35168. /**
  35169. * Will stop the animation of the given target
  35170. * @param target - the target
  35171. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  35172. * @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)
  35173. */
  35174. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  35175. /**
  35176. * Removes the given animation group from this scene.
  35177. * @param toRemove The animation group to remove
  35178. * @returns The index of the removed animation group
  35179. */
  35180. removeAnimationGroup(toRemove: AnimationGroup): number;
  35181. /**
  35182. * Removes the given multi-material from this scene.
  35183. * @param toRemove The multi-material to remove
  35184. * @returns The index of the removed multi-material
  35185. */
  35186. removeMultiMaterial(toRemove: MultiMaterial): number;
  35187. /**
  35188. * Removes the given material from this scene.
  35189. * @param toRemove The material to remove
  35190. * @returns The index of the removed material
  35191. */
  35192. removeMaterial(toRemove: Material): number;
  35193. /**
  35194. * Removes the given action manager from this scene.
  35195. * @param toRemove The action manager to remove
  35196. * @returns The index of the removed action manager
  35197. */
  35198. removeActionManager(toRemove: AbstractActionManager): number;
  35199. /**
  35200. * Removes the given texture from this scene.
  35201. * @param toRemove The texture to remove
  35202. * @returns The index of the removed texture
  35203. */
  35204. removeTexture(toRemove: BaseTexture): number;
  35205. /**
  35206. * Adds the given light to this scene
  35207. * @param newLight The light to add
  35208. */
  35209. addLight(newLight: Light): void;
  35210. /**
  35211. * Sorts the list list based on light priorities
  35212. */
  35213. sortLightsByPriority(): void;
  35214. /**
  35215. * Adds the given camera to this scene
  35216. * @param newCamera The camera to add
  35217. */
  35218. addCamera(newCamera: Camera): void;
  35219. /**
  35220. * Adds the given skeleton to this scene
  35221. * @param newSkeleton The skeleton to add
  35222. */
  35223. addSkeleton(newSkeleton: Skeleton): void;
  35224. /**
  35225. * Adds the given particle system to this scene
  35226. * @param newParticleSystem The particle system to add
  35227. */
  35228. addParticleSystem(newParticleSystem: IParticleSystem): void;
  35229. /**
  35230. * Adds the given animation to this scene
  35231. * @param newAnimation The animation to add
  35232. */
  35233. addAnimation(newAnimation: Animation): void;
  35234. /**
  35235. * Adds the given animation group to this scene.
  35236. * @param newAnimationGroup The animation group to add
  35237. */
  35238. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  35239. /**
  35240. * Adds the given multi-material to this scene
  35241. * @param newMultiMaterial The multi-material to add
  35242. */
  35243. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  35244. /**
  35245. * Adds the given material to this scene
  35246. * @param newMaterial The material to add
  35247. */
  35248. addMaterial(newMaterial: Material): void;
  35249. /**
  35250. * Adds the given morph target to this scene
  35251. * @param newMorphTargetManager The morph target to add
  35252. */
  35253. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  35254. /**
  35255. * Adds the given geometry to this scene
  35256. * @param newGeometry The geometry to add
  35257. */
  35258. addGeometry(newGeometry: Geometry): void;
  35259. /**
  35260. * Adds the given action manager to this scene
  35261. * @param newActionManager The action manager to add
  35262. */
  35263. addActionManager(newActionManager: AbstractActionManager): void;
  35264. /**
  35265. * Adds the given texture to this scene.
  35266. * @param newTexture The texture to add
  35267. */
  35268. addTexture(newTexture: BaseTexture): void;
  35269. /**
  35270. * Switch active camera
  35271. * @param newCamera defines the new active camera
  35272. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  35273. */
  35274. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  35275. /**
  35276. * sets the active camera of the scene using its ID
  35277. * @param id defines the camera's ID
  35278. * @return the new active camera or null if none found.
  35279. */
  35280. setActiveCameraByID(id: string): Nullable<Camera>;
  35281. /**
  35282. * sets the active camera of the scene using its name
  35283. * @param name defines the camera's name
  35284. * @returns the new active camera or null if none found.
  35285. */
  35286. setActiveCameraByName(name: string): Nullable<Camera>;
  35287. /**
  35288. * get an animation group using its name
  35289. * @param name defines the material's name
  35290. * @return the animation group or null if none found.
  35291. */
  35292. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  35293. /**
  35294. * Get a material using its unique id
  35295. * @param uniqueId defines the material's unique id
  35296. * @return the material or null if none found.
  35297. */
  35298. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  35299. /**
  35300. * get a material using its id
  35301. * @param id defines the material's ID
  35302. * @return the material or null if none found.
  35303. */
  35304. getMaterialByID(id: string): Nullable<Material>;
  35305. /**
  35306. * Gets a the last added material using a given id
  35307. * @param id defines the material's ID
  35308. * @return the last material with the given id or null if none found.
  35309. */
  35310. getLastMaterialByID(id: string): Nullable<Material>;
  35311. /**
  35312. * Gets a material using its name
  35313. * @param name defines the material's name
  35314. * @return the material or null if none found.
  35315. */
  35316. getMaterialByName(name: string): Nullable<Material>;
  35317. /**
  35318. * Get a texture using its unique id
  35319. * @param uniqueId defines the texture's unique id
  35320. * @return the texture or null if none found.
  35321. */
  35322. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  35323. /**
  35324. * Gets a camera using its id
  35325. * @param id defines the id to look for
  35326. * @returns the camera or null if not found
  35327. */
  35328. getCameraByID(id: string): Nullable<Camera>;
  35329. /**
  35330. * Gets a camera using its unique id
  35331. * @param uniqueId defines the unique id to look for
  35332. * @returns the camera or null if not found
  35333. */
  35334. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  35335. /**
  35336. * Gets a camera using its name
  35337. * @param name defines the camera's name
  35338. * @return the camera or null if none found.
  35339. */
  35340. getCameraByName(name: string): Nullable<Camera>;
  35341. /**
  35342. * Gets a bone using its id
  35343. * @param id defines the bone's id
  35344. * @return the bone or null if not found
  35345. */
  35346. getBoneByID(id: string): Nullable<Bone>;
  35347. /**
  35348. * Gets a bone using its id
  35349. * @param name defines the bone's name
  35350. * @return the bone or null if not found
  35351. */
  35352. getBoneByName(name: string): Nullable<Bone>;
  35353. /**
  35354. * Gets a light node using its name
  35355. * @param name defines the the light's name
  35356. * @return the light or null if none found.
  35357. */
  35358. getLightByName(name: string): Nullable<Light>;
  35359. /**
  35360. * Gets a light node using its id
  35361. * @param id defines the light's id
  35362. * @return the light or null if none found.
  35363. */
  35364. getLightByID(id: string): Nullable<Light>;
  35365. /**
  35366. * Gets a light node using its scene-generated unique ID
  35367. * @param uniqueId defines the light's unique id
  35368. * @return the light or null if none found.
  35369. */
  35370. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  35371. /**
  35372. * Gets a particle system by id
  35373. * @param id defines the particle system id
  35374. * @return the corresponding system or null if none found
  35375. */
  35376. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  35377. /**
  35378. * Gets a geometry using its ID
  35379. * @param id defines the geometry's id
  35380. * @return the geometry or null if none found.
  35381. */
  35382. getGeometryByID(id: string): Nullable<Geometry>;
  35383. private _getGeometryByUniqueID;
  35384. /**
  35385. * Add a new geometry to this scene
  35386. * @param geometry defines the geometry to be added to the scene.
  35387. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  35388. * @return a boolean defining if the geometry was added or not
  35389. */
  35390. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  35391. /**
  35392. * Removes an existing geometry
  35393. * @param geometry defines the geometry to be removed from the scene
  35394. * @return a boolean defining if the geometry was removed or not
  35395. */
  35396. removeGeometry(geometry: Geometry): boolean;
  35397. /**
  35398. * Gets the list of geometries attached to the scene
  35399. * @returns an array of Geometry
  35400. */
  35401. getGeometries(): Geometry[];
  35402. /**
  35403. * Gets the first added mesh found of a given ID
  35404. * @param id defines the id to search for
  35405. * @return the mesh found or null if not found at all
  35406. */
  35407. getMeshByID(id: string): Nullable<AbstractMesh>;
  35408. /**
  35409. * Gets a list of meshes using their id
  35410. * @param id defines the id to search for
  35411. * @returns a list of meshes
  35412. */
  35413. getMeshesByID(id: string): Array<AbstractMesh>;
  35414. /**
  35415. * Gets the first added transform node found of a given ID
  35416. * @param id defines the id to search for
  35417. * @return the found transform node or null if not found at all.
  35418. */
  35419. getTransformNodeByID(id: string): Nullable<TransformNode>;
  35420. /**
  35421. * Gets a transform node with its auto-generated unique id
  35422. * @param uniqueId efines the unique id to search for
  35423. * @return the found transform node or null if not found at all.
  35424. */
  35425. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  35426. /**
  35427. * Gets a list of transform nodes using their id
  35428. * @param id defines the id to search for
  35429. * @returns a list of transform nodes
  35430. */
  35431. getTransformNodesByID(id: string): Array<TransformNode>;
  35432. /**
  35433. * Gets a mesh with its auto-generated unique id
  35434. * @param uniqueId defines the unique id to search for
  35435. * @return the found mesh or null if not found at all.
  35436. */
  35437. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  35438. /**
  35439. * Gets a the last added mesh using a given id
  35440. * @param id defines the id to search for
  35441. * @return the found mesh or null if not found at all.
  35442. */
  35443. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  35444. /**
  35445. * Gets a the last added node (Mesh, Camera, Light) using a given id
  35446. * @param id defines the id to search for
  35447. * @return the found node or null if not found at all
  35448. */
  35449. getLastEntryByID(id: string): Nullable<Node>;
  35450. /**
  35451. * Gets a node (Mesh, Camera, Light) using a given id
  35452. * @param id defines the id to search for
  35453. * @return the found node or null if not found at all
  35454. */
  35455. getNodeByID(id: string): Nullable<Node>;
  35456. /**
  35457. * Gets a node (Mesh, Camera, Light) using a given name
  35458. * @param name defines the name to search for
  35459. * @return the found node or null if not found at all.
  35460. */
  35461. getNodeByName(name: string): Nullable<Node>;
  35462. /**
  35463. * Gets a mesh using a given name
  35464. * @param name defines the name to search for
  35465. * @return the found mesh or null if not found at all.
  35466. */
  35467. getMeshByName(name: string): Nullable<AbstractMesh>;
  35468. /**
  35469. * Gets a transform node using a given name
  35470. * @param name defines the name to search for
  35471. * @return the found transform node or null if not found at all.
  35472. */
  35473. getTransformNodeByName(name: string): Nullable<TransformNode>;
  35474. /**
  35475. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  35476. * @param id defines the id to search for
  35477. * @return the found skeleton or null if not found at all.
  35478. */
  35479. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  35480. /**
  35481. * Gets a skeleton using a given auto generated unique id
  35482. * @param uniqueId defines the unique id to search for
  35483. * @return the found skeleton or null if not found at all.
  35484. */
  35485. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  35486. /**
  35487. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  35488. * @param id defines the id to search for
  35489. * @return the found skeleton or null if not found at all.
  35490. */
  35491. getSkeletonById(id: string): Nullable<Skeleton>;
  35492. /**
  35493. * Gets a skeleton using a given name
  35494. * @param name defines the name to search for
  35495. * @return the found skeleton or null if not found at all.
  35496. */
  35497. getSkeletonByName(name: string): Nullable<Skeleton>;
  35498. /**
  35499. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  35500. * @param id defines the id to search for
  35501. * @return the found morph target manager or null if not found at all.
  35502. */
  35503. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  35504. /**
  35505. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  35506. * @param id defines the id to search for
  35507. * @return the found morph target or null if not found at all.
  35508. */
  35509. getMorphTargetById(id: string): Nullable<MorphTarget>;
  35510. /**
  35511. * Gets a boolean indicating if the given mesh is active
  35512. * @param mesh defines the mesh to look for
  35513. * @returns true if the mesh is in the active list
  35514. */
  35515. isActiveMesh(mesh: AbstractMesh): boolean;
  35516. /**
  35517. * Return a unique id as a string which can serve as an identifier for the scene
  35518. */
  35519. readonly uid: string;
  35520. /**
  35521. * Add an externaly attached data from its key.
  35522. * This method call will fail and return false, if such key already exists.
  35523. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  35524. * @param key the unique key that identifies the data
  35525. * @param data the data object to associate to the key for this Engine instance
  35526. * @return true if no such key were already present and the data was added successfully, false otherwise
  35527. */
  35528. addExternalData<T>(key: string, data: T): boolean;
  35529. /**
  35530. * Get an externaly attached data from its key
  35531. * @param key the unique key that identifies the data
  35532. * @return the associated data, if present (can be null), or undefined if not present
  35533. */
  35534. getExternalData<T>(key: string): Nullable<T>;
  35535. /**
  35536. * Get an externaly attached data from its key, create it using a factory if it's not already present
  35537. * @param key the unique key that identifies the data
  35538. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  35539. * @return the associated data, can be null if the factory returned null.
  35540. */
  35541. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  35542. /**
  35543. * Remove an externaly attached data from the Engine instance
  35544. * @param key the unique key that identifies the data
  35545. * @return true if the data was successfully removed, false if it doesn't exist
  35546. */
  35547. removeExternalData(key: string): boolean;
  35548. private _evaluateSubMesh;
  35549. /**
  35550. * Clear the processed materials smart array preventing retention point in material dispose.
  35551. */
  35552. freeProcessedMaterials(): void;
  35553. private _preventFreeActiveMeshesAndRenderingGroups;
  35554. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  35555. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  35556. * when disposing several meshes in a row or a hierarchy of meshes.
  35557. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  35558. */
  35559. blockfreeActiveMeshesAndRenderingGroups: boolean;
  35560. /**
  35561. * Clear the active meshes smart array preventing retention point in mesh dispose.
  35562. */
  35563. freeActiveMeshes(): void;
  35564. /**
  35565. * Clear the info related to rendering groups preventing retention points during dispose.
  35566. */
  35567. freeRenderingGroups(): void;
  35568. /** @hidden */
  35569. _isInIntermediateRendering(): boolean;
  35570. /**
  35571. * Lambda returning the list of potentially active meshes.
  35572. */
  35573. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  35574. /**
  35575. * Lambda returning the list of potentially active sub meshes.
  35576. */
  35577. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  35578. /**
  35579. * Lambda returning the list of potentially intersecting sub meshes.
  35580. */
  35581. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  35582. /**
  35583. * Lambda returning the list of potentially colliding sub meshes.
  35584. */
  35585. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  35586. private _activeMeshesFrozen;
  35587. /**
  35588. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  35589. * @returns the current scene
  35590. */
  35591. freezeActiveMeshes(): Scene;
  35592. /**
  35593. * Use this function to restart evaluating active meshes on every frame
  35594. * @returns the current scene
  35595. */
  35596. unfreezeActiveMeshes(): Scene;
  35597. private _evaluateActiveMeshes;
  35598. private _activeMesh;
  35599. /**
  35600. * Update the transform matrix to update from the current active camera
  35601. * @param force defines a boolean used to force the update even if cache is up to date
  35602. */
  35603. updateTransformMatrix(force?: boolean): void;
  35604. private _bindFrameBuffer;
  35605. /** @hidden */
  35606. _allowPostProcessClearColor: boolean;
  35607. /** @hidden */
  35608. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  35609. private _processSubCameras;
  35610. private _checkIntersections;
  35611. /** @hidden */
  35612. _advancePhysicsEngineStep(step: number): void;
  35613. /**
  35614. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  35615. */
  35616. getDeterministicFrameTime: () => number;
  35617. /** @hidden */
  35618. _animate(): void;
  35619. /** Execute all animations (for a frame) */
  35620. animate(): void;
  35621. /**
  35622. * Render the scene
  35623. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  35624. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  35625. */
  35626. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  35627. /**
  35628. * Freeze all materials
  35629. * A frozen material will not be updatable but should be faster to render
  35630. */
  35631. freezeMaterials(): void;
  35632. /**
  35633. * Unfreeze all materials
  35634. * A frozen material will not be updatable but should be faster to render
  35635. */
  35636. unfreezeMaterials(): void;
  35637. /**
  35638. * Releases all held ressources
  35639. */
  35640. dispose(): void;
  35641. /**
  35642. * Gets if the scene is already disposed
  35643. */
  35644. readonly isDisposed: boolean;
  35645. /**
  35646. * Call this function to reduce memory footprint of the scene.
  35647. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  35648. */
  35649. clearCachedVertexData(): void;
  35650. /**
  35651. * This function will remove the local cached buffer data from texture.
  35652. * It will save memory but will prevent the texture from being rebuilt
  35653. */
  35654. cleanCachedTextureBuffer(): void;
  35655. /**
  35656. * Get the world extend vectors with an optional filter
  35657. *
  35658. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  35659. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  35660. */
  35661. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  35662. min: Vector3;
  35663. max: Vector3;
  35664. };
  35665. /**
  35666. * Creates a ray that can be used to pick in the scene
  35667. * @param x defines the x coordinate of the origin (on-screen)
  35668. * @param y defines the y coordinate of the origin (on-screen)
  35669. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35670. * @param camera defines the camera to use for the picking
  35671. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35672. * @returns a Ray
  35673. */
  35674. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  35675. /**
  35676. * Creates a ray that can be used to pick in the scene
  35677. * @param x defines the x coordinate of the origin (on-screen)
  35678. * @param y defines the y coordinate of the origin (on-screen)
  35679. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  35680. * @param result defines the ray where to store the picking ray
  35681. * @param camera defines the camera to use for the picking
  35682. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  35683. * @returns the current scene
  35684. */
  35685. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  35686. /**
  35687. * Creates a ray that can be used to pick in the scene
  35688. * @param x defines the x coordinate of the origin (on-screen)
  35689. * @param y defines the y coordinate of the origin (on-screen)
  35690. * @param camera defines the camera to use for the picking
  35691. * @returns a Ray
  35692. */
  35693. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  35694. /**
  35695. * Creates a ray that can be used to pick in the scene
  35696. * @param x defines the x coordinate of the origin (on-screen)
  35697. * @param y defines the y coordinate of the origin (on-screen)
  35698. * @param result defines the ray where to store the picking ray
  35699. * @param camera defines the camera to use for the picking
  35700. * @returns the current scene
  35701. */
  35702. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  35703. /** Launch a ray to try to pick a mesh in the scene
  35704. * @param x position on screen
  35705. * @param y position on screen
  35706. * @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
  35707. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  35708. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35709. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35710. * @returns a PickingInfo
  35711. */
  35712. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35713. /** Use the given ray to pick a mesh in the scene
  35714. * @param ray The ray to use to pick meshes
  35715. * @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
  35716. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  35717. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35718. * @returns a PickingInfo
  35719. */
  35720. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  35721. /**
  35722. * Launch a ray to try to pick a mesh in the scene
  35723. * @param x X position on screen
  35724. * @param y Y position on screen
  35725. * @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
  35726. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  35727. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35728. * @returns an array of PickingInfo
  35729. */
  35730. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35731. /**
  35732. * Launch a ray to try to pick a mesh in the scene
  35733. * @param ray Ray to use
  35734. * @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
  35735. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  35736. * @returns an array of PickingInfo
  35737. */
  35738. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  35739. /**
  35740. * Force the value of meshUnderPointer
  35741. * @param mesh defines the mesh to use
  35742. */
  35743. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  35744. /**
  35745. * Gets the mesh under the pointer
  35746. * @returns a Mesh or null if no mesh is under the pointer
  35747. */
  35748. getPointerOverMesh(): Nullable<AbstractMesh>;
  35749. /** @hidden */
  35750. _rebuildGeometries(): void;
  35751. /** @hidden */
  35752. _rebuildTextures(): void;
  35753. private _getByTags;
  35754. /**
  35755. * Get a list of meshes by tags
  35756. * @param tagsQuery defines the tags query to use
  35757. * @param forEach defines a predicate used to filter results
  35758. * @returns an array of Mesh
  35759. */
  35760. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  35761. /**
  35762. * Get a list of cameras by tags
  35763. * @param tagsQuery defines the tags query to use
  35764. * @param forEach defines a predicate used to filter results
  35765. * @returns an array of Camera
  35766. */
  35767. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  35768. /**
  35769. * Get a list of lights by tags
  35770. * @param tagsQuery defines the tags query to use
  35771. * @param forEach defines a predicate used to filter results
  35772. * @returns an array of Light
  35773. */
  35774. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  35775. /**
  35776. * Get a list of materials by tags
  35777. * @param tagsQuery defines the tags query to use
  35778. * @param forEach defines a predicate used to filter results
  35779. * @returns an array of Material
  35780. */
  35781. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  35782. /**
  35783. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  35784. * This allowed control for front to back rendering or reversly depending of the special needs.
  35785. *
  35786. * @param renderingGroupId The rendering group id corresponding to its index
  35787. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  35788. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  35789. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  35790. */
  35791. 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;
  35792. /**
  35793. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  35794. *
  35795. * @param renderingGroupId The rendering group id corresponding to its index
  35796. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  35797. * @param depth Automatically clears depth between groups if true and autoClear is true.
  35798. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  35799. */
  35800. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  35801. /**
  35802. * Gets the current auto clear configuration for one rendering group of the rendering
  35803. * manager.
  35804. * @param index the rendering group index to get the information for
  35805. * @returns The auto clear setup for the requested rendering group
  35806. */
  35807. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  35808. private _blockMaterialDirtyMechanism;
  35809. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  35810. blockMaterialDirtyMechanism: boolean;
  35811. /**
  35812. * Will flag all materials as dirty to trigger new shader compilation
  35813. * @param flag defines the flag used to specify which material part must be marked as dirty
  35814. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  35815. */
  35816. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  35817. /** @hidden */
  35818. _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;
  35819. /** @hidden */
  35820. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35821. }
  35822. }
  35823. declare module "babylonjs/assetContainer" {
  35824. import { AbstractScene } from "babylonjs/abstractScene";
  35825. import { Scene } from "babylonjs/scene";
  35826. import { Mesh } from "babylonjs/Meshes/mesh";
  35827. /**
  35828. * Set of assets to keep when moving a scene into an asset container.
  35829. */
  35830. export class KeepAssets extends AbstractScene {
  35831. }
  35832. /**
  35833. * Container with a set of assets that can be added or removed from a scene.
  35834. */
  35835. export class AssetContainer extends AbstractScene {
  35836. /**
  35837. * The scene the AssetContainer belongs to.
  35838. */
  35839. scene: Scene;
  35840. /**
  35841. * Instantiates an AssetContainer.
  35842. * @param scene The scene the AssetContainer belongs to.
  35843. */
  35844. constructor(scene: Scene);
  35845. /**
  35846. * Adds all the assets from the container to the scene.
  35847. */
  35848. addAllToScene(): void;
  35849. /**
  35850. * Removes all the assets in the container from the scene
  35851. */
  35852. removeAllFromScene(): void;
  35853. /**
  35854. * Disposes all the assets in the container
  35855. */
  35856. dispose(): void;
  35857. private _moveAssets;
  35858. /**
  35859. * Removes all the assets contained in the scene and adds them to the container.
  35860. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  35861. */
  35862. moveAllFromScene(keepAssets?: KeepAssets): void;
  35863. /**
  35864. * 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.
  35865. * @returns the root mesh
  35866. */
  35867. createRootMesh(): Mesh;
  35868. }
  35869. }
  35870. declare module "babylonjs/abstractScene" {
  35871. import { Scene } from "babylonjs/scene";
  35872. import { Nullable } from "babylonjs/types";
  35873. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35874. import { TransformNode } from "babylonjs/Meshes/transformNode";
  35875. import { Geometry } from "babylonjs/Meshes/geometry";
  35876. import { Skeleton } from "babylonjs/Bones/skeleton";
  35877. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  35878. import { AssetContainer } from "babylonjs/assetContainer";
  35879. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  35880. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  35881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35882. import { Material } from "babylonjs/Materials/material";
  35883. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  35884. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  35885. import { Camera } from "babylonjs/Cameras/camera";
  35886. import { Light } from "babylonjs/Lights/light";
  35887. import { Node } from "babylonjs/node";
  35888. import { Animation } from "babylonjs/Animations/animation";
  35889. /**
  35890. * Defines how the parser contract is defined.
  35891. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  35892. */
  35893. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  35894. /**
  35895. * Defines how the individual parser contract is defined.
  35896. * These parser can parse an individual asset
  35897. */
  35898. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  35899. /**
  35900. * Base class of the scene acting as a container for the different elements composing a scene.
  35901. * This class is dynamically extended by the different components of the scene increasing
  35902. * flexibility and reducing coupling
  35903. */
  35904. export abstract class AbstractScene {
  35905. /**
  35906. * Stores the list of available parsers in the application.
  35907. */
  35908. private static _BabylonFileParsers;
  35909. /**
  35910. * Stores the list of available individual parsers in the application.
  35911. */
  35912. private static _IndividualBabylonFileParsers;
  35913. /**
  35914. * Adds a parser in the list of available ones
  35915. * @param name Defines the name of the parser
  35916. * @param parser Defines the parser to add
  35917. */
  35918. static AddParser(name: string, parser: BabylonFileParser): void;
  35919. /**
  35920. * Gets a general parser from the list of avaialble ones
  35921. * @param name Defines the name of the parser
  35922. * @returns the requested parser or null
  35923. */
  35924. static GetParser(name: string): Nullable<BabylonFileParser>;
  35925. /**
  35926. * Adds n individual parser in the list of available ones
  35927. * @param name Defines the name of the parser
  35928. * @param parser Defines the parser to add
  35929. */
  35930. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  35931. /**
  35932. * Gets an individual parser from the list of avaialble ones
  35933. * @param name Defines the name of the parser
  35934. * @returns the requested parser or null
  35935. */
  35936. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  35937. /**
  35938. * Parser json data and populate both a scene and its associated container object
  35939. * @param jsonData Defines the data to parse
  35940. * @param scene Defines the scene to parse the data for
  35941. * @param container Defines the container attached to the parsing sequence
  35942. * @param rootUrl Defines the root url of the data
  35943. */
  35944. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  35945. /**
  35946. * Gets the list of root nodes (ie. nodes with no parent)
  35947. */
  35948. rootNodes: Node[];
  35949. /** All of the cameras added to this scene
  35950. * @see http://doc.babylonjs.com/babylon101/cameras
  35951. */
  35952. cameras: Camera[];
  35953. /**
  35954. * All of the lights added to this scene
  35955. * @see http://doc.babylonjs.com/babylon101/lights
  35956. */
  35957. lights: Light[];
  35958. /**
  35959. * All of the (abstract) meshes added to this scene
  35960. */
  35961. meshes: AbstractMesh[];
  35962. /**
  35963. * The list of skeletons added to the scene
  35964. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  35965. */
  35966. skeletons: Skeleton[];
  35967. /**
  35968. * All of the particle systems added to this scene
  35969. * @see http://doc.babylonjs.com/babylon101/particles
  35970. */
  35971. particleSystems: IParticleSystem[];
  35972. /**
  35973. * Gets a list of Animations associated with the scene
  35974. */
  35975. animations: Animation[];
  35976. /**
  35977. * All of the animation groups added to this scene
  35978. * @see http://doc.babylonjs.com/how_to/group
  35979. */
  35980. animationGroups: AnimationGroup[];
  35981. /**
  35982. * All of the multi-materials added to this scene
  35983. * @see http://doc.babylonjs.com/how_to/multi_materials
  35984. */
  35985. multiMaterials: MultiMaterial[];
  35986. /**
  35987. * All of the materials added to this scene
  35988. * In the context of a Scene, it is not supposed to be modified manually.
  35989. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  35990. * Note also that the order of the Material wihin the array is not significant and might change.
  35991. * @see http://doc.babylonjs.com/babylon101/materials
  35992. */
  35993. materials: Material[];
  35994. /**
  35995. * The list of morph target managers added to the scene
  35996. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  35997. */
  35998. morphTargetManagers: MorphTargetManager[];
  35999. /**
  36000. * The list of geometries used in the scene.
  36001. */
  36002. geometries: Geometry[];
  36003. /**
  36004. * All of the tranform nodes added to this scene
  36005. * In the context of a Scene, it is not supposed to be modified manually.
  36006. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  36007. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  36008. * @see http://doc.babylonjs.com/how_to/transformnode
  36009. */
  36010. transformNodes: TransformNode[];
  36011. /**
  36012. * ActionManagers available on the scene.
  36013. */
  36014. actionManagers: AbstractActionManager[];
  36015. /**
  36016. * Textures to keep.
  36017. */
  36018. textures: BaseTexture[];
  36019. /**
  36020. * Environment texture for the scene
  36021. */
  36022. environmentTexture: Nullable<BaseTexture>;
  36023. }
  36024. }
  36025. declare module "babylonjs/Audio/sound" {
  36026. import { Observable } from "babylonjs/Misc/observable";
  36027. import { Vector3 } from "babylonjs/Maths/math.vector";
  36028. import { Nullable } from "babylonjs/types";
  36029. import { Scene } from "babylonjs/scene";
  36030. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36031. /**
  36032. * Interface used to define options for Sound class
  36033. */
  36034. export interface ISoundOptions {
  36035. /**
  36036. * Does the sound autoplay once loaded.
  36037. */
  36038. autoplay?: boolean;
  36039. /**
  36040. * Does the sound loop after it finishes playing once.
  36041. */
  36042. loop?: boolean;
  36043. /**
  36044. * Sound's volume
  36045. */
  36046. volume?: number;
  36047. /**
  36048. * Is it a spatial sound?
  36049. */
  36050. spatialSound?: boolean;
  36051. /**
  36052. * Maximum distance to hear that sound
  36053. */
  36054. maxDistance?: number;
  36055. /**
  36056. * Uses user defined attenuation function
  36057. */
  36058. useCustomAttenuation?: boolean;
  36059. /**
  36060. * Define the roll off factor of spatial sounds.
  36061. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36062. */
  36063. rolloffFactor?: number;
  36064. /**
  36065. * Define the reference distance the sound should be heard perfectly.
  36066. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36067. */
  36068. refDistance?: number;
  36069. /**
  36070. * Define the distance attenuation model the sound will follow.
  36071. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36072. */
  36073. distanceModel?: string;
  36074. /**
  36075. * Defines the playback speed (1 by default)
  36076. */
  36077. playbackRate?: number;
  36078. /**
  36079. * Defines if the sound is from a streaming source
  36080. */
  36081. streaming?: boolean;
  36082. /**
  36083. * Defines an optional length (in seconds) inside the sound file
  36084. */
  36085. length?: number;
  36086. /**
  36087. * Defines an optional offset (in seconds) inside the sound file
  36088. */
  36089. offset?: number;
  36090. /**
  36091. * If true, URLs will not be required to state the audio file codec to use.
  36092. */
  36093. skipCodecCheck?: boolean;
  36094. }
  36095. /**
  36096. * Defines a sound that can be played in the application.
  36097. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  36098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36099. */
  36100. export class Sound {
  36101. /**
  36102. * The name of the sound in the scene.
  36103. */
  36104. name: string;
  36105. /**
  36106. * Does the sound autoplay once loaded.
  36107. */
  36108. autoplay: boolean;
  36109. /**
  36110. * Does the sound loop after it finishes playing once.
  36111. */
  36112. loop: boolean;
  36113. /**
  36114. * Does the sound use a custom attenuation curve to simulate the falloff
  36115. * happening when the source gets further away from the camera.
  36116. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36117. */
  36118. useCustomAttenuation: boolean;
  36119. /**
  36120. * The sound track id this sound belongs to.
  36121. */
  36122. soundTrackId: number;
  36123. /**
  36124. * Is this sound currently played.
  36125. */
  36126. isPlaying: boolean;
  36127. /**
  36128. * Is this sound currently paused.
  36129. */
  36130. isPaused: boolean;
  36131. /**
  36132. * Does this sound enables spatial sound.
  36133. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36134. */
  36135. spatialSound: boolean;
  36136. /**
  36137. * Define the reference distance the sound should be heard perfectly.
  36138. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36139. */
  36140. refDistance: number;
  36141. /**
  36142. * Define the roll off factor of spatial sounds.
  36143. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36144. */
  36145. rolloffFactor: number;
  36146. /**
  36147. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  36148. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36149. */
  36150. maxDistance: number;
  36151. /**
  36152. * Define the distance attenuation model the sound will follow.
  36153. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36154. */
  36155. distanceModel: string;
  36156. /**
  36157. * @hidden
  36158. * Back Compat
  36159. **/
  36160. onended: () => any;
  36161. /**
  36162. * Observable event when the current playing sound finishes.
  36163. */
  36164. onEndedObservable: Observable<Sound>;
  36165. private _panningModel;
  36166. private _playbackRate;
  36167. private _streaming;
  36168. private _startTime;
  36169. private _startOffset;
  36170. private _position;
  36171. /** @hidden */
  36172. _positionInEmitterSpace: boolean;
  36173. private _localDirection;
  36174. private _volume;
  36175. private _isReadyToPlay;
  36176. private _isDirectional;
  36177. private _readyToPlayCallback;
  36178. private _audioBuffer;
  36179. private _soundSource;
  36180. private _streamingSource;
  36181. private _soundPanner;
  36182. private _soundGain;
  36183. private _inputAudioNode;
  36184. private _outputAudioNode;
  36185. private _coneInnerAngle;
  36186. private _coneOuterAngle;
  36187. private _coneOuterGain;
  36188. private _scene;
  36189. private _connectedTransformNode;
  36190. private _customAttenuationFunction;
  36191. private _registerFunc;
  36192. private _isOutputConnected;
  36193. private _htmlAudioElement;
  36194. private _urlType;
  36195. private _length?;
  36196. private _offset?;
  36197. /** @hidden */
  36198. static _SceneComponentInitialization: (scene: Scene) => void;
  36199. /**
  36200. * Create a sound and attach it to a scene
  36201. * @param name Name of your sound
  36202. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  36203. * @param scene defines the scene the sound belongs to
  36204. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  36205. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  36206. */
  36207. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  36208. /**
  36209. * Release the sound and its associated resources
  36210. */
  36211. dispose(): void;
  36212. /**
  36213. * Gets if the sounds is ready to be played or not.
  36214. * @returns true if ready, otherwise false
  36215. */
  36216. isReady(): boolean;
  36217. private _soundLoaded;
  36218. /**
  36219. * Sets the data of the sound from an audiobuffer
  36220. * @param audioBuffer The audioBuffer containing the data
  36221. */
  36222. setAudioBuffer(audioBuffer: AudioBuffer): void;
  36223. /**
  36224. * Updates the current sounds options such as maxdistance, loop...
  36225. * @param options A JSON object containing values named as the object properties
  36226. */
  36227. updateOptions(options: ISoundOptions): void;
  36228. private _createSpatialParameters;
  36229. private _updateSpatialParameters;
  36230. /**
  36231. * Switch the panning model to HRTF:
  36232. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36234. */
  36235. switchPanningModelToHRTF(): void;
  36236. /**
  36237. * Switch the panning model to Equal Power:
  36238. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36239. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36240. */
  36241. switchPanningModelToEqualPower(): void;
  36242. private _switchPanningModel;
  36243. /**
  36244. * Connect this sound to a sound track audio node like gain...
  36245. * @param soundTrackAudioNode the sound track audio node to connect to
  36246. */
  36247. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  36248. /**
  36249. * Transform this sound into a directional source
  36250. * @param coneInnerAngle Size of the inner cone in degree
  36251. * @param coneOuterAngle Size of the outer cone in degree
  36252. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  36253. */
  36254. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  36255. /**
  36256. * Gets or sets the inner angle for the directional cone.
  36257. */
  36258. /**
  36259. * Gets or sets the inner angle for the directional cone.
  36260. */
  36261. directionalConeInnerAngle: number;
  36262. /**
  36263. * Gets or sets the outer angle for the directional cone.
  36264. */
  36265. /**
  36266. * Gets or sets the outer angle for the directional cone.
  36267. */
  36268. directionalConeOuterAngle: number;
  36269. /**
  36270. * Sets the position of the emitter if spatial sound is enabled
  36271. * @param newPosition Defines the new posisiton
  36272. */
  36273. setPosition(newPosition: Vector3): void;
  36274. /**
  36275. * Sets the local direction of the emitter if spatial sound is enabled
  36276. * @param newLocalDirection Defines the new local direction
  36277. */
  36278. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  36279. private _updateDirection;
  36280. /** @hidden */
  36281. updateDistanceFromListener(): void;
  36282. /**
  36283. * Sets a new custom attenuation function for the sound.
  36284. * @param callback Defines the function used for the attenuation
  36285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  36286. */
  36287. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  36288. /**
  36289. * Play the sound
  36290. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  36291. * @param offset (optional) Start the sound at a specific time in seconds
  36292. * @param length (optional) Sound duration (in seconds)
  36293. */
  36294. play(time?: number, offset?: number, length?: number): void;
  36295. private _onended;
  36296. /**
  36297. * Stop the sound
  36298. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  36299. */
  36300. stop(time?: number): void;
  36301. /**
  36302. * Put the sound in pause
  36303. */
  36304. pause(): void;
  36305. /**
  36306. * Sets a dedicated volume for this sounds
  36307. * @param newVolume Define the new volume of the sound
  36308. * @param time Define time for gradual change to new volume
  36309. */
  36310. setVolume(newVolume: number, time?: number): void;
  36311. /**
  36312. * Set the sound play back rate
  36313. * @param newPlaybackRate Define the playback rate the sound should be played at
  36314. */
  36315. setPlaybackRate(newPlaybackRate: number): void;
  36316. /**
  36317. * Gets the volume of the sound.
  36318. * @returns the volume of the sound
  36319. */
  36320. getVolume(): number;
  36321. /**
  36322. * Attach the sound to a dedicated mesh
  36323. * @param transformNode The transform node to connect the sound with
  36324. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36325. */
  36326. attachToMesh(transformNode: TransformNode): void;
  36327. /**
  36328. * Detach the sound from the previously attached mesh
  36329. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  36330. */
  36331. detachFromMesh(): void;
  36332. private _onRegisterAfterWorldMatrixUpdate;
  36333. /**
  36334. * Clone the current sound in the scene.
  36335. * @returns the new sound clone
  36336. */
  36337. clone(): Nullable<Sound>;
  36338. /**
  36339. * Gets the current underlying audio buffer containing the data
  36340. * @returns the audio buffer
  36341. */
  36342. getAudioBuffer(): Nullable<AudioBuffer>;
  36343. /**
  36344. * Serializes the Sound in a JSON representation
  36345. * @returns the JSON representation of the sound
  36346. */
  36347. serialize(): any;
  36348. /**
  36349. * Parse a JSON representation of a sound to innstantiate in a given scene
  36350. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  36351. * @param scene Define the scene the new parsed sound should be created in
  36352. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  36353. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  36354. * @returns the newly parsed sound
  36355. */
  36356. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  36357. }
  36358. }
  36359. declare module "babylonjs/Actions/directAudioActions" {
  36360. import { Action } from "babylonjs/Actions/action";
  36361. import { Condition } from "babylonjs/Actions/condition";
  36362. import { Sound } from "babylonjs/Audio/sound";
  36363. /**
  36364. * This defines an action helpful to play a defined sound on a triggered action.
  36365. */
  36366. export class PlaySoundAction extends Action {
  36367. private _sound;
  36368. /**
  36369. * Instantiate the action
  36370. * @param triggerOptions defines the trigger options
  36371. * @param sound defines the sound to play
  36372. * @param condition defines the trigger related conditions
  36373. */
  36374. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36375. /** @hidden */
  36376. _prepare(): void;
  36377. /**
  36378. * Execute the action and play the sound.
  36379. */
  36380. execute(): void;
  36381. /**
  36382. * Serializes the actions and its related information.
  36383. * @param parent defines the object to serialize in
  36384. * @returns the serialized object
  36385. */
  36386. serialize(parent: any): any;
  36387. }
  36388. /**
  36389. * This defines an action helpful to stop a defined sound on a triggered action.
  36390. */
  36391. export class StopSoundAction extends Action {
  36392. private _sound;
  36393. /**
  36394. * Instantiate the action
  36395. * @param triggerOptions defines the trigger options
  36396. * @param sound defines the sound to stop
  36397. * @param condition defines the trigger related conditions
  36398. */
  36399. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  36400. /** @hidden */
  36401. _prepare(): void;
  36402. /**
  36403. * Execute the action and stop the sound.
  36404. */
  36405. execute(): void;
  36406. /**
  36407. * Serializes the actions and its related information.
  36408. * @param parent defines the object to serialize in
  36409. * @returns the serialized object
  36410. */
  36411. serialize(parent: any): any;
  36412. }
  36413. }
  36414. declare module "babylonjs/Actions/interpolateValueAction" {
  36415. import { Action } from "babylonjs/Actions/action";
  36416. import { Condition } from "babylonjs/Actions/condition";
  36417. import { Observable } from "babylonjs/Misc/observable";
  36418. /**
  36419. * This defines an action responsible to change the value of a property
  36420. * by interpolating between its current value and the newly set one once triggered.
  36421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  36422. */
  36423. export class InterpolateValueAction extends Action {
  36424. /**
  36425. * Defines the path of the property where the value should be interpolated
  36426. */
  36427. propertyPath: string;
  36428. /**
  36429. * Defines the target value at the end of the interpolation.
  36430. */
  36431. value: any;
  36432. /**
  36433. * Defines the time it will take for the property to interpolate to the value.
  36434. */
  36435. duration: number;
  36436. /**
  36437. * Defines if the other scene animations should be stopped when the action has been triggered
  36438. */
  36439. stopOtherAnimations?: boolean;
  36440. /**
  36441. * Defines a callback raised once the interpolation animation has been done.
  36442. */
  36443. onInterpolationDone?: () => void;
  36444. /**
  36445. * Observable triggered once the interpolation animation has been done.
  36446. */
  36447. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  36448. private _target;
  36449. private _effectiveTarget;
  36450. private _property;
  36451. /**
  36452. * Instantiate the action
  36453. * @param triggerOptions defines the trigger options
  36454. * @param target defines the object containing the value to interpolate
  36455. * @param propertyPath defines the path to the property in the target object
  36456. * @param value defines the target value at the end of the interpolation
  36457. * @param duration deines the time it will take for the property to interpolate to the value.
  36458. * @param condition defines the trigger related conditions
  36459. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  36460. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  36461. */
  36462. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  36463. /** @hidden */
  36464. _prepare(): void;
  36465. /**
  36466. * Execute the action starts the value interpolation.
  36467. */
  36468. execute(): void;
  36469. /**
  36470. * Serializes the actions and its related information.
  36471. * @param parent defines the object to serialize in
  36472. * @returns the serialized object
  36473. */
  36474. serialize(parent: any): any;
  36475. }
  36476. }
  36477. declare module "babylonjs/Actions/index" {
  36478. export * from "babylonjs/Actions/abstractActionManager";
  36479. export * from "babylonjs/Actions/action";
  36480. export * from "babylonjs/Actions/actionEvent";
  36481. export * from "babylonjs/Actions/actionManager";
  36482. export * from "babylonjs/Actions/condition";
  36483. export * from "babylonjs/Actions/directActions";
  36484. export * from "babylonjs/Actions/directAudioActions";
  36485. export * from "babylonjs/Actions/interpolateValueAction";
  36486. }
  36487. declare module "babylonjs/Animations/index" {
  36488. export * from "babylonjs/Animations/animatable";
  36489. export * from "babylonjs/Animations/animation";
  36490. export * from "babylonjs/Animations/animationGroup";
  36491. export * from "babylonjs/Animations/animationPropertiesOverride";
  36492. export * from "babylonjs/Animations/easing";
  36493. export * from "babylonjs/Animations/runtimeAnimation";
  36494. export * from "babylonjs/Animations/animationEvent";
  36495. export * from "babylonjs/Animations/animationGroup";
  36496. export * from "babylonjs/Animations/animationKey";
  36497. export * from "babylonjs/Animations/animationRange";
  36498. export * from "babylonjs/Animations/animatable.interface";
  36499. }
  36500. declare module "babylonjs/Audio/soundTrack" {
  36501. import { Sound } from "babylonjs/Audio/sound";
  36502. import { Analyser } from "babylonjs/Audio/analyser";
  36503. import { Scene } from "babylonjs/scene";
  36504. /**
  36505. * Options allowed during the creation of a sound track.
  36506. */
  36507. export interface ISoundTrackOptions {
  36508. /**
  36509. * The volume the sound track should take during creation
  36510. */
  36511. volume?: number;
  36512. /**
  36513. * Define if the sound track is the main sound track of the scene
  36514. */
  36515. mainTrack?: boolean;
  36516. }
  36517. /**
  36518. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  36519. * It will be also used in a future release to apply effects on a specific track.
  36520. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36521. */
  36522. export class SoundTrack {
  36523. /**
  36524. * The unique identifier of the sound track in the scene.
  36525. */
  36526. id: number;
  36527. /**
  36528. * The list of sounds included in the sound track.
  36529. */
  36530. soundCollection: Array<Sound>;
  36531. private _outputAudioNode;
  36532. private _scene;
  36533. private _isMainTrack;
  36534. private _connectedAnalyser;
  36535. private _options;
  36536. private _isInitialized;
  36537. /**
  36538. * Creates a new sound track.
  36539. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  36540. * @param scene Define the scene the sound track belongs to
  36541. * @param options
  36542. */
  36543. constructor(scene: Scene, options?: ISoundTrackOptions);
  36544. private _initializeSoundTrackAudioGraph;
  36545. /**
  36546. * Release the sound track and its associated resources
  36547. */
  36548. dispose(): void;
  36549. /**
  36550. * Adds a sound to this sound track
  36551. * @param sound define the cound to add
  36552. * @ignoreNaming
  36553. */
  36554. AddSound(sound: Sound): void;
  36555. /**
  36556. * Removes a sound to this sound track
  36557. * @param sound define the cound to remove
  36558. * @ignoreNaming
  36559. */
  36560. RemoveSound(sound: Sound): void;
  36561. /**
  36562. * Set a global volume for the full sound track.
  36563. * @param newVolume Define the new volume of the sound track
  36564. */
  36565. setVolume(newVolume: number): void;
  36566. /**
  36567. * Switch the panning model to HRTF:
  36568. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  36569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36570. */
  36571. switchPanningModelToHRTF(): void;
  36572. /**
  36573. * Switch the panning model to Equal Power:
  36574. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  36575. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  36576. */
  36577. switchPanningModelToEqualPower(): void;
  36578. /**
  36579. * Connect the sound track to an audio analyser allowing some amazing
  36580. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  36581. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  36582. * @param analyser The analyser to connect to the engine
  36583. */
  36584. connectToAnalyser(analyser: Analyser): void;
  36585. }
  36586. }
  36587. declare module "babylonjs/Audio/audioSceneComponent" {
  36588. import { Sound } from "babylonjs/Audio/sound";
  36589. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  36590. import { Nullable } from "babylonjs/types";
  36591. import { Vector3 } from "babylonjs/Maths/math.vector";
  36592. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  36593. import { Scene } from "babylonjs/scene";
  36594. import { AbstractScene } from "babylonjs/abstractScene";
  36595. import "babylonjs/Audio/audioEngine";
  36596. module "babylonjs/abstractScene" {
  36597. interface AbstractScene {
  36598. /**
  36599. * The list of sounds used in the scene.
  36600. */
  36601. sounds: Nullable<Array<Sound>>;
  36602. }
  36603. }
  36604. module "babylonjs/scene" {
  36605. interface Scene {
  36606. /**
  36607. * @hidden
  36608. * Backing field
  36609. */
  36610. _mainSoundTrack: SoundTrack;
  36611. /**
  36612. * The main sound track played by the scene.
  36613. * It cotains your primary collection of sounds.
  36614. */
  36615. mainSoundTrack: SoundTrack;
  36616. /**
  36617. * The list of sound tracks added to the scene
  36618. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36619. */
  36620. soundTracks: Nullable<Array<SoundTrack>>;
  36621. /**
  36622. * Gets a sound using a given name
  36623. * @param name defines the name to search for
  36624. * @return the found sound or null if not found at all.
  36625. */
  36626. getSoundByName(name: string): Nullable<Sound>;
  36627. /**
  36628. * Gets or sets if audio support is enabled
  36629. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36630. */
  36631. audioEnabled: boolean;
  36632. /**
  36633. * Gets or sets if audio will be output to headphones
  36634. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36635. */
  36636. headphone: boolean;
  36637. /**
  36638. * Gets or sets custom audio listener position provider
  36639. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  36640. */
  36641. audioListenerPositionProvider: Nullable<() => Vector3>;
  36642. }
  36643. }
  36644. /**
  36645. * Defines the sound scene component responsible to manage any sounds
  36646. * in a given scene.
  36647. */
  36648. export class AudioSceneComponent implements ISceneSerializableComponent {
  36649. /**
  36650. * The component name helpfull to identify the component in the list of scene components.
  36651. */
  36652. readonly name: string;
  36653. /**
  36654. * The scene the component belongs to.
  36655. */
  36656. scene: Scene;
  36657. private _audioEnabled;
  36658. /**
  36659. * Gets whether audio is enabled or not.
  36660. * Please use related enable/disable method to switch state.
  36661. */
  36662. readonly audioEnabled: boolean;
  36663. private _headphone;
  36664. /**
  36665. * Gets whether audio is outputing to headphone or not.
  36666. * Please use the according Switch methods to change output.
  36667. */
  36668. readonly headphone: boolean;
  36669. private _audioListenerPositionProvider;
  36670. /**
  36671. * Gets the current audio listener position provider
  36672. */
  36673. /**
  36674. * Sets a custom listener position for all sounds in the scene
  36675. * By default, this is the position of the first active camera
  36676. */
  36677. audioListenerPositionProvider: Nullable<() => Vector3>;
  36678. /**
  36679. * Creates a new instance of the component for the given scene
  36680. * @param scene Defines the scene to register the component in
  36681. */
  36682. constructor(scene: Scene);
  36683. /**
  36684. * Registers the component in a given scene
  36685. */
  36686. register(): void;
  36687. /**
  36688. * Rebuilds the elements related to this component in case of
  36689. * context lost for instance.
  36690. */
  36691. rebuild(): void;
  36692. /**
  36693. * Serializes the component data to the specified json object
  36694. * @param serializationObject The object to serialize to
  36695. */
  36696. serialize(serializationObject: any): void;
  36697. /**
  36698. * Adds all the elements from the container to the scene
  36699. * @param container the container holding the elements
  36700. */
  36701. addFromContainer(container: AbstractScene): void;
  36702. /**
  36703. * Removes all the elements in the container from the scene
  36704. * @param container contains the elements to remove
  36705. * @param dispose if the removed element should be disposed (default: false)
  36706. */
  36707. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  36708. /**
  36709. * Disposes the component and the associated ressources.
  36710. */
  36711. dispose(): void;
  36712. /**
  36713. * Disables audio in the associated scene.
  36714. */
  36715. disableAudio(): void;
  36716. /**
  36717. * Enables audio in the associated scene.
  36718. */
  36719. enableAudio(): void;
  36720. /**
  36721. * Switch audio to headphone output.
  36722. */
  36723. switchAudioModeForHeadphones(): void;
  36724. /**
  36725. * Switch audio to normal speakers.
  36726. */
  36727. switchAudioModeForNormalSpeakers(): void;
  36728. private _afterRender;
  36729. }
  36730. }
  36731. declare module "babylonjs/Audio/weightedsound" {
  36732. import { Sound } from "babylonjs/Audio/sound";
  36733. /**
  36734. * Wraps one or more Sound objects and selects one with random weight for playback.
  36735. */
  36736. export class WeightedSound {
  36737. /** When true a Sound will be selected and played when the current playing Sound completes. */
  36738. loop: boolean;
  36739. private _coneInnerAngle;
  36740. private _coneOuterAngle;
  36741. private _volume;
  36742. /** A Sound is currently playing. */
  36743. isPlaying: boolean;
  36744. /** A Sound is currently paused. */
  36745. isPaused: boolean;
  36746. private _sounds;
  36747. private _weights;
  36748. private _currentIndex?;
  36749. /**
  36750. * Creates a new WeightedSound from the list of sounds given.
  36751. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  36752. * @param sounds Array of Sounds that will be selected from.
  36753. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  36754. */
  36755. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  36756. /**
  36757. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  36758. */
  36759. /**
  36760. * The size of cone in degress for a directional sound in which there will be no attenuation.
  36761. */
  36762. directionalConeInnerAngle: number;
  36763. /**
  36764. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36765. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36766. */
  36767. /**
  36768. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  36769. * Listener angles between innerAngle and outerAngle will falloff linearly.
  36770. */
  36771. directionalConeOuterAngle: number;
  36772. /**
  36773. * Playback volume.
  36774. */
  36775. /**
  36776. * Playback volume.
  36777. */
  36778. volume: number;
  36779. private _onended;
  36780. /**
  36781. * Suspend playback
  36782. */
  36783. pause(): void;
  36784. /**
  36785. * Stop playback
  36786. */
  36787. stop(): void;
  36788. /**
  36789. * Start playback.
  36790. * @param startOffset Position the clip head at a specific time in seconds.
  36791. */
  36792. play(startOffset?: number): void;
  36793. }
  36794. }
  36795. declare module "babylonjs/Audio/index" {
  36796. export * from "babylonjs/Audio/analyser";
  36797. export * from "babylonjs/Audio/audioEngine";
  36798. export * from "babylonjs/Audio/audioSceneComponent";
  36799. export * from "babylonjs/Audio/sound";
  36800. export * from "babylonjs/Audio/soundTrack";
  36801. export * from "babylonjs/Audio/weightedsound";
  36802. }
  36803. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  36804. import { Behavior } from "babylonjs/Behaviors/behavior";
  36805. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36806. import { BackEase } from "babylonjs/Animations/easing";
  36807. /**
  36808. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  36809. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36810. */
  36811. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  36812. /**
  36813. * Gets the name of the behavior.
  36814. */
  36815. readonly name: string;
  36816. /**
  36817. * The easing function used by animations
  36818. */
  36819. static EasingFunction: BackEase;
  36820. /**
  36821. * The easing mode used by animations
  36822. */
  36823. static EasingMode: number;
  36824. /**
  36825. * The duration of the animation, in milliseconds
  36826. */
  36827. transitionDuration: number;
  36828. /**
  36829. * Length of the distance animated by the transition when lower radius is reached
  36830. */
  36831. lowerRadiusTransitionRange: number;
  36832. /**
  36833. * Length of the distance animated by the transition when upper radius is reached
  36834. */
  36835. upperRadiusTransitionRange: number;
  36836. private _autoTransitionRange;
  36837. /**
  36838. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36839. */
  36840. /**
  36841. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  36842. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  36843. */
  36844. autoTransitionRange: boolean;
  36845. private _attachedCamera;
  36846. private _onAfterCheckInputsObserver;
  36847. private _onMeshTargetChangedObserver;
  36848. /**
  36849. * Initializes the behavior.
  36850. */
  36851. init(): void;
  36852. /**
  36853. * Attaches the behavior to its arc rotate camera.
  36854. * @param camera Defines the camera to attach the behavior to
  36855. */
  36856. attach(camera: ArcRotateCamera): void;
  36857. /**
  36858. * Detaches the behavior from its current arc rotate camera.
  36859. */
  36860. detach(): void;
  36861. private _radiusIsAnimating;
  36862. private _radiusBounceTransition;
  36863. private _animatables;
  36864. private _cachedWheelPrecision;
  36865. /**
  36866. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  36867. * @param radiusLimit The limit to check against.
  36868. * @return Bool to indicate if at limit.
  36869. */
  36870. private _isRadiusAtLimit;
  36871. /**
  36872. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  36873. * @param radiusDelta The delta by which to animate to. Can be negative.
  36874. */
  36875. private _applyBoundRadiusAnimation;
  36876. /**
  36877. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  36878. */
  36879. protected _clearAnimationLocks(): void;
  36880. /**
  36881. * Stops and removes all animations that have been applied to the camera
  36882. */
  36883. stopAllAnimations(): void;
  36884. }
  36885. }
  36886. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  36887. import { Behavior } from "babylonjs/Behaviors/behavior";
  36888. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36889. import { ExponentialEase } from "babylonjs/Animations/easing";
  36890. import { Nullable } from "babylonjs/types";
  36891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36892. import { Vector3 } from "babylonjs/Maths/math.vector";
  36893. /**
  36894. * 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.
  36895. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36896. */
  36897. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  36898. /**
  36899. * Gets the name of the behavior.
  36900. */
  36901. readonly name: string;
  36902. private _mode;
  36903. private _radiusScale;
  36904. private _positionScale;
  36905. private _defaultElevation;
  36906. private _elevationReturnTime;
  36907. private _elevationReturnWaitTime;
  36908. private _zoomStopsAnimation;
  36909. private _framingTime;
  36910. /**
  36911. * The easing function used by animations
  36912. */
  36913. static EasingFunction: ExponentialEase;
  36914. /**
  36915. * The easing mode used by animations
  36916. */
  36917. static EasingMode: number;
  36918. /**
  36919. * Sets the current mode used by the behavior
  36920. */
  36921. /**
  36922. * Gets current mode used by the behavior.
  36923. */
  36924. mode: number;
  36925. /**
  36926. * Sets the scale applied to the radius (1 by default)
  36927. */
  36928. /**
  36929. * Gets the scale applied to the radius
  36930. */
  36931. radiusScale: number;
  36932. /**
  36933. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36934. */
  36935. /**
  36936. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  36937. */
  36938. positionScale: number;
  36939. /**
  36940. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36941. * behaviour is triggered, in radians.
  36942. */
  36943. /**
  36944. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  36945. * behaviour is triggered, in radians.
  36946. */
  36947. defaultElevation: number;
  36948. /**
  36949. * Sets the time (in milliseconds) taken to return to the default beta position.
  36950. * Negative value indicates camera should not return to default.
  36951. */
  36952. /**
  36953. * Gets the time (in milliseconds) taken to return to the default beta position.
  36954. * Negative value indicates camera should not return to default.
  36955. */
  36956. elevationReturnTime: number;
  36957. /**
  36958. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36959. */
  36960. /**
  36961. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  36962. */
  36963. elevationReturnWaitTime: number;
  36964. /**
  36965. * Sets the flag that indicates if user zooming should stop animation.
  36966. */
  36967. /**
  36968. * Gets the flag that indicates if user zooming should stop animation.
  36969. */
  36970. zoomStopsAnimation: boolean;
  36971. /**
  36972. * Sets the transition time when framing the mesh, in milliseconds
  36973. */
  36974. /**
  36975. * Gets the transition time when framing the mesh, in milliseconds
  36976. */
  36977. framingTime: number;
  36978. /**
  36979. * Define if the behavior should automatically change the configured
  36980. * camera limits and sensibilities.
  36981. */
  36982. autoCorrectCameraLimitsAndSensibility: boolean;
  36983. private _onPrePointerObservableObserver;
  36984. private _onAfterCheckInputsObserver;
  36985. private _onMeshTargetChangedObserver;
  36986. private _attachedCamera;
  36987. private _isPointerDown;
  36988. private _lastInteractionTime;
  36989. /**
  36990. * Initializes the behavior.
  36991. */
  36992. init(): void;
  36993. /**
  36994. * Attaches the behavior to its arc rotate camera.
  36995. * @param camera Defines the camera to attach the behavior to
  36996. */
  36997. attach(camera: ArcRotateCamera): void;
  36998. /**
  36999. * Detaches the behavior from its current arc rotate camera.
  37000. */
  37001. detach(): void;
  37002. private _animatables;
  37003. private _betaIsAnimating;
  37004. private _betaTransition;
  37005. private _radiusTransition;
  37006. private _vectorTransition;
  37007. /**
  37008. * Targets the given mesh and updates zoom level accordingly.
  37009. * @param mesh The mesh to target.
  37010. * @param radius Optional. If a cached radius position already exists, overrides default.
  37011. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37012. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37013. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37014. */
  37015. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37016. /**
  37017. * Targets the given mesh with its children and updates zoom level accordingly.
  37018. * @param mesh The mesh to target.
  37019. * @param radius Optional. If a cached radius position already exists, overrides default.
  37020. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37021. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37022. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37023. */
  37024. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37025. /**
  37026. * Targets the given meshes with their children and updates zoom level accordingly.
  37027. * @param meshes The mesh to target.
  37028. * @param radius Optional. If a cached radius position already exists, overrides default.
  37029. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  37030. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37031. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37032. */
  37033. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37034. /**
  37035. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  37036. * @param minimumWorld Determines the smaller position of the bounding box extend
  37037. * @param maximumWorld Determines the bigger position of the bounding box extend
  37038. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  37039. * @param onAnimationEnd Callback triggered at the end of the framing animation
  37040. */
  37041. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  37042. /**
  37043. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  37044. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  37045. * frustum width.
  37046. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  37047. * to fully enclose the mesh in the viewing frustum.
  37048. */
  37049. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  37050. /**
  37051. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  37052. * is automatically returned to its default position (expected to be above ground plane).
  37053. */
  37054. private _maintainCameraAboveGround;
  37055. /**
  37056. * Returns the frustum slope based on the canvas ratio and camera FOV
  37057. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  37058. */
  37059. private _getFrustumSlope;
  37060. /**
  37061. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  37062. */
  37063. private _clearAnimationLocks;
  37064. /**
  37065. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37066. */
  37067. private _applyUserInteraction;
  37068. /**
  37069. * Stops and removes all animations that have been applied to the camera
  37070. */
  37071. stopAllAnimations(): void;
  37072. /**
  37073. * Gets a value indicating if the user is moving the camera
  37074. */
  37075. readonly isUserIsMoving: boolean;
  37076. /**
  37077. * The camera can move all the way towards the mesh.
  37078. */
  37079. static IgnoreBoundsSizeMode: number;
  37080. /**
  37081. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  37082. */
  37083. static FitFrustumSidesMode: number;
  37084. }
  37085. }
  37086. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  37087. import { Nullable } from "babylonjs/types";
  37088. import { Camera } from "babylonjs/Cameras/camera";
  37089. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37090. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37091. /**
  37092. * Base class for Camera Pointer Inputs.
  37093. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  37094. * for example usage.
  37095. */
  37096. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  37097. /**
  37098. * Defines the camera the input is attached to.
  37099. */
  37100. abstract camera: Camera;
  37101. /**
  37102. * Whether keyboard modifier keys are pressed at time of last mouse event.
  37103. */
  37104. protected _altKey: boolean;
  37105. protected _ctrlKey: boolean;
  37106. protected _metaKey: boolean;
  37107. protected _shiftKey: boolean;
  37108. /**
  37109. * Which mouse buttons were pressed at time of last mouse event.
  37110. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  37111. */
  37112. protected _buttonsPressed: number;
  37113. /**
  37114. * Defines the buttons associated with the input to handle camera move.
  37115. */
  37116. buttons: number[];
  37117. /**
  37118. * Attach the input controls to a specific dom element to get the input from.
  37119. * @param element Defines the element the controls should be listened from
  37120. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37121. */
  37122. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37123. /**
  37124. * Detach the current controls from the specified dom element.
  37125. * @param element Defines the element to stop listening the inputs from
  37126. */
  37127. detachControl(element: Nullable<HTMLElement>): void;
  37128. /**
  37129. * Gets the class name of the current input.
  37130. * @returns the class name
  37131. */
  37132. getClassName(): string;
  37133. /**
  37134. * Get the friendly name associated with the input class.
  37135. * @returns the input friendly name
  37136. */
  37137. getSimpleName(): string;
  37138. /**
  37139. * Called on pointer POINTERDOUBLETAP event.
  37140. * Override this method to provide functionality on POINTERDOUBLETAP event.
  37141. */
  37142. protected onDoubleTap(type: string): void;
  37143. /**
  37144. * Called on pointer POINTERMOVE event if only a single touch is active.
  37145. * Override this method to provide functionality.
  37146. */
  37147. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37148. /**
  37149. * Called on pointer POINTERMOVE event if multiple touches are active.
  37150. * Override this method to provide functionality.
  37151. */
  37152. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37153. /**
  37154. * Called on JS contextmenu event.
  37155. * Override this method to provide functionality.
  37156. */
  37157. protected onContextMenu(evt: PointerEvent): void;
  37158. /**
  37159. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37160. * press.
  37161. * Override this method to provide functionality.
  37162. */
  37163. protected onButtonDown(evt: PointerEvent): void;
  37164. /**
  37165. * Called each time a new POINTERUP event occurs. Ie, for each button
  37166. * release.
  37167. * Override this method to provide functionality.
  37168. */
  37169. protected onButtonUp(evt: PointerEvent): void;
  37170. /**
  37171. * Called when window becomes inactive.
  37172. * Override this method to provide functionality.
  37173. */
  37174. protected onLostFocus(): void;
  37175. private _pointerInput;
  37176. private _observer;
  37177. private _onLostFocus;
  37178. private pointA;
  37179. private pointB;
  37180. }
  37181. }
  37182. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  37183. import { Nullable } from "babylonjs/types";
  37184. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37185. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37186. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37187. /**
  37188. * Manage the pointers inputs to control an arc rotate camera.
  37189. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37190. */
  37191. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  37192. /**
  37193. * Defines the camera the input is attached to.
  37194. */
  37195. camera: ArcRotateCamera;
  37196. /**
  37197. * Gets the class name of the current input.
  37198. * @returns the class name
  37199. */
  37200. getClassName(): string;
  37201. /**
  37202. * Defines the buttons associated with the input to handle camera move.
  37203. */
  37204. buttons: number[];
  37205. /**
  37206. * Defines the pointer angular sensibility along the X axis or how fast is
  37207. * the camera rotating.
  37208. */
  37209. angularSensibilityX: number;
  37210. /**
  37211. * Defines the pointer angular sensibility along the Y axis or how fast is
  37212. * the camera rotating.
  37213. */
  37214. angularSensibilityY: number;
  37215. /**
  37216. * Defines the pointer pinch precision or how fast is the camera zooming.
  37217. */
  37218. pinchPrecision: number;
  37219. /**
  37220. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37221. * from 0.
  37222. * It defines the percentage of current camera.radius to use as delta when
  37223. * pinch zoom is used.
  37224. */
  37225. pinchDeltaPercentage: number;
  37226. /**
  37227. * Defines the pointer panning sensibility or how fast is the camera moving.
  37228. */
  37229. panningSensibility: number;
  37230. /**
  37231. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  37232. */
  37233. multiTouchPanning: boolean;
  37234. /**
  37235. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  37236. * zoom (pinch) through multitouch.
  37237. */
  37238. multiTouchPanAndZoom: boolean;
  37239. /**
  37240. * Revers pinch action direction.
  37241. */
  37242. pinchInwards: boolean;
  37243. private _isPanClick;
  37244. private _twoFingerActivityCount;
  37245. private _isPinching;
  37246. /**
  37247. * Called on pointer POINTERMOVE event if only a single touch is active.
  37248. */
  37249. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37250. /**
  37251. * Called on pointer POINTERDOUBLETAP event.
  37252. */
  37253. protected onDoubleTap(type: string): void;
  37254. /**
  37255. * Called on pointer POINTERMOVE event if multiple touches are active.
  37256. */
  37257. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37258. /**
  37259. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  37260. * press.
  37261. */
  37262. protected onButtonDown(evt: PointerEvent): void;
  37263. /**
  37264. * Called each time a new POINTERUP event occurs. Ie, for each button
  37265. * release.
  37266. */
  37267. protected onButtonUp(evt: PointerEvent): void;
  37268. /**
  37269. * Called when window becomes inactive.
  37270. */
  37271. protected onLostFocus(): void;
  37272. }
  37273. }
  37274. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  37275. import { Nullable } from "babylonjs/types";
  37276. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37277. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37278. /**
  37279. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  37280. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37281. */
  37282. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  37283. /**
  37284. * Defines the camera the input is attached to.
  37285. */
  37286. camera: ArcRotateCamera;
  37287. /**
  37288. * Defines the list of key codes associated with the up action (increase alpha)
  37289. */
  37290. keysUp: number[];
  37291. /**
  37292. * Defines the list of key codes associated with the down action (decrease alpha)
  37293. */
  37294. keysDown: number[];
  37295. /**
  37296. * Defines the list of key codes associated with the left action (increase beta)
  37297. */
  37298. keysLeft: number[];
  37299. /**
  37300. * Defines the list of key codes associated with the right action (decrease beta)
  37301. */
  37302. keysRight: number[];
  37303. /**
  37304. * Defines the list of key codes associated with the reset action.
  37305. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  37306. */
  37307. keysReset: number[];
  37308. /**
  37309. * Defines the panning sensibility of the inputs.
  37310. * (How fast is the camera paning)
  37311. */
  37312. panningSensibility: number;
  37313. /**
  37314. * Defines the zooming sensibility of the inputs.
  37315. * (How fast is the camera zooming)
  37316. */
  37317. zoomingSensibility: number;
  37318. /**
  37319. * Defines wether maintaining the alt key down switch the movement mode from
  37320. * orientation to zoom.
  37321. */
  37322. useAltToZoom: boolean;
  37323. /**
  37324. * Rotation speed of the camera
  37325. */
  37326. angularSpeed: number;
  37327. private _keys;
  37328. private _ctrlPressed;
  37329. private _altPressed;
  37330. private _onCanvasBlurObserver;
  37331. private _onKeyboardObserver;
  37332. private _engine;
  37333. private _scene;
  37334. /**
  37335. * Attach the input controls to a specific dom element to get the input from.
  37336. * @param element Defines the element the controls should be listened from
  37337. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37338. */
  37339. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37340. /**
  37341. * Detach the current controls from the specified dom element.
  37342. * @param element Defines the element to stop listening the inputs from
  37343. */
  37344. detachControl(element: Nullable<HTMLElement>): void;
  37345. /**
  37346. * Update the current camera state depending on the inputs that have been used this frame.
  37347. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37348. */
  37349. checkInputs(): void;
  37350. /**
  37351. * Gets the class name of the current intput.
  37352. * @returns the class name
  37353. */
  37354. getClassName(): string;
  37355. /**
  37356. * Get the friendly name associated with the input class.
  37357. * @returns the input friendly name
  37358. */
  37359. getSimpleName(): string;
  37360. }
  37361. }
  37362. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  37363. import { Nullable } from "babylonjs/types";
  37364. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37365. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37366. /**
  37367. * Manage the mouse wheel inputs to control an arc rotate camera.
  37368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37369. */
  37370. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  37371. /**
  37372. * Defines the camera the input is attached to.
  37373. */
  37374. camera: ArcRotateCamera;
  37375. /**
  37376. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37377. */
  37378. wheelPrecision: number;
  37379. /**
  37380. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37381. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37382. */
  37383. wheelDeltaPercentage: number;
  37384. private _wheel;
  37385. private _observer;
  37386. private computeDeltaFromMouseWheelLegacyEvent;
  37387. /**
  37388. * Attach the input controls to a specific dom element to get the input from.
  37389. * @param element Defines the element the controls should be listened from
  37390. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37391. */
  37392. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37393. /**
  37394. * Detach the current controls from the specified dom element.
  37395. * @param element Defines the element to stop listening the inputs from
  37396. */
  37397. detachControl(element: Nullable<HTMLElement>): void;
  37398. /**
  37399. * Gets the class name of the current intput.
  37400. * @returns the class name
  37401. */
  37402. getClassName(): string;
  37403. /**
  37404. * Get the friendly name associated with the input class.
  37405. * @returns the input friendly name
  37406. */
  37407. getSimpleName(): string;
  37408. }
  37409. }
  37410. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37411. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37412. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37413. /**
  37414. * Default Inputs manager for the ArcRotateCamera.
  37415. * It groups all the default supported inputs for ease of use.
  37416. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37417. */
  37418. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  37419. /**
  37420. * Instantiates a new ArcRotateCameraInputsManager.
  37421. * @param camera Defines the camera the inputs belong to
  37422. */
  37423. constructor(camera: ArcRotateCamera);
  37424. /**
  37425. * Add mouse wheel input support to the input manager.
  37426. * @returns the current input manager
  37427. */
  37428. addMouseWheel(): ArcRotateCameraInputsManager;
  37429. /**
  37430. * Add pointers input support to the input manager.
  37431. * @returns the current input manager
  37432. */
  37433. addPointers(): ArcRotateCameraInputsManager;
  37434. /**
  37435. * Add keyboard input support to the input manager.
  37436. * @returns the current input manager
  37437. */
  37438. addKeyboard(): ArcRotateCameraInputsManager;
  37439. }
  37440. }
  37441. declare module "babylonjs/Cameras/arcRotateCamera" {
  37442. import { Observable } from "babylonjs/Misc/observable";
  37443. import { Nullable } from "babylonjs/types";
  37444. import { Scene } from "babylonjs/scene";
  37445. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  37446. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37447. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37448. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37449. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  37450. import { Camera } from "babylonjs/Cameras/camera";
  37451. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37452. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  37453. import { Collider } from "babylonjs/Collisions/collider";
  37454. /**
  37455. * This represents an orbital type of camera.
  37456. *
  37457. * 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.
  37458. * 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.
  37459. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  37460. */
  37461. export class ArcRotateCamera extends TargetCamera {
  37462. /**
  37463. * Defines the rotation angle of the camera along the longitudinal axis.
  37464. */
  37465. alpha: number;
  37466. /**
  37467. * Defines the rotation angle of the camera along the latitudinal axis.
  37468. */
  37469. beta: number;
  37470. /**
  37471. * Defines the radius of the camera from it s target point.
  37472. */
  37473. radius: number;
  37474. protected _target: Vector3;
  37475. protected _targetHost: Nullable<AbstractMesh>;
  37476. /**
  37477. * Defines the target point of the camera.
  37478. * The camera looks towards it form the radius distance.
  37479. */
  37480. target: Vector3;
  37481. /**
  37482. * Define the current local position of the camera in the scene
  37483. */
  37484. position: Vector3;
  37485. protected _upVector: Vector3;
  37486. protected _upToYMatrix: Matrix;
  37487. protected _YToUpMatrix: Matrix;
  37488. /**
  37489. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  37490. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  37491. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  37492. */
  37493. upVector: Vector3;
  37494. /**
  37495. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  37496. */
  37497. setMatUp(): void;
  37498. /**
  37499. * Current inertia value on the longitudinal axis.
  37500. * The bigger this number the longer it will take for the camera to stop.
  37501. */
  37502. inertialAlphaOffset: number;
  37503. /**
  37504. * Current inertia value on the latitudinal axis.
  37505. * The bigger this number the longer it will take for the camera to stop.
  37506. */
  37507. inertialBetaOffset: number;
  37508. /**
  37509. * Current inertia value on the radius axis.
  37510. * The bigger this number the longer it will take for the camera to stop.
  37511. */
  37512. inertialRadiusOffset: number;
  37513. /**
  37514. * Minimum allowed angle on the longitudinal axis.
  37515. * This can help limiting how the Camera is able to move in the scene.
  37516. */
  37517. lowerAlphaLimit: Nullable<number>;
  37518. /**
  37519. * Maximum allowed angle on the longitudinal axis.
  37520. * This can help limiting how the Camera is able to move in the scene.
  37521. */
  37522. upperAlphaLimit: Nullable<number>;
  37523. /**
  37524. * Minimum allowed angle on the latitudinal axis.
  37525. * This can help limiting how the Camera is able to move in the scene.
  37526. */
  37527. lowerBetaLimit: number;
  37528. /**
  37529. * Maximum allowed angle on the latitudinal axis.
  37530. * This can help limiting how the Camera is able to move in the scene.
  37531. */
  37532. upperBetaLimit: number;
  37533. /**
  37534. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  37535. * This can help limiting how the Camera is able to move in the scene.
  37536. */
  37537. lowerRadiusLimit: Nullable<number>;
  37538. /**
  37539. * Maximum allowed distance of the camera to the target (The camera can not get further).
  37540. * This can help limiting how the Camera is able to move in the scene.
  37541. */
  37542. upperRadiusLimit: Nullable<number>;
  37543. /**
  37544. * Defines the current inertia value used during panning of the camera along the X axis.
  37545. */
  37546. inertialPanningX: number;
  37547. /**
  37548. * Defines the current inertia value used during panning of the camera along the Y axis.
  37549. */
  37550. inertialPanningY: number;
  37551. /**
  37552. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  37553. * Basically if your fingers moves away from more than this distance you will be considered
  37554. * in pinch mode.
  37555. */
  37556. pinchToPanMaxDistance: number;
  37557. /**
  37558. * Defines the maximum distance the camera can pan.
  37559. * This could help keeping the cammera always in your scene.
  37560. */
  37561. panningDistanceLimit: Nullable<number>;
  37562. /**
  37563. * Defines the target of the camera before paning.
  37564. */
  37565. panningOriginTarget: Vector3;
  37566. /**
  37567. * Defines the value of the inertia used during panning.
  37568. * 0 would mean stop inertia and one would mean no decelleration at all.
  37569. */
  37570. panningInertia: number;
  37571. /**
  37572. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  37573. */
  37574. angularSensibilityX: number;
  37575. /**
  37576. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  37577. */
  37578. angularSensibilityY: number;
  37579. /**
  37580. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  37581. */
  37582. pinchPrecision: number;
  37583. /**
  37584. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  37585. * It will be used instead of pinchDeltaPrecision if different from 0.
  37586. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37587. */
  37588. pinchDeltaPercentage: number;
  37589. /**
  37590. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  37591. */
  37592. panningSensibility: number;
  37593. /**
  37594. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  37595. */
  37596. keysUp: number[];
  37597. /**
  37598. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  37599. */
  37600. keysDown: number[];
  37601. /**
  37602. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  37603. */
  37604. keysLeft: number[];
  37605. /**
  37606. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  37607. */
  37608. keysRight: number[];
  37609. /**
  37610. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  37611. */
  37612. wheelPrecision: number;
  37613. /**
  37614. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  37615. * It will be used instead of pinchDeltaPrecision if different from 0.
  37616. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  37617. */
  37618. wheelDeltaPercentage: number;
  37619. /**
  37620. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  37621. */
  37622. zoomOnFactor: number;
  37623. /**
  37624. * Defines a screen offset for the camera position.
  37625. */
  37626. targetScreenOffset: Vector2;
  37627. /**
  37628. * Allows the camera to be completely reversed.
  37629. * If false the camera can not arrive upside down.
  37630. */
  37631. allowUpsideDown: boolean;
  37632. /**
  37633. * Define if double tap/click is used to restore the previously saved state of the camera.
  37634. */
  37635. useInputToRestoreState: boolean;
  37636. /** @hidden */
  37637. _viewMatrix: Matrix;
  37638. /** @hidden */
  37639. _useCtrlForPanning: boolean;
  37640. /** @hidden */
  37641. _panningMouseButton: number;
  37642. /**
  37643. * Defines the input associated to the camera.
  37644. */
  37645. inputs: ArcRotateCameraInputsManager;
  37646. /** @hidden */
  37647. _reset: () => void;
  37648. /**
  37649. * Defines the allowed panning axis.
  37650. */
  37651. panningAxis: Vector3;
  37652. protected _localDirection: Vector3;
  37653. protected _transformedDirection: Vector3;
  37654. private _bouncingBehavior;
  37655. /**
  37656. * Gets the bouncing behavior of the camera if it has been enabled.
  37657. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37658. */
  37659. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  37660. /**
  37661. * Defines if the bouncing behavior of the camera is enabled on the camera.
  37662. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  37663. */
  37664. useBouncingBehavior: boolean;
  37665. private _framingBehavior;
  37666. /**
  37667. * Gets the framing behavior of the camera if it has been enabled.
  37668. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37669. */
  37670. readonly framingBehavior: Nullable<FramingBehavior>;
  37671. /**
  37672. * Defines if the framing behavior of the camera is enabled on the camera.
  37673. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  37674. */
  37675. useFramingBehavior: boolean;
  37676. private _autoRotationBehavior;
  37677. /**
  37678. * Gets the auto rotation behavior of the camera if it has been enabled.
  37679. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37680. */
  37681. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  37682. /**
  37683. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  37684. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37685. */
  37686. useAutoRotationBehavior: boolean;
  37687. /**
  37688. * Observable triggered when the mesh target has been changed on the camera.
  37689. */
  37690. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  37691. /**
  37692. * Event raised when the camera is colliding with a mesh.
  37693. */
  37694. onCollide: (collidedMesh: AbstractMesh) => void;
  37695. /**
  37696. * Defines whether the camera should check collision with the objects oh the scene.
  37697. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  37698. */
  37699. checkCollisions: boolean;
  37700. /**
  37701. * Defines the collision radius of the camera.
  37702. * This simulates a sphere around the camera.
  37703. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37704. */
  37705. collisionRadius: Vector3;
  37706. protected _collider: Collider;
  37707. protected _previousPosition: Vector3;
  37708. protected _collisionVelocity: Vector3;
  37709. protected _newPosition: Vector3;
  37710. protected _previousAlpha: number;
  37711. protected _previousBeta: number;
  37712. protected _previousRadius: number;
  37713. protected _collisionTriggered: boolean;
  37714. protected _targetBoundingCenter: Nullable<Vector3>;
  37715. private _computationVector;
  37716. /**
  37717. * Instantiates a new ArcRotateCamera in a given scene
  37718. * @param name Defines the name of the camera
  37719. * @param alpha Defines the camera rotation along the logitudinal axis
  37720. * @param beta Defines the camera rotation along the latitudinal axis
  37721. * @param radius Defines the camera distance from its target
  37722. * @param target Defines the camera target
  37723. * @param scene Defines the scene the camera belongs to
  37724. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  37725. */
  37726. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37727. /** @hidden */
  37728. _initCache(): void;
  37729. /** @hidden */
  37730. _updateCache(ignoreParentClass?: boolean): void;
  37731. protected _getTargetPosition(): Vector3;
  37732. private _storedAlpha;
  37733. private _storedBeta;
  37734. private _storedRadius;
  37735. private _storedTarget;
  37736. private _storedTargetScreenOffset;
  37737. /**
  37738. * Stores the current state of the camera (alpha, beta, radius and target)
  37739. * @returns the camera itself
  37740. */
  37741. storeState(): Camera;
  37742. /**
  37743. * @hidden
  37744. * Restored camera state. You must call storeState() first
  37745. */
  37746. _restoreStateValues(): boolean;
  37747. /** @hidden */
  37748. _isSynchronizedViewMatrix(): boolean;
  37749. /**
  37750. * Attached controls to the current camera.
  37751. * @param element Defines the element the controls should be listened from
  37752. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37753. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  37754. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  37755. */
  37756. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  37757. /**
  37758. * Detach the current controls from the camera.
  37759. * The camera will stop reacting to inputs.
  37760. * @param element Defines the element to stop listening the inputs from
  37761. */
  37762. detachControl(element: HTMLElement): void;
  37763. /** @hidden */
  37764. _checkInputs(): void;
  37765. protected _checkLimits(): void;
  37766. /**
  37767. * Rebuilds angles (alpha, beta) and radius from the give position and target
  37768. */
  37769. rebuildAnglesAndRadius(): void;
  37770. /**
  37771. * Use a position to define the current camera related information like alpha, beta and radius
  37772. * @param position Defines the position to set the camera at
  37773. */
  37774. setPosition(position: Vector3): void;
  37775. /**
  37776. * Defines the target the camera should look at.
  37777. * This will automatically adapt alpha beta and radius to fit within the new target.
  37778. * @param target Defines the new target as a Vector or a mesh
  37779. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  37780. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  37781. */
  37782. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  37783. /** @hidden */
  37784. _getViewMatrix(): Matrix;
  37785. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  37786. /**
  37787. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  37788. * @param meshes Defines the mesh to zoom on
  37789. * @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)
  37790. */
  37791. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  37792. /**
  37793. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  37794. * The target will be changed but the radius
  37795. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  37796. * @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)
  37797. */
  37798. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  37799. min: Vector3;
  37800. max: Vector3;
  37801. distance: number;
  37802. }, doNotUpdateMaxZ?: boolean): void;
  37803. /**
  37804. * @override
  37805. * Override Camera.createRigCamera
  37806. */
  37807. createRigCamera(name: string, cameraIndex: number): Camera;
  37808. /**
  37809. * @hidden
  37810. * @override
  37811. * Override Camera._updateRigCameras
  37812. */
  37813. _updateRigCameras(): void;
  37814. /**
  37815. * Destroy the camera and release the current resources hold by it.
  37816. */
  37817. dispose(): void;
  37818. /**
  37819. * Gets the current object class name.
  37820. * @return the class name
  37821. */
  37822. getClassName(): string;
  37823. }
  37824. }
  37825. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  37826. import { Behavior } from "babylonjs/Behaviors/behavior";
  37827. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37828. /**
  37829. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  37830. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  37831. */
  37832. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  37833. /**
  37834. * Gets the name of the behavior.
  37835. */
  37836. readonly name: string;
  37837. private _zoomStopsAnimation;
  37838. private _idleRotationSpeed;
  37839. private _idleRotationWaitTime;
  37840. private _idleRotationSpinupTime;
  37841. /**
  37842. * Sets the flag that indicates if user zooming should stop animation.
  37843. */
  37844. /**
  37845. * Gets the flag that indicates if user zooming should stop animation.
  37846. */
  37847. zoomStopsAnimation: boolean;
  37848. /**
  37849. * Sets the default speed at which the camera rotates around the model.
  37850. */
  37851. /**
  37852. * Gets the default speed at which the camera rotates around the model.
  37853. */
  37854. idleRotationSpeed: number;
  37855. /**
  37856. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  37857. */
  37858. /**
  37859. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  37860. */
  37861. idleRotationWaitTime: number;
  37862. /**
  37863. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37864. */
  37865. /**
  37866. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  37867. */
  37868. idleRotationSpinupTime: number;
  37869. /**
  37870. * Gets a value indicating if the camera is currently rotating because of this behavior
  37871. */
  37872. readonly rotationInProgress: boolean;
  37873. private _onPrePointerObservableObserver;
  37874. private _onAfterCheckInputsObserver;
  37875. private _attachedCamera;
  37876. private _isPointerDown;
  37877. private _lastFrameTime;
  37878. private _lastInteractionTime;
  37879. private _cameraRotationSpeed;
  37880. /**
  37881. * Initializes the behavior.
  37882. */
  37883. init(): void;
  37884. /**
  37885. * Attaches the behavior to its arc rotate camera.
  37886. * @param camera Defines the camera to attach the behavior to
  37887. */
  37888. attach(camera: ArcRotateCamera): void;
  37889. /**
  37890. * Detaches the behavior from its current arc rotate camera.
  37891. */
  37892. detach(): void;
  37893. /**
  37894. * Returns true if user is scrolling.
  37895. * @return true if user is scrolling.
  37896. */
  37897. private _userIsZooming;
  37898. private _lastFrameRadius;
  37899. private _shouldAnimationStopForInteraction;
  37900. /**
  37901. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  37902. */
  37903. private _applyUserInteraction;
  37904. private _userIsMoving;
  37905. }
  37906. }
  37907. declare module "babylonjs/Behaviors/Cameras/index" {
  37908. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  37909. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  37910. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  37911. }
  37912. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  37913. import { Mesh } from "babylonjs/Meshes/mesh";
  37914. import { TransformNode } from "babylonjs/Meshes/transformNode";
  37915. import { Behavior } from "babylonjs/Behaviors/behavior";
  37916. /**
  37917. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  37918. */
  37919. export class AttachToBoxBehavior implements Behavior<Mesh> {
  37920. private ui;
  37921. /**
  37922. * The name of the behavior
  37923. */
  37924. name: string;
  37925. /**
  37926. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  37927. */
  37928. distanceAwayFromFace: number;
  37929. /**
  37930. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  37931. */
  37932. distanceAwayFromBottomOfFace: number;
  37933. private _faceVectors;
  37934. private _target;
  37935. private _scene;
  37936. private _onRenderObserver;
  37937. private _tmpMatrix;
  37938. private _tmpVector;
  37939. /**
  37940. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  37941. * @param ui The transform node that should be attched to the mesh
  37942. */
  37943. constructor(ui: TransformNode);
  37944. /**
  37945. * Initializes the behavior
  37946. */
  37947. init(): void;
  37948. private _closestFace;
  37949. private _zeroVector;
  37950. private _lookAtTmpMatrix;
  37951. private _lookAtToRef;
  37952. /**
  37953. * Attaches the AttachToBoxBehavior to the passed in mesh
  37954. * @param target The mesh that the specified node will be attached to
  37955. */
  37956. attach(target: Mesh): void;
  37957. /**
  37958. * Detaches the behavior from the mesh
  37959. */
  37960. detach(): void;
  37961. }
  37962. }
  37963. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  37964. import { Behavior } from "babylonjs/Behaviors/behavior";
  37965. import { Mesh } from "babylonjs/Meshes/mesh";
  37966. /**
  37967. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  37968. */
  37969. export class FadeInOutBehavior implements Behavior<Mesh> {
  37970. /**
  37971. * Time in milliseconds to delay before fading in (Default: 0)
  37972. */
  37973. delay: number;
  37974. /**
  37975. * Time in milliseconds for the mesh to fade in (Default: 300)
  37976. */
  37977. fadeInTime: number;
  37978. private _millisecondsPerFrame;
  37979. private _hovered;
  37980. private _hoverValue;
  37981. private _ownerNode;
  37982. /**
  37983. * Instatiates the FadeInOutBehavior
  37984. */
  37985. constructor();
  37986. /**
  37987. * The name of the behavior
  37988. */
  37989. readonly name: string;
  37990. /**
  37991. * Initializes the behavior
  37992. */
  37993. init(): void;
  37994. /**
  37995. * Attaches the fade behavior on the passed in mesh
  37996. * @param ownerNode The mesh that will be faded in/out once attached
  37997. */
  37998. attach(ownerNode: Mesh): void;
  37999. /**
  38000. * Detaches the behavior from the mesh
  38001. */
  38002. detach(): void;
  38003. /**
  38004. * Triggers the mesh to begin fading in or out
  38005. * @param value if the object should fade in or out (true to fade in)
  38006. */
  38007. fadeIn(value: boolean): void;
  38008. private _update;
  38009. private _setAllVisibility;
  38010. }
  38011. }
  38012. declare module "babylonjs/Misc/pivotTools" {
  38013. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38014. /**
  38015. * Class containing a set of static utilities functions for managing Pivots
  38016. * @hidden
  38017. */
  38018. export class PivotTools {
  38019. private static _PivotCached;
  38020. private static _OldPivotPoint;
  38021. private static _PivotTranslation;
  38022. private static _PivotTmpVector;
  38023. /** @hidden */
  38024. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  38025. /** @hidden */
  38026. static _RestorePivotPoint(mesh: AbstractMesh): void;
  38027. }
  38028. }
  38029. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  38030. import { Scene } from "babylonjs/scene";
  38031. import { Vector4 } from "babylonjs/Maths/math.vector";
  38032. import { Mesh } from "babylonjs/Meshes/mesh";
  38033. import { Nullable } from "babylonjs/types";
  38034. import { Plane } from "babylonjs/Maths/math.plane";
  38035. /**
  38036. * Class containing static functions to help procedurally build meshes
  38037. */
  38038. export class PlaneBuilder {
  38039. /**
  38040. * Creates a plane mesh
  38041. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  38042. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  38043. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  38044. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  38045. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  38046. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  38047. * @param name defines the name of the mesh
  38048. * @param options defines the options used to create the mesh
  38049. * @param scene defines the hosting scene
  38050. * @returns the plane mesh
  38051. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  38052. */
  38053. static CreatePlane(name: string, options: {
  38054. size?: number;
  38055. width?: number;
  38056. height?: number;
  38057. sideOrientation?: number;
  38058. frontUVs?: Vector4;
  38059. backUVs?: Vector4;
  38060. updatable?: boolean;
  38061. sourcePlane?: Plane;
  38062. }, scene?: Nullable<Scene>): Mesh;
  38063. }
  38064. }
  38065. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  38066. import { Behavior } from "babylonjs/Behaviors/behavior";
  38067. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38068. import { Observable } from "babylonjs/Misc/observable";
  38069. import { Vector3 } from "babylonjs/Maths/math.vector";
  38070. import { Ray } from "babylonjs/Culling/ray";
  38071. import "babylonjs/Meshes/Builders/planeBuilder";
  38072. /**
  38073. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  38074. */
  38075. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  38076. private static _AnyMouseID;
  38077. /**
  38078. * Abstract mesh the behavior is set on
  38079. */
  38080. attachedNode: AbstractMesh;
  38081. private _dragPlane;
  38082. private _scene;
  38083. private _pointerObserver;
  38084. private _beforeRenderObserver;
  38085. private static _planeScene;
  38086. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  38087. /**
  38088. * 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)
  38089. */
  38090. maxDragAngle: number;
  38091. /**
  38092. * @hidden
  38093. */
  38094. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  38095. /**
  38096. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38097. */
  38098. currentDraggingPointerID: number;
  38099. /**
  38100. * The last position where the pointer hit the drag plane in world space
  38101. */
  38102. lastDragPosition: Vector3;
  38103. /**
  38104. * If the behavior is currently in a dragging state
  38105. */
  38106. dragging: boolean;
  38107. /**
  38108. * 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)
  38109. */
  38110. dragDeltaRatio: number;
  38111. /**
  38112. * If the drag plane orientation should be updated during the dragging (Default: true)
  38113. */
  38114. updateDragPlane: boolean;
  38115. private _debugMode;
  38116. private _moving;
  38117. /**
  38118. * Fires each time the attached mesh is dragged with the pointer
  38119. * * delta between last drag position and current drag position in world space
  38120. * * dragDistance along the drag axis
  38121. * * dragPlaneNormal normal of the current drag plane used during the drag
  38122. * * dragPlanePoint in world space where the drag intersects the drag plane
  38123. */
  38124. onDragObservable: Observable<{
  38125. delta: Vector3;
  38126. dragPlanePoint: Vector3;
  38127. dragPlaneNormal: Vector3;
  38128. dragDistance: number;
  38129. pointerId: number;
  38130. }>;
  38131. /**
  38132. * Fires each time a drag begins (eg. mouse down on mesh)
  38133. */
  38134. onDragStartObservable: Observable<{
  38135. dragPlanePoint: Vector3;
  38136. pointerId: number;
  38137. }>;
  38138. /**
  38139. * Fires each time a drag ends (eg. mouse release after drag)
  38140. */
  38141. onDragEndObservable: Observable<{
  38142. dragPlanePoint: Vector3;
  38143. pointerId: number;
  38144. }>;
  38145. /**
  38146. * If the attached mesh should be moved when dragged
  38147. */
  38148. moveAttached: boolean;
  38149. /**
  38150. * If the drag behavior will react to drag events (Default: true)
  38151. */
  38152. enabled: boolean;
  38153. /**
  38154. * If pointer events should start and release the drag (Default: true)
  38155. */
  38156. startAndReleaseDragOnPointerEvents: boolean;
  38157. /**
  38158. * If camera controls should be detached during the drag
  38159. */
  38160. detachCameraControls: boolean;
  38161. /**
  38162. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  38163. */
  38164. useObjectOrienationForDragging: boolean;
  38165. private _options;
  38166. /**
  38167. * Creates a pointer drag behavior that can be attached to a mesh
  38168. * @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)
  38169. */
  38170. constructor(options?: {
  38171. dragAxis?: Vector3;
  38172. dragPlaneNormal?: Vector3;
  38173. });
  38174. /**
  38175. * Predicate to determine if it is valid to move the object to a new position when it is moved
  38176. */
  38177. validateDrag: (targetPosition: Vector3) => boolean;
  38178. /**
  38179. * The name of the behavior
  38180. */
  38181. readonly name: string;
  38182. /**
  38183. * Initializes the behavior
  38184. */
  38185. init(): void;
  38186. private _tmpVector;
  38187. private _alternatePickedPoint;
  38188. private _worldDragAxis;
  38189. private _targetPosition;
  38190. private _attachedElement;
  38191. /**
  38192. * Attaches the drag behavior the passed in mesh
  38193. * @param ownerNode The mesh that will be dragged around once attached
  38194. * @param predicate Predicate to use for pick filtering
  38195. */
  38196. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  38197. /**
  38198. * Force relase the drag action by code.
  38199. */
  38200. releaseDrag(): void;
  38201. private _startDragRay;
  38202. private _lastPointerRay;
  38203. /**
  38204. * Simulates the start of a pointer drag event on the behavior
  38205. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  38206. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  38207. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  38208. */
  38209. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  38210. private _startDrag;
  38211. private _dragDelta;
  38212. private _moveDrag;
  38213. private _pickWithRayOnDragPlane;
  38214. private _pointA;
  38215. private _pointB;
  38216. private _pointC;
  38217. private _lineA;
  38218. private _lineB;
  38219. private _localAxis;
  38220. private _lookAt;
  38221. private _updateDragPlanePosition;
  38222. /**
  38223. * Detaches the behavior from the mesh
  38224. */
  38225. detach(): void;
  38226. }
  38227. }
  38228. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  38229. import { Mesh } from "babylonjs/Meshes/mesh";
  38230. import { Behavior } from "babylonjs/Behaviors/behavior";
  38231. /**
  38232. * A behavior that when attached to a mesh will allow the mesh to be scaled
  38233. */
  38234. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  38235. private _dragBehaviorA;
  38236. private _dragBehaviorB;
  38237. private _startDistance;
  38238. private _initialScale;
  38239. private _targetScale;
  38240. private _ownerNode;
  38241. private _sceneRenderObserver;
  38242. /**
  38243. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  38244. */
  38245. constructor();
  38246. /**
  38247. * The name of the behavior
  38248. */
  38249. readonly name: string;
  38250. /**
  38251. * Initializes the behavior
  38252. */
  38253. init(): void;
  38254. private _getCurrentDistance;
  38255. /**
  38256. * Attaches the scale behavior the passed in mesh
  38257. * @param ownerNode The mesh that will be scaled around once attached
  38258. */
  38259. attach(ownerNode: Mesh): void;
  38260. /**
  38261. * Detaches the behavior from the mesh
  38262. */
  38263. detach(): void;
  38264. }
  38265. }
  38266. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  38267. import { Behavior } from "babylonjs/Behaviors/behavior";
  38268. import { Mesh } from "babylonjs/Meshes/mesh";
  38269. import { Observable } from "babylonjs/Misc/observable";
  38270. /**
  38271. * 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
  38272. */
  38273. export class SixDofDragBehavior implements Behavior<Mesh> {
  38274. private static _virtualScene;
  38275. private _ownerNode;
  38276. private _sceneRenderObserver;
  38277. private _scene;
  38278. private _targetPosition;
  38279. private _virtualOriginMesh;
  38280. private _virtualDragMesh;
  38281. private _pointerObserver;
  38282. private _moving;
  38283. private _startingOrientation;
  38284. /**
  38285. * 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)
  38286. */
  38287. private zDragFactor;
  38288. /**
  38289. * If the object should rotate to face the drag origin
  38290. */
  38291. rotateDraggedObject: boolean;
  38292. /**
  38293. * If the behavior is currently in a dragging state
  38294. */
  38295. dragging: boolean;
  38296. /**
  38297. * 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)
  38298. */
  38299. dragDeltaRatio: number;
  38300. /**
  38301. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  38302. */
  38303. currentDraggingPointerID: number;
  38304. /**
  38305. * If camera controls should be detached during the drag
  38306. */
  38307. detachCameraControls: boolean;
  38308. /**
  38309. * Fires each time a drag starts
  38310. */
  38311. onDragStartObservable: Observable<{}>;
  38312. /**
  38313. * Fires each time a drag ends (eg. mouse release after drag)
  38314. */
  38315. onDragEndObservable: Observable<{}>;
  38316. /**
  38317. * 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
  38318. */
  38319. constructor();
  38320. /**
  38321. * The name of the behavior
  38322. */
  38323. readonly name: string;
  38324. /**
  38325. * Initializes the behavior
  38326. */
  38327. init(): void;
  38328. /**
  38329. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  38330. */
  38331. private readonly _pointerCamera;
  38332. /**
  38333. * Attaches the scale behavior the passed in mesh
  38334. * @param ownerNode The mesh that will be scaled around once attached
  38335. */
  38336. attach(ownerNode: Mesh): void;
  38337. /**
  38338. * Detaches the behavior from the mesh
  38339. */
  38340. detach(): void;
  38341. }
  38342. }
  38343. declare module "babylonjs/Behaviors/Meshes/index" {
  38344. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  38345. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  38346. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  38347. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  38348. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  38349. }
  38350. declare module "babylonjs/Behaviors/index" {
  38351. export * from "babylonjs/Behaviors/behavior";
  38352. export * from "babylonjs/Behaviors/Cameras/index";
  38353. export * from "babylonjs/Behaviors/Meshes/index";
  38354. }
  38355. declare module "babylonjs/Bones/boneIKController" {
  38356. import { Bone } from "babylonjs/Bones/bone";
  38357. import { Vector3 } from "babylonjs/Maths/math.vector";
  38358. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38359. import { Nullable } from "babylonjs/types";
  38360. /**
  38361. * Class used to apply inverse kinematics to bones
  38362. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  38363. */
  38364. export class BoneIKController {
  38365. private static _tmpVecs;
  38366. private static _tmpQuat;
  38367. private static _tmpMats;
  38368. /**
  38369. * Gets or sets the target mesh
  38370. */
  38371. targetMesh: AbstractMesh;
  38372. /** Gets or sets the mesh used as pole */
  38373. poleTargetMesh: AbstractMesh;
  38374. /**
  38375. * Gets or sets the bone used as pole
  38376. */
  38377. poleTargetBone: Nullable<Bone>;
  38378. /**
  38379. * Gets or sets the target position
  38380. */
  38381. targetPosition: Vector3;
  38382. /**
  38383. * Gets or sets the pole target position
  38384. */
  38385. poleTargetPosition: Vector3;
  38386. /**
  38387. * Gets or sets the pole target local offset
  38388. */
  38389. poleTargetLocalOffset: Vector3;
  38390. /**
  38391. * Gets or sets the pole angle
  38392. */
  38393. poleAngle: number;
  38394. /**
  38395. * Gets or sets the mesh associated with the controller
  38396. */
  38397. mesh: AbstractMesh;
  38398. /**
  38399. * 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)
  38400. */
  38401. slerpAmount: number;
  38402. private _bone1Quat;
  38403. private _bone1Mat;
  38404. private _bone2Ang;
  38405. private _bone1;
  38406. private _bone2;
  38407. private _bone1Length;
  38408. private _bone2Length;
  38409. private _maxAngle;
  38410. private _maxReach;
  38411. private _rightHandedSystem;
  38412. private _bendAxis;
  38413. private _slerping;
  38414. private _adjustRoll;
  38415. /**
  38416. * Gets or sets maximum allowed angle
  38417. */
  38418. maxAngle: number;
  38419. /**
  38420. * Creates a new BoneIKController
  38421. * @param mesh defines the mesh to control
  38422. * @param bone defines the bone to control
  38423. * @param options defines options to set up the controller
  38424. */
  38425. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  38426. targetMesh?: AbstractMesh;
  38427. poleTargetMesh?: AbstractMesh;
  38428. poleTargetBone?: Bone;
  38429. poleTargetLocalOffset?: Vector3;
  38430. poleAngle?: number;
  38431. bendAxis?: Vector3;
  38432. maxAngle?: number;
  38433. slerpAmount?: number;
  38434. });
  38435. private _setMaxAngle;
  38436. /**
  38437. * Force the controller to update the bones
  38438. */
  38439. update(): void;
  38440. }
  38441. }
  38442. declare module "babylonjs/Bones/boneLookController" {
  38443. import { Vector3 } from "babylonjs/Maths/math.vector";
  38444. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38445. import { Bone } from "babylonjs/Bones/bone";
  38446. import { Space } from "babylonjs/Maths/math.axis";
  38447. /**
  38448. * Class used to make a bone look toward a point in space
  38449. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  38450. */
  38451. export class BoneLookController {
  38452. private static _tmpVecs;
  38453. private static _tmpQuat;
  38454. private static _tmpMats;
  38455. /**
  38456. * The target Vector3 that the bone will look at
  38457. */
  38458. target: Vector3;
  38459. /**
  38460. * The mesh that the bone is attached to
  38461. */
  38462. mesh: AbstractMesh;
  38463. /**
  38464. * The bone that will be looking to the target
  38465. */
  38466. bone: Bone;
  38467. /**
  38468. * The up axis of the coordinate system that is used when the bone is rotated
  38469. */
  38470. upAxis: Vector3;
  38471. /**
  38472. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  38473. */
  38474. upAxisSpace: Space;
  38475. /**
  38476. * Used to make an adjustment to the yaw of the bone
  38477. */
  38478. adjustYaw: number;
  38479. /**
  38480. * Used to make an adjustment to the pitch of the bone
  38481. */
  38482. adjustPitch: number;
  38483. /**
  38484. * Used to make an adjustment to the roll of the bone
  38485. */
  38486. adjustRoll: number;
  38487. /**
  38488. * 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)
  38489. */
  38490. slerpAmount: number;
  38491. private _minYaw;
  38492. private _maxYaw;
  38493. private _minPitch;
  38494. private _maxPitch;
  38495. private _minYawSin;
  38496. private _minYawCos;
  38497. private _maxYawSin;
  38498. private _maxYawCos;
  38499. private _midYawConstraint;
  38500. private _minPitchTan;
  38501. private _maxPitchTan;
  38502. private _boneQuat;
  38503. private _slerping;
  38504. private _transformYawPitch;
  38505. private _transformYawPitchInv;
  38506. private _firstFrameSkipped;
  38507. private _yawRange;
  38508. private _fowardAxis;
  38509. /**
  38510. * Gets or sets the minimum yaw angle that the bone can look to
  38511. */
  38512. minYaw: number;
  38513. /**
  38514. * Gets or sets the maximum yaw angle that the bone can look to
  38515. */
  38516. maxYaw: number;
  38517. /**
  38518. * Gets or sets the minimum pitch angle that the bone can look to
  38519. */
  38520. minPitch: number;
  38521. /**
  38522. * Gets or sets the maximum pitch angle that the bone can look to
  38523. */
  38524. maxPitch: number;
  38525. /**
  38526. * Create a BoneLookController
  38527. * @param mesh the mesh that the bone belongs to
  38528. * @param bone the bone that will be looking to the target
  38529. * @param target the target Vector3 to look at
  38530. * @param options optional settings:
  38531. * * maxYaw: the maximum angle the bone will yaw to
  38532. * * minYaw: the minimum angle the bone will yaw to
  38533. * * maxPitch: the maximum angle the bone will pitch to
  38534. * * minPitch: the minimum angle the bone will yaw to
  38535. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  38536. * * upAxis: the up axis of the coordinate system
  38537. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  38538. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  38539. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  38540. * * adjustYaw: used to make an adjustment to the yaw of the bone
  38541. * * adjustPitch: used to make an adjustment to the pitch of the bone
  38542. * * adjustRoll: used to make an adjustment to the roll of the bone
  38543. **/
  38544. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  38545. maxYaw?: number;
  38546. minYaw?: number;
  38547. maxPitch?: number;
  38548. minPitch?: number;
  38549. slerpAmount?: number;
  38550. upAxis?: Vector3;
  38551. upAxisSpace?: Space;
  38552. yawAxis?: Vector3;
  38553. pitchAxis?: Vector3;
  38554. adjustYaw?: number;
  38555. adjustPitch?: number;
  38556. adjustRoll?: number;
  38557. });
  38558. /**
  38559. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  38560. */
  38561. update(): void;
  38562. private _getAngleDiff;
  38563. private _getAngleBetween;
  38564. private _isAngleBetween;
  38565. }
  38566. }
  38567. declare module "babylonjs/Bones/index" {
  38568. export * from "babylonjs/Bones/bone";
  38569. export * from "babylonjs/Bones/boneIKController";
  38570. export * from "babylonjs/Bones/boneLookController";
  38571. export * from "babylonjs/Bones/skeleton";
  38572. }
  38573. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  38574. import { Nullable } from "babylonjs/types";
  38575. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38576. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38577. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38578. /**
  38579. * Manage the gamepad inputs to control an arc rotate camera.
  38580. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38581. */
  38582. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  38583. /**
  38584. * Defines the camera the input is attached to.
  38585. */
  38586. camera: ArcRotateCamera;
  38587. /**
  38588. * Defines the gamepad the input is gathering event from.
  38589. */
  38590. gamepad: Nullable<Gamepad>;
  38591. /**
  38592. * Defines the gamepad rotation sensiblity.
  38593. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38594. */
  38595. gamepadRotationSensibility: number;
  38596. /**
  38597. * Defines the gamepad move sensiblity.
  38598. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38599. */
  38600. gamepadMoveSensibility: number;
  38601. private _onGamepadConnectedObserver;
  38602. private _onGamepadDisconnectedObserver;
  38603. /**
  38604. * Attach the input controls to a specific dom element to get the input from.
  38605. * @param element Defines the element the controls should be listened from
  38606. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38607. */
  38608. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38609. /**
  38610. * Detach the current controls from the specified dom element.
  38611. * @param element Defines the element to stop listening the inputs from
  38612. */
  38613. detachControl(element: Nullable<HTMLElement>): void;
  38614. /**
  38615. * Update the current camera state depending on the inputs that have been used this frame.
  38616. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38617. */
  38618. checkInputs(): void;
  38619. /**
  38620. * Gets the class name of the current intput.
  38621. * @returns the class name
  38622. */
  38623. getClassName(): string;
  38624. /**
  38625. * Get the friendly name associated with the input class.
  38626. * @returns the input friendly name
  38627. */
  38628. getSimpleName(): string;
  38629. }
  38630. }
  38631. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  38632. import { Nullable } from "babylonjs/types";
  38633. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38634. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38635. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  38636. interface ArcRotateCameraInputsManager {
  38637. /**
  38638. * Add orientation input support to the input manager.
  38639. * @returns the current input manager
  38640. */
  38641. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  38642. }
  38643. }
  38644. /**
  38645. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  38646. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38647. */
  38648. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  38649. /**
  38650. * Defines the camera the input is attached to.
  38651. */
  38652. camera: ArcRotateCamera;
  38653. /**
  38654. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  38655. */
  38656. alphaCorrection: number;
  38657. /**
  38658. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  38659. */
  38660. gammaCorrection: number;
  38661. private _alpha;
  38662. private _gamma;
  38663. private _dirty;
  38664. private _deviceOrientationHandler;
  38665. /**
  38666. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  38667. */
  38668. constructor();
  38669. /**
  38670. * Attach the input controls to a specific dom element to get the input from.
  38671. * @param element Defines the element the controls should be listened from
  38672. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38673. */
  38674. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38675. /** @hidden */
  38676. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  38677. /**
  38678. * Update the current camera state depending on the inputs that have been used this frame.
  38679. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38680. */
  38681. checkInputs(): void;
  38682. /**
  38683. * Detach the current controls from the specified dom element.
  38684. * @param element Defines the element to stop listening the inputs from
  38685. */
  38686. detachControl(element: Nullable<HTMLElement>): void;
  38687. /**
  38688. * Gets the class name of the current intput.
  38689. * @returns the class name
  38690. */
  38691. getClassName(): string;
  38692. /**
  38693. * Get the friendly name associated with the input class.
  38694. * @returns the input friendly name
  38695. */
  38696. getSimpleName(): string;
  38697. }
  38698. }
  38699. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  38700. import { Nullable } from "babylonjs/types";
  38701. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38702. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38703. /**
  38704. * Listen to mouse events to control the camera.
  38705. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38706. */
  38707. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  38708. /**
  38709. * Defines the camera the input is attached to.
  38710. */
  38711. camera: FlyCamera;
  38712. /**
  38713. * Defines if touch is enabled. (Default is true.)
  38714. */
  38715. touchEnabled: boolean;
  38716. /**
  38717. * Defines the buttons associated with the input to handle camera rotation.
  38718. */
  38719. buttons: number[];
  38720. /**
  38721. * Assign buttons for Yaw control.
  38722. */
  38723. buttonsYaw: number[];
  38724. /**
  38725. * Assign buttons for Pitch control.
  38726. */
  38727. buttonsPitch: number[];
  38728. /**
  38729. * Assign buttons for Roll control.
  38730. */
  38731. buttonsRoll: number[];
  38732. /**
  38733. * Detect if any button is being pressed while mouse is moved.
  38734. * -1 = Mouse locked.
  38735. * 0 = Left button.
  38736. * 1 = Middle Button.
  38737. * 2 = Right Button.
  38738. */
  38739. activeButton: number;
  38740. /**
  38741. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  38742. * Higher values reduce its sensitivity.
  38743. */
  38744. angularSensibility: number;
  38745. private _mousemoveCallback;
  38746. private _observer;
  38747. private _rollObserver;
  38748. private previousPosition;
  38749. private noPreventDefault;
  38750. private element;
  38751. /**
  38752. * Listen to mouse events to control the camera.
  38753. * @param touchEnabled Define if touch is enabled. (Default is true.)
  38754. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38755. */
  38756. constructor(touchEnabled?: boolean);
  38757. /**
  38758. * Attach the mouse control to the HTML DOM element.
  38759. * @param element Defines the element that listens to the input events.
  38760. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  38761. */
  38762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38763. /**
  38764. * Detach the current controls from the specified dom element.
  38765. * @param element Defines the element to stop listening the inputs from
  38766. */
  38767. detachControl(element: Nullable<HTMLElement>): void;
  38768. /**
  38769. * Gets the class name of the current input.
  38770. * @returns the class name.
  38771. */
  38772. getClassName(): string;
  38773. /**
  38774. * Get the friendly name associated with the input class.
  38775. * @returns the input's friendly name.
  38776. */
  38777. getSimpleName(): string;
  38778. private _pointerInput;
  38779. private _onMouseMove;
  38780. /**
  38781. * Rotate camera by mouse offset.
  38782. */
  38783. private rotateCamera;
  38784. }
  38785. }
  38786. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  38787. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  38788. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  38789. /**
  38790. * Default Inputs manager for the FlyCamera.
  38791. * It groups all the default supported inputs for ease of use.
  38792. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38793. */
  38794. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  38795. /**
  38796. * Instantiates a new FlyCameraInputsManager.
  38797. * @param camera Defines the camera the inputs belong to.
  38798. */
  38799. constructor(camera: FlyCamera);
  38800. /**
  38801. * Add keyboard input support to the input manager.
  38802. * @returns the new FlyCameraKeyboardMoveInput().
  38803. */
  38804. addKeyboard(): FlyCameraInputsManager;
  38805. /**
  38806. * Add mouse input support to the input manager.
  38807. * @param touchEnabled Enable touch screen support.
  38808. * @returns the new FlyCameraMouseInput().
  38809. */
  38810. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  38811. }
  38812. }
  38813. declare module "babylonjs/Cameras/flyCamera" {
  38814. import { Scene } from "babylonjs/scene";
  38815. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  38816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38817. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  38818. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  38819. /**
  38820. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38821. * such as in a 3D Space Shooter or a Flight Simulator.
  38822. */
  38823. export class FlyCamera extends TargetCamera {
  38824. /**
  38825. * Define the collision ellipsoid of the camera.
  38826. * This is helpful for simulating a camera body, like a player's body.
  38827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  38828. */
  38829. ellipsoid: Vector3;
  38830. /**
  38831. * Define an offset for the position of the ellipsoid around the camera.
  38832. * This can be helpful if the camera is attached away from the player's body center,
  38833. * such as at its head.
  38834. */
  38835. ellipsoidOffset: Vector3;
  38836. /**
  38837. * Enable or disable collisions of the camera with the rest of the scene objects.
  38838. */
  38839. checkCollisions: boolean;
  38840. /**
  38841. * Enable or disable gravity on the camera.
  38842. */
  38843. applyGravity: boolean;
  38844. /**
  38845. * Define the current direction the camera is moving to.
  38846. */
  38847. cameraDirection: Vector3;
  38848. /**
  38849. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  38850. * This overrides and empties cameraRotation.
  38851. */
  38852. rotationQuaternion: Quaternion;
  38853. /**
  38854. * Track Roll to maintain the wanted Rolling when looking around.
  38855. */
  38856. _trackRoll: number;
  38857. /**
  38858. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  38859. */
  38860. rollCorrect: number;
  38861. /**
  38862. * Mimic a banked turn, Rolling the camera when Yawing.
  38863. * It's recommended to use rollCorrect = 10 for faster banking correction.
  38864. */
  38865. bankedTurn: boolean;
  38866. /**
  38867. * Limit in radians for how much Roll banking will add. (Default: 90°)
  38868. */
  38869. bankedTurnLimit: number;
  38870. /**
  38871. * Value of 0 disables the banked Roll.
  38872. * Value of 1 is equal to the Yaw angle in radians.
  38873. */
  38874. bankedTurnMultiplier: number;
  38875. /**
  38876. * The inputs manager loads all the input sources, such as keyboard and mouse.
  38877. */
  38878. inputs: FlyCameraInputsManager;
  38879. /**
  38880. * Gets the input sensibility for mouse input.
  38881. * Higher values reduce sensitivity.
  38882. */
  38883. /**
  38884. * Sets the input sensibility for a mouse input.
  38885. * Higher values reduce sensitivity.
  38886. */
  38887. angularSensibility: number;
  38888. /**
  38889. * Get the keys for camera movement forward.
  38890. */
  38891. /**
  38892. * Set the keys for camera movement forward.
  38893. */
  38894. keysForward: number[];
  38895. /**
  38896. * Get the keys for camera movement backward.
  38897. */
  38898. keysBackward: number[];
  38899. /**
  38900. * Get the keys for camera movement up.
  38901. */
  38902. /**
  38903. * Set the keys for camera movement up.
  38904. */
  38905. keysUp: number[];
  38906. /**
  38907. * Get the keys for camera movement down.
  38908. */
  38909. /**
  38910. * Set the keys for camera movement down.
  38911. */
  38912. keysDown: number[];
  38913. /**
  38914. * Get the keys for camera movement left.
  38915. */
  38916. /**
  38917. * Set the keys for camera movement left.
  38918. */
  38919. keysLeft: number[];
  38920. /**
  38921. * Set the keys for camera movement right.
  38922. */
  38923. /**
  38924. * Set the keys for camera movement right.
  38925. */
  38926. keysRight: number[];
  38927. /**
  38928. * Event raised when the camera collides with a mesh in the scene.
  38929. */
  38930. onCollide: (collidedMesh: AbstractMesh) => void;
  38931. private _collider;
  38932. private _needMoveForGravity;
  38933. private _oldPosition;
  38934. private _diffPosition;
  38935. private _newPosition;
  38936. /** @hidden */
  38937. _localDirection: Vector3;
  38938. /** @hidden */
  38939. _transformedDirection: Vector3;
  38940. /**
  38941. * Instantiates a FlyCamera.
  38942. * This is a flying camera, designed for 3D movement and rotation in all directions,
  38943. * such as in a 3D Space Shooter or a Flight Simulator.
  38944. * @param name Define the name of the camera in the scene.
  38945. * @param position Define the starting position of the camera in the scene.
  38946. * @param scene Define the scene the camera belongs to.
  38947. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  38948. */
  38949. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  38950. /**
  38951. * Attach a control to the HTML DOM element.
  38952. * @param element Defines the element that listens to the input events.
  38953. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  38954. */
  38955. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38956. /**
  38957. * Detach a control from the HTML DOM element.
  38958. * The camera will stop reacting to that input.
  38959. * @param element Defines the element that listens to the input events.
  38960. */
  38961. detachControl(element: HTMLElement): void;
  38962. private _collisionMask;
  38963. /**
  38964. * Get the mask that the camera ignores in collision events.
  38965. */
  38966. /**
  38967. * Set the mask that the camera ignores in collision events.
  38968. */
  38969. collisionMask: number;
  38970. /** @hidden */
  38971. _collideWithWorld(displacement: Vector3): void;
  38972. /** @hidden */
  38973. private _onCollisionPositionChange;
  38974. /** @hidden */
  38975. _checkInputs(): void;
  38976. /** @hidden */
  38977. _decideIfNeedsToMove(): boolean;
  38978. /** @hidden */
  38979. _updatePosition(): void;
  38980. /**
  38981. * Restore the Roll to its target value at the rate specified.
  38982. * @param rate - Higher means slower restoring.
  38983. * @hidden
  38984. */
  38985. restoreRoll(rate: number): void;
  38986. /**
  38987. * Destroy the camera and release the current resources held by it.
  38988. */
  38989. dispose(): void;
  38990. /**
  38991. * Get the current object class name.
  38992. * @returns the class name.
  38993. */
  38994. getClassName(): string;
  38995. }
  38996. }
  38997. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  38998. import { Nullable } from "babylonjs/types";
  38999. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39000. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  39001. /**
  39002. * Listen to keyboard events to control the camera.
  39003. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39004. */
  39005. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  39006. /**
  39007. * Defines the camera the input is attached to.
  39008. */
  39009. camera: FlyCamera;
  39010. /**
  39011. * The list of keyboard keys used to control the forward move of the camera.
  39012. */
  39013. keysForward: number[];
  39014. /**
  39015. * The list of keyboard keys used to control the backward move of the camera.
  39016. */
  39017. keysBackward: number[];
  39018. /**
  39019. * The list of keyboard keys used to control the forward move of the camera.
  39020. */
  39021. keysUp: number[];
  39022. /**
  39023. * The list of keyboard keys used to control the backward move of the camera.
  39024. */
  39025. keysDown: number[];
  39026. /**
  39027. * The list of keyboard keys used to control the right strafe move of the camera.
  39028. */
  39029. keysRight: number[];
  39030. /**
  39031. * The list of keyboard keys used to control the left strafe move of the camera.
  39032. */
  39033. keysLeft: number[];
  39034. private _keys;
  39035. private _onCanvasBlurObserver;
  39036. private _onKeyboardObserver;
  39037. private _engine;
  39038. private _scene;
  39039. /**
  39040. * Attach the input controls to a specific dom element to get the input from.
  39041. * @param element Defines the element the controls should be listened from
  39042. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39043. */
  39044. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39045. /**
  39046. * Detach the current controls from the specified dom element.
  39047. * @param element Defines the element to stop listening the inputs from
  39048. */
  39049. detachControl(element: Nullable<HTMLElement>): void;
  39050. /**
  39051. * Gets the class name of the current intput.
  39052. * @returns the class name
  39053. */
  39054. getClassName(): string;
  39055. /** @hidden */
  39056. _onLostFocus(e: FocusEvent): void;
  39057. /**
  39058. * Get the friendly name associated with the input class.
  39059. * @returns the input friendly name
  39060. */
  39061. getSimpleName(): string;
  39062. /**
  39063. * Update the current camera state depending on the inputs that have been used this frame.
  39064. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39065. */
  39066. checkInputs(): void;
  39067. }
  39068. }
  39069. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  39070. import { Nullable } from "babylonjs/types";
  39071. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39072. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39073. /**
  39074. * Manage the mouse wheel inputs to control a follow camera.
  39075. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39076. */
  39077. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  39078. /**
  39079. * Defines the camera the input is attached to.
  39080. */
  39081. camera: FollowCamera;
  39082. /**
  39083. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  39084. */
  39085. axisControlRadius: boolean;
  39086. /**
  39087. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  39088. */
  39089. axisControlHeight: boolean;
  39090. /**
  39091. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  39092. */
  39093. axisControlRotation: boolean;
  39094. /**
  39095. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  39096. * relation to mouseWheel events.
  39097. */
  39098. wheelPrecision: number;
  39099. /**
  39100. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  39101. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  39102. */
  39103. wheelDeltaPercentage: number;
  39104. private _wheel;
  39105. private _observer;
  39106. /**
  39107. * Attach the input controls to a specific dom element to get the input from.
  39108. * @param element Defines the element the controls should be listened from
  39109. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39110. */
  39111. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39112. /**
  39113. * Detach the current controls from the specified dom element.
  39114. * @param element Defines the element to stop listening the inputs from
  39115. */
  39116. detachControl(element: Nullable<HTMLElement>): void;
  39117. /**
  39118. * Gets the class name of the current intput.
  39119. * @returns the class name
  39120. */
  39121. getClassName(): string;
  39122. /**
  39123. * Get the friendly name associated with the input class.
  39124. * @returns the input friendly name
  39125. */
  39126. getSimpleName(): string;
  39127. }
  39128. }
  39129. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  39130. import { Nullable } from "babylonjs/types";
  39131. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39132. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39133. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39134. /**
  39135. * Manage the pointers inputs to control an follow camera.
  39136. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39137. */
  39138. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  39139. /**
  39140. * Defines the camera the input is attached to.
  39141. */
  39142. camera: FollowCamera;
  39143. /**
  39144. * Gets the class name of the current input.
  39145. * @returns the class name
  39146. */
  39147. getClassName(): string;
  39148. /**
  39149. * Defines the pointer angular sensibility along the X axis or how fast is
  39150. * the camera rotating.
  39151. * A negative number will reverse the axis direction.
  39152. */
  39153. angularSensibilityX: number;
  39154. /**
  39155. * Defines the pointer angular sensibility along the Y axis or how fast is
  39156. * the camera rotating.
  39157. * A negative number will reverse the axis direction.
  39158. */
  39159. angularSensibilityY: number;
  39160. /**
  39161. * Defines the pointer pinch precision or how fast is the camera zooming.
  39162. * A negative number will reverse the axis direction.
  39163. */
  39164. pinchPrecision: number;
  39165. /**
  39166. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39167. * from 0.
  39168. * It defines the percentage of current camera.radius to use as delta when
  39169. * pinch zoom is used.
  39170. */
  39171. pinchDeltaPercentage: number;
  39172. /**
  39173. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  39174. */
  39175. axisXControlRadius: boolean;
  39176. /**
  39177. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  39178. */
  39179. axisXControlHeight: boolean;
  39180. /**
  39181. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  39182. */
  39183. axisXControlRotation: boolean;
  39184. /**
  39185. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  39186. */
  39187. axisYControlRadius: boolean;
  39188. /**
  39189. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  39190. */
  39191. axisYControlHeight: boolean;
  39192. /**
  39193. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  39194. */
  39195. axisYControlRotation: boolean;
  39196. /**
  39197. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  39198. */
  39199. axisPinchControlRadius: boolean;
  39200. /**
  39201. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  39202. */
  39203. axisPinchControlHeight: boolean;
  39204. /**
  39205. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  39206. */
  39207. axisPinchControlRotation: boolean;
  39208. /**
  39209. * Log error messages if basic misconfiguration has occurred.
  39210. */
  39211. warningEnable: boolean;
  39212. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39213. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39214. private _warningCounter;
  39215. private _warning;
  39216. }
  39217. }
  39218. declare module "babylonjs/Cameras/followCameraInputsManager" {
  39219. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  39220. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39221. /**
  39222. * Default Inputs manager for the FollowCamera.
  39223. * It groups all the default supported inputs for ease of use.
  39224. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39225. */
  39226. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  39227. /**
  39228. * Instantiates a new FollowCameraInputsManager.
  39229. * @param camera Defines the camera the inputs belong to
  39230. */
  39231. constructor(camera: FollowCamera);
  39232. /**
  39233. * Add keyboard input support to the input manager.
  39234. * @returns the current input manager
  39235. */
  39236. addKeyboard(): FollowCameraInputsManager;
  39237. /**
  39238. * Add mouse wheel input support to the input manager.
  39239. * @returns the current input manager
  39240. */
  39241. addMouseWheel(): FollowCameraInputsManager;
  39242. /**
  39243. * Add pointers input support to the input manager.
  39244. * @returns the current input manager
  39245. */
  39246. addPointers(): FollowCameraInputsManager;
  39247. /**
  39248. * Add orientation input support to the input manager.
  39249. * @returns the current input manager
  39250. */
  39251. addVRDeviceOrientation(): FollowCameraInputsManager;
  39252. }
  39253. }
  39254. declare module "babylonjs/Cameras/followCamera" {
  39255. import { Nullable } from "babylonjs/types";
  39256. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  39257. import { Scene } from "babylonjs/scene";
  39258. import { Vector3 } from "babylonjs/Maths/math.vector";
  39259. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39260. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  39261. /**
  39262. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  39263. * an arc rotate version arcFollowCamera are available.
  39264. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39265. */
  39266. export class FollowCamera extends TargetCamera {
  39267. /**
  39268. * Distance the follow camera should follow an object at
  39269. */
  39270. radius: number;
  39271. /**
  39272. * Minimum allowed distance of the camera to the axis of rotation
  39273. * (The camera can not get closer).
  39274. * This can help limiting how the Camera is able to move in the scene.
  39275. */
  39276. lowerRadiusLimit: Nullable<number>;
  39277. /**
  39278. * Maximum allowed distance of the camera to the axis of rotation
  39279. * (The camera can not get further).
  39280. * This can help limiting how the Camera is able to move in the scene.
  39281. */
  39282. upperRadiusLimit: Nullable<number>;
  39283. /**
  39284. * Define a rotation offset between the camera and the object it follows
  39285. */
  39286. rotationOffset: number;
  39287. /**
  39288. * Minimum allowed angle to camera position relative to target object.
  39289. * This can help limiting how the Camera is able to move in the scene.
  39290. */
  39291. lowerRotationOffsetLimit: Nullable<number>;
  39292. /**
  39293. * Maximum allowed angle to camera position relative to target object.
  39294. * This can help limiting how the Camera is able to move in the scene.
  39295. */
  39296. upperRotationOffsetLimit: Nullable<number>;
  39297. /**
  39298. * Define a height offset between the camera and the object it follows.
  39299. * It can help following an object from the top (like a car chaing a plane)
  39300. */
  39301. heightOffset: number;
  39302. /**
  39303. * Minimum allowed height of camera position relative to target object.
  39304. * This can help limiting how the Camera is able to move in the scene.
  39305. */
  39306. lowerHeightOffsetLimit: Nullable<number>;
  39307. /**
  39308. * Maximum allowed height of camera position relative to target object.
  39309. * This can help limiting how the Camera is able to move in the scene.
  39310. */
  39311. upperHeightOffsetLimit: Nullable<number>;
  39312. /**
  39313. * Define how fast the camera can accelerate to follow it s target.
  39314. */
  39315. cameraAcceleration: number;
  39316. /**
  39317. * Define the speed limit of the camera following an object.
  39318. */
  39319. maxCameraSpeed: number;
  39320. /**
  39321. * Define the target of the camera.
  39322. */
  39323. lockedTarget: Nullable<AbstractMesh>;
  39324. /**
  39325. * Defines the input associated with the camera.
  39326. */
  39327. inputs: FollowCameraInputsManager;
  39328. /**
  39329. * Instantiates the follow camera.
  39330. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39331. * @param name Define the name of the camera in the scene
  39332. * @param position Define the position of the camera
  39333. * @param scene Define the scene the camera belong to
  39334. * @param lockedTarget Define the target of the camera
  39335. */
  39336. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  39337. private _follow;
  39338. /**
  39339. * Attached controls to the current camera.
  39340. * @param element Defines the element the controls should be listened from
  39341. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39342. */
  39343. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39344. /**
  39345. * Detach the current controls from the camera.
  39346. * The camera will stop reacting to inputs.
  39347. * @param element Defines the element to stop listening the inputs from
  39348. */
  39349. detachControl(element: HTMLElement): void;
  39350. /** @hidden */
  39351. _checkInputs(): void;
  39352. private _checkLimits;
  39353. /**
  39354. * Gets the camera class name.
  39355. * @returns the class name
  39356. */
  39357. getClassName(): string;
  39358. }
  39359. /**
  39360. * Arc Rotate version of the follow camera.
  39361. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  39362. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39363. */
  39364. export class ArcFollowCamera extends TargetCamera {
  39365. /** The longitudinal angle of the camera */
  39366. alpha: number;
  39367. /** The latitudinal angle of the camera */
  39368. beta: number;
  39369. /** The radius of the camera from its target */
  39370. radius: number;
  39371. /** Define the camera target (the messh it should follow) */
  39372. target: Nullable<AbstractMesh>;
  39373. private _cartesianCoordinates;
  39374. /**
  39375. * Instantiates a new ArcFollowCamera
  39376. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  39377. * @param name Define the name of the camera
  39378. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  39379. * @param beta Define the rotation angle of the camera around the elevation axis
  39380. * @param radius Define the radius of the camera from its target point
  39381. * @param target Define the target of the camera
  39382. * @param scene Define the scene the camera belongs to
  39383. */
  39384. constructor(name: string,
  39385. /** The longitudinal angle of the camera */
  39386. alpha: number,
  39387. /** The latitudinal angle of the camera */
  39388. beta: number,
  39389. /** The radius of the camera from its target */
  39390. radius: number,
  39391. /** Define the camera target (the messh it should follow) */
  39392. target: Nullable<AbstractMesh>, scene: Scene);
  39393. private _follow;
  39394. /** @hidden */
  39395. _checkInputs(): void;
  39396. /**
  39397. * Returns the class name of the object.
  39398. * It is mostly used internally for serialization purposes.
  39399. */
  39400. getClassName(): string;
  39401. }
  39402. }
  39403. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  39404. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39405. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  39406. import { Nullable } from "babylonjs/types";
  39407. /**
  39408. * Manage the keyboard inputs to control the movement of a follow camera.
  39409. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39410. */
  39411. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  39412. /**
  39413. * Defines the camera the input is attached to.
  39414. */
  39415. camera: FollowCamera;
  39416. /**
  39417. * Defines the list of key codes associated with the up action (increase heightOffset)
  39418. */
  39419. keysHeightOffsetIncr: number[];
  39420. /**
  39421. * Defines the list of key codes associated with the down action (decrease heightOffset)
  39422. */
  39423. keysHeightOffsetDecr: number[];
  39424. /**
  39425. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  39426. */
  39427. keysHeightOffsetModifierAlt: boolean;
  39428. /**
  39429. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  39430. */
  39431. keysHeightOffsetModifierCtrl: boolean;
  39432. /**
  39433. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  39434. */
  39435. keysHeightOffsetModifierShift: boolean;
  39436. /**
  39437. * Defines the list of key codes associated with the left action (increase rotationOffset)
  39438. */
  39439. keysRotationOffsetIncr: number[];
  39440. /**
  39441. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  39442. */
  39443. keysRotationOffsetDecr: number[];
  39444. /**
  39445. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  39446. */
  39447. keysRotationOffsetModifierAlt: boolean;
  39448. /**
  39449. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  39450. */
  39451. keysRotationOffsetModifierCtrl: boolean;
  39452. /**
  39453. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  39454. */
  39455. keysRotationOffsetModifierShift: boolean;
  39456. /**
  39457. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  39458. */
  39459. keysRadiusIncr: number[];
  39460. /**
  39461. * Defines the list of key codes associated with the zoom-out action (increase radius)
  39462. */
  39463. keysRadiusDecr: number[];
  39464. /**
  39465. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  39466. */
  39467. keysRadiusModifierAlt: boolean;
  39468. /**
  39469. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  39470. */
  39471. keysRadiusModifierCtrl: boolean;
  39472. /**
  39473. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  39474. */
  39475. keysRadiusModifierShift: boolean;
  39476. /**
  39477. * Defines the rate of change of heightOffset.
  39478. */
  39479. heightSensibility: number;
  39480. /**
  39481. * Defines the rate of change of rotationOffset.
  39482. */
  39483. rotationSensibility: number;
  39484. /**
  39485. * Defines the rate of change of radius.
  39486. */
  39487. radiusSensibility: number;
  39488. private _keys;
  39489. private _ctrlPressed;
  39490. private _altPressed;
  39491. private _shiftPressed;
  39492. private _onCanvasBlurObserver;
  39493. private _onKeyboardObserver;
  39494. private _engine;
  39495. private _scene;
  39496. /**
  39497. * Attach the input controls to a specific dom element to get the input from.
  39498. * @param element Defines the element the controls should be listened from
  39499. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39500. */
  39501. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39502. /**
  39503. * Detach the current controls from the specified dom element.
  39504. * @param element Defines the element to stop listening the inputs from
  39505. */
  39506. detachControl(element: Nullable<HTMLElement>): void;
  39507. /**
  39508. * Update the current camera state depending on the inputs that have been used this frame.
  39509. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39510. */
  39511. checkInputs(): void;
  39512. /**
  39513. * Gets the class name of the current input.
  39514. * @returns the class name
  39515. */
  39516. getClassName(): string;
  39517. /**
  39518. * Get the friendly name associated with the input class.
  39519. * @returns the input friendly name
  39520. */
  39521. getSimpleName(): string;
  39522. /**
  39523. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39524. * allow modification of the heightOffset value.
  39525. */
  39526. private _modifierHeightOffset;
  39527. /**
  39528. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39529. * allow modification of the rotationOffset value.
  39530. */
  39531. private _modifierRotationOffset;
  39532. /**
  39533. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  39534. * allow modification of the radius value.
  39535. */
  39536. private _modifierRadius;
  39537. }
  39538. }
  39539. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  39540. import { Nullable } from "babylonjs/types";
  39541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39542. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39543. import { Observable } from "babylonjs/Misc/observable";
  39544. module "babylonjs/Cameras/freeCameraInputsManager" {
  39545. interface FreeCameraInputsManager {
  39546. /**
  39547. * @hidden
  39548. */
  39549. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  39550. /**
  39551. * Add orientation input support to the input manager.
  39552. * @returns the current input manager
  39553. */
  39554. addDeviceOrientation(): FreeCameraInputsManager;
  39555. }
  39556. }
  39557. /**
  39558. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  39559. * Screen rotation is taken into account.
  39560. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39561. */
  39562. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  39563. private _camera;
  39564. private _screenOrientationAngle;
  39565. private _constantTranform;
  39566. private _screenQuaternion;
  39567. private _alpha;
  39568. private _beta;
  39569. private _gamma;
  39570. /**
  39571. * Can be used to detect if a device orientation sensor is availible on a device
  39572. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  39573. * @returns a promise that will resolve on orientation change
  39574. */
  39575. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  39576. /**
  39577. * @hidden
  39578. */
  39579. _onDeviceOrientationChangedObservable: Observable<void>;
  39580. /**
  39581. * Instantiates a new input
  39582. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39583. */
  39584. constructor();
  39585. /**
  39586. * Define the camera controlled by the input.
  39587. */
  39588. camera: FreeCamera;
  39589. /**
  39590. * Attach the input controls to a specific dom element to get the input from.
  39591. * @param element Defines the element the controls should be listened from
  39592. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39593. */
  39594. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39595. private _orientationChanged;
  39596. private _deviceOrientation;
  39597. /**
  39598. * Detach the current controls from the specified dom element.
  39599. * @param element Defines the element to stop listening the inputs from
  39600. */
  39601. detachControl(element: Nullable<HTMLElement>): void;
  39602. /**
  39603. * Update the current camera state depending on the inputs that have been used this frame.
  39604. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39605. */
  39606. checkInputs(): void;
  39607. /**
  39608. * Gets the class name of the current intput.
  39609. * @returns the class name
  39610. */
  39611. getClassName(): string;
  39612. /**
  39613. * Get the friendly name associated with the input class.
  39614. * @returns the input friendly name
  39615. */
  39616. getSimpleName(): string;
  39617. }
  39618. }
  39619. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  39620. import { Nullable } from "babylonjs/types";
  39621. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39622. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39623. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39624. /**
  39625. * Manage the gamepad inputs to control a free camera.
  39626. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39627. */
  39628. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  39629. /**
  39630. * Define the camera the input is attached to.
  39631. */
  39632. camera: FreeCamera;
  39633. /**
  39634. * Define the Gamepad controlling the input
  39635. */
  39636. gamepad: Nullable<Gamepad>;
  39637. /**
  39638. * Defines the gamepad rotation sensiblity.
  39639. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  39640. */
  39641. gamepadAngularSensibility: number;
  39642. /**
  39643. * Defines the gamepad move sensiblity.
  39644. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  39645. */
  39646. gamepadMoveSensibility: number;
  39647. private _onGamepadConnectedObserver;
  39648. private _onGamepadDisconnectedObserver;
  39649. private _cameraTransform;
  39650. private _deltaTransform;
  39651. private _vector3;
  39652. private _vector2;
  39653. /**
  39654. * Attach the input controls to a specific dom element to get the input from.
  39655. * @param element Defines the element the controls should be listened from
  39656. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39657. */
  39658. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39659. /**
  39660. * Detach the current controls from the specified dom element.
  39661. * @param element Defines the element to stop listening the inputs from
  39662. */
  39663. detachControl(element: Nullable<HTMLElement>): void;
  39664. /**
  39665. * Update the current camera state depending on the inputs that have been used this frame.
  39666. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39667. */
  39668. checkInputs(): void;
  39669. /**
  39670. * Gets the class name of the current intput.
  39671. * @returns the class name
  39672. */
  39673. getClassName(): string;
  39674. /**
  39675. * Get the friendly name associated with the input class.
  39676. * @returns the input friendly name
  39677. */
  39678. getSimpleName(): string;
  39679. }
  39680. }
  39681. declare module "babylonjs/Misc/virtualJoystick" {
  39682. import { Nullable } from "babylonjs/types";
  39683. import { Vector3 } from "babylonjs/Maths/math.vector";
  39684. /**
  39685. * Defines the potential axis of a Joystick
  39686. */
  39687. export enum JoystickAxis {
  39688. /** X axis */
  39689. X = 0,
  39690. /** Y axis */
  39691. Y = 1,
  39692. /** Z axis */
  39693. Z = 2
  39694. }
  39695. /**
  39696. * Class used to define virtual joystick (used in touch mode)
  39697. */
  39698. export class VirtualJoystick {
  39699. /**
  39700. * Gets or sets a boolean indicating that left and right values must be inverted
  39701. */
  39702. reverseLeftRight: boolean;
  39703. /**
  39704. * Gets or sets a boolean indicating that up and down values must be inverted
  39705. */
  39706. reverseUpDown: boolean;
  39707. /**
  39708. * Gets the offset value for the position (ie. the change of the position value)
  39709. */
  39710. deltaPosition: Vector3;
  39711. /**
  39712. * Gets a boolean indicating if the virtual joystick was pressed
  39713. */
  39714. pressed: boolean;
  39715. /**
  39716. * Canvas the virtual joystick will render onto, default z-index of this is 5
  39717. */
  39718. static Canvas: Nullable<HTMLCanvasElement>;
  39719. private static _globalJoystickIndex;
  39720. private static vjCanvasContext;
  39721. private static vjCanvasWidth;
  39722. private static vjCanvasHeight;
  39723. private static halfWidth;
  39724. private _action;
  39725. private _axisTargetedByLeftAndRight;
  39726. private _axisTargetedByUpAndDown;
  39727. private _joystickSensibility;
  39728. private _inversedSensibility;
  39729. private _joystickPointerID;
  39730. private _joystickColor;
  39731. private _joystickPointerPos;
  39732. private _joystickPreviousPointerPos;
  39733. private _joystickPointerStartPos;
  39734. private _deltaJoystickVector;
  39735. private _leftJoystick;
  39736. private _touches;
  39737. private _onPointerDownHandlerRef;
  39738. private _onPointerMoveHandlerRef;
  39739. private _onPointerUpHandlerRef;
  39740. private _onResize;
  39741. /**
  39742. * Creates a new virtual joystick
  39743. * @param leftJoystick defines that the joystick is for left hand (false by default)
  39744. */
  39745. constructor(leftJoystick?: boolean);
  39746. /**
  39747. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  39748. * @param newJoystickSensibility defines the new sensibility
  39749. */
  39750. setJoystickSensibility(newJoystickSensibility: number): void;
  39751. private _onPointerDown;
  39752. private _onPointerMove;
  39753. private _onPointerUp;
  39754. /**
  39755. * Change the color of the virtual joystick
  39756. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  39757. */
  39758. setJoystickColor(newColor: string): void;
  39759. /**
  39760. * Defines a callback to call when the joystick is touched
  39761. * @param action defines the callback
  39762. */
  39763. setActionOnTouch(action: () => any): void;
  39764. /**
  39765. * Defines which axis you'd like to control for left & right
  39766. * @param axis defines the axis to use
  39767. */
  39768. setAxisForLeftRight(axis: JoystickAxis): void;
  39769. /**
  39770. * Defines which axis you'd like to control for up & down
  39771. * @param axis defines the axis to use
  39772. */
  39773. setAxisForUpDown(axis: JoystickAxis): void;
  39774. private _drawVirtualJoystick;
  39775. /**
  39776. * Release internal HTML canvas
  39777. */
  39778. releaseCanvas(): void;
  39779. }
  39780. }
  39781. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  39782. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  39783. import { Nullable } from "babylonjs/types";
  39784. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39785. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39786. module "babylonjs/Cameras/freeCameraInputsManager" {
  39787. interface FreeCameraInputsManager {
  39788. /**
  39789. * Add virtual joystick input support to the input manager.
  39790. * @returns the current input manager
  39791. */
  39792. addVirtualJoystick(): FreeCameraInputsManager;
  39793. }
  39794. }
  39795. /**
  39796. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  39797. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39798. */
  39799. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  39800. /**
  39801. * Defines the camera the input is attached to.
  39802. */
  39803. camera: FreeCamera;
  39804. private _leftjoystick;
  39805. private _rightjoystick;
  39806. /**
  39807. * Gets the left stick of the virtual joystick.
  39808. * @returns The virtual Joystick
  39809. */
  39810. getLeftJoystick(): VirtualJoystick;
  39811. /**
  39812. * Gets the right stick of the virtual joystick.
  39813. * @returns The virtual Joystick
  39814. */
  39815. getRightJoystick(): VirtualJoystick;
  39816. /**
  39817. * Update the current camera state depending on the inputs that have been used this frame.
  39818. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  39819. */
  39820. checkInputs(): void;
  39821. /**
  39822. * Attach the input controls to a specific dom element to get the input from.
  39823. * @param element Defines the element the controls should be listened from
  39824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39825. */
  39826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39827. /**
  39828. * Detach the current controls from the specified dom element.
  39829. * @param element Defines the element to stop listening the inputs from
  39830. */
  39831. detachControl(element: Nullable<HTMLElement>): void;
  39832. /**
  39833. * Gets the class name of the current intput.
  39834. * @returns the class name
  39835. */
  39836. getClassName(): string;
  39837. /**
  39838. * Get the friendly name associated with the input class.
  39839. * @returns the input friendly name
  39840. */
  39841. getSimpleName(): string;
  39842. }
  39843. }
  39844. declare module "babylonjs/Cameras/Inputs/index" {
  39845. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  39846. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  39847. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  39848. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  39849. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  39850. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  39851. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  39852. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  39853. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  39854. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  39855. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39856. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  39857. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  39858. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  39859. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  39860. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  39861. }
  39862. declare module "babylonjs/Cameras/touchCamera" {
  39863. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39864. import { Scene } from "babylonjs/scene";
  39865. import { Vector3 } from "babylonjs/Maths/math.vector";
  39866. /**
  39867. * This represents a FPS type of camera controlled by touch.
  39868. * This is like a universal camera minus the Gamepad controls.
  39869. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39870. */
  39871. export class TouchCamera extends FreeCamera {
  39872. /**
  39873. * Defines the touch sensibility for rotation.
  39874. * The higher the faster.
  39875. */
  39876. touchAngularSensibility: number;
  39877. /**
  39878. * Defines the touch sensibility for move.
  39879. * The higher the faster.
  39880. */
  39881. touchMoveSensibility: number;
  39882. /**
  39883. * Instantiates a new touch camera.
  39884. * This represents a FPS type of camera controlled by touch.
  39885. * This is like a universal camera minus the Gamepad controls.
  39886. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  39887. * @param name Define the name of the camera in the scene
  39888. * @param position Define the start position of the camera in the scene
  39889. * @param scene Define the scene the camera belongs to
  39890. */
  39891. constructor(name: string, position: Vector3, scene: Scene);
  39892. /**
  39893. * Gets the current object class name.
  39894. * @return the class name
  39895. */
  39896. getClassName(): string;
  39897. /** @hidden */
  39898. _setupInputs(): void;
  39899. }
  39900. }
  39901. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  39902. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  39903. import { Scene } from "babylonjs/scene";
  39904. import { Vector3 } from "babylonjs/Maths/math.vector";
  39905. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  39906. import { Axis } from "babylonjs/Maths/math.axis";
  39907. /**
  39908. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  39909. * being tilted forward or back and left or right.
  39910. */
  39911. export class DeviceOrientationCamera extends FreeCamera {
  39912. private _initialQuaternion;
  39913. private _quaternionCache;
  39914. private _tmpDragQuaternion;
  39915. private _disablePointerInputWhenUsingDeviceOrientation;
  39916. /**
  39917. * Creates a new device orientation camera
  39918. * @param name The name of the camera
  39919. * @param position The start position camera
  39920. * @param scene The scene the camera belongs to
  39921. */
  39922. constructor(name: string, position: Vector3, scene: Scene);
  39923. /**
  39924. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  39925. */
  39926. disablePointerInputWhenUsingDeviceOrientation: boolean;
  39927. private _dragFactor;
  39928. /**
  39929. * Enabled turning on the y axis when the orientation sensor is active
  39930. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  39931. */
  39932. enableHorizontalDragging(dragFactor?: number): void;
  39933. /**
  39934. * Gets the current instance class name ("DeviceOrientationCamera").
  39935. * This helps avoiding instanceof at run time.
  39936. * @returns the class name
  39937. */
  39938. getClassName(): string;
  39939. /**
  39940. * @hidden
  39941. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  39942. */
  39943. _checkInputs(): void;
  39944. /**
  39945. * Reset the camera to its default orientation on the specified axis only.
  39946. * @param axis The axis to reset
  39947. */
  39948. resetToCurrentRotation(axis?: Axis): void;
  39949. }
  39950. }
  39951. declare module "babylonjs/Gamepads/xboxGamepad" {
  39952. import { Observable } from "babylonjs/Misc/observable";
  39953. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39954. /**
  39955. * Defines supported buttons for XBox360 compatible gamepads
  39956. */
  39957. export enum Xbox360Button {
  39958. /** A */
  39959. A = 0,
  39960. /** B */
  39961. B = 1,
  39962. /** X */
  39963. X = 2,
  39964. /** Y */
  39965. Y = 3,
  39966. /** Start */
  39967. Start = 4,
  39968. /** Back */
  39969. Back = 5,
  39970. /** Left button */
  39971. LB = 6,
  39972. /** Right button */
  39973. RB = 7,
  39974. /** Left stick */
  39975. LeftStick = 8,
  39976. /** Right stick */
  39977. RightStick = 9
  39978. }
  39979. /** Defines values for XBox360 DPad */
  39980. export enum Xbox360Dpad {
  39981. /** Up */
  39982. Up = 0,
  39983. /** Down */
  39984. Down = 1,
  39985. /** Left */
  39986. Left = 2,
  39987. /** Right */
  39988. Right = 3
  39989. }
  39990. /**
  39991. * Defines a XBox360 gamepad
  39992. */
  39993. export class Xbox360Pad extends Gamepad {
  39994. private _leftTrigger;
  39995. private _rightTrigger;
  39996. private _onlefttriggerchanged;
  39997. private _onrighttriggerchanged;
  39998. private _onbuttondown;
  39999. private _onbuttonup;
  40000. private _ondpaddown;
  40001. private _ondpadup;
  40002. /** Observable raised when a button is pressed */
  40003. onButtonDownObservable: Observable<Xbox360Button>;
  40004. /** Observable raised when a button is released */
  40005. onButtonUpObservable: Observable<Xbox360Button>;
  40006. /** Observable raised when a pad is pressed */
  40007. onPadDownObservable: Observable<Xbox360Dpad>;
  40008. /** Observable raised when a pad is released */
  40009. onPadUpObservable: Observable<Xbox360Dpad>;
  40010. private _buttonA;
  40011. private _buttonB;
  40012. private _buttonX;
  40013. private _buttonY;
  40014. private _buttonBack;
  40015. private _buttonStart;
  40016. private _buttonLB;
  40017. private _buttonRB;
  40018. private _buttonLeftStick;
  40019. private _buttonRightStick;
  40020. private _dPadUp;
  40021. private _dPadDown;
  40022. private _dPadLeft;
  40023. private _dPadRight;
  40024. private _isXboxOnePad;
  40025. /**
  40026. * Creates a new XBox360 gamepad object
  40027. * @param id defines the id of this gamepad
  40028. * @param index defines its index
  40029. * @param gamepad defines the internal HTML gamepad object
  40030. * @param xboxOne defines if it is a XBox One gamepad
  40031. */
  40032. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  40033. /**
  40034. * Defines the callback to call when left trigger is pressed
  40035. * @param callback defines the callback to use
  40036. */
  40037. onlefttriggerchanged(callback: (value: number) => void): void;
  40038. /**
  40039. * Defines the callback to call when right trigger is pressed
  40040. * @param callback defines the callback to use
  40041. */
  40042. onrighttriggerchanged(callback: (value: number) => void): void;
  40043. /**
  40044. * Gets the left trigger value
  40045. */
  40046. /**
  40047. * Sets the left trigger value
  40048. */
  40049. leftTrigger: number;
  40050. /**
  40051. * Gets the right trigger value
  40052. */
  40053. /**
  40054. * Sets the right trigger value
  40055. */
  40056. rightTrigger: number;
  40057. /**
  40058. * Defines the callback to call when a button is pressed
  40059. * @param callback defines the callback to use
  40060. */
  40061. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  40062. /**
  40063. * Defines the callback to call when a button is released
  40064. * @param callback defines the callback to use
  40065. */
  40066. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  40067. /**
  40068. * Defines the callback to call when a pad is pressed
  40069. * @param callback defines the callback to use
  40070. */
  40071. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  40072. /**
  40073. * Defines the callback to call when a pad is released
  40074. * @param callback defines the callback to use
  40075. */
  40076. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  40077. private _setButtonValue;
  40078. private _setDPadValue;
  40079. /**
  40080. * Gets the value of the `A` button
  40081. */
  40082. /**
  40083. * Sets the value of the `A` button
  40084. */
  40085. buttonA: number;
  40086. /**
  40087. * Gets the value of the `B` button
  40088. */
  40089. /**
  40090. * Sets the value of the `B` button
  40091. */
  40092. buttonB: number;
  40093. /**
  40094. * Gets the value of the `X` button
  40095. */
  40096. /**
  40097. * Sets the value of the `X` button
  40098. */
  40099. buttonX: number;
  40100. /**
  40101. * Gets the value of the `Y` button
  40102. */
  40103. /**
  40104. * Sets the value of the `Y` button
  40105. */
  40106. buttonY: number;
  40107. /**
  40108. * Gets the value of the `Start` button
  40109. */
  40110. /**
  40111. * Sets the value of the `Start` button
  40112. */
  40113. buttonStart: number;
  40114. /**
  40115. * Gets the value of the `Back` button
  40116. */
  40117. /**
  40118. * Sets the value of the `Back` button
  40119. */
  40120. buttonBack: number;
  40121. /**
  40122. * Gets the value of the `Left` button
  40123. */
  40124. /**
  40125. * Sets the value of the `Left` button
  40126. */
  40127. buttonLB: number;
  40128. /**
  40129. * Gets the value of the `Right` button
  40130. */
  40131. /**
  40132. * Sets the value of the `Right` button
  40133. */
  40134. buttonRB: number;
  40135. /**
  40136. * Gets the value of the Left joystick
  40137. */
  40138. /**
  40139. * Sets the value of the Left joystick
  40140. */
  40141. buttonLeftStick: number;
  40142. /**
  40143. * Gets the value of the Right joystick
  40144. */
  40145. /**
  40146. * Sets the value of the Right joystick
  40147. */
  40148. buttonRightStick: number;
  40149. /**
  40150. * Gets the value of D-pad up
  40151. */
  40152. /**
  40153. * Sets the value of D-pad up
  40154. */
  40155. dPadUp: number;
  40156. /**
  40157. * Gets the value of D-pad down
  40158. */
  40159. /**
  40160. * Sets the value of D-pad down
  40161. */
  40162. dPadDown: number;
  40163. /**
  40164. * Gets the value of D-pad left
  40165. */
  40166. /**
  40167. * Sets the value of D-pad left
  40168. */
  40169. dPadLeft: number;
  40170. /**
  40171. * Gets the value of D-pad right
  40172. */
  40173. /**
  40174. * Sets the value of D-pad right
  40175. */
  40176. dPadRight: number;
  40177. /**
  40178. * Force the gamepad to synchronize with device values
  40179. */
  40180. update(): void;
  40181. /**
  40182. * Disposes the gamepad
  40183. */
  40184. dispose(): void;
  40185. }
  40186. }
  40187. declare module "babylonjs/Gamepads/dualShockGamepad" {
  40188. import { Observable } from "babylonjs/Misc/observable";
  40189. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40190. /**
  40191. * Defines supported buttons for DualShock compatible gamepads
  40192. */
  40193. export enum DualShockButton {
  40194. /** Cross */
  40195. Cross = 0,
  40196. /** Circle */
  40197. Circle = 1,
  40198. /** Square */
  40199. Square = 2,
  40200. /** Triangle */
  40201. Triangle = 3,
  40202. /** Options */
  40203. Options = 4,
  40204. /** Share */
  40205. Share = 5,
  40206. /** L1 */
  40207. L1 = 6,
  40208. /** R1 */
  40209. R1 = 7,
  40210. /** Left stick */
  40211. LeftStick = 8,
  40212. /** Right stick */
  40213. RightStick = 9
  40214. }
  40215. /** Defines values for DualShock DPad */
  40216. export enum DualShockDpad {
  40217. /** Up */
  40218. Up = 0,
  40219. /** Down */
  40220. Down = 1,
  40221. /** Left */
  40222. Left = 2,
  40223. /** Right */
  40224. Right = 3
  40225. }
  40226. /**
  40227. * Defines a DualShock gamepad
  40228. */
  40229. export class DualShockPad extends Gamepad {
  40230. private _leftTrigger;
  40231. private _rightTrigger;
  40232. private _onlefttriggerchanged;
  40233. private _onrighttriggerchanged;
  40234. private _onbuttondown;
  40235. private _onbuttonup;
  40236. private _ondpaddown;
  40237. private _ondpadup;
  40238. /** Observable raised when a button is pressed */
  40239. onButtonDownObservable: Observable<DualShockButton>;
  40240. /** Observable raised when a button is released */
  40241. onButtonUpObservable: Observable<DualShockButton>;
  40242. /** Observable raised when a pad is pressed */
  40243. onPadDownObservable: Observable<DualShockDpad>;
  40244. /** Observable raised when a pad is released */
  40245. onPadUpObservable: Observable<DualShockDpad>;
  40246. private _buttonCross;
  40247. private _buttonCircle;
  40248. private _buttonSquare;
  40249. private _buttonTriangle;
  40250. private _buttonShare;
  40251. private _buttonOptions;
  40252. private _buttonL1;
  40253. private _buttonR1;
  40254. private _buttonLeftStick;
  40255. private _buttonRightStick;
  40256. private _dPadUp;
  40257. private _dPadDown;
  40258. private _dPadLeft;
  40259. private _dPadRight;
  40260. /**
  40261. * Creates a new DualShock gamepad object
  40262. * @param id defines the id of this gamepad
  40263. * @param index defines its index
  40264. * @param gamepad defines the internal HTML gamepad object
  40265. */
  40266. constructor(id: string, index: number, gamepad: any);
  40267. /**
  40268. * Defines the callback to call when left trigger is pressed
  40269. * @param callback defines the callback to use
  40270. */
  40271. onlefttriggerchanged(callback: (value: number) => void): void;
  40272. /**
  40273. * Defines the callback to call when right trigger is pressed
  40274. * @param callback defines the callback to use
  40275. */
  40276. onrighttriggerchanged(callback: (value: number) => void): void;
  40277. /**
  40278. * Gets the left trigger value
  40279. */
  40280. /**
  40281. * Sets the left trigger value
  40282. */
  40283. leftTrigger: number;
  40284. /**
  40285. * Gets the right trigger value
  40286. */
  40287. /**
  40288. * Sets the right trigger value
  40289. */
  40290. rightTrigger: number;
  40291. /**
  40292. * Defines the callback to call when a button is pressed
  40293. * @param callback defines the callback to use
  40294. */
  40295. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  40296. /**
  40297. * Defines the callback to call when a button is released
  40298. * @param callback defines the callback to use
  40299. */
  40300. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  40301. /**
  40302. * Defines the callback to call when a pad is pressed
  40303. * @param callback defines the callback to use
  40304. */
  40305. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  40306. /**
  40307. * Defines the callback to call when a pad is released
  40308. * @param callback defines the callback to use
  40309. */
  40310. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  40311. private _setButtonValue;
  40312. private _setDPadValue;
  40313. /**
  40314. * Gets the value of the `Cross` button
  40315. */
  40316. /**
  40317. * Sets the value of the `Cross` button
  40318. */
  40319. buttonCross: number;
  40320. /**
  40321. * Gets the value of the `Circle` button
  40322. */
  40323. /**
  40324. * Sets the value of the `Circle` button
  40325. */
  40326. buttonCircle: number;
  40327. /**
  40328. * Gets the value of the `Square` button
  40329. */
  40330. /**
  40331. * Sets the value of the `Square` button
  40332. */
  40333. buttonSquare: number;
  40334. /**
  40335. * Gets the value of the `Triangle` button
  40336. */
  40337. /**
  40338. * Sets the value of the `Triangle` button
  40339. */
  40340. buttonTriangle: number;
  40341. /**
  40342. * Gets the value of the `Options` button
  40343. */
  40344. /**
  40345. * Sets the value of the `Options` button
  40346. */
  40347. buttonOptions: number;
  40348. /**
  40349. * Gets the value of the `Share` button
  40350. */
  40351. /**
  40352. * Sets the value of the `Share` button
  40353. */
  40354. buttonShare: number;
  40355. /**
  40356. * Gets the value of the `L1` button
  40357. */
  40358. /**
  40359. * Sets the value of the `L1` button
  40360. */
  40361. buttonL1: number;
  40362. /**
  40363. * Gets the value of the `R1` button
  40364. */
  40365. /**
  40366. * Sets the value of the `R1` button
  40367. */
  40368. buttonR1: number;
  40369. /**
  40370. * Gets the value of the Left joystick
  40371. */
  40372. /**
  40373. * Sets the value of the Left joystick
  40374. */
  40375. buttonLeftStick: number;
  40376. /**
  40377. * Gets the value of the Right joystick
  40378. */
  40379. /**
  40380. * Sets the value of the Right joystick
  40381. */
  40382. buttonRightStick: number;
  40383. /**
  40384. * Gets the value of D-pad up
  40385. */
  40386. /**
  40387. * Sets the value of D-pad up
  40388. */
  40389. dPadUp: number;
  40390. /**
  40391. * Gets the value of D-pad down
  40392. */
  40393. /**
  40394. * Sets the value of D-pad down
  40395. */
  40396. dPadDown: number;
  40397. /**
  40398. * Gets the value of D-pad left
  40399. */
  40400. /**
  40401. * Sets the value of D-pad left
  40402. */
  40403. dPadLeft: number;
  40404. /**
  40405. * Gets the value of D-pad right
  40406. */
  40407. /**
  40408. * Sets the value of D-pad right
  40409. */
  40410. dPadRight: number;
  40411. /**
  40412. * Force the gamepad to synchronize with device values
  40413. */
  40414. update(): void;
  40415. /**
  40416. * Disposes the gamepad
  40417. */
  40418. dispose(): void;
  40419. }
  40420. }
  40421. declare module "babylonjs/Gamepads/gamepadManager" {
  40422. import { Observable } from "babylonjs/Misc/observable";
  40423. import { Nullable } from "babylonjs/types";
  40424. import { Scene } from "babylonjs/scene";
  40425. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40426. /**
  40427. * Manager for handling gamepads
  40428. */
  40429. export class GamepadManager {
  40430. private _scene?;
  40431. private _babylonGamepads;
  40432. private _oneGamepadConnected;
  40433. /** @hidden */
  40434. _isMonitoring: boolean;
  40435. private _gamepadEventSupported;
  40436. private _gamepadSupport;
  40437. /**
  40438. * observable to be triggered when the gamepad controller has been connected
  40439. */
  40440. onGamepadConnectedObservable: Observable<Gamepad>;
  40441. /**
  40442. * observable to be triggered when the gamepad controller has been disconnected
  40443. */
  40444. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40445. private _onGamepadConnectedEvent;
  40446. private _onGamepadDisconnectedEvent;
  40447. /**
  40448. * Initializes the gamepad manager
  40449. * @param _scene BabylonJS scene
  40450. */
  40451. constructor(_scene?: Scene | undefined);
  40452. /**
  40453. * The gamepads in the game pad manager
  40454. */
  40455. readonly gamepads: Gamepad[];
  40456. /**
  40457. * Get the gamepad controllers based on type
  40458. * @param type The type of gamepad controller
  40459. * @returns Nullable gamepad
  40460. */
  40461. getGamepadByType(type?: number): Nullable<Gamepad>;
  40462. /**
  40463. * Disposes the gamepad manager
  40464. */
  40465. dispose(): void;
  40466. private _addNewGamepad;
  40467. private _startMonitoringGamepads;
  40468. private _stopMonitoringGamepads;
  40469. /** @hidden */
  40470. _checkGamepadsStatus(): void;
  40471. private _updateGamepadObjects;
  40472. }
  40473. }
  40474. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40475. import { Nullable } from "babylonjs/types";
  40476. import { Scene } from "babylonjs/scene";
  40477. import { ISceneComponent } from "babylonjs/sceneComponent";
  40478. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40479. module "babylonjs/scene" {
  40480. interface Scene {
  40481. /** @hidden */
  40482. _gamepadManager: Nullable<GamepadManager>;
  40483. /**
  40484. * Gets the gamepad manager associated with the scene
  40485. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40486. */
  40487. gamepadManager: GamepadManager;
  40488. }
  40489. }
  40490. module "babylonjs/Cameras/freeCameraInputsManager" {
  40491. /**
  40492. * Interface representing a free camera inputs manager
  40493. */
  40494. interface FreeCameraInputsManager {
  40495. /**
  40496. * Adds gamepad input support to the FreeCameraInputsManager.
  40497. * @returns the FreeCameraInputsManager
  40498. */
  40499. addGamepad(): FreeCameraInputsManager;
  40500. }
  40501. }
  40502. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40503. /**
  40504. * Interface representing an arc rotate camera inputs manager
  40505. */
  40506. interface ArcRotateCameraInputsManager {
  40507. /**
  40508. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40509. * @returns the camera inputs manager
  40510. */
  40511. addGamepad(): ArcRotateCameraInputsManager;
  40512. }
  40513. }
  40514. /**
  40515. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40516. */
  40517. export class GamepadSystemSceneComponent implements ISceneComponent {
  40518. /**
  40519. * The component name helpfull to identify the component in the list of scene components.
  40520. */
  40521. readonly name: string;
  40522. /**
  40523. * The scene the component belongs to.
  40524. */
  40525. scene: Scene;
  40526. /**
  40527. * Creates a new instance of the component for the given scene
  40528. * @param scene Defines the scene to register the component in
  40529. */
  40530. constructor(scene: Scene);
  40531. /**
  40532. * Registers the component in a given scene
  40533. */
  40534. register(): void;
  40535. /**
  40536. * Rebuilds the elements related to this component in case of
  40537. * context lost for instance.
  40538. */
  40539. rebuild(): void;
  40540. /**
  40541. * Disposes the component and the associated ressources
  40542. */
  40543. dispose(): void;
  40544. private _beforeCameraUpdate;
  40545. }
  40546. }
  40547. declare module "babylonjs/Cameras/universalCamera" {
  40548. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  40549. import { Scene } from "babylonjs/scene";
  40550. import { Vector3 } from "babylonjs/Maths/math.vector";
  40551. import "babylonjs/Gamepads/gamepadSceneComponent";
  40552. /**
  40553. * 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,
  40554. * which still works and will still be found in many Playgrounds.
  40555. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40556. */
  40557. export class UniversalCamera extends TouchCamera {
  40558. /**
  40559. * Defines the gamepad rotation sensiblity.
  40560. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  40561. */
  40562. gamepadAngularSensibility: number;
  40563. /**
  40564. * Defines the gamepad move sensiblity.
  40565. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  40566. */
  40567. gamepadMoveSensibility: number;
  40568. /**
  40569. * 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,
  40570. * which still works and will still be found in many Playgrounds.
  40571. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40572. * @param name Define the name of the camera in the scene
  40573. * @param position Define the start position of the camera in the scene
  40574. * @param scene Define the scene the camera belongs to
  40575. */
  40576. constructor(name: string, position: Vector3, scene: Scene);
  40577. /**
  40578. * Gets the current object class name.
  40579. * @return the class name
  40580. */
  40581. getClassName(): string;
  40582. }
  40583. }
  40584. declare module "babylonjs/Cameras/gamepadCamera" {
  40585. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40586. import { Scene } from "babylonjs/scene";
  40587. import { Vector3 } from "babylonjs/Maths/math.vector";
  40588. /**
  40589. * This represents a FPS type of camera. This is only here for back compat purpose.
  40590. * Please use the UniversalCamera instead as both are identical.
  40591. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40592. */
  40593. export class GamepadCamera extends UniversalCamera {
  40594. /**
  40595. * Instantiates a new Gamepad Camera
  40596. * This represents a FPS type of camera. This is only here for back compat purpose.
  40597. * Please use the UniversalCamera instead as both are identical.
  40598. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  40599. * @param name Define the name of the camera in the scene
  40600. * @param position Define the start position of the camera in the scene
  40601. * @param scene Define the scene the camera belongs to
  40602. */
  40603. constructor(name: string, position: Vector3, scene: Scene);
  40604. /**
  40605. * Gets the current object class name.
  40606. * @return the class name
  40607. */
  40608. getClassName(): string;
  40609. }
  40610. }
  40611. declare module "babylonjs/Shaders/pass.fragment" {
  40612. /** @hidden */
  40613. export var passPixelShader: {
  40614. name: string;
  40615. shader: string;
  40616. };
  40617. }
  40618. declare module "babylonjs/Shaders/passCube.fragment" {
  40619. /** @hidden */
  40620. export var passCubePixelShader: {
  40621. name: string;
  40622. shader: string;
  40623. };
  40624. }
  40625. declare module "babylonjs/PostProcesses/passPostProcess" {
  40626. import { Nullable } from "babylonjs/types";
  40627. import { Camera } from "babylonjs/Cameras/camera";
  40628. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40629. import { Engine } from "babylonjs/Engines/engine";
  40630. import "babylonjs/Shaders/pass.fragment";
  40631. import "babylonjs/Shaders/passCube.fragment";
  40632. /**
  40633. * PassPostProcess which produces an output the same as it's input
  40634. */
  40635. export class PassPostProcess extends PostProcess {
  40636. /**
  40637. * Creates the PassPostProcess
  40638. * @param name The name of the effect.
  40639. * @param options The required width/height ratio to downsize to before computing the render pass.
  40640. * @param camera The camera to apply the render pass to.
  40641. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40642. * @param engine The engine which the post process will be applied. (default: current engine)
  40643. * @param reusable If the post process can be reused on the same frame. (default: false)
  40644. * @param textureType The type of texture to be used when performing the post processing.
  40645. * @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)
  40646. */
  40647. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40648. }
  40649. /**
  40650. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  40651. */
  40652. export class PassCubePostProcess extends PostProcess {
  40653. private _face;
  40654. /**
  40655. * Gets or sets the cube face to display.
  40656. * * 0 is +X
  40657. * * 1 is -X
  40658. * * 2 is +Y
  40659. * * 3 is -Y
  40660. * * 4 is +Z
  40661. * * 5 is -Z
  40662. */
  40663. face: number;
  40664. /**
  40665. * Creates the PassCubePostProcess
  40666. * @param name The name of the effect.
  40667. * @param options The required width/height ratio to downsize to before computing the render pass.
  40668. * @param camera The camera to apply the render pass to.
  40669. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40670. * @param engine The engine which the post process will be applied. (default: current engine)
  40671. * @param reusable If the post process can be reused on the same frame. (default: false)
  40672. * @param textureType The type of texture to be used when performing the post processing.
  40673. * @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)
  40674. */
  40675. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  40676. }
  40677. }
  40678. declare module "babylonjs/Shaders/anaglyph.fragment" {
  40679. /** @hidden */
  40680. export var anaglyphPixelShader: {
  40681. name: string;
  40682. shader: string;
  40683. };
  40684. }
  40685. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  40686. import { Engine } from "babylonjs/Engines/engine";
  40687. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40688. import { Camera } from "babylonjs/Cameras/camera";
  40689. import "babylonjs/Shaders/anaglyph.fragment";
  40690. /**
  40691. * Postprocess used to generate anaglyphic rendering
  40692. */
  40693. export class AnaglyphPostProcess extends PostProcess {
  40694. private _passedProcess;
  40695. /**
  40696. * Creates a new AnaglyphPostProcess
  40697. * @param name defines postprocess name
  40698. * @param options defines creation options or target ratio scale
  40699. * @param rigCameras defines cameras using this postprocess
  40700. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  40701. * @param engine defines hosting engine
  40702. * @param reusable defines if the postprocess will be reused multiple times per frame
  40703. */
  40704. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  40705. }
  40706. }
  40707. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  40708. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  40709. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40710. import { Scene } from "babylonjs/scene";
  40711. import { Vector3 } from "babylonjs/Maths/math.vector";
  40712. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40713. /**
  40714. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  40715. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40716. */
  40717. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  40718. /**
  40719. * Creates a new AnaglyphArcRotateCamera
  40720. * @param name defines camera name
  40721. * @param alpha defines alpha angle (in radians)
  40722. * @param beta defines beta angle (in radians)
  40723. * @param radius defines radius
  40724. * @param target defines camera target
  40725. * @param interaxialDistance defines distance between each color axis
  40726. * @param scene defines the hosting scene
  40727. */
  40728. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  40729. /**
  40730. * Gets camera class name
  40731. * @returns AnaglyphArcRotateCamera
  40732. */
  40733. getClassName(): string;
  40734. }
  40735. }
  40736. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  40737. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40738. import { Scene } from "babylonjs/scene";
  40739. import { Vector3 } from "babylonjs/Maths/math.vector";
  40740. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40741. /**
  40742. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  40743. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40744. */
  40745. export class AnaglyphFreeCamera extends FreeCamera {
  40746. /**
  40747. * Creates a new AnaglyphFreeCamera
  40748. * @param name defines camera name
  40749. * @param position defines initial position
  40750. * @param interaxialDistance defines distance between each color axis
  40751. * @param scene defines the hosting scene
  40752. */
  40753. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40754. /**
  40755. * Gets camera class name
  40756. * @returns AnaglyphFreeCamera
  40757. */
  40758. getClassName(): string;
  40759. }
  40760. }
  40761. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  40762. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40763. import { Scene } from "babylonjs/scene";
  40764. import { Vector3 } from "babylonjs/Maths/math.vector";
  40765. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40766. /**
  40767. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  40768. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40769. */
  40770. export class AnaglyphGamepadCamera extends GamepadCamera {
  40771. /**
  40772. * Creates a new AnaglyphGamepadCamera
  40773. * @param name defines camera name
  40774. * @param position defines initial position
  40775. * @param interaxialDistance defines distance between each color axis
  40776. * @param scene defines the hosting scene
  40777. */
  40778. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40779. /**
  40780. * Gets camera class name
  40781. * @returns AnaglyphGamepadCamera
  40782. */
  40783. getClassName(): string;
  40784. }
  40785. }
  40786. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  40787. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40788. import { Scene } from "babylonjs/scene";
  40789. import { Vector3 } from "babylonjs/Maths/math.vector";
  40790. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  40791. /**
  40792. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  40793. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  40794. */
  40795. export class AnaglyphUniversalCamera extends UniversalCamera {
  40796. /**
  40797. * Creates a new AnaglyphUniversalCamera
  40798. * @param name defines camera name
  40799. * @param position defines initial position
  40800. * @param interaxialDistance defines distance between each color axis
  40801. * @param scene defines the hosting scene
  40802. */
  40803. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  40804. /**
  40805. * Gets camera class name
  40806. * @returns AnaglyphUniversalCamera
  40807. */
  40808. getClassName(): string;
  40809. }
  40810. }
  40811. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  40812. /** @hidden */
  40813. export var stereoscopicInterlacePixelShader: {
  40814. name: string;
  40815. shader: string;
  40816. };
  40817. }
  40818. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  40819. import { Camera } from "babylonjs/Cameras/camera";
  40820. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40821. import { Engine } from "babylonjs/Engines/engine";
  40822. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  40823. /**
  40824. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  40825. */
  40826. export class StereoscopicInterlacePostProcess extends PostProcess {
  40827. private _stepSize;
  40828. private _passedProcess;
  40829. /**
  40830. * Initializes a StereoscopicInterlacePostProcess
  40831. * @param name The name of the effect.
  40832. * @param rigCameras The rig cameras to be appled to the post process
  40833. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  40834. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  40835. * @param engine The engine which the post process will be applied. (default: current engine)
  40836. * @param reusable If the post process can be reused on the same frame. (default: false)
  40837. */
  40838. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  40839. }
  40840. }
  40841. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  40842. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  40843. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40844. import { Scene } from "babylonjs/scene";
  40845. import { Vector3 } from "babylonjs/Maths/math.vector";
  40846. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40847. /**
  40848. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  40849. * @see http://doc.babylonjs.com/features/cameras
  40850. */
  40851. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  40852. /**
  40853. * Creates a new StereoscopicArcRotateCamera
  40854. * @param name defines camera name
  40855. * @param alpha defines alpha angle (in radians)
  40856. * @param beta defines beta angle (in radians)
  40857. * @param radius defines radius
  40858. * @param target defines camera target
  40859. * @param interaxialDistance defines distance between each color axis
  40860. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40861. * @param scene defines the hosting scene
  40862. */
  40863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40864. /**
  40865. * Gets camera class name
  40866. * @returns StereoscopicArcRotateCamera
  40867. */
  40868. getClassName(): string;
  40869. }
  40870. }
  40871. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  40872. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40873. import { Scene } from "babylonjs/scene";
  40874. import { Vector3 } from "babylonjs/Maths/math.vector";
  40875. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40876. /**
  40877. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  40878. * @see http://doc.babylonjs.com/features/cameras
  40879. */
  40880. export class StereoscopicFreeCamera extends FreeCamera {
  40881. /**
  40882. * Creates a new StereoscopicFreeCamera
  40883. * @param name defines camera name
  40884. * @param position defines initial position
  40885. * @param interaxialDistance defines distance between each color axis
  40886. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40887. * @param scene defines the hosting scene
  40888. */
  40889. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40890. /**
  40891. * Gets camera class name
  40892. * @returns StereoscopicFreeCamera
  40893. */
  40894. getClassName(): string;
  40895. }
  40896. }
  40897. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  40898. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  40899. import { Scene } from "babylonjs/scene";
  40900. import { Vector3 } from "babylonjs/Maths/math.vector";
  40901. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40902. /**
  40903. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  40904. * @see http://doc.babylonjs.com/features/cameras
  40905. */
  40906. export class StereoscopicGamepadCamera extends GamepadCamera {
  40907. /**
  40908. * Creates a new StereoscopicGamepadCamera
  40909. * @param name defines camera name
  40910. * @param position defines initial position
  40911. * @param interaxialDistance defines distance between each color axis
  40912. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40913. * @param scene defines the hosting scene
  40914. */
  40915. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40916. /**
  40917. * Gets camera class name
  40918. * @returns StereoscopicGamepadCamera
  40919. */
  40920. getClassName(): string;
  40921. }
  40922. }
  40923. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  40924. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  40925. import { Scene } from "babylonjs/scene";
  40926. import { Vector3 } from "babylonjs/Maths/math.vector";
  40927. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  40928. /**
  40929. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  40930. * @see http://doc.babylonjs.com/features/cameras
  40931. */
  40932. export class StereoscopicUniversalCamera extends UniversalCamera {
  40933. /**
  40934. * Creates a new StereoscopicUniversalCamera
  40935. * @param name defines camera name
  40936. * @param position defines initial position
  40937. * @param interaxialDistance defines distance between each color axis
  40938. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  40939. * @param scene defines the hosting scene
  40940. */
  40941. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  40942. /**
  40943. * Gets camera class name
  40944. * @returns StereoscopicUniversalCamera
  40945. */
  40946. getClassName(): string;
  40947. }
  40948. }
  40949. declare module "babylonjs/Cameras/Stereoscopic/index" {
  40950. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  40951. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  40952. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  40953. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  40954. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  40955. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  40956. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  40957. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  40958. }
  40959. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  40960. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  40961. import { Scene } from "babylonjs/scene";
  40962. import { Vector3 } from "babylonjs/Maths/math.vector";
  40963. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  40964. /**
  40965. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  40966. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40967. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40968. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40969. */
  40970. export class VirtualJoysticksCamera extends FreeCamera {
  40971. /**
  40972. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  40973. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  40974. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  40975. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  40976. * @param name Define the name of the camera in the scene
  40977. * @param position Define the start position of the camera in the scene
  40978. * @param scene Define the scene the camera belongs to
  40979. */
  40980. constructor(name: string, position: Vector3, scene: Scene);
  40981. /**
  40982. * Gets the current object class name.
  40983. * @return the class name
  40984. */
  40985. getClassName(): string;
  40986. }
  40987. }
  40988. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  40989. import { Matrix } from "babylonjs/Maths/math.vector";
  40990. /**
  40991. * This represents all the required metrics to create a VR camera.
  40992. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  40993. */
  40994. export class VRCameraMetrics {
  40995. /**
  40996. * Define the horizontal resolution off the screen.
  40997. */
  40998. hResolution: number;
  40999. /**
  41000. * Define the vertical resolution off the screen.
  41001. */
  41002. vResolution: number;
  41003. /**
  41004. * Define the horizontal screen size.
  41005. */
  41006. hScreenSize: number;
  41007. /**
  41008. * Define the vertical screen size.
  41009. */
  41010. vScreenSize: number;
  41011. /**
  41012. * Define the vertical screen center position.
  41013. */
  41014. vScreenCenter: number;
  41015. /**
  41016. * Define the distance of the eyes to the screen.
  41017. */
  41018. eyeToScreenDistance: number;
  41019. /**
  41020. * Define the distance between both lenses
  41021. */
  41022. lensSeparationDistance: number;
  41023. /**
  41024. * Define the distance between both viewer's eyes.
  41025. */
  41026. interpupillaryDistance: number;
  41027. /**
  41028. * Define the distortion factor of the VR postprocess.
  41029. * Please, touch with care.
  41030. */
  41031. distortionK: number[];
  41032. /**
  41033. * Define the chromatic aberration correction factors for the VR post process.
  41034. */
  41035. chromaAbCorrection: number[];
  41036. /**
  41037. * Define the scale factor of the post process.
  41038. * The smaller the better but the slower.
  41039. */
  41040. postProcessScaleFactor: number;
  41041. /**
  41042. * Define an offset for the lens center.
  41043. */
  41044. lensCenterOffset: number;
  41045. /**
  41046. * Define if the current vr camera should compensate the distortion of the lense or not.
  41047. */
  41048. compensateDistortion: boolean;
  41049. /**
  41050. * Defines if multiview should be enabled when rendering (Default: false)
  41051. */
  41052. multiviewEnabled: boolean;
  41053. /**
  41054. * Gets the rendering aspect ratio based on the provided resolutions.
  41055. */
  41056. readonly aspectRatio: number;
  41057. /**
  41058. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  41059. */
  41060. readonly aspectRatioFov: number;
  41061. /**
  41062. * @hidden
  41063. */
  41064. readonly leftHMatrix: Matrix;
  41065. /**
  41066. * @hidden
  41067. */
  41068. readonly rightHMatrix: Matrix;
  41069. /**
  41070. * @hidden
  41071. */
  41072. readonly leftPreViewMatrix: Matrix;
  41073. /**
  41074. * @hidden
  41075. */
  41076. readonly rightPreViewMatrix: Matrix;
  41077. /**
  41078. * Get the default VRMetrics based on the most generic setup.
  41079. * @returns the default vr metrics
  41080. */
  41081. static GetDefault(): VRCameraMetrics;
  41082. }
  41083. }
  41084. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  41085. /** @hidden */
  41086. export var vrDistortionCorrectionPixelShader: {
  41087. name: string;
  41088. shader: string;
  41089. };
  41090. }
  41091. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  41092. import { Camera } from "babylonjs/Cameras/camera";
  41093. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41094. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  41095. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  41096. /**
  41097. * VRDistortionCorrectionPostProcess used for mobile VR
  41098. */
  41099. export class VRDistortionCorrectionPostProcess extends PostProcess {
  41100. private _isRightEye;
  41101. private _distortionFactors;
  41102. private _postProcessScaleFactor;
  41103. private _lensCenterOffset;
  41104. private _scaleIn;
  41105. private _scaleFactor;
  41106. private _lensCenter;
  41107. /**
  41108. * Initializes the VRDistortionCorrectionPostProcess
  41109. * @param name The name of the effect.
  41110. * @param camera The camera to apply the render pass to.
  41111. * @param isRightEye If this is for the right eye distortion
  41112. * @param vrMetrics All the required metrics for the VR camera
  41113. */
  41114. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  41115. }
  41116. }
  41117. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  41118. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  41119. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41120. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41121. import { Scene } from "babylonjs/scene";
  41122. import { Vector3 } from "babylonjs/Maths/math.vector";
  41123. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  41124. import "babylonjs/Cameras/RigModes/vrRigMode";
  41125. /**
  41126. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  41127. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41128. */
  41129. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  41130. /**
  41131. * Creates a new VRDeviceOrientationArcRotateCamera
  41132. * @param name defines camera name
  41133. * @param alpha defines the camera rotation along the logitudinal axis
  41134. * @param beta defines the camera rotation along the latitudinal axis
  41135. * @param radius defines the camera distance from its target
  41136. * @param target defines the camera target
  41137. * @param scene defines the scene the camera belongs to
  41138. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41139. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41140. */
  41141. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41142. /**
  41143. * Gets camera class name
  41144. * @returns VRDeviceOrientationArcRotateCamera
  41145. */
  41146. getClassName(): string;
  41147. }
  41148. }
  41149. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  41150. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  41151. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41152. import { Scene } from "babylonjs/scene";
  41153. import { Vector3 } from "babylonjs/Maths/math.vector";
  41154. import "babylonjs/Cameras/RigModes/vrRigMode";
  41155. /**
  41156. * Camera used to simulate VR rendering (based on FreeCamera)
  41157. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41158. */
  41159. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  41160. /**
  41161. * Creates a new VRDeviceOrientationFreeCamera
  41162. * @param name defines camera name
  41163. * @param position defines the start position of the camera
  41164. * @param scene defines the scene the camera belongs to
  41165. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41166. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41167. */
  41168. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41169. /**
  41170. * Gets camera class name
  41171. * @returns VRDeviceOrientationFreeCamera
  41172. */
  41173. getClassName(): string;
  41174. }
  41175. }
  41176. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  41177. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41178. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  41179. import { Scene } from "babylonjs/scene";
  41180. import { Vector3 } from "babylonjs/Maths/math.vector";
  41181. import "babylonjs/Gamepads/gamepadSceneComponent";
  41182. /**
  41183. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  41184. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  41185. */
  41186. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  41187. /**
  41188. * Creates a new VRDeviceOrientationGamepadCamera
  41189. * @param name defines camera name
  41190. * @param position defines the start position of the camera
  41191. * @param scene defines the scene the camera belongs to
  41192. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  41193. * @param vrCameraMetrics defines the vr metrics associated to the camera
  41194. */
  41195. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  41196. /**
  41197. * Gets camera class name
  41198. * @returns VRDeviceOrientationGamepadCamera
  41199. */
  41200. getClassName(): string;
  41201. }
  41202. }
  41203. declare module "babylonjs/Materials/pushMaterial" {
  41204. import { Nullable } from "babylonjs/types";
  41205. import { Scene } from "babylonjs/scene";
  41206. import { Matrix } from "babylonjs/Maths/math.vector";
  41207. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41208. import { Mesh } from "babylonjs/Meshes/mesh";
  41209. import { Material } from "babylonjs/Materials/material";
  41210. import { Effect } from "babylonjs/Materials/effect";
  41211. /**
  41212. * Base class of materials working in push mode in babylon JS
  41213. * @hidden
  41214. */
  41215. export class PushMaterial extends Material {
  41216. protected _activeEffect: Effect;
  41217. protected _normalMatrix: Matrix;
  41218. /**
  41219. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  41220. * This means that the material can keep using a previous shader while a new one is being compiled.
  41221. * This is mostly used when shader parallel compilation is supported (true by default)
  41222. */
  41223. allowShaderHotSwapping: boolean;
  41224. constructor(name: string, scene: Scene);
  41225. getEffect(): Effect;
  41226. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  41227. /**
  41228. * Binds the given world matrix to the active effect
  41229. *
  41230. * @param world the matrix to bind
  41231. */
  41232. bindOnlyWorldMatrix(world: Matrix): void;
  41233. /**
  41234. * Binds the given normal matrix to the active effect
  41235. *
  41236. * @param normalMatrix the matrix to bind
  41237. */
  41238. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  41239. bind(world: Matrix, mesh?: Mesh): void;
  41240. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  41241. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  41242. }
  41243. }
  41244. declare module "babylonjs/Materials/materialFlags" {
  41245. /**
  41246. * This groups all the flags used to control the materials channel.
  41247. */
  41248. export class MaterialFlags {
  41249. private static _DiffuseTextureEnabled;
  41250. /**
  41251. * Are diffuse textures enabled in the application.
  41252. */
  41253. static DiffuseTextureEnabled: boolean;
  41254. private static _AmbientTextureEnabled;
  41255. /**
  41256. * Are ambient textures enabled in the application.
  41257. */
  41258. static AmbientTextureEnabled: boolean;
  41259. private static _OpacityTextureEnabled;
  41260. /**
  41261. * Are opacity textures enabled in the application.
  41262. */
  41263. static OpacityTextureEnabled: boolean;
  41264. private static _ReflectionTextureEnabled;
  41265. /**
  41266. * Are reflection textures enabled in the application.
  41267. */
  41268. static ReflectionTextureEnabled: boolean;
  41269. private static _EmissiveTextureEnabled;
  41270. /**
  41271. * Are emissive textures enabled in the application.
  41272. */
  41273. static EmissiveTextureEnabled: boolean;
  41274. private static _SpecularTextureEnabled;
  41275. /**
  41276. * Are specular textures enabled in the application.
  41277. */
  41278. static SpecularTextureEnabled: boolean;
  41279. private static _BumpTextureEnabled;
  41280. /**
  41281. * Are bump textures enabled in the application.
  41282. */
  41283. static BumpTextureEnabled: boolean;
  41284. private static _LightmapTextureEnabled;
  41285. /**
  41286. * Are lightmap textures enabled in the application.
  41287. */
  41288. static LightmapTextureEnabled: boolean;
  41289. private static _RefractionTextureEnabled;
  41290. /**
  41291. * Are refraction textures enabled in the application.
  41292. */
  41293. static RefractionTextureEnabled: boolean;
  41294. private static _ColorGradingTextureEnabled;
  41295. /**
  41296. * Are color grading textures enabled in the application.
  41297. */
  41298. static ColorGradingTextureEnabled: boolean;
  41299. private static _FresnelEnabled;
  41300. /**
  41301. * Are fresnels enabled in the application.
  41302. */
  41303. static FresnelEnabled: boolean;
  41304. private static _ClearCoatTextureEnabled;
  41305. /**
  41306. * Are clear coat textures enabled in the application.
  41307. */
  41308. static ClearCoatTextureEnabled: boolean;
  41309. private static _ClearCoatBumpTextureEnabled;
  41310. /**
  41311. * Are clear coat bump textures enabled in the application.
  41312. */
  41313. static ClearCoatBumpTextureEnabled: boolean;
  41314. private static _ClearCoatTintTextureEnabled;
  41315. /**
  41316. * Are clear coat tint textures enabled in the application.
  41317. */
  41318. static ClearCoatTintTextureEnabled: boolean;
  41319. private static _SheenTextureEnabled;
  41320. /**
  41321. * Are sheen textures enabled in the application.
  41322. */
  41323. static SheenTextureEnabled: boolean;
  41324. private static _AnisotropicTextureEnabled;
  41325. /**
  41326. * Are anisotropic textures enabled in the application.
  41327. */
  41328. static AnisotropicTextureEnabled: boolean;
  41329. private static _ThicknessTextureEnabled;
  41330. /**
  41331. * Are thickness textures enabled in the application.
  41332. */
  41333. static ThicknessTextureEnabled: boolean;
  41334. }
  41335. }
  41336. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  41337. /** @hidden */
  41338. export var defaultFragmentDeclaration: {
  41339. name: string;
  41340. shader: string;
  41341. };
  41342. }
  41343. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  41344. /** @hidden */
  41345. export var defaultUboDeclaration: {
  41346. name: string;
  41347. shader: string;
  41348. };
  41349. }
  41350. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  41351. /** @hidden */
  41352. export var lightFragmentDeclaration: {
  41353. name: string;
  41354. shader: string;
  41355. };
  41356. }
  41357. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  41358. /** @hidden */
  41359. export var lightUboDeclaration: {
  41360. name: string;
  41361. shader: string;
  41362. };
  41363. }
  41364. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  41365. /** @hidden */
  41366. export var lightsFragmentFunctions: {
  41367. name: string;
  41368. shader: string;
  41369. };
  41370. }
  41371. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  41372. /** @hidden */
  41373. export var shadowsFragmentFunctions: {
  41374. name: string;
  41375. shader: string;
  41376. };
  41377. }
  41378. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  41379. /** @hidden */
  41380. export var fresnelFunction: {
  41381. name: string;
  41382. shader: string;
  41383. };
  41384. }
  41385. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  41386. /** @hidden */
  41387. export var reflectionFunction: {
  41388. name: string;
  41389. shader: string;
  41390. };
  41391. }
  41392. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  41393. /** @hidden */
  41394. export var bumpFragmentFunctions: {
  41395. name: string;
  41396. shader: string;
  41397. };
  41398. }
  41399. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  41400. /** @hidden */
  41401. export var logDepthDeclaration: {
  41402. name: string;
  41403. shader: string;
  41404. };
  41405. }
  41406. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  41407. /** @hidden */
  41408. export var bumpFragment: {
  41409. name: string;
  41410. shader: string;
  41411. };
  41412. }
  41413. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  41414. /** @hidden */
  41415. export var depthPrePass: {
  41416. name: string;
  41417. shader: string;
  41418. };
  41419. }
  41420. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  41421. /** @hidden */
  41422. export var lightFragment: {
  41423. name: string;
  41424. shader: string;
  41425. };
  41426. }
  41427. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  41428. /** @hidden */
  41429. export var logDepthFragment: {
  41430. name: string;
  41431. shader: string;
  41432. };
  41433. }
  41434. declare module "babylonjs/Shaders/default.fragment" {
  41435. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  41436. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41437. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41438. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41439. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41440. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  41441. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  41442. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  41443. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  41444. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  41445. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  41446. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  41447. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  41448. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41449. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  41450. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  41451. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  41452. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  41453. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  41454. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  41455. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  41456. /** @hidden */
  41457. export var defaultPixelShader: {
  41458. name: string;
  41459. shader: string;
  41460. };
  41461. }
  41462. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  41463. /** @hidden */
  41464. export var defaultVertexDeclaration: {
  41465. name: string;
  41466. shader: string;
  41467. };
  41468. }
  41469. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  41470. /** @hidden */
  41471. export var bumpVertexDeclaration: {
  41472. name: string;
  41473. shader: string;
  41474. };
  41475. }
  41476. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  41477. /** @hidden */
  41478. export var bumpVertex: {
  41479. name: string;
  41480. shader: string;
  41481. };
  41482. }
  41483. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  41484. /** @hidden */
  41485. export var fogVertex: {
  41486. name: string;
  41487. shader: string;
  41488. };
  41489. }
  41490. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  41491. /** @hidden */
  41492. export var shadowsVertex: {
  41493. name: string;
  41494. shader: string;
  41495. };
  41496. }
  41497. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  41498. /** @hidden */
  41499. export var pointCloudVertex: {
  41500. name: string;
  41501. shader: string;
  41502. };
  41503. }
  41504. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  41505. /** @hidden */
  41506. export var logDepthVertex: {
  41507. name: string;
  41508. shader: string;
  41509. };
  41510. }
  41511. declare module "babylonjs/Shaders/default.vertex" {
  41512. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  41513. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  41514. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  41515. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  41516. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  41517. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  41518. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  41519. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  41520. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  41521. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  41522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  41523. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  41524. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  41525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  41526. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  41527. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  41528. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  41529. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  41530. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  41531. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  41532. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  41533. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  41534. /** @hidden */
  41535. export var defaultVertexShader: {
  41536. name: string;
  41537. shader: string;
  41538. };
  41539. }
  41540. declare module "babylonjs/Materials/standardMaterial" {
  41541. import { SmartArray } from "babylonjs/Misc/smartArray";
  41542. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  41543. import { Nullable } from "babylonjs/types";
  41544. import { Scene } from "babylonjs/scene";
  41545. import { Matrix } from "babylonjs/Maths/math.vector";
  41546. import { Color3 } from "babylonjs/Maths/math.color";
  41547. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41549. import { Mesh } from "babylonjs/Meshes/mesh";
  41550. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  41551. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  41552. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  41553. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  41554. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  41555. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  41556. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41557. import "babylonjs/Shaders/default.fragment";
  41558. import "babylonjs/Shaders/default.vertex";
  41559. /** @hidden */
  41560. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  41561. MAINUV1: boolean;
  41562. MAINUV2: boolean;
  41563. DIFFUSE: boolean;
  41564. DIFFUSEDIRECTUV: number;
  41565. AMBIENT: boolean;
  41566. AMBIENTDIRECTUV: number;
  41567. OPACITY: boolean;
  41568. OPACITYDIRECTUV: number;
  41569. OPACITYRGB: boolean;
  41570. REFLECTION: boolean;
  41571. EMISSIVE: boolean;
  41572. EMISSIVEDIRECTUV: number;
  41573. SPECULAR: boolean;
  41574. SPECULARDIRECTUV: number;
  41575. BUMP: boolean;
  41576. BUMPDIRECTUV: number;
  41577. PARALLAX: boolean;
  41578. PARALLAXOCCLUSION: boolean;
  41579. SPECULAROVERALPHA: boolean;
  41580. CLIPPLANE: boolean;
  41581. CLIPPLANE2: boolean;
  41582. CLIPPLANE3: boolean;
  41583. CLIPPLANE4: boolean;
  41584. ALPHATEST: boolean;
  41585. DEPTHPREPASS: boolean;
  41586. ALPHAFROMDIFFUSE: boolean;
  41587. POINTSIZE: boolean;
  41588. FOG: boolean;
  41589. SPECULARTERM: boolean;
  41590. DIFFUSEFRESNEL: boolean;
  41591. OPACITYFRESNEL: boolean;
  41592. REFLECTIONFRESNEL: boolean;
  41593. REFRACTIONFRESNEL: boolean;
  41594. EMISSIVEFRESNEL: boolean;
  41595. FRESNEL: boolean;
  41596. NORMAL: boolean;
  41597. UV1: boolean;
  41598. UV2: boolean;
  41599. VERTEXCOLOR: boolean;
  41600. VERTEXALPHA: boolean;
  41601. NUM_BONE_INFLUENCERS: number;
  41602. BonesPerMesh: number;
  41603. BONETEXTURE: boolean;
  41604. INSTANCES: boolean;
  41605. GLOSSINESS: boolean;
  41606. ROUGHNESS: boolean;
  41607. EMISSIVEASILLUMINATION: boolean;
  41608. LINKEMISSIVEWITHDIFFUSE: boolean;
  41609. REFLECTIONFRESNELFROMSPECULAR: boolean;
  41610. LIGHTMAP: boolean;
  41611. LIGHTMAPDIRECTUV: number;
  41612. OBJECTSPACE_NORMALMAP: boolean;
  41613. USELIGHTMAPASSHADOWMAP: boolean;
  41614. REFLECTIONMAP_3D: boolean;
  41615. REFLECTIONMAP_SPHERICAL: boolean;
  41616. REFLECTIONMAP_PLANAR: boolean;
  41617. REFLECTIONMAP_CUBIC: boolean;
  41618. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  41619. REFLECTIONMAP_PROJECTION: boolean;
  41620. REFLECTIONMAP_SKYBOX: boolean;
  41621. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  41622. REFLECTIONMAP_EXPLICIT: boolean;
  41623. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  41624. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  41625. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  41626. INVERTCUBICMAP: boolean;
  41627. LOGARITHMICDEPTH: boolean;
  41628. REFRACTION: boolean;
  41629. REFRACTIONMAP_3D: boolean;
  41630. REFLECTIONOVERALPHA: boolean;
  41631. TWOSIDEDLIGHTING: boolean;
  41632. SHADOWFLOAT: boolean;
  41633. MORPHTARGETS: boolean;
  41634. MORPHTARGETS_NORMAL: boolean;
  41635. MORPHTARGETS_TANGENT: boolean;
  41636. MORPHTARGETS_UV: boolean;
  41637. NUM_MORPH_INFLUENCERS: number;
  41638. NONUNIFORMSCALING: boolean;
  41639. PREMULTIPLYALPHA: boolean;
  41640. IMAGEPROCESSING: boolean;
  41641. VIGNETTE: boolean;
  41642. VIGNETTEBLENDMODEMULTIPLY: boolean;
  41643. VIGNETTEBLENDMODEOPAQUE: boolean;
  41644. TONEMAPPING: boolean;
  41645. TONEMAPPING_ACES: boolean;
  41646. CONTRAST: boolean;
  41647. COLORCURVES: boolean;
  41648. COLORGRADING: boolean;
  41649. COLORGRADING3D: boolean;
  41650. SAMPLER3DGREENDEPTH: boolean;
  41651. SAMPLER3DBGRMAP: boolean;
  41652. IMAGEPROCESSINGPOSTPROCESS: boolean;
  41653. MULTIVIEW: boolean;
  41654. /**
  41655. * If the reflection texture on this material is in linear color space
  41656. * @hidden
  41657. */
  41658. IS_REFLECTION_LINEAR: boolean;
  41659. /**
  41660. * If the refraction texture on this material is in linear color space
  41661. * @hidden
  41662. */
  41663. IS_REFRACTION_LINEAR: boolean;
  41664. EXPOSURE: boolean;
  41665. constructor();
  41666. setReflectionMode(modeToEnable: string): void;
  41667. }
  41668. /**
  41669. * This is the default material used in Babylon. It is the best trade off between quality
  41670. * and performances.
  41671. * @see http://doc.babylonjs.com/babylon101/materials
  41672. */
  41673. export class StandardMaterial extends PushMaterial {
  41674. private _diffuseTexture;
  41675. /**
  41676. * The basic texture of the material as viewed under a light.
  41677. */
  41678. diffuseTexture: Nullable<BaseTexture>;
  41679. private _ambientTexture;
  41680. /**
  41681. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  41682. */
  41683. ambientTexture: Nullable<BaseTexture>;
  41684. private _opacityTexture;
  41685. /**
  41686. * Define the transparency of the material from a texture.
  41687. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  41688. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  41689. */
  41690. opacityTexture: Nullable<BaseTexture>;
  41691. private _reflectionTexture;
  41692. /**
  41693. * Define the texture used to display the reflection.
  41694. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41695. */
  41696. reflectionTexture: Nullable<BaseTexture>;
  41697. private _emissiveTexture;
  41698. /**
  41699. * Define texture of the material as if self lit.
  41700. * This will be mixed in the final result even in the absence of light.
  41701. */
  41702. emissiveTexture: Nullable<BaseTexture>;
  41703. private _specularTexture;
  41704. /**
  41705. * Define how the color and intensity of the highlight given by the light in the material.
  41706. */
  41707. specularTexture: Nullable<BaseTexture>;
  41708. private _bumpTexture;
  41709. /**
  41710. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  41711. * 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.
  41712. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  41713. */
  41714. bumpTexture: Nullable<BaseTexture>;
  41715. private _lightmapTexture;
  41716. /**
  41717. * Complex lighting can be computationally expensive to compute at runtime.
  41718. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  41719. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  41720. */
  41721. lightmapTexture: Nullable<BaseTexture>;
  41722. private _refractionTexture;
  41723. /**
  41724. * Define the texture used to display the refraction.
  41725. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41726. */
  41727. refractionTexture: Nullable<BaseTexture>;
  41728. /**
  41729. * The color of the material lit by the environmental background lighting.
  41730. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  41731. */
  41732. ambientColor: Color3;
  41733. /**
  41734. * The basic color of the material as viewed under a light.
  41735. */
  41736. diffuseColor: Color3;
  41737. /**
  41738. * Define how the color and intensity of the highlight given by the light in the material.
  41739. */
  41740. specularColor: Color3;
  41741. /**
  41742. * Define the color of the material as if self lit.
  41743. * This will be mixed in the final result even in the absence of light.
  41744. */
  41745. emissiveColor: Color3;
  41746. /**
  41747. * Defines how sharp are the highlights in the material.
  41748. * The bigger the value the sharper giving a more glossy feeling to the result.
  41749. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  41750. */
  41751. specularPower: number;
  41752. private _useAlphaFromDiffuseTexture;
  41753. /**
  41754. * Does the transparency come from the diffuse texture alpha channel.
  41755. */
  41756. useAlphaFromDiffuseTexture: boolean;
  41757. private _useEmissiveAsIllumination;
  41758. /**
  41759. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  41760. */
  41761. useEmissiveAsIllumination: boolean;
  41762. private _linkEmissiveWithDiffuse;
  41763. /**
  41764. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  41765. * the emissive level when the final color is close to one.
  41766. */
  41767. linkEmissiveWithDiffuse: boolean;
  41768. private _useSpecularOverAlpha;
  41769. /**
  41770. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  41771. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  41772. */
  41773. useSpecularOverAlpha: boolean;
  41774. private _useReflectionOverAlpha;
  41775. /**
  41776. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  41777. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  41778. */
  41779. useReflectionOverAlpha: boolean;
  41780. private _disableLighting;
  41781. /**
  41782. * Does lights from the scene impacts this material.
  41783. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  41784. */
  41785. disableLighting: boolean;
  41786. private _useObjectSpaceNormalMap;
  41787. /**
  41788. * Allows using an object space normal map (instead of tangent space).
  41789. */
  41790. useObjectSpaceNormalMap: boolean;
  41791. private _useParallax;
  41792. /**
  41793. * Is parallax enabled or not.
  41794. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41795. */
  41796. useParallax: boolean;
  41797. private _useParallaxOcclusion;
  41798. /**
  41799. * Is parallax occlusion enabled or not.
  41800. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  41801. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  41802. */
  41803. useParallaxOcclusion: boolean;
  41804. /**
  41805. * 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.
  41806. */
  41807. parallaxScaleBias: number;
  41808. private _roughness;
  41809. /**
  41810. * Helps to define how blurry the reflections should appears in the material.
  41811. */
  41812. roughness: number;
  41813. /**
  41814. * In case of refraction, define the value of the index of refraction.
  41815. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41816. */
  41817. indexOfRefraction: number;
  41818. /**
  41819. * Invert the refraction texture alongside the y axis.
  41820. * It can be useful with procedural textures or probe for instance.
  41821. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  41822. */
  41823. invertRefractionY: boolean;
  41824. /**
  41825. * Defines the alpha limits in alpha test mode.
  41826. */
  41827. alphaCutOff: number;
  41828. private _useLightmapAsShadowmap;
  41829. /**
  41830. * In case of light mapping, define whether the map contains light or shadow informations.
  41831. */
  41832. useLightmapAsShadowmap: boolean;
  41833. private _diffuseFresnelParameters;
  41834. /**
  41835. * Define the diffuse fresnel parameters of the material.
  41836. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41837. */
  41838. diffuseFresnelParameters: FresnelParameters;
  41839. private _opacityFresnelParameters;
  41840. /**
  41841. * Define the opacity fresnel parameters of the material.
  41842. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41843. */
  41844. opacityFresnelParameters: FresnelParameters;
  41845. private _reflectionFresnelParameters;
  41846. /**
  41847. * Define the reflection fresnel parameters of the material.
  41848. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41849. */
  41850. reflectionFresnelParameters: FresnelParameters;
  41851. private _refractionFresnelParameters;
  41852. /**
  41853. * Define the refraction fresnel parameters of the material.
  41854. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41855. */
  41856. refractionFresnelParameters: FresnelParameters;
  41857. private _emissiveFresnelParameters;
  41858. /**
  41859. * Define the emissive fresnel parameters of the material.
  41860. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41861. */
  41862. emissiveFresnelParameters: FresnelParameters;
  41863. private _useReflectionFresnelFromSpecular;
  41864. /**
  41865. * If true automatically deducts the fresnels values from the material specularity.
  41866. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  41867. */
  41868. useReflectionFresnelFromSpecular: boolean;
  41869. private _useGlossinessFromSpecularMapAlpha;
  41870. /**
  41871. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  41872. */
  41873. useGlossinessFromSpecularMapAlpha: boolean;
  41874. private _maxSimultaneousLights;
  41875. /**
  41876. * Defines the maximum number of lights that can be used in the material
  41877. */
  41878. maxSimultaneousLights: number;
  41879. private _invertNormalMapX;
  41880. /**
  41881. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  41882. */
  41883. invertNormalMapX: boolean;
  41884. private _invertNormalMapY;
  41885. /**
  41886. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  41887. */
  41888. invertNormalMapY: boolean;
  41889. private _twoSidedLighting;
  41890. /**
  41891. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  41892. */
  41893. twoSidedLighting: boolean;
  41894. /**
  41895. * Default configuration related to image processing available in the standard Material.
  41896. */
  41897. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41898. /**
  41899. * Gets the image processing configuration used either in this material.
  41900. */
  41901. /**
  41902. * Sets the Default image processing configuration used either in the this material.
  41903. *
  41904. * If sets to null, the scene one is in use.
  41905. */
  41906. imageProcessingConfiguration: ImageProcessingConfiguration;
  41907. /**
  41908. * Keep track of the image processing observer to allow dispose and replace.
  41909. */
  41910. private _imageProcessingObserver;
  41911. /**
  41912. * Attaches a new image processing configuration to the Standard Material.
  41913. * @param configuration
  41914. */
  41915. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  41916. /**
  41917. * Gets wether the color curves effect is enabled.
  41918. */
  41919. /**
  41920. * Sets wether the color curves effect is enabled.
  41921. */
  41922. cameraColorCurvesEnabled: boolean;
  41923. /**
  41924. * Gets wether the color grading effect is enabled.
  41925. */
  41926. /**
  41927. * Gets wether the color grading effect is enabled.
  41928. */
  41929. cameraColorGradingEnabled: boolean;
  41930. /**
  41931. * Gets wether tonemapping is enabled or not.
  41932. */
  41933. /**
  41934. * Sets wether tonemapping is enabled or not
  41935. */
  41936. cameraToneMappingEnabled: boolean;
  41937. /**
  41938. * The camera exposure used on this material.
  41939. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41940. * This corresponds to a photographic exposure.
  41941. */
  41942. /**
  41943. * The camera exposure used on this material.
  41944. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  41945. * This corresponds to a photographic exposure.
  41946. */
  41947. cameraExposure: number;
  41948. /**
  41949. * Gets The camera contrast used on this material.
  41950. */
  41951. /**
  41952. * Sets The camera contrast used on this material.
  41953. */
  41954. cameraContrast: number;
  41955. /**
  41956. * Gets the Color Grading 2D Lookup Texture.
  41957. */
  41958. /**
  41959. * Sets the Color Grading 2D Lookup Texture.
  41960. */
  41961. cameraColorGradingTexture: Nullable<BaseTexture>;
  41962. /**
  41963. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41964. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41965. * 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;
  41966. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41967. */
  41968. /**
  41969. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  41970. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  41971. * 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;
  41972. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  41973. */
  41974. cameraColorCurves: Nullable<ColorCurves>;
  41975. /**
  41976. * Custom callback helping to override the default shader used in the material.
  41977. */
  41978. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  41979. protected _renderTargets: SmartArray<RenderTargetTexture>;
  41980. protected _worldViewProjectionMatrix: Matrix;
  41981. protected _globalAmbientColor: Color3;
  41982. protected _useLogarithmicDepth: boolean;
  41983. protected _rebuildInParallel: boolean;
  41984. /**
  41985. * Instantiates a new standard material.
  41986. * This is the default material used in Babylon. It is the best trade off between quality
  41987. * and performances.
  41988. * @see http://doc.babylonjs.com/babylon101/materials
  41989. * @param name Define the name of the material in the scene
  41990. * @param scene Define the scene the material belong to
  41991. */
  41992. constructor(name: string, scene: Scene);
  41993. /**
  41994. * Gets a boolean indicating that current material needs to register RTT
  41995. */
  41996. readonly hasRenderTargetTextures: boolean;
  41997. /**
  41998. * Gets the current class name of the material e.g. "StandardMaterial"
  41999. * Mainly use in serialization.
  42000. * @returns the class name
  42001. */
  42002. getClassName(): string;
  42003. /**
  42004. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  42005. * You can try switching to logarithmic depth.
  42006. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  42007. */
  42008. useLogarithmicDepth: boolean;
  42009. /**
  42010. * Specifies if the material will require alpha blending
  42011. * @returns a boolean specifying if alpha blending is needed
  42012. */
  42013. needAlphaBlending(): boolean;
  42014. /**
  42015. * Specifies if this material should be rendered in alpha test mode
  42016. * @returns a boolean specifying if an alpha test is needed.
  42017. */
  42018. needAlphaTesting(): boolean;
  42019. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  42020. /**
  42021. * Get the texture used for alpha test purpose.
  42022. * @returns the diffuse texture in case of the standard material.
  42023. */
  42024. getAlphaTestTexture(): Nullable<BaseTexture>;
  42025. /**
  42026. * Get if the submesh is ready to be used and all its information available.
  42027. * Child classes can use it to update shaders
  42028. * @param mesh defines the mesh to check
  42029. * @param subMesh defines which submesh to check
  42030. * @param useInstances specifies that instances should be used
  42031. * @returns a boolean indicating that the submesh is ready or not
  42032. */
  42033. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  42034. /**
  42035. * Builds the material UBO layouts.
  42036. * Used internally during the effect preparation.
  42037. */
  42038. buildUniformLayout(): void;
  42039. /**
  42040. * Unbinds the material from the mesh
  42041. */
  42042. unbind(): void;
  42043. /**
  42044. * Binds the submesh to this material by preparing the effect and shader to draw
  42045. * @param world defines the world transformation matrix
  42046. * @param mesh defines the mesh containing the submesh
  42047. * @param subMesh defines the submesh to bind the material to
  42048. */
  42049. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  42050. /**
  42051. * Get the list of animatables in the material.
  42052. * @returns the list of animatables object used in the material
  42053. */
  42054. getAnimatables(): IAnimatable[];
  42055. /**
  42056. * Gets the active textures from the material
  42057. * @returns an array of textures
  42058. */
  42059. getActiveTextures(): BaseTexture[];
  42060. /**
  42061. * Specifies if the material uses a texture
  42062. * @param texture defines the texture to check against the material
  42063. * @returns a boolean specifying if the material uses the texture
  42064. */
  42065. hasTexture(texture: BaseTexture): boolean;
  42066. /**
  42067. * Disposes the material
  42068. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  42069. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  42070. */
  42071. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  42072. /**
  42073. * Makes a duplicate of the material, and gives it a new name
  42074. * @param name defines the new name for the duplicated material
  42075. * @returns the cloned material
  42076. */
  42077. clone(name: string): StandardMaterial;
  42078. /**
  42079. * Serializes this material in a JSON representation
  42080. * @returns the serialized material object
  42081. */
  42082. serialize(): any;
  42083. /**
  42084. * Creates a standard material from parsed material data
  42085. * @param source defines the JSON representation of the material
  42086. * @param scene defines the hosting scene
  42087. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  42088. * @returns a new standard material
  42089. */
  42090. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  42091. /**
  42092. * Are diffuse textures enabled in the application.
  42093. */
  42094. static DiffuseTextureEnabled: boolean;
  42095. /**
  42096. * Are ambient textures enabled in the application.
  42097. */
  42098. static AmbientTextureEnabled: boolean;
  42099. /**
  42100. * Are opacity textures enabled in the application.
  42101. */
  42102. static OpacityTextureEnabled: boolean;
  42103. /**
  42104. * Are reflection textures enabled in the application.
  42105. */
  42106. static ReflectionTextureEnabled: boolean;
  42107. /**
  42108. * Are emissive textures enabled in the application.
  42109. */
  42110. static EmissiveTextureEnabled: boolean;
  42111. /**
  42112. * Are specular textures enabled in the application.
  42113. */
  42114. static SpecularTextureEnabled: boolean;
  42115. /**
  42116. * Are bump textures enabled in the application.
  42117. */
  42118. static BumpTextureEnabled: boolean;
  42119. /**
  42120. * Are lightmap textures enabled in the application.
  42121. */
  42122. static LightmapTextureEnabled: boolean;
  42123. /**
  42124. * Are refraction textures enabled in the application.
  42125. */
  42126. static RefractionTextureEnabled: boolean;
  42127. /**
  42128. * Are color grading textures enabled in the application.
  42129. */
  42130. static ColorGradingTextureEnabled: boolean;
  42131. /**
  42132. * Are fresnels enabled in the application.
  42133. */
  42134. static FresnelEnabled: boolean;
  42135. }
  42136. }
  42137. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  42138. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  42139. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  42140. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  42141. /** @hidden */
  42142. export var imageProcessingPixelShader: {
  42143. name: string;
  42144. shader: string;
  42145. };
  42146. }
  42147. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  42148. import { Nullable } from "babylonjs/types";
  42149. import { Color4 } from "babylonjs/Maths/math.color";
  42150. import { Camera } from "babylonjs/Cameras/camera";
  42151. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42152. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  42153. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  42154. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  42155. import { Engine } from "babylonjs/Engines/engine";
  42156. import "babylonjs/Shaders/imageProcessing.fragment";
  42157. import "babylonjs/Shaders/postprocess.vertex";
  42158. /**
  42159. * ImageProcessingPostProcess
  42160. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  42161. */
  42162. export class ImageProcessingPostProcess extends PostProcess {
  42163. /**
  42164. * Default configuration related to image processing available in the PBR Material.
  42165. */
  42166. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  42167. /**
  42168. * Gets the image processing configuration used either in this material.
  42169. */
  42170. /**
  42171. * Sets the Default image processing configuration used either in the this material.
  42172. *
  42173. * If sets to null, the scene one is in use.
  42174. */
  42175. imageProcessingConfiguration: ImageProcessingConfiguration;
  42176. /**
  42177. * Keep track of the image processing observer to allow dispose and replace.
  42178. */
  42179. private _imageProcessingObserver;
  42180. /**
  42181. * Attaches a new image processing configuration to the PBR Material.
  42182. * @param configuration
  42183. */
  42184. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  42185. /**
  42186. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42187. */
  42188. /**
  42189. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  42190. */
  42191. colorCurves: Nullable<ColorCurves>;
  42192. /**
  42193. * Gets wether the color curves effect is enabled.
  42194. */
  42195. /**
  42196. * Sets wether the color curves effect is enabled.
  42197. */
  42198. colorCurvesEnabled: boolean;
  42199. /**
  42200. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42201. */
  42202. /**
  42203. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  42204. */
  42205. colorGradingTexture: Nullable<BaseTexture>;
  42206. /**
  42207. * Gets wether the color grading effect is enabled.
  42208. */
  42209. /**
  42210. * Gets wether the color grading effect is enabled.
  42211. */
  42212. colorGradingEnabled: boolean;
  42213. /**
  42214. * Gets exposure used in the effect.
  42215. */
  42216. /**
  42217. * Sets exposure used in the effect.
  42218. */
  42219. exposure: number;
  42220. /**
  42221. * Gets wether tonemapping is enabled or not.
  42222. */
  42223. /**
  42224. * Sets wether tonemapping is enabled or not
  42225. */
  42226. toneMappingEnabled: boolean;
  42227. /**
  42228. * Gets the type of tone mapping effect.
  42229. */
  42230. /**
  42231. * Sets the type of tone mapping effect.
  42232. */
  42233. toneMappingType: number;
  42234. /**
  42235. * Gets contrast used in the effect.
  42236. */
  42237. /**
  42238. * Sets contrast used in the effect.
  42239. */
  42240. contrast: number;
  42241. /**
  42242. * Gets Vignette stretch size.
  42243. */
  42244. /**
  42245. * Sets Vignette stretch size.
  42246. */
  42247. vignetteStretch: number;
  42248. /**
  42249. * Gets Vignette centre X Offset.
  42250. */
  42251. /**
  42252. * Sets Vignette centre X Offset.
  42253. */
  42254. vignetteCentreX: number;
  42255. /**
  42256. * Gets Vignette centre Y Offset.
  42257. */
  42258. /**
  42259. * Sets Vignette centre Y Offset.
  42260. */
  42261. vignetteCentreY: number;
  42262. /**
  42263. * Gets Vignette weight or intensity of the vignette effect.
  42264. */
  42265. /**
  42266. * Sets Vignette weight or intensity of the vignette effect.
  42267. */
  42268. vignetteWeight: number;
  42269. /**
  42270. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42271. * if vignetteEnabled is set to true.
  42272. */
  42273. /**
  42274. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  42275. * if vignetteEnabled is set to true.
  42276. */
  42277. vignetteColor: Color4;
  42278. /**
  42279. * Gets Camera field of view used by the Vignette effect.
  42280. */
  42281. /**
  42282. * Sets Camera field of view used by the Vignette effect.
  42283. */
  42284. vignetteCameraFov: number;
  42285. /**
  42286. * Gets the vignette blend mode allowing different kind of effect.
  42287. */
  42288. /**
  42289. * Sets the vignette blend mode allowing different kind of effect.
  42290. */
  42291. vignetteBlendMode: number;
  42292. /**
  42293. * Gets wether the vignette effect is enabled.
  42294. */
  42295. /**
  42296. * Sets wether the vignette effect is enabled.
  42297. */
  42298. vignetteEnabled: boolean;
  42299. private _fromLinearSpace;
  42300. /**
  42301. * Gets wether the input of the processing is in Gamma or Linear Space.
  42302. */
  42303. /**
  42304. * Sets wether the input of the processing is in Gamma or Linear Space.
  42305. */
  42306. fromLinearSpace: boolean;
  42307. /**
  42308. * Defines cache preventing GC.
  42309. */
  42310. private _defines;
  42311. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  42312. /**
  42313. * "ImageProcessingPostProcess"
  42314. * @returns "ImageProcessingPostProcess"
  42315. */
  42316. getClassName(): string;
  42317. protected _updateParameters(): void;
  42318. dispose(camera?: Camera): void;
  42319. }
  42320. }
  42321. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  42322. import { Scene } from "babylonjs/scene";
  42323. import { Color3 } from "babylonjs/Maths/math.color";
  42324. import { Mesh } from "babylonjs/Meshes/mesh";
  42325. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  42326. import { Nullable } from "babylonjs/types";
  42327. /**
  42328. * Class containing static functions to help procedurally build meshes
  42329. */
  42330. export class GroundBuilder {
  42331. /**
  42332. * Creates a ground mesh
  42333. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  42334. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  42335. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42336. * @param name defines the name of the mesh
  42337. * @param options defines the options used to create the mesh
  42338. * @param scene defines the hosting scene
  42339. * @returns the ground mesh
  42340. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  42341. */
  42342. static CreateGround(name: string, options: {
  42343. width?: number;
  42344. height?: number;
  42345. subdivisions?: number;
  42346. subdivisionsX?: number;
  42347. subdivisionsY?: number;
  42348. updatable?: boolean;
  42349. }, scene: any): Mesh;
  42350. /**
  42351. * Creates a tiled ground mesh
  42352. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  42353. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  42354. * * 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
  42355. * * 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
  42356. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42357. * @param name defines the name of the mesh
  42358. * @param options defines the options used to create the mesh
  42359. * @param scene defines the hosting scene
  42360. * @returns the tiled ground mesh
  42361. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  42362. */
  42363. static CreateTiledGround(name: string, options: {
  42364. xmin: number;
  42365. zmin: number;
  42366. xmax: number;
  42367. zmax: number;
  42368. subdivisions?: {
  42369. w: number;
  42370. h: number;
  42371. };
  42372. precision?: {
  42373. w: number;
  42374. h: number;
  42375. };
  42376. updatable?: boolean;
  42377. }, scene?: Nullable<Scene>): Mesh;
  42378. /**
  42379. * Creates a ground mesh from a height map
  42380. * * The parameter `url` sets the URL of the height map image resource.
  42381. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  42382. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  42383. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  42384. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  42385. * * 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.
  42386. * * 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).
  42387. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  42388. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42389. * @param name defines the name of the mesh
  42390. * @param url defines the url to the height map
  42391. * @param options defines the options used to create the mesh
  42392. * @param scene defines the hosting scene
  42393. * @returns the ground mesh
  42394. * @see https://doc.babylonjs.com/babylon101/height_map
  42395. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  42396. */
  42397. static CreateGroundFromHeightMap(name: string, url: string, options: {
  42398. width?: number;
  42399. height?: number;
  42400. subdivisions?: number;
  42401. minHeight?: number;
  42402. maxHeight?: number;
  42403. colorFilter?: Color3;
  42404. alphaFilter?: number;
  42405. updatable?: boolean;
  42406. onReady?: (mesh: GroundMesh) => void;
  42407. }, scene?: Nullable<Scene>): GroundMesh;
  42408. }
  42409. }
  42410. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  42411. import { Vector4 } from "babylonjs/Maths/math.vector";
  42412. import { Mesh } from "babylonjs/Meshes/mesh";
  42413. /**
  42414. * Class containing static functions to help procedurally build meshes
  42415. */
  42416. export class TorusBuilder {
  42417. /**
  42418. * Creates a torus mesh
  42419. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  42420. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  42421. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  42422. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42423. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42424. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42425. * @param name defines the name of the mesh
  42426. * @param options defines the options used to create the mesh
  42427. * @param scene defines the hosting scene
  42428. * @returns the torus mesh
  42429. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  42430. */
  42431. static CreateTorus(name: string, options: {
  42432. diameter?: number;
  42433. thickness?: number;
  42434. tessellation?: number;
  42435. updatable?: boolean;
  42436. sideOrientation?: number;
  42437. frontUVs?: Vector4;
  42438. backUVs?: Vector4;
  42439. }, scene: any): Mesh;
  42440. }
  42441. }
  42442. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  42443. import { Vector4 } from "babylonjs/Maths/math.vector";
  42444. import { Color4 } from "babylonjs/Maths/math.color";
  42445. import { Mesh } from "babylonjs/Meshes/mesh";
  42446. /**
  42447. * Class containing static functions to help procedurally build meshes
  42448. */
  42449. export class CylinderBuilder {
  42450. /**
  42451. * Creates a cylinder or a cone mesh
  42452. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  42453. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  42454. * * 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.
  42455. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  42456. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  42457. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  42458. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  42459. * * 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).
  42460. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  42461. * * 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).
  42462. * * 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
  42463. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  42464. * * 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
  42465. * * 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.
  42466. * * If `enclose` is false, a ring surface is one element.
  42467. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  42468. * * 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
  42469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  42472. * @param name defines the name of the mesh
  42473. * @param options defines the options used to create the mesh
  42474. * @param scene defines the hosting scene
  42475. * @returns the cylinder mesh
  42476. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  42477. */
  42478. static CreateCylinder(name: string, options: {
  42479. height?: number;
  42480. diameterTop?: number;
  42481. diameterBottom?: number;
  42482. diameter?: number;
  42483. tessellation?: number;
  42484. subdivisions?: number;
  42485. arc?: number;
  42486. faceColors?: Color4[];
  42487. faceUV?: Vector4[];
  42488. updatable?: boolean;
  42489. hasRings?: boolean;
  42490. enclose?: boolean;
  42491. cap?: number;
  42492. sideOrientation?: number;
  42493. frontUVs?: Vector4;
  42494. backUVs?: Vector4;
  42495. }, scene: any): Mesh;
  42496. }
  42497. }
  42498. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  42499. import { Observable } from "babylonjs/Misc/observable";
  42500. import { Nullable } from "babylonjs/types";
  42501. import { Camera } from "babylonjs/Cameras/camera";
  42502. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  42503. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42504. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  42505. import { Scene } from "babylonjs/scene";
  42506. import { Vector3 } from "babylonjs/Maths/math.vector";
  42507. import { Color3 } from "babylonjs/Maths/math.color";
  42508. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  42509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42510. import { Mesh } from "babylonjs/Meshes/mesh";
  42511. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  42512. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  42513. import "babylonjs/Meshes/Builders/groundBuilder";
  42514. import "babylonjs/Meshes/Builders/torusBuilder";
  42515. import "babylonjs/Meshes/Builders/cylinderBuilder";
  42516. import "babylonjs/Gamepads/gamepadSceneComponent";
  42517. import "babylonjs/Animations/animatable";
  42518. /**
  42519. * Options to modify the vr teleportation behavior.
  42520. */
  42521. export interface VRTeleportationOptions {
  42522. /**
  42523. * The name of the mesh which should be used as the teleportation floor. (default: null)
  42524. */
  42525. floorMeshName?: string;
  42526. /**
  42527. * A list of meshes to be used as the teleportation floor. (default: empty)
  42528. */
  42529. floorMeshes?: Mesh[];
  42530. }
  42531. /**
  42532. * Options to modify the vr experience helper's behavior.
  42533. */
  42534. export interface VRExperienceHelperOptions extends WebVROptions {
  42535. /**
  42536. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  42537. */
  42538. createDeviceOrientationCamera?: boolean;
  42539. /**
  42540. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  42541. */
  42542. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  42543. /**
  42544. * Uses the main button on the controller to toggle the laser casted. (default: true)
  42545. */
  42546. laserToggle?: boolean;
  42547. /**
  42548. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  42549. */
  42550. floorMeshes?: Mesh[];
  42551. /**
  42552. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  42553. */
  42554. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  42555. }
  42556. /**
  42557. * Event containing information after VR has been entered
  42558. */
  42559. export class OnAfterEnteringVRObservableEvent {
  42560. /**
  42561. * If entering vr was successful
  42562. */
  42563. success: boolean;
  42564. }
  42565. /**
  42566. * Helps to quickly add VR support to an existing scene.
  42567. * See http://doc.babylonjs.com/how_to/webvr_helper
  42568. */
  42569. export class VRExperienceHelper {
  42570. /** Options to modify the vr experience helper's behavior. */
  42571. webVROptions: VRExperienceHelperOptions;
  42572. private _scene;
  42573. private _position;
  42574. private _btnVR;
  42575. private _btnVRDisplayed;
  42576. private _webVRsupported;
  42577. private _webVRready;
  42578. private _webVRrequesting;
  42579. private _webVRpresenting;
  42580. private _hasEnteredVR;
  42581. private _fullscreenVRpresenting;
  42582. private _canvas;
  42583. private _webVRCamera;
  42584. private _vrDeviceOrientationCamera;
  42585. private _deviceOrientationCamera;
  42586. private _existingCamera;
  42587. private _onKeyDown;
  42588. private _onVrDisplayPresentChange;
  42589. private _onVRDisplayChanged;
  42590. private _onVRRequestPresentStart;
  42591. private _onVRRequestPresentComplete;
  42592. /**
  42593. * 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)
  42594. */
  42595. enableGazeEvenWhenNoPointerLock: boolean;
  42596. /**
  42597. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  42598. */
  42599. exitVROnDoubleTap: boolean;
  42600. /**
  42601. * Observable raised right before entering VR.
  42602. */
  42603. onEnteringVRObservable: Observable<VRExperienceHelper>;
  42604. /**
  42605. * Observable raised when entering VR has completed.
  42606. */
  42607. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  42608. /**
  42609. * Observable raised when exiting VR.
  42610. */
  42611. onExitingVRObservable: Observable<VRExperienceHelper>;
  42612. /**
  42613. * Observable raised when controller mesh is loaded.
  42614. */
  42615. onControllerMeshLoadedObservable: Observable<WebVRController>;
  42616. /** Return this.onEnteringVRObservable
  42617. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  42618. */
  42619. readonly onEnteringVR: Observable<VRExperienceHelper>;
  42620. /** Return this.onExitingVRObservable
  42621. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  42622. */
  42623. readonly onExitingVR: Observable<VRExperienceHelper>;
  42624. /** Return this.onControllerMeshLoadedObservable
  42625. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  42626. */
  42627. readonly onControllerMeshLoaded: Observable<WebVRController>;
  42628. private _rayLength;
  42629. private _useCustomVRButton;
  42630. private _teleportationRequested;
  42631. private _teleportActive;
  42632. private _floorMeshName;
  42633. private _floorMeshesCollection;
  42634. private _rotationAllowed;
  42635. private _teleportBackwardsVector;
  42636. private _teleportationTarget;
  42637. private _isDefaultTeleportationTarget;
  42638. private _postProcessMove;
  42639. private _teleportationFillColor;
  42640. private _teleportationBorderColor;
  42641. private _rotationAngle;
  42642. private _haloCenter;
  42643. private _cameraGazer;
  42644. private _padSensibilityUp;
  42645. private _padSensibilityDown;
  42646. private _leftController;
  42647. private _rightController;
  42648. /**
  42649. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  42650. */
  42651. onNewMeshSelected: Observable<AbstractMesh>;
  42652. /**
  42653. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  42654. * This observable will provide the mesh and the controller used to select the mesh
  42655. */
  42656. onMeshSelectedWithController: Observable<{
  42657. mesh: AbstractMesh;
  42658. controller: WebVRController;
  42659. }>;
  42660. /**
  42661. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  42662. */
  42663. onNewMeshPicked: Observable<PickingInfo>;
  42664. private _circleEase;
  42665. /**
  42666. * Observable raised before camera teleportation
  42667. */
  42668. onBeforeCameraTeleport: Observable<Vector3>;
  42669. /**
  42670. * Observable raised after camera teleportation
  42671. */
  42672. onAfterCameraTeleport: Observable<Vector3>;
  42673. /**
  42674. * Observable raised when current selected mesh gets unselected
  42675. */
  42676. onSelectedMeshUnselected: Observable<AbstractMesh>;
  42677. private _raySelectionPredicate;
  42678. /**
  42679. * To be optionaly changed by user to define custom ray selection
  42680. */
  42681. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  42682. /**
  42683. * To be optionaly changed by user to define custom selection logic (after ray selection)
  42684. */
  42685. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  42686. /**
  42687. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  42688. */
  42689. teleportationEnabled: boolean;
  42690. private _defaultHeight;
  42691. private _teleportationInitialized;
  42692. private _interactionsEnabled;
  42693. private _interactionsRequested;
  42694. private _displayGaze;
  42695. private _displayLaserPointer;
  42696. /**
  42697. * The mesh used to display where the user is going to teleport.
  42698. */
  42699. /**
  42700. * Sets the mesh to be used to display where the user is going to teleport.
  42701. */
  42702. teleportationTarget: Mesh;
  42703. /**
  42704. * 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
  42705. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  42706. * See http://doc.babylonjs.com/resources/baking_transformations
  42707. */
  42708. gazeTrackerMesh: Mesh;
  42709. /**
  42710. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  42711. */
  42712. updateGazeTrackerScale: boolean;
  42713. /**
  42714. * If the gaze trackers color should be updated when selecting meshes
  42715. */
  42716. updateGazeTrackerColor: boolean;
  42717. /**
  42718. * If the controller laser color should be updated when selecting meshes
  42719. */
  42720. updateControllerLaserColor: boolean;
  42721. /**
  42722. * The gaze tracking mesh corresponding to the left controller
  42723. */
  42724. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  42725. /**
  42726. * The gaze tracking mesh corresponding to the right controller
  42727. */
  42728. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  42729. /**
  42730. * If the ray of the gaze should be displayed.
  42731. */
  42732. /**
  42733. * Sets if the ray of the gaze should be displayed.
  42734. */
  42735. displayGaze: boolean;
  42736. /**
  42737. * If the ray of the LaserPointer should be displayed.
  42738. */
  42739. /**
  42740. * Sets if the ray of the LaserPointer should be displayed.
  42741. */
  42742. displayLaserPointer: boolean;
  42743. /**
  42744. * The deviceOrientationCamera used as the camera when not in VR.
  42745. */
  42746. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  42747. /**
  42748. * Based on the current WebVR support, returns the current VR camera used.
  42749. */
  42750. readonly currentVRCamera: Nullable<Camera>;
  42751. /**
  42752. * The webVRCamera which is used when in VR.
  42753. */
  42754. readonly webVRCamera: WebVRFreeCamera;
  42755. /**
  42756. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  42757. */
  42758. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  42759. /**
  42760. * The html button that is used to trigger entering into VR.
  42761. */
  42762. readonly vrButton: Nullable<HTMLButtonElement>;
  42763. private readonly _teleportationRequestInitiated;
  42764. /**
  42765. * Defines wether or not Pointer lock should be requested when switching to
  42766. * full screen.
  42767. */
  42768. requestPointerLockOnFullScreen: boolean;
  42769. /**
  42770. * Instantiates a VRExperienceHelper.
  42771. * Helps to quickly add VR support to an existing scene.
  42772. * @param scene The scene the VRExperienceHelper belongs to.
  42773. * @param webVROptions Options to modify the vr experience helper's behavior.
  42774. */
  42775. constructor(scene: Scene,
  42776. /** Options to modify the vr experience helper's behavior. */
  42777. webVROptions?: VRExperienceHelperOptions);
  42778. private _onDefaultMeshLoaded;
  42779. private _onResize;
  42780. private _onFullscreenChange;
  42781. /**
  42782. * Gets a value indicating if we are currently in VR mode.
  42783. */
  42784. readonly isInVRMode: boolean;
  42785. private onVrDisplayPresentChange;
  42786. private onVRDisplayChanged;
  42787. private moveButtonToBottomRight;
  42788. private displayVRButton;
  42789. private updateButtonVisibility;
  42790. private _cachedAngularSensibility;
  42791. /**
  42792. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  42793. * Otherwise, will use the fullscreen API.
  42794. */
  42795. enterVR(): void;
  42796. /**
  42797. * Attempt to exit VR, or fullscreen.
  42798. */
  42799. exitVR(): void;
  42800. /**
  42801. * The position of the vr experience helper.
  42802. */
  42803. /**
  42804. * Sets the position of the vr experience helper.
  42805. */
  42806. position: Vector3;
  42807. /**
  42808. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  42809. */
  42810. enableInteractions(): void;
  42811. private readonly _noControllerIsActive;
  42812. private beforeRender;
  42813. private _isTeleportationFloor;
  42814. /**
  42815. * Adds a floor mesh to be used for teleportation.
  42816. * @param floorMesh the mesh to be used for teleportation.
  42817. */
  42818. addFloorMesh(floorMesh: Mesh): void;
  42819. /**
  42820. * Removes a floor mesh from being used for teleportation.
  42821. * @param floorMesh the mesh to be removed.
  42822. */
  42823. removeFloorMesh(floorMesh: Mesh): void;
  42824. /**
  42825. * Enables interactions and teleportation using the VR controllers and gaze.
  42826. * @param vrTeleportationOptions options to modify teleportation behavior.
  42827. */
  42828. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  42829. private _onNewGamepadConnected;
  42830. private _tryEnableInteractionOnController;
  42831. private _onNewGamepadDisconnected;
  42832. private _enableInteractionOnController;
  42833. private _checkTeleportWithRay;
  42834. private _checkRotate;
  42835. private _checkTeleportBackwards;
  42836. private _enableTeleportationOnController;
  42837. private _createTeleportationCircles;
  42838. private _displayTeleportationTarget;
  42839. private _hideTeleportationTarget;
  42840. private _rotateCamera;
  42841. private _moveTeleportationSelectorTo;
  42842. private _workingVector;
  42843. private _workingQuaternion;
  42844. private _workingMatrix;
  42845. /**
  42846. * Teleports the users feet to the desired location
  42847. * @param location The location where the user's feet should be placed
  42848. */
  42849. teleportCamera(location: Vector3): void;
  42850. private _convertNormalToDirectionOfRay;
  42851. private _castRayAndSelectObject;
  42852. private _notifySelectedMeshUnselected;
  42853. /**
  42854. * Sets the color of the laser ray from the vr controllers.
  42855. * @param color new color for the ray.
  42856. */
  42857. changeLaserColor(color: Color3): void;
  42858. /**
  42859. * Sets the color of the ray from the vr headsets gaze.
  42860. * @param color new color for the ray.
  42861. */
  42862. changeGazeColor(color: Color3): void;
  42863. /**
  42864. * Exits VR and disposes of the vr experience helper
  42865. */
  42866. dispose(): void;
  42867. /**
  42868. * Gets the name of the VRExperienceHelper class
  42869. * @returns "VRExperienceHelper"
  42870. */
  42871. getClassName(): string;
  42872. }
  42873. }
  42874. declare module "babylonjs/Cameras/VR/index" {
  42875. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  42876. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  42877. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  42878. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  42879. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  42880. export * from "babylonjs/Cameras/VR/webVRCamera";
  42881. }
  42882. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  42883. import { Observable } from "babylonjs/Misc/observable";
  42884. import { Nullable } from "babylonjs/types";
  42885. import { IDisposable, Scene } from "babylonjs/scene";
  42886. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  42887. /**
  42888. * Manages an XRSession to work with Babylon's engine
  42889. * @see https://doc.babylonjs.com/how_to/webxr
  42890. */
  42891. export class WebXRSessionManager implements IDisposable {
  42892. private scene;
  42893. /**
  42894. * Fires every time a new xrFrame arrives which can be used to update the camera
  42895. */
  42896. onXRFrameObservable: Observable<any>;
  42897. /**
  42898. * Fires when the xr session is ended either by the device or manually done
  42899. */
  42900. onXRSessionEnded: Observable<any>;
  42901. /**
  42902. * Underlying xr session
  42903. */
  42904. session: XRSession;
  42905. /**
  42906. * Type of reference space used when creating the session
  42907. */
  42908. referenceSpace: XRReferenceSpace;
  42909. /** @hidden */
  42910. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  42911. /**
  42912. * Current XR frame
  42913. */
  42914. currentFrame: Nullable<XRFrame>;
  42915. private _xrNavigator;
  42916. private baseLayer;
  42917. /**
  42918. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  42919. * @param scene The scene which the session should be created for
  42920. */
  42921. constructor(scene: Scene);
  42922. /**
  42923. * Initializes the manager
  42924. * After initialization enterXR can be called to start an XR session
  42925. * @returns Promise which resolves after it is initialized
  42926. */
  42927. initializeAsync(): Promise<void>;
  42928. /**
  42929. * Initializes an xr session
  42930. * @param xrSessionMode mode to initialize
  42931. * @returns a promise which will resolve once the session has been initialized
  42932. */
  42933. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  42934. /**
  42935. * Sets the reference space on the xr session
  42936. * @param referenceSpace space to set
  42937. * @returns a promise that will resolve once the reference space has been set
  42938. */
  42939. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  42940. /**
  42941. * Updates the render state of the session
  42942. * @param state state to set
  42943. * @returns a promise that resolves once the render state has been updated
  42944. */
  42945. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  42946. /**
  42947. * Starts rendering to the xr layer
  42948. * @returns a promise that will resolve once rendering has started
  42949. */
  42950. startRenderingToXRAsync(): Promise<void>;
  42951. /**
  42952. * Stops the xrSession and restores the renderloop
  42953. * @returns Promise which resolves after it exits XR
  42954. */
  42955. exitXRAsync(): Promise<unknown>;
  42956. /**
  42957. * Checks if a session would be supported for the creation options specified
  42958. * @param sessionMode session mode to check if supported eg. immersive-vr
  42959. * @returns true if supported
  42960. */
  42961. supportsSessionAsync(sessionMode: XRSessionMode): any;
  42962. /**
  42963. * @hidden
  42964. * Converts the render layer of xrSession to a render target
  42965. * @param session session to create render target for
  42966. * @param scene scene the new render target should be created for
  42967. */
  42968. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  42969. /**
  42970. * Disposes of the session manager
  42971. */
  42972. dispose(): void;
  42973. }
  42974. }
  42975. declare module "babylonjs/Cameras/XR/webXRCamera" {
  42976. import { Scene } from "babylonjs/scene";
  42977. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42978. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  42979. /**
  42980. * WebXR Camera which holds the views for the xrSession
  42981. * @see https://doc.babylonjs.com/how_to/webxr
  42982. */
  42983. export class WebXRCamera extends FreeCamera {
  42984. private static _TmpMatrix;
  42985. /**
  42986. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  42987. * @param name the name of the camera
  42988. * @param scene the scene to add the camera to
  42989. */
  42990. constructor(name: string, scene: Scene);
  42991. private _updateNumberOfRigCameras;
  42992. /** @hidden */
  42993. _updateForDualEyeDebugging(pupilDistance?: number): void;
  42994. /**
  42995. * Updates the cameras position from the current pose information of the XR session
  42996. * @param xrSessionManager the session containing pose information
  42997. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  42998. */
  42999. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  43000. }
  43001. }
  43002. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  43003. import { Nullable } from "babylonjs/types";
  43004. import { IDisposable } from "babylonjs/scene";
  43005. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43006. /**
  43007. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  43008. */
  43009. export class WebXRManagedOutputCanvas implements IDisposable {
  43010. private helper;
  43011. private _canvas;
  43012. /**
  43013. * xrpresent context of the canvas which can be used to display/mirror xr content
  43014. */
  43015. canvasContext: WebGLRenderingContext;
  43016. /**
  43017. * xr layer for the canvas
  43018. */
  43019. xrLayer: Nullable<XRWebGLLayer>;
  43020. /**
  43021. * Initializes the xr layer for the session
  43022. * @param xrSession xr session
  43023. * @returns a promise that will resolve once the XR Layer has been created
  43024. */
  43025. initializeXRLayerAsync(xrSession: any): any;
  43026. /**
  43027. * Initializes the canvas to be added/removed upon entering/exiting xr
  43028. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  43029. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  43030. */
  43031. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  43032. /**
  43033. * Disposes of the object
  43034. */
  43035. dispose(): void;
  43036. private _setManagedOutputCanvas;
  43037. private _addCanvas;
  43038. private _removeCanvas;
  43039. }
  43040. }
  43041. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  43042. import { Observable } from "babylonjs/Misc/observable";
  43043. import { IDisposable, Scene } from "babylonjs/scene";
  43044. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  43045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43046. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  43047. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  43048. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43049. /**
  43050. * States of the webXR experience
  43051. */
  43052. export enum WebXRState {
  43053. /**
  43054. * Transitioning to being in XR mode
  43055. */
  43056. ENTERING_XR = 0,
  43057. /**
  43058. * Transitioning to non XR mode
  43059. */
  43060. EXITING_XR = 1,
  43061. /**
  43062. * In XR mode and presenting
  43063. */
  43064. IN_XR = 2,
  43065. /**
  43066. * Not entered XR mode
  43067. */
  43068. NOT_IN_XR = 3
  43069. }
  43070. /**
  43071. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  43072. * @see https://doc.babylonjs.com/how_to/webxr
  43073. */
  43074. export class WebXRExperienceHelper implements IDisposable {
  43075. private scene;
  43076. /**
  43077. * 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
  43078. */
  43079. container: AbstractMesh;
  43080. /**
  43081. * Camera used to render xr content
  43082. */
  43083. camera: WebXRCamera;
  43084. /**
  43085. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  43086. */
  43087. state: WebXRState;
  43088. private _setState;
  43089. private static _TmpVector;
  43090. /**
  43091. * Fires when the state of the experience helper has changed
  43092. */
  43093. onStateChangedObservable: Observable<WebXRState>;
  43094. /** Session manager used to keep track of xr session */
  43095. sessionManager: WebXRSessionManager;
  43096. private _nonVRCamera;
  43097. private _originalSceneAutoClear;
  43098. private _supported;
  43099. /**
  43100. * Creates the experience helper
  43101. * @param scene the scene to attach the experience helper to
  43102. * @returns a promise for the experience helper
  43103. */
  43104. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  43105. /**
  43106. * Creates a WebXRExperienceHelper
  43107. * @param scene The scene the helper should be created in
  43108. */
  43109. private constructor();
  43110. /**
  43111. * Exits XR mode and returns the scene to its original state
  43112. * @returns promise that resolves after xr mode has exited
  43113. */
  43114. exitXRAsync(): Promise<unknown>;
  43115. /**
  43116. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  43117. * @param sessionCreationOptions options for the XR session
  43118. * @param referenceSpaceType frame of reference of the XR session
  43119. * @param outputCanvas the output canvas that will be used to enter XR mode
  43120. * @returns promise that resolves after xr mode has entered
  43121. */
  43122. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  43123. /**
  43124. * Updates the global position of the camera by moving the camera's container
  43125. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  43126. * @param position The desired global position of the camera
  43127. */
  43128. setPositionOfCameraUsingContainer(position: Vector3): void;
  43129. /**
  43130. * Rotates the xr camera by rotating the camera's container around the camera's position
  43131. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  43132. * @param rotation the desired quaternion rotation to apply to the camera
  43133. */
  43134. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  43135. /**
  43136. * Disposes of the experience helper
  43137. */
  43138. dispose(): void;
  43139. }
  43140. }
  43141. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  43142. import { Nullable } from "babylonjs/types";
  43143. import { Observable } from "babylonjs/Misc/observable";
  43144. import { IDisposable, Scene } from "babylonjs/scene";
  43145. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43146. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  43147. /**
  43148. * Button which can be used to enter a different mode of XR
  43149. */
  43150. export class WebXREnterExitUIButton {
  43151. /** button element */
  43152. element: HTMLElement;
  43153. /** XR initialization options for the button */
  43154. sessionMode: XRSessionMode;
  43155. /** Reference space type */
  43156. referenceSpaceType: XRReferenceSpaceType;
  43157. /**
  43158. * Creates a WebXREnterExitUIButton
  43159. * @param element button element
  43160. * @param sessionMode XR initialization session mode
  43161. * @param referenceSpaceType the type of reference space to be used
  43162. */
  43163. constructor(
  43164. /** button element */
  43165. element: HTMLElement,
  43166. /** XR initialization options for the button */
  43167. sessionMode: XRSessionMode,
  43168. /** Reference space type */
  43169. referenceSpaceType: XRReferenceSpaceType);
  43170. /**
  43171. * Overwritable function which can be used to update the button's visuals when the state changes
  43172. * @param activeButton the current active button in the UI
  43173. */
  43174. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  43175. }
  43176. /**
  43177. * Options to create the webXR UI
  43178. */
  43179. export class WebXREnterExitUIOptions {
  43180. /**
  43181. * Context to enter xr with
  43182. */
  43183. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  43184. /**
  43185. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  43186. */
  43187. customButtons?: Array<WebXREnterExitUIButton>;
  43188. }
  43189. /**
  43190. * UI to allow the user to enter/exit XR mode
  43191. */
  43192. export class WebXREnterExitUI implements IDisposable {
  43193. private scene;
  43194. private _overlay;
  43195. private _buttons;
  43196. private _activeButton;
  43197. /**
  43198. * Fired every time the active button is changed.
  43199. *
  43200. * When xr is entered via a button that launches xr that button will be the callback parameter
  43201. *
  43202. * When exiting xr the callback parameter will be null)
  43203. */
  43204. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  43205. /**
  43206. * Creates UI to allow the user to enter/exit XR mode
  43207. * @param scene the scene to add the ui to
  43208. * @param helper the xr experience helper to enter/exit xr with
  43209. * @param options options to configure the UI
  43210. * @returns the created ui
  43211. */
  43212. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  43213. private constructor();
  43214. private _updateButtons;
  43215. /**
  43216. * Disposes of the object
  43217. */
  43218. dispose(): void;
  43219. }
  43220. }
  43221. declare module "babylonjs/Cameras/XR/webXRController" {
  43222. import { Nullable } from "babylonjs/types";
  43223. import { Observable } from "babylonjs/Misc/observable";
  43224. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43225. import { Ray } from "babylonjs/Culling/ray";
  43226. import { Scene } from "babylonjs/scene";
  43227. /**
  43228. * Represents an XR input
  43229. */
  43230. export class WebXRController {
  43231. private scene;
  43232. /** The underlying input source for the controller */
  43233. inputSource: XRInputSource;
  43234. private parentContainer;
  43235. /**
  43236. * 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
  43237. */
  43238. grip?: AbstractMesh;
  43239. /**
  43240. * Pointer which can be used to select objects or attach a visible laser to
  43241. */
  43242. pointer: AbstractMesh;
  43243. /**
  43244. * Event that fires when the controller is removed/disposed
  43245. */
  43246. onDisposeObservable: Observable<{}>;
  43247. private _tmpMatrix;
  43248. private _tmpQuaternion;
  43249. private _tmpVector;
  43250. /**
  43251. * Creates the controller
  43252. * @see https://doc.babylonjs.com/how_to/webxr
  43253. * @param scene the scene which the controller should be associated to
  43254. * @param inputSource the underlying input source for the controller
  43255. * @param parentContainer parent that the controller meshes should be children of
  43256. */
  43257. constructor(scene: Scene,
  43258. /** The underlying input source for the controller */
  43259. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  43260. /**
  43261. * Updates the controller pose based on the given XRFrame
  43262. * @param xrFrame xr frame to update the pose with
  43263. * @param referenceSpace reference space to use
  43264. */
  43265. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  43266. /**
  43267. * Gets a world space ray coming from the controller
  43268. * @param result the resulting ray
  43269. */
  43270. getWorldPointerRayToRef(result: Ray): void;
  43271. /**
  43272. * Disposes of the object
  43273. */
  43274. dispose(): void;
  43275. }
  43276. }
  43277. declare module "babylonjs/Cameras/XR/webXRInput" {
  43278. import { Observable } from "babylonjs/Misc/observable";
  43279. import { IDisposable } from "babylonjs/scene";
  43280. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  43281. import { WebXRController } from "babylonjs/Cameras/XR/webXRController";
  43282. /**
  43283. * XR input used to track XR inputs such as controllers/rays
  43284. */
  43285. export class WebXRInput implements IDisposable {
  43286. /**
  43287. * Base experience the input listens to
  43288. */
  43289. baseExperience: WebXRExperienceHelper;
  43290. /**
  43291. * XR controllers being tracked
  43292. */
  43293. controllers: Array<WebXRController>;
  43294. private _frameObserver;
  43295. private _stateObserver;
  43296. /**
  43297. * Event when a controller has been connected/added
  43298. */
  43299. onControllerAddedObservable: Observable<WebXRController>;
  43300. /**
  43301. * Event when a controller has been removed/disconnected
  43302. */
  43303. onControllerRemovedObservable: Observable<WebXRController>;
  43304. /**
  43305. * Initializes the WebXRInput
  43306. * @param baseExperience experience helper which the input should be created for
  43307. */
  43308. constructor(
  43309. /**
  43310. * Base experience the input listens to
  43311. */
  43312. baseExperience: WebXRExperienceHelper);
  43313. private _onInputSourcesChange;
  43314. private _addAndRemoveControllers;
  43315. /**
  43316. * Disposes of the object
  43317. */
  43318. dispose(): void;
  43319. }
  43320. }
  43321. declare module "babylonjs/Cameras/XR/webXRControllerTeleportation" {
  43322. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43323. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43324. /**
  43325. * Enables teleportation
  43326. */
  43327. export class WebXRControllerTeleportation {
  43328. private _teleportationFillColor;
  43329. private _teleportationBorderColor;
  43330. private _tmpRay;
  43331. private _tmpVector;
  43332. /**
  43333. * Creates a WebXRControllerTeleportation
  43334. * @param input input manager to add teleportation to
  43335. * @param floorMeshes floormeshes which can be teleported to
  43336. */
  43337. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  43338. }
  43339. }
  43340. declare module "babylonjs/Cameras/XR/webXRControllerPointerSelection" {
  43341. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  43342. /**
  43343. * Handles pointer input automatically for the pointer of XR controllers
  43344. */
  43345. export class WebXRControllerPointerSelection {
  43346. private static _idCounter;
  43347. private _tmpRay;
  43348. /**
  43349. * Creates a WebXRControllerPointerSelection
  43350. * @param input input manager to setup pointer selection
  43351. */
  43352. constructor(input: WebXRInput);
  43353. private _convertNormalToDirectionOfRay;
  43354. private _updatePointerDistance;
  43355. }
  43356. }
  43357. declare module "babylonjs/Loading/sceneLoader" {
  43358. import { Observable } from "babylonjs/Misc/observable";
  43359. import { Nullable } from "babylonjs/types";
  43360. import { Scene } from "babylonjs/scene";
  43361. import { Engine } from "babylonjs/Engines/engine";
  43362. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43363. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43364. import { AssetContainer } from "babylonjs/assetContainer";
  43365. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43366. import { Skeleton } from "babylonjs/Bones/skeleton";
  43367. /**
  43368. * Class used to represent data loading progression
  43369. */
  43370. export class SceneLoaderProgressEvent {
  43371. /** defines if data length to load can be evaluated */
  43372. readonly lengthComputable: boolean;
  43373. /** defines the loaded data length */
  43374. readonly loaded: number;
  43375. /** defines the data length to load */
  43376. readonly total: number;
  43377. /**
  43378. * Create a new progress event
  43379. * @param lengthComputable defines if data length to load can be evaluated
  43380. * @param loaded defines the loaded data length
  43381. * @param total defines the data length to load
  43382. */
  43383. constructor(
  43384. /** defines if data length to load can be evaluated */
  43385. lengthComputable: boolean,
  43386. /** defines the loaded data length */
  43387. loaded: number,
  43388. /** defines the data length to load */
  43389. total: number);
  43390. /**
  43391. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43392. * @param event defines the source event
  43393. * @returns a new SceneLoaderProgressEvent
  43394. */
  43395. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43396. }
  43397. /**
  43398. * Interface used by SceneLoader plugins to define supported file extensions
  43399. */
  43400. export interface ISceneLoaderPluginExtensions {
  43401. /**
  43402. * Defines the list of supported extensions
  43403. */
  43404. [extension: string]: {
  43405. isBinary: boolean;
  43406. };
  43407. }
  43408. /**
  43409. * Interface used by SceneLoader plugin factory
  43410. */
  43411. export interface ISceneLoaderPluginFactory {
  43412. /**
  43413. * Defines the name of the factory
  43414. */
  43415. name: string;
  43416. /**
  43417. * Function called to create a new plugin
  43418. * @return the new plugin
  43419. */
  43420. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43421. /**
  43422. * Boolean indicating if the plugin can direct load specific data
  43423. */
  43424. canDirectLoad?: (data: string) => boolean;
  43425. }
  43426. /**
  43427. * Interface used to define a SceneLoader plugin
  43428. */
  43429. export interface ISceneLoaderPlugin {
  43430. /**
  43431. * The friendly name of this plugin.
  43432. */
  43433. name: string;
  43434. /**
  43435. * The file extensions supported by this plugin.
  43436. */
  43437. extensions: string | ISceneLoaderPluginExtensions;
  43438. /**
  43439. * Import meshes into a scene.
  43440. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43441. * @param scene The scene to import into
  43442. * @param data The data to import
  43443. * @param rootUrl The root url for scene and resources
  43444. * @param meshes The meshes array to import into
  43445. * @param particleSystems The particle systems array to import into
  43446. * @param skeletons The skeletons array to import into
  43447. * @param onError The callback when import fails
  43448. * @returns True if successful or false otherwise
  43449. */
  43450. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43451. /**
  43452. * Load into a scene.
  43453. * @param scene The scene to load into
  43454. * @param data The data to import
  43455. * @param rootUrl The root url for scene and resources
  43456. * @param onError The callback when import fails
  43457. * @returns true if successful or false otherwise
  43458. */
  43459. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43460. /**
  43461. * The callback that returns true if the data can be directly loaded.
  43462. */
  43463. canDirectLoad?: (data: string) => boolean;
  43464. /**
  43465. * The callback that allows custom handling of the root url based on the response url.
  43466. */
  43467. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43468. /**
  43469. * Load into an asset container.
  43470. * @param scene The scene to load into
  43471. * @param data The data to import
  43472. * @param rootUrl The root url for scene and resources
  43473. * @param onError The callback when import fails
  43474. * @returns The loaded asset container
  43475. */
  43476. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43477. }
  43478. /**
  43479. * Interface used to define an async SceneLoader plugin
  43480. */
  43481. export interface ISceneLoaderPluginAsync {
  43482. /**
  43483. * The friendly name of this plugin.
  43484. */
  43485. name: string;
  43486. /**
  43487. * The file extensions supported by this plugin.
  43488. */
  43489. extensions: string | ISceneLoaderPluginExtensions;
  43490. /**
  43491. * Import meshes into a scene.
  43492. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43493. * @param scene The scene to import into
  43494. * @param data The data to import
  43495. * @param rootUrl The root url for scene and resources
  43496. * @param onProgress The callback when the load progresses
  43497. * @param fileName Defines the name of the file to load
  43498. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43499. */
  43500. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43501. meshes: AbstractMesh[];
  43502. particleSystems: IParticleSystem[];
  43503. skeletons: Skeleton[];
  43504. animationGroups: AnimationGroup[];
  43505. }>;
  43506. /**
  43507. * Load into a scene.
  43508. * @param scene The scene to load into
  43509. * @param data The data to import
  43510. * @param rootUrl The root url for scene and resources
  43511. * @param onProgress The callback when the load progresses
  43512. * @param fileName Defines the name of the file to load
  43513. * @returns Nothing
  43514. */
  43515. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43516. /**
  43517. * The callback that returns true if the data can be directly loaded.
  43518. */
  43519. canDirectLoad?: (data: string) => boolean;
  43520. /**
  43521. * The callback that allows custom handling of the root url based on the response url.
  43522. */
  43523. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43524. /**
  43525. * Load into an asset container.
  43526. * @param scene The scene to load into
  43527. * @param data The data to import
  43528. * @param rootUrl The root url for scene and resources
  43529. * @param onProgress The callback when the load progresses
  43530. * @param fileName Defines the name of the file to load
  43531. * @returns The loaded asset container
  43532. */
  43533. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43534. }
  43535. /**
  43536. * Class used to load scene from various file formats using registered plugins
  43537. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43538. */
  43539. export class SceneLoader {
  43540. /**
  43541. * No logging while loading
  43542. */
  43543. static readonly NO_LOGGING: number;
  43544. /**
  43545. * Minimal logging while loading
  43546. */
  43547. static readonly MINIMAL_LOGGING: number;
  43548. /**
  43549. * Summary logging while loading
  43550. */
  43551. static readonly SUMMARY_LOGGING: number;
  43552. /**
  43553. * Detailled logging while loading
  43554. */
  43555. static readonly DETAILED_LOGGING: number;
  43556. /**
  43557. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43558. */
  43559. static ForceFullSceneLoadingForIncremental: boolean;
  43560. /**
  43561. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43562. */
  43563. static ShowLoadingScreen: boolean;
  43564. /**
  43565. * Defines the current logging level (while loading the scene)
  43566. * @ignorenaming
  43567. */
  43568. static loggingLevel: number;
  43569. /**
  43570. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43571. */
  43572. static CleanBoneMatrixWeights: boolean;
  43573. /**
  43574. * Event raised when a plugin is used to load a scene
  43575. */
  43576. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43577. private static _registeredPlugins;
  43578. private static _getDefaultPlugin;
  43579. private static _getPluginForExtension;
  43580. private static _getPluginForDirectLoad;
  43581. private static _getPluginForFilename;
  43582. private static _getDirectLoad;
  43583. private static _loadData;
  43584. private static _getFileInfo;
  43585. /**
  43586. * Gets a plugin that can load the given extension
  43587. * @param extension defines the extension to load
  43588. * @returns a plugin or null if none works
  43589. */
  43590. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43591. /**
  43592. * Gets a boolean indicating that the given extension can be loaded
  43593. * @param extension defines the extension to load
  43594. * @returns true if the extension is supported
  43595. */
  43596. static IsPluginForExtensionAvailable(extension: string): boolean;
  43597. /**
  43598. * Adds a new plugin to the list of registered plugins
  43599. * @param plugin defines the plugin to add
  43600. */
  43601. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43602. /**
  43603. * Import meshes into a scene
  43604. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43605. * @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)
  43606. * @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)
  43607. * @param scene the instance of BABYLON.Scene to append to
  43608. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43609. * @param onProgress a callback with a progress event for each file being loaded
  43610. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43611. * @param pluginExtension the extension used to determine the plugin
  43612. * @returns The loaded plugin
  43613. */
  43614. 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>;
  43615. /**
  43616. * Import meshes into a scene
  43617. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43618. * @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)
  43619. * @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)
  43620. * @param scene the instance of BABYLON.Scene to append to
  43621. * @param onProgress a callback with a progress event for each file being loaded
  43622. * @param pluginExtension the extension used to determine the plugin
  43623. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43624. */
  43625. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43626. meshes: AbstractMesh[];
  43627. particleSystems: IParticleSystem[];
  43628. skeletons: Skeleton[];
  43629. animationGroups: AnimationGroup[];
  43630. }>;
  43631. /**
  43632. * Load a scene
  43633. * @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)
  43634. * @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)
  43635. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43636. * @param onSuccess a callback with the scene when import succeeds
  43637. * @param onProgress a callback with a progress event for each file being loaded
  43638. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43639. * @param pluginExtension the extension used to determine the plugin
  43640. * @returns The loaded plugin
  43641. */
  43642. 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>;
  43643. /**
  43644. * Load a scene
  43645. * @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)
  43646. * @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)
  43647. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43648. * @param onProgress a callback with a progress event for each file being loaded
  43649. * @param pluginExtension the extension used to determine the plugin
  43650. * @returns The loaded scene
  43651. */
  43652. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43653. /**
  43654. * Append a scene
  43655. * @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)
  43656. * @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)
  43657. * @param scene is the instance of BABYLON.Scene to append to
  43658. * @param onSuccess a callback with the scene when import succeeds
  43659. * @param onProgress a callback with a progress event for each file being loaded
  43660. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43661. * @param pluginExtension the extension used to determine the plugin
  43662. * @returns The loaded plugin
  43663. */
  43664. 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>;
  43665. /**
  43666. * Append a scene
  43667. * @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)
  43668. * @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)
  43669. * @param scene is the instance of BABYLON.Scene to append to
  43670. * @param onProgress a callback with a progress event for each file being loaded
  43671. * @param pluginExtension the extension used to determine the plugin
  43672. * @returns The given scene
  43673. */
  43674. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43675. /**
  43676. * Load a scene into an asset container
  43677. * @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)
  43678. * @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)
  43679. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43680. * @param onSuccess a callback with the scene when import succeeds
  43681. * @param onProgress a callback with a progress event for each file being loaded
  43682. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43683. * @param pluginExtension the extension used to determine the plugin
  43684. * @returns The loaded plugin
  43685. */
  43686. 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>;
  43687. /**
  43688. * Load a scene into an asset container
  43689. * @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)
  43690. * @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)
  43691. * @param scene is the instance of Scene to append to
  43692. * @param onProgress a callback with a progress event for each file being loaded
  43693. * @param pluginExtension the extension used to determine the plugin
  43694. * @returns The loaded asset container
  43695. */
  43696. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43697. }
  43698. }
  43699. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43700. import { Scene } from "babylonjs/scene";
  43701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43702. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43703. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43704. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43705. /**
  43706. * Generic Controller
  43707. */
  43708. export class GenericController extends WebVRController {
  43709. /**
  43710. * Base Url for the controller model.
  43711. */
  43712. static readonly MODEL_BASE_URL: string;
  43713. /**
  43714. * File name for the controller model.
  43715. */
  43716. static readonly MODEL_FILENAME: string;
  43717. /**
  43718. * Creates a new GenericController from a gamepad
  43719. * @param vrGamepad the gamepad that the controller should be created from
  43720. */
  43721. constructor(vrGamepad: any);
  43722. /**
  43723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43724. * @param scene scene in which to add meshes
  43725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43726. */
  43727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43728. /**
  43729. * Called once for each button that changed state since the last frame
  43730. * @param buttonIdx Which button index changed
  43731. * @param state New state of the button
  43732. * @param changes Which properties on the state changed since last frame
  43733. */
  43734. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43735. }
  43736. }
  43737. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43738. import { Observable } from "babylonjs/Misc/observable";
  43739. import { Scene } from "babylonjs/scene";
  43740. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43741. import { Ray } from "babylonjs/Culling/ray";
  43742. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43743. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43744. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43745. /**
  43746. * Defines the WindowsMotionController object that the state of the windows motion controller
  43747. */
  43748. export class WindowsMotionController extends WebVRController {
  43749. /**
  43750. * The base url used to load the left and right controller models
  43751. */
  43752. static MODEL_BASE_URL: string;
  43753. /**
  43754. * The name of the left controller model file
  43755. */
  43756. static MODEL_LEFT_FILENAME: string;
  43757. /**
  43758. * The name of the right controller model file
  43759. */
  43760. static MODEL_RIGHT_FILENAME: string;
  43761. /**
  43762. * The controller name prefix for this controller type
  43763. */
  43764. static readonly GAMEPAD_ID_PREFIX: string;
  43765. /**
  43766. * The controller id pattern for this controller type
  43767. */
  43768. private static readonly GAMEPAD_ID_PATTERN;
  43769. private _loadedMeshInfo;
  43770. private readonly _mapping;
  43771. /**
  43772. * Fired when the trackpad on this controller is clicked
  43773. */
  43774. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43775. /**
  43776. * Fired when the trackpad on this controller is modified
  43777. */
  43778. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43779. /**
  43780. * The current x and y values of this controller's trackpad
  43781. */
  43782. trackpad: StickValues;
  43783. /**
  43784. * Creates a new WindowsMotionController from a gamepad
  43785. * @param vrGamepad the gamepad that the controller should be created from
  43786. */
  43787. constructor(vrGamepad: any);
  43788. /**
  43789. * Fired when the trigger on this controller is modified
  43790. */
  43791. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43792. /**
  43793. * Fired when the menu button on this controller is modified
  43794. */
  43795. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43796. /**
  43797. * Fired when the grip button on this controller is modified
  43798. */
  43799. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43800. /**
  43801. * Fired when the thumbstick button on this controller is modified
  43802. */
  43803. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43804. /**
  43805. * Fired when the touchpad button on this controller is modified
  43806. */
  43807. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43808. /**
  43809. * Fired when the touchpad values on this controller are modified
  43810. */
  43811. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43812. private _updateTrackpad;
  43813. /**
  43814. * Called once per frame by the engine.
  43815. */
  43816. update(): void;
  43817. /**
  43818. * Called once for each button that changed state since the last frame
  43819. * @param buttonIdx Which button index changed
  43820. * @param state New state of the button
  43821. * @param changes Which properties on the state changed since last frame
  43822. */
  43823. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43824. /**
  43825. * Moves the buttons on the controller mesh based on their current state
  43826. * @param buttonName the name of the button to move
  43827. * @param buttonValue the value of the button which determines the buttons new position
  43828. */
  43829. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43830. /**
  43831. * Moves the axis on the controller mesh based on its current state
  43832. * @param axis the index of the axis
  43833. * @param axisValue the value of the axis which determines the meshes new position
  43834. * @hidden
  43835. */
  43836. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43837. /**
  43838. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43839. * @param scene scene in which to add meshes
  43840. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43841. */
  43842. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43843. /**
  43844. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43845. * can be transformed by button presses and axes values, based on this._mapping.
  43846. *
  43847. * @param scene scene in which the meshes exist
  43848. * @param meshes list of meshes that make up the controller model to process
  43849. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43850. */
  43851. private processModel;
  43852. private createMeshInfo;
  43853. /**
  43854. * Gets the ray of the controller in the direction the controller is pointing
  43855. * @param length the length the resulting ray should be
  43856. * @returns a ray in the direction the controller is pointing
  43857. */
  43858. getForwardRay(length?: number): Ray;
  43859. /**
  43860. * Disposes of the controller
  43861. */
  43862. dispose(): void;
  43863. }
  43864. }
  43865. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43866. import { Observable } from "babylonjs/Misc/observable";
  43867. import { Scene } from "babylonjs/scene";
  43868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43869. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43870. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43871. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43872. /**
  43873. * Oculus Touch Controller
  43874. */
  43875. export class OculusTouchController extends WebVRController {
  43876. /**
  43877. * Base Url for the controller model.
  43878. */
  43879. static MODEL_BASE_URL: string;
  43880. /**
  43881. * File name for the left controller model.
  43882. */
  43883. static MODEL_LEFT_FILENAME: string;
  43884. /**
  43885. * File name for the right controller model.
  43886. */
  43887. static MODEL_RIGHT_FILENAME: string;
  43888. /**
  43889. * Base Url for the Quest controller model.
  43890. */
  43891. static QUEST_MODEL_BASE_URL: string;
  43892. /**
  43893. * @hidden
  43894. * If the controllers are running on a device that needs the updated Quest controller models
  43895. */
  43896. static _IsQuest: boolean;
  43897. /**
  43898. * Fired when the secondary trigger on this controller is modified
  43899. */
  43900. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43901. /**
  43902. * Fired when the thumb rest on this controller is modified
  43903. */
  43904. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43905. /**
  43906. * Creates a new OculusTouchController from a gamepad
  43907. * @param vrGamepad the gamepad that the controller should be created from
  43908. */
  43909. constructor(vrGamepad: any);
  43910. /**
  43911. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43912. * @param scene scene in which to add meshes
  43913. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43914. */
  43915. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43916. /**
  43917. * Fired when the A button on this controller is modified
  43918. */
  43919. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43920. /**
  43921. * Fired when the B button on this controller is modified
  43922. */
  43923. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43924. /**
  43925. * Fired when the X button on this controller is modified
  43926. */
  43927. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43928. /**
  43929. * Fired when the Y button on this controller is modified
  43930. */
  43931. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43932. /**
  43933. * Called once for each button that changed state since the last frame
  43934. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43935. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43936. * 2) secondary trigger (same)
  43937. * 3) A (right) X (left), touch, pressed = value
  43938. * 4) B / Y
  43939. * 5) thumb rest
  43940. * @param buttonIdx Which button index changed
  43941. * @param state New state of the button
  43942. * @param changes Which properties on the state changed since last frame
  43943. */
  43944. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43945. }
  43946. }
  43947. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43948. import { Scene } from "babylonjs/scene";
  43949. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43950. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43951. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43952. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43953. import { Observable } from "babylonjs/Misc/observable";
  43954. /**
  43955. * Vive Controller
  43956. */
  43957. export class ViveController extends WebVRController {
  43958. /**
  43959. * Base Url for the controller model.
  43960. */
  43961. static MODEL_BASE_URL: string;
  43962. /**
  43963. * File name for the controller model.
  43964. */
  43965. static MODEL_FILENAME: string;
  43966. /**
  43967. * Creates a new ViveController from a gamepad
  43968. * @param vrGamepad the gamepad that the controller should be created from
  43969. */
  43970. constructor(vrGamepad: any);
  43971. /**
  43972. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43973. * @param scene scene in which to add meshes
  43974. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43975. */
  43976. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43977. /**
  43978. * Fired when the left button on this controller is modified
  43979. */
  43980. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43981. /**
  43982. * Fired when the right button on this controller is modified
  43983. */
  43984. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43985. /**
  43986. * Fired when the menu button on this controller is modified
  43987. */
  43988. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43989. /**
  43990. * Called once for each button that changed state since the last frame
  43991. * Vive mapping:
  43992. * 0: touchpad
  43993. * 1: trigger
  43994. * 2: left AND right buttons
  43995. * 3: menu button
  43996. * @param buttonIdx Which button index changed
  43997. * @param state New state of the button
  43998. * @param changes Which properties on the state changed since last frame
  43999. */
  44000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  44001. }
  44002. }
  44003. declare module "babylonjs/Cameras/XR/webXRControllerModelLoader" {
  44004. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  44005. /**
  44006. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  44007. */
  44008. export class WebXRControllerModelLoader {
  44009. /**
  44010. * Creates the WebXRControllerModelLoader
  44011. * @param input xr input that creates the controllers
  44012. */
  44013. constructor(input: WebXRInput);
  44014. }
  44015. }
  44016. declare module "babylonjs/Cameras/XR/index" {
  44017. export * from "babylonjs/Cameras/XR/webXRCamera";
  44018. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  44019. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  44020. export * from "babylonjs/Cameras/XR/webXRInput";
  44021. export * from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  44022. export * from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  44023. export * from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  44024. export * from "babylonjs/Cameras/XR/webXRController";
  44025. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  44026. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  44027. }
  44028. declare module "babylonjs/Cameras/RigModes/index" {
  44029. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  44030. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  44031. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  44032. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  44033. }
  44034. declare module "babylonjs/Cameras/index" {
  44035. export * from "babylonjs/Cameras/Inputs/index";
  44036. export * from "babylonjs/Cameras/cameraInputsManager";
  44037. export * from "babylonjs/Cameras/camera";
  44038. export * from "babylonjs/Cameras/targetCamera";
  44039. export * from "babylonjs/Cameras/freeCamera";
  44040. export * from "babylonjs/Cameras/freeCameraInputsManager";
  44041. export * from "babylonjs/Cameras/touchCamera";
  44042. export * from "babylonjs/Cameras/arcRotateCamera";
  44043. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44044. export * from "babylonjs/Cameras/deviceOrientationCamera";
  44045. export * from "babylonjs/Cameras/flyCamera";
  44046. export * from "babylonjs/Cameras/flyCameraInputsManager";
  44047. export * from "babylonjs/Cameras/followCamera";
  44048. export * from "babylonjs/Cameras/followCameraInputsManager";
  44049. export * from "babylonjs/Cameras/gamepadCamera";
  44050. export * from "babylonjs/Cameras/Stereoscopic/index";
  44051. export * from "babylonjs/Cameras/universalCamera";
  44052. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  44053. export * from "babylonjs/Cameras/VR/index";
  44054. export * from "babylonjs/Cameras/XR/index";
  44055. export * from "babylonjs/Cameras/RigModes/index";
  44056. }
  44057. declare module "babylonjs/Collisions/index" {
  44058. export * from "babylonjs/Collisions/collider";
  44059. export * from "babylonjs/Collisions/collisionCoordinator";
  44060. export * from "babylonjs/Collisions/pickingInfo";
  44061. export * from "babylonjs/Collisions/intersectionInfo";
  44062. export * from "babylonjs/Collisions/meshCollisionData";
  44063. }
  44064. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  44065. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  44066. import { Vector3 } from "babylonjs/Maths/math.vector";
  44067. import { Ray } from "babylonjs/Culling/ray";
  44068. import { Plane } from "babylonjs/Maths/math.plane";
  44069. /**
  44070. * Contains an array of blocks representing the octree
  44071. */
  44072. export interface IOctreeContainer<T> {
  44073. /**
  44074. * Blocks within the octree
  44075. */
  44076. blocks: Array<OctreeBlock<T>>;
  44077. }
  44078. /**
  44079. * Class used to store a cell in an octree
  44080. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44081. */
  44082. export class OctreeBlock<T> {
  44083. /**
  44084. * Gets the content of the current block
  44085. */
  44086. entries: T[];
  44087. /**
  44088. * Gets the list of block children
  44089. */
  44090. blocks: Array<OctreeBlock<T>>;
  44091. private _depth;
  44092. private _maxDepth;
  44093. private _capacity;
  44094. private _minPoint;
  44095. private _maxPoint;
  44096. private _boundingVectors;
  44097. private _creationFunc;
  44098. /**
  44099. * Creates a new block
  44100. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  44101. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  44102. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44103. * @param depth defines the current depth of this block in the octree
  44104. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  44105. * @param creationFunc defines a callback to call when an element is added to the block
  44106. */
  44107. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  44108. /**
  44109. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  44110. */
  44111. readonly capacity: number;
  44112. /**
  44113. * Gets the minimum vector (in world space) of the block's bounding box
  44114. */
  44115. readonly minPoint: Vector3;
  44116. /**
  44117. * Gets the maximum vector (in world space) of the block's bounding box
  44118. */
  44119. readonly maxPoint: Vector3;
  44120. /**
  44121. * Add a new element to this block
  44122. * @param entry defines the element to add
  44123. */
  44124. addEntry(entry: T): void;
  44125. /**
  44126. * Remove an element from this block
  44127. * @param entry defines the element to remove
  44128. */
  44129. removeEntry(entry: T): void;
  44130. /**
  44131. * Add an array of elements to this block
  44132. * @param entries defines the array of elements to add
  44133. */
  44134. addEntries(entries: T[]): void;
  44135. /**
  44136. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  44137. * @param frustumPlanes defines the frustum planes to test
  44138. * @param selection defines the array to store current content if selection is positive
  44139. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44140. */
  44141. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44142. /**
  44143. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  44144. * @param sphereCenter defines the bounding sphere center
  44145. * @param sphereRadius defines the bounding sphere radius
  44146. * @param selection defines the array to store current content if selection is positive
  44147. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44148. */
  44149. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  44150. /**
  44151. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  44152. * @param ray defines the ray to test with
  44153. * @param selection defines the array to store current content if selection is positive
  44154. */
  44155. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  44156. /**
  44157. * Subdivide the content into child blocks (this block will then be empty)
  44158. */
  44159. createInnerBlocks(): void;
  44160. /**
  44161. * @hidden
  44162. */
  44163. 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;
  44164. }
  44165. }
  44166. declare module "babylonjs/Culling/Octrees/octree" {
  44167. import { SmartArray } from "babylonjs/Misc/smartArray";
  44168. import { Vector3 } from "babylonjs/Maths/math.vector";
  44169. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44171. import { Ray } from "babylonjs/Culling/ray";
  44172. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  44173. import { Plane } from "babylonjs/Maths/math.plane";
  44174. /**
  44175. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  44176. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44177. */
  44178. export class Octree<T> {
  44179. /** 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.) */
  44180. maxDepth: number;
  44181. /**
  44182. * Blocks within the octree containing objects
  44183. */
  44184. blocks: Array<OctreeBlock<T>>;
  44185. /**
  44186. * Content stored in the octree
  44187. */
  44188. dynamicContent: T[];
  44189. private _maxBlockCapacity;
  44190. private _selectionContent;
  44191. private _creationFunc;
  44192. /**
  44193. * Creates a octree
  44194. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44195. * @param creationFunc function to be used to instatiate the octree
  44196. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  44197. * @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.)
  44198. */
  44199. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  44200. /** 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.) */
  44201. maxDepth?: number);
  44202. /**
  44203. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  44204. * @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);
  44205. * @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);
  44206. * @param entries meshes to be added to the octree blocks
  44207. */
  44208. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  44209. /**
  44210. * Adds a mesh to the octree
  44211. * @param entry Mesh to add to the octree
  44212. */
  44213. addMesh(entry: T): void;
  44214. /**
  44215. * Remove an element from the octree
  44216. * @param entry defines the element to remove
  44217. */
  44218. removeMesh(entry: T): void;
  44219. /**
  44220. * Selects an array of meshes within the frustum
  44221. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  44222. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  44223. * @returns array of meshes within the frustum
  44224. */
  44225. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  44226. /**
  44227. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  44228. * @param sphereCenter defines the bounding sphere center
  44229. * @param sphereRadius defines the bounding sphere radius
  44230. * @param allowDuplicate defines if the selection array can contains duplicated entries
  44231. * @returns an array of objects that intersect the sphere
  44232. */
  44233. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  44234. /**
  44235. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  44236. * @param ray defines the ray to test with
  44237. * @returns array of intersected objects
  44238. */
  44239. intersectsRay(ray: Ray): SmartArray<T>;
  44240. /**
  44241. * Adds a mesh into the octree block if it intersects the block
  44242. */
  44243. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  44244. /**
  44245. * Adds a submesh into the octree block if it intersects the block
  44246. */
  44247. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  44248. }
  44249. }
  44250. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  44251. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  44252. import { Scene } from "babylonjs/scene";
  44253. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44255. import { Ray } from "babylonjs/Culling/ray";
  44256. import { Octree } from "babylonjs/Culling/Octrees/octree";
  44257. import { Collider } from "babylonjs/Collisions/collider";
  44258. module "babylonjs/scene" {
  44259. interface Scene {
  44260. /**
  44261. * @hidden
  44262. * Backing Filed
  44263. */
  44264. _selectionOctree: Octree<AbstractMesh>;
  44265. /**
  44266. * Gets the octree used to boost mesh selection (picking)
  44267. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44268. */
  44269. selectionOctree: Octree<AbstractMesh>;
  44270. /**
  44271. * Creates or updates the octree used to boost selection (picking)
  44272. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44273. * @param maxCapacity defines the maximum capacity per leaf
  44274. * @param maxDepth defines the maximum depth of the octree
  44275. * @returns an octree of AbstractMesh
  44276. */
  44277. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  44278. }
  44279. }
  44280. module "babylonjs/Meshes/abstractMesh" {
  44281. interface AbstractMesh {
  44282. /**
  44283. * @hidden
  44284. * Backing Field
  44285. */
  44286. _submeshesOctree: Octree<SubMesh>;
  44287. /**
  44288. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  44289. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  44290. * @param maxCapacity defines the maximum size of each block (64 by default)
  44291. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  44292. * @returns the new octree
  44293. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  44294. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  44295. */
  44296. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  44297. }
  44298. }
  44299. /**
  44300. * Defines the octree scene component responsible to manage any octrees
  44301. * in a given scene.
  44302. */
  44303. export class OctreeSceneComponent {
  44304. /**
  44305. * The component name help to identify the component in the list of scene components.
  44306. */
  44307. readonly name: string;
  44308. /**
  44309. * The scene the component belongs to.
  44310. */
  44311. scene: Scene;
  44312. /**
  44313. * Indicates if the meshes have been checked to make sure they are isEnabled()
  44314. */
  44315. readonly checksIsEnabled: boolean;
  44316. /**
  44317. * Creates a new instance of the component for the given scene
  44318. * @param scene Defines the scene to register the component in
  44319. */
  44320. constructor(scene: Scene);
  44321. /**
  44322. * Registers the component in a given scene
  44323. */
  44324. register(): void;
  44325. /**
  44326. * Return the list of active meshes
  44327. * @returns the list of active meshes
  44328. */
  44329. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  44330. /**
  44331. * Return the list of active sub meshes
  44332. * @param mesh The mesh to get the candidates sub meshes from
  44333. * @returns the list of active sub meshes
  44334. */
  44335. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  44336. private _tempRay;
  44337. /**
  44338. * Return the list of sub meshes intersecting with a given local ray
  44339. * @param mesh defines the mesh to find the submesh for
  44340. * @param localRay defines the ray in local space
  44341. * @returns the list of intersecting sub meshes
  44342. */
  44343. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  44344. /**
  44345. * Return the list of sub meshes colliding with a collider
  44346. * @param mesh defines the mesh to find the submesh for
  44347. * @param collider defines the collider to evaluate the collision against
  44348. * @returns the list of colliding sub meshes
  44349. */
  44350. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  44351. /**
  44352. * Rebuilds the elements related to this component in case of
  44353. * context lost for instance.
  44354. */
  44355. rebuild(): void;
  44356. /**
  44357. * Disposes the component and the associated ressources.
  44358. */
  44359. dispose(): void;
  44360. }
  44361. }
  44362. declare module "babylonjs/Culling/Octrees/index" {
  44363. export * from "babylonjs/Culling/Octrees/octree";
  44364. export * from "babylonjs/Culling/Octrees/octreeBlock";
  44365. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  44366. }
  44367. declare module "babylonjs/Culling/index" {
  44368. export * from "babylonjs/Culling/boundingBox";
  44369. export * from "babylonjs/Culling/boundingInfo";
  44370. export * from "babylonjs/Culling/boundingSphere";
  44371. export * from "babylonjs/Culling/Octrees/index";
  44372. export * from "babylonjs/Culling/ray";
  44373. }
  44374. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  44375. import { IDisposable, Scene } from "babylonjs/scene";
  44376. import { Nullable } from "babylonjs/types";
  44377. import { Observable } from "babylonjs/Misc/observable";
  44378. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44379. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  44380. import { Camera } from "babylonjs/Cameras/camera";
  44381. /**
  44382. * Renders a layer on top of an existing scene
  44383. */
  44384. export class UtilityLayerRenderer implements IDisposable {
  44385. /** the original scene that will be rendered on top of */
  44386. originalScene: Scene;
  44387. private _pointerCaptures;
  44388. private _lastPointerEvents;
  44389. private static _DefaultUtilityLayer;
  44390. private static _DefaultKeepDepthUtilityLayer;
  44391. private _sharedGizmoLight;
  44392. private _renderCamera;
  44393. /**
  44394. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  44395. * @returns the camera that is used when rendering the utility layer
  44396. */
  44397. getRenderCamera(): Nullable<Camera>;
  44398. /**
  44399. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  44400. * @param cam the camera that should be used when rendering the utility layer
  44401. */
  44402. setRenderCamera(cam: Nullable<Camera>): void;
  44403. /**
  44404. * @hidden
  44405. * Light which used by gizmos to get light shading
  44406. */
  44407. _getSharedGizmoLight(): HemisphericLight;
  44408. /**
  44409. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  44410. */
  44411. pickUtilitySceneFirst: boolean;
  44412. /**
  44413. * 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)
  44414. */
  44415. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  44416. /**
  44417. * 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)
  44418. */
  44419. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  44420. /**
  44421. * The scene that is rendered on top of the original scene
  44422. */
  44423. utilityLayerScene: Scene;
  44424. /**
  44425. * If the utility layer should automatically be rendered on top of existing scene
  44426. */
  44427. shouldRender: boolean;
  44428. /**
  44429. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  44430. */
  44431. onlyCheckPointerDownEvents: boolean;
  44432. /**
  44433. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  44434. */
  44435. processAllEvents: boolean;
  44436. /**
  44437. * Observable raised when the pointer move from the utility layer scene to the main scene
  44438. */
  44439. onPointerOutObservable: Observable<number>;
  44440. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  44441. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  44442. private _afterRenderObserver;
  44443. private _sceneDisposeObserver;
  44444. private _originalPointerObserver;
  44445. /**
  44446. * Instantiates a UtilityLayerRenderer
  44447. * @param originalScene the original scene that will be rendered on top of
  44448. * @param handleEvents boolean indicating if the utility layer should handle events
  44449. */
  44450. constructor(
  44451. /** the original scene that will be rendered on top of */
  44452. originalScene: Scene, handleEvents?: boolean);
  44453. private _notifyObservers;
  44454. /**
  44455. * Renders the utility layers scene on top of the original scene
  44456. */
  44457. render(): void;
  44458. /**
  44459. * Disposes of the renderer
  44460. */
  44461. dispose(): void;
  44462. private _updateCamera;
  44463. }
  44464. }
  44465. declare module "babylonjs/Gizmos/gizmo" {
  44466. import { Nullable } from "babylonjs/types";
  44467. import { IDisposable } from "babylonjs/scene";
  44468. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44469. import { Mesh } from "babylonjs/Meshes/mesh";
  44470. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44471. /**
  44472. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  44473. */
  44474. export class Gizmo implements IDisposable {
  44475. /** The utility layer the gizmo will be added to */
  44476. gizmoLayer: UtilityLayerRenderer;
  44477. /**
  44478. * The root mesh of the gizmo
  44479. */
  44480. _rootMesh: Mesh;
  44481. private _attachedMesh;
  44482. /**
  44483. * Ratio for the scale of the gizmo (Default: 1)
  44484. */
  44485. scaleRatio: number;
  44486. /**
  44487. * If a custom mesh has been set (Default: false)
  44488. */
  44489. protected _customMeshSet: boolean;
  44490. /**
  44491. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  44492. * * When set, interactions will be enabled
  44493. */
  44494. attachedMesh: Nullable<AbstractMesh>;
  44495. /**
  44496. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  44497. * @param mesh The mesh to replace the default mesh of the gizmo
  44498. */
  44499. setCustomMesh(mesh: Mesh): void;
  44500. /**
  44501. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  44502. */
  44503. updateGizmoRotationToMatchAttachedMesh: boolean;
  44504. /**
  44505. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  44506. */
  44507. updateGizmoPositionToMatchAttachedMesh: boolean;
  44508. /**
  44509. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  44510. */
  44511. updateScale: boolean;
  44512. protected _interactionsEnabled: boolean;
  44513. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44514. private _beforeRenderObserver;
  44515. private _tempVector;
  44516. /**
  44517. * Creates a gizmo
  44518. * @param gizmoLayer The utility layer the gizmo will be added to
  44519. */
  44520. constructor(
  44521. /** The utility layer the gizmo will be added to */
  44522. gizmoLayer?: UtilityLayerRenderer);
  44523. /**
  44524. * Updates the gizmo to match the attached mesh's position/rotation
  44525. */
  44526. protected _update(): void;
  44527. /**
  44528. * Disposes of the gizmo
  44529. */
  44530. dispose(): void;
  44531. }
  44532. }
  44533. declare module "babylonjs/Gizmos/planeDragGizmo" {
  44534. import { Observable } from "babylonjs/Misc/observable";
  44535. import { Nullable } from "babylonjs/types";
  44536. import { Vector3 } from "babylonjs/Maths/math.vector";
  44537. import { Color3 } from "babylonjs/Maths/math.color";
  44538. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44539. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44540. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44541. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44542. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44543. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44544. import { Scene } from "babylonjs/scene";
  44545. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44546. /**
  44547. * Single plane drag gizmo
  44548. */
  44549. export class PlaneDragGizmo extends Gizmo {
  44550. /**
  44551. * Drag behavior responsible for the gizmos dragging interactions
  44552. */
  44553. dragBehavior: PointerDragBehavior;
  44554. private _pointerObserver;
  44555. /**
  44556. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44557. */
  44558. snapDistance: number;
  44559. /**
  44560. * Event that fires each time the gizmo snaps to a new location.
  44561. * * snapDistance is the the change in distance
  44562. */
  44563. onSnapObservable: Observable<{
  44564. snapDistance: number;
  44565. }>;
  44566. private _plane;
  44567. private _coloredMaterial;
  44568. private _hoverMaterial;
  44569. private _isEnabled;
  44570. private _parent;
  44571. /** @hidden */
  44572. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  44573. /** @hidden */
  44574. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44575. /**
  44576. * Creates a PlaneDragGizmo
  44577. * @param gizmoLayer The utility layer the gizmo will be added to
  44578. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  44579. * @param color The color of the gizmo
  44580. */
  44581. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44582. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44583. /**
  44584. * If the gizmo is enabled
  44585. */
  44586. isEnabled: boolean;
  44587. /**
  44588. * Disposes of the gizmo
  44589. */
  44590. dispose(): void;
  44591. }
  44592. }
  44593. declare module "babylonjs/Gizmos/positionGizmo" {
  44594. import { Observable } from "babylonjs/Misc/observable";
  44595. import { Nullable } from "babylonjs/types";
  44596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44597. import { Mesh } from "babylonjs/Meshes/mesh";
  44598. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44599. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44600. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  44601. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44602. /**
  44603. * Gizmo that enables dragging a mesh along 3 axis
  44604. */
  44605. export class PositionGizmo extends Gizmo {
  44606. /**
  44607. * Internal gizmo used for interactions on the x axis
  44608. */
  44609. xGizmo: AxisDragGizmo;
  44610. /**
  44611. * Internal gizmo used for interactions on the y axis
  44612. */
  44613. yGizmo: AxisDragGizmo;
  44614. /**
  44615. * Internal gizmo used for interactions on the z axis
  44616. */
  44617. zGizmo: AxisDragGizmo;
  44618. /**
  44619. * Internal gizmo used for interactions on the yz plane
  44620. */
  44621. xPlaneGizmo: PlaneDragGizmo;
  44622. /**
  44623. * Internal gizmo used for interactions on the xz plane
  44624. */
  44625. yPlaneGizmo: PlaneDragGizmo;
  44626. /**
  44627. * Internal gizmo used for interactions on the xy plane
  44628. */
  44629. zPlaneGizmo: PlaneDragGizmo;
  44630. /**
  44631. * private variables
  44632. */
  44633. private _meshAttached;
  44634. private _updateGizmoRotationToMatchAttachedMesh;
  44635. private _snapDistance;
  44636. private _scaleRatio;
  44637. /** Fires an event when any of it's sub gizmos are dragged */
  44638. onDragStartObservable: Observable<unknown>;
  44639. /** Fires an event when any of it's sub gizmos are released from dragging */
  44640. onDragEndObservable: Observable<unknown>;
  44641. /**
  44642. * If set to true, planar drag is enabled
  44643. */
  44644. private _planarGizmoEnabled;
  44645. attachedMesh: Nullable<AbstractMesh>;
  44646. /**
  44647. * Creates a PositionGizmo
  44648. * @param gizmoLayer The utility layer the gizmo will be added to
  44649. */
  44650. constructor(gizmoLayer?: UtilityLayerRenderer);
  44651. /**
  44652. * If the planar drag gizmo is enabled
  44653. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  44654. */
  44655. planarGizmoEnabled: boolean;
  44656. updateGizmoRotationToMatchAttachedMesh: boolean;
  44657. /**
  44658. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44659. */
  44660. snapDistance: number;
  44661. /**
  44662. * Ratio for the scale of the gizmo (Default: 1)
  44663. */
  44664. scaleRatio: number;
  44665. /**
  44666. * Disposes of the gizmo
  44667. */
  44668. dispose(): void;
  44669. /**
  44670. * CustomMeshes are not supported by this gizmo
  44671. * @param mesh The mesh to replace the default mesh of the gizmo
  44672. */
  44673. setCustomMesh(mesh: Mesh): void;
  44674. }
  44675. }
  44676. declare module "babylonjs/Gizmos/axisDragGizmo" {
  44677. import { Observable } from "babylonjs/Misc/observable";
  44678. import { Nullable } from "babylonjs/types";
  44679. import { Vector3 } from "babylonjs/Maths/math.vector";
  44680. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44681. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44682. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  44683. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44684. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44685. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  44686. import { Scene } from "babylonjs/scene";
  44687. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44688. import { Color3 } from "babylonjs/Maths/math.color";
  44689. /**
  44690. * Single axis drag gizmo
  44691. */
  44692. export class AxisDragGizmo extends Gizmo {
  44693. /**
  44694. * Drag behavior responsible for the gizmos dragging interactions
  44695. */
  44696. dragBehavior: PointerDragBehavior;
  44697. private _pointerObserver;
  44698. /**
  44699. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44700. */
  44701. snapDistance: number;
  44702. /**
  44703. * Event that fires each time the gizmo snaps to a new location.
  44704. * * snapDistance is the the change in distance
  44705. */
  44706. onSnapObservable: Observable<{
  44707. snapDistance: number;
  44708. }>;
  44709. private _isEnabled;
  44710. private _parent;
  44711. private _arrow;
  44712. private _coloredMaterial;
  44713. private _hoverMaterial;
  44714. /** @hidden */
  44715. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  44716. /** @hidden */
  44717. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  44718. /**
  44719. * Creates an AxisDragGizmo
  44720. * @param gizmoLayer The utility layer the gizmo will be added to
  44721. * @param dragAxis The axis which the gizmo will be able to drag on
  44722. * @param color The color of the gizmo
  44723. */
  44724. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  44725. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44726. /**
  44727. * If the gizmo is enabled
  44728. */
  44729. isEnabled: boolean;
  44730. /**
  44731. * Disposes of the gizmo
  44732. */
  44733. dispose(): void;
  44734. }
  44735. }
  44736. declare module "babylonjs/Debug/axesViewer" {
  44737. import { Vector3 } from "babylonjs/Maths/math.vector";
  44738. import { Nullable } from "babylonjs/types";
  44739. import { Scene } from "babylonjs/scene";
  44740. import { TransformNode } from "babylonjs/Meshes/transformNode";
  44741. /**
  44742. * The Axes viewer will show 3 axes in a specific point in space
  44743. */
  44744. export class AxesViewer {
  44745. private _xAxis;
  44746. private _yAxis;
  44747. private _zAxis;
  44748. private _scaleLinesFactor;
  44749. private _instanced;
  44750. /**
  44751. * Gets the hosting scene
  44752. */
  44753. scene: Scene;
  44754. /**
  44755. * Gets or sets a number used to scale line length
  44756. */
  44757. scaleLines: number;
  44758. /** Gets the node hierarchy used to render x-axis */
  44759. readonly xAxis: TransformNode;
  44760. /** Gets the node hierarchy used to render y-axis */
  44761. readonly yAxis: TransformNode;
  44762. /** Gets the node hierarchy used to render z-axis */
  44763. readonly zAxis: TransformNode;
  44764. /**
  44765. * Creates a new AxesViewer
  44766. * @param scene defines the hosting scene
  44767. * @param scaleLines defines a number used to scale line length (1 by default)
  44768. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  44769. * @param xAxis defines the node hierarchy used to render the x-axis
  44770. * @param yAxis defines the node hierarchy used to render the y-axis
  44771. * @param zAxis defines the node hierarchy used to render the z-axis
  44772. */
  44773. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  44774. /**
  44775. * Force the viewer to update
  44776. * @param position defines the position of the viewer
  44777. * @param xaxis defines the x axis of the viewer
  44778. * @param yaxis defines the y axis of the viewer
  44779. * @param zaxis defines the z axis of the viewer
  44780. */
  44781. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  44782. /**
  44783. * Creates an instance of this axes viewer.
  44784. * @returns a new axes viewer with instanced meshes
  44785. */
  44786. createInstance(): AxesViewer;
  44787. /** Releases resources */
  44788. dispose(): void;
  44789. private static _SetRenderingGroupId;
  44790. }
  44791. }
  44792. declare module "babylonjs/Debug/boneAxesViewer" {
  44793. import { Nullable } from "babylonjs/types";
  44794. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  44795. import { Vector3 } from "babylonjs/Maths/math.vector";
  44796. import { Mesh } from "babylonjs/Meshes/mesh";
  44797. import { Bone } from "babylonjs/Bones/bone";
  44798. import { Scene } from "babylonjs/scene";
  44799. /**
  44800. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  44801. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  44802. */
  44803. export class BoneAxesViewer extends AxesViewer {
  44804. /**
  44805. * Gets or sets the target mesh where to display the axes viewer
  44806. */
  44807. mesh: Nullable<Mesh>;
  44808. /**
  44809. * Gets or sets the target bone where to display the axes viewer
  44810. */
  44811. bone: Nullable<Bone>;
  44812. /** Gets current position */
  44813. pos: Vector3;
  44814. /** Gets direction of X axis */
  44815. xaxis: Vector3;
  44816. /** Gets direction of Y axis */
  44817. yaxis: Vector3;
  44818. /** Gets direction of Z axis */
  44819. zaxis: Vector3;
  44820. /**
  44821. * Creates a new BoneAxesViewer
  44822. * @param scene defines the hosting scene
  44823. * @param bone defines the target bone
  44824. * @param mesh defines the target mesh
  44825. * @param scaleLines defines a scaling factor for line length (1 by default)
  44826. */
  44827. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  44828. /**
  44829. * Force the viewer to update
  44830. */
  44831. update(): void;
  44832. /** Releases resources */
  44833. dispose(): void;
  44834. }
  44835. }
  44836. declare module "babylonjs/Debug/debugLayer" {
  44837. import { Scene } from "babylonjs/scene";
  44838. /**
  44839. * Interface used to define scene explorer extensibility option
  44840. */
  44841. export interface IExplorerExtensibilityOption {
  44842. /**
  44843. * Define the option label
  44844. */
  44845. label: string;
  44846. /**
  44847. * Defines the action to execute on click
  44848. */
  44849. action: (entity: any) => void;
  44850. }
  44851. /**
  44852. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  44853. */
  44854. export interface IExplorerExtensibilityGroup {
  44855. /**
  44856. * Defines a predicate to test if a given type mut be extended
  44857. */
  44858. predicate: (entity: any) => boolean;
  44859. /**
  44860. * Gets the list of options added to a type
  44861. */
  44862. entries: IExplorerExtensibilityOption[];
  44863. }
  44864. /**
  44865. * Interface used to define the options to use to create the Inspector
  44866. */
  44867. export interface IInspectorOptions {
  44868. /**
  44869. * Display in overlay mode (default: false)
  44870. */
  44871. overlay?: boolean;
  44872. /**
  44873. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  44874. */
  44875. globalRoot?: HTMLElement;
  44876. /**
  44877. * Display the Scene explorer
  44878. */
  44879. showExplorer?: boolean;
  44880. /**
  44881. * Display the property inspector
  44882. */
  44883. showInspector?: boolean;
  44884. /**
  44885. * Display in embed mode (both panes on the right)
  44886. */
  44887. embedMode?: boolean;
  44888. /**
  44889. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  44890. */
  44891. handleResize?: boolean;
  44892. /**
  44893. * Allow the panes to popup (default: true)
  44894. */
  44895. enablePopup?: boolean;
  44896. /**
  44897. * Allow the panes to be closed by users (default: true)
  44898. */
  44899. enableClose?: boolean;
  44900. /**
  44901. * Optional list of extensibility entries
  44902. */
  44903. explorerExtensibility?: IExplorerExtensibilityGroup[];
  44904. /**
  44905. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  44906. */
  44907. inspectorURL?: string;
  44908. }
  44909. module "babylonjs/scene" {
  44910. interface Scene {
  44911. /**
  44912. * @hidden
  44913. * Backing field
  44914. */
  44915. _debugLayer: DebugLayer;
  44916. /**
  44917. * Gets the debug layer (aka Inspector) associated with the scene
  44918. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44919. */
  44920. debugLayer: DebugLayer;
  44921. }
  44922. }
  44923. /**
  44924. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44925. * what is happening in your scene
  44926. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44927. */
  44928. export class DebugLayer {
  44929. /**
  44930. * Define the url to get the inspector script from.
  44931. * By default it uses the babylonjs CDN.
  44932. * @ignoreNaming
  44933. */
  44934. static InspectorURL: string;
  44935. private _scene;
  44936. private BJSINSPECTOR;
  44937. private _onPropertyChangedObservable?;
  44938. /**
  44939. * Observable triggered when a property is changed through the inspector.
  44940. */
  44941. readonly onPropertyChangedObservable: any;
  44942. /**
  44943. * Instantiates a new debug layer.
  44944. * The debug layer (aka Inspector) is the go to tool in order to better understand
  44945. * what is happening in your scene
  44946. * @see http://doc.babylonjs.com/features/playground_debuglayer
  44947. * @param scene Defines the scene to inspect
  44948. */
  44949. constructor(scene: Scene);
  44950. /** Creates the inspector window. */
  44951. private _createInspector;
  44952. /**
  44953. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  44954. * @param entity defines the entity to select
  44955. * @param lineContainerTitle defines the specific block to highlight
  44956. */
  44957. select(entity: any, lineContainerTitle?: string): void;
  44958. /** Get the inspector from bundle or global */
  44959. private _getGlobalInspector;
  44960. /**
  44961. * Get if the inspector is visible or not.
  44962. * @returns true if visible otherwise, false
  44963. */
  44964. isVisible(): boolean;
  44965. /**
  44966. * Hide the inspector and close its window.
  44967. */
  44968. hide(): void;
  44969. /**
  44970. * Launch the debugLayer.
  44971. * @param config Define the configuration of the inspector
  44972. * @return a promise fulfilled when the debug layer is visible
  44973. */
  44974. show(config?: IInspectorOptions): Promise<DebugLayer>;
  44975. }
  44976. }
  44977. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  44978. import { Nullable } from "babylonjs/types";
  44979. import { Scene } from "babylonjs/scene";
  44980. import { Vector4 } from "babylonjs/Maths/math.vector";
  44981. import { Color4 } from "babylonjs/Maths/math.color";
  44982. import { Mesh } from "babylonjs/Meshes/mesh";
  44983. /**
  44984. * Class containing static functions to help procedurally build meshes
  44985. */
  44986. export class BoxBuilder {
  44987. /**
  44988. * Creates a box mesh
  44989. * * The parameter `size` sets the size (float) of each box side (default 1)
  44990. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  44991. * * 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)
  44992. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  44993. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44994. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44995. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44996. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  44997. * @param name defines the name of the mesh
  44998. * @param options defines the options used to create the mesh
  44999. * @param scene defines the hosting scene
  45000. * @returns the box mesh
  45001. */
  45002. static CreateBox(name: string, options: {
  45003. size?: number;
  45004. width?: number;
  45005. height?: number;
  45006. depth?: number;
  45007. faceUV?: Vector4[];
  45008. faceColors?: Color4[];
  45009. sideOrientation?: number;
  45010. frontUVs?: Vector4;
  45011. backUVs?: Vector4;
  45012. wrap?: boolean;
  45013. topBaseAt?: number;
  45014. bottomBaseAt?: number;
  45015. updatable?: boolean;
  45016. }, scene?: Nullable<Scene>): Mesh;
  45017. }
  45018. }
  45019. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45020. import { Vector4 } from "babylonjs/Maths/math.vector";
  45021. import { Mesh } from "babylonjs/Meshes/mesh";
  45022. import { Scene } from "babylonjs/scene";
  45023. import { Nullable } from "babylonjs/types";
  45024. /**
  45025. * Class containing static functions to help procedurally build meshes
  45026. */
  45027. export class SphereBuilder {
  45028. /**
  45029. * Creates a sphere mesh
  45030. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45031. * * 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`)
  45032. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45033. * * 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
  45034. * * 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)
  45035. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45036. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45037. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45038. * @param name defines the name of the mesh
  45039. * @param options defines the options used to create the mesh
  45040. * @param scene defines the hosting scene
  45041. * @returns the sphere mesh
  45042. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45043. */
  45044. static CreateSphere(name: string, options: {
  45045. segments?: number;
  45046. diameter?: number;
  45047. diameterX?: number;
  45048. diameterY?: number;
  45049. diameterZ?: number;
  45050. arc?: number;
  45051. slice?: number;
  45052. sideOrientation?: number;
  45053. frontUVs?: Vector4;
  45054. backUVs?: Vector4;
  45055. updatable?: boolean;
  45056. }, scene?: Nullable<Scene>): Mesh;
  45057. }
  45058. }
  45059. declare module "babylonjs/Debug/physicsViewer" {
  45060. import { Nullable } from "babylonjs/types";
  45061. import { Scene } from "babylonjs/scene";
  45062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45063. import { Mesh } from "babylonjs/Meshes/mesh";
  45064. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  45065. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  45066. /**
  45067. * Used to show the physics impostor around the specific mesh
  45068. */
  45069. export class PhysicsViewer {
  45070. /** @hidden */
  45071. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  45072. /** @hidden */
  45073. protected _meshes: Array<Nullable<AbstractMesh>>;
  45074. /** @hidden */
  45075. protected _scene: Nullable<Scene>;
  45076. /** @hidden */
  45077. protected _numMeshes: number;
  45078. /** @hidden */
  45079. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  45080. private _renderFunction;
  45081. private _utilityLayer;
  45082. private _debugBoxMesh;
  45083. private _debugSphereMesh;
  45084. private _debugCylinderMesh;
  45085. private _debugMaterial;
  45086. private _debugMeshMeshes;
  45087. /**
  45088. * Creates a new PhysicsViewer
  45089. * @param scene defines the hosting scene
  45090. */
  45091. constructor(scene: Scene);
  45092. /** @hidden */
  45093. protected _updateDebugMeshes(): void;
  45094. /**
  45095. * Renders a specified physic impostor
  45096. * @param impostor defines the impostor to render
  45097. * @param targetMesh defines the mesh represented by the impostor
  45098. * @returns the new debug mesh used to render the impostor
  45099. */
  45100. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  45101. /**
  45102. * Hides a specified physic impostor
  45103. * @param impostor defines the impostor to hide
  45104. */
  45105. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  45106. private _getDebugMaterial;
  45107. private _getDebugBoxMesh;
  45108. private _getDebugSphereMesh;
  45109. private _getDebugCylinderMesh;
  45110. private _getDebugMeshMesh;
  45111. private _getDebugMesh;
  45112. /** Releases all resources */
  45113. dispose(): void;
  45114. }
  45115. }
  45116. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  45117. import { Vector3 } from "babylonjs/Maths/math.vector";
  45118. import { Color4 } from "babylonjs/Maths/math.color";
  45119. import { Nullable } from "babylonjs/types";
  45120. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45121. import { Scene } from "babylonjs/scene";
  45122. /**
  45123. * Class containing static functions to help procedurally build meshes
  45124. */
  45125. export class LinesBuilder {
  45126. /**
  45127. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  45128. * * 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
  45129. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  45130. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  45131. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  45132. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  45133. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  45134. * * 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
  45135. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  45136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45137. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  45138. * @param name defines the name of the new line system
  45139. * @param options defines the options used to create the line system
  45140. * @param scene defines the hosting scene
  45141. * @returns a new line system mesh
  45142. */
  45143. static CreateLineSystem(name: string, options: {
  45144. lines: Vector3[][];
  45145. updatable?: boolean;
  45146. instance?: Nullable<LinesMesh>;
  45147. colors?: Nullable<Color4[][]>;
  45148. useVertexAlpha?: boolean;
  45149. }, scene: Nullable<Scene>): LinesMesh;
  45150. /**
  45151. * Creates a line mesh
  45152. * 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
  45153. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45154. * * The parameter `points` is an array successive Vector3
  45155. * * 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
  45156. * * The optional parameter `colors` is an array of successive Color4, one per line point
  45157. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  45158. * * When updating an instance, remember that only point positions can change, not the number of points
  45159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45160. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  45161. * @param name defines the name of the new line system
  45162. * @param options defines the options used to create the line system
  45163. * @param scene defines the hosting scene
  45164. * @returns a new line mesh
  45165. */
  45166. static CreateLines(name: string, options: {
  45167. points: Vector3[];
  45168. updatable?: boolean;
  45169. instance?: Nullable<LinesMesh>;
  45170. colors?: Color4[];
  45171. useVertexAlpha?: boolean;
  45172. }, scene?: Nullable<Scene>): LinesMesh;
  45173. /**
  45174. * Creates a dashed line mesh
  45175. * * 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
  45176. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  45177. * * The parameter `points` is an array successive Vector3
  45178. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  45179. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  45180. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  45181. * * 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
  45182. * * When updating an instance, remember that only point positions can change, not the number of points
  45183. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45184. * @param name defines the name of the mesh
  45185. * @param options defines the options used to create the mesh
  45186. * @param scene defines the hosting scene
  45187. * @returns the dashed line mesh
  45188. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  45189. */
  45190. static CreateDashedLines(name: string, options: {
  45191. points: Vector3[];
  45192. dashSize?: number;
  45193. gapSize?: number;
  45194. dashNb?: number;
  45195. updatable?: boolean;
  45196. instance?: LinesMesh;
  45197. }, scene?: Nullable<Scene>): LinesMesh;
  45198. }
  45199. }
  45200. declare module "babylonjs/Debug/rayHelper" {
  45201. import { Nullable } from "babylonjs/types";
  45202. import { Ray } from "babylonjs/Culling/ray";
  45203. import { Vector3 } from "babylonjs/Maths/math.vector";
  45204. import { Color3 } from "babylonjs/Maths/math.color";
  45205. import { Scene } from "babylonjs/scene";
  45206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45207. import "babylonjs/Meshes/Builders/linesBuilder";
  45208. /**
  45209. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45210. * in order to better appreciate the issue one might have.
  45211. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45212. */
  45213. export class RayHelper {
  45214. /**
  45215. * Defines the ray we are currently tryin to visualize.
  45216. */
  45217. ray: Nullable<Ray>;
  45218. private _renderPoints;
  45219. private _renderLine;
  45220. private _renderFunction;
  45221. private _scene;
  45222. private _updateToMeshFunction;
  45223. private _attachedToMesh;
  45224. private _meshSpaceDirection;
  45225. private _meshSpaceOrigin;
  45226. /**
  45227. * Helper function to create a colored helper in a scene in one line.
  45228. * @param ray Defines the ray we are currently tryin to visualize
  45229. * @param scene Defines the scene the ray is used in
  45230. * @param color Defines the color we want to see the ray in
  45231. * @returns The newly created ray helper.
  45232. */
  45233. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  45234. /**
  45235. * Instantiate a new ray helper.
  45236. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  45237. * in order to better appreciate the issue one might have.
  45238. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  45239. * @param ray Defines the ray we are currently tryin to visualize
  45240. */
  45241. constructor(ray: Ray);
  45242. /**
  45243. * Shows the ray we are willing to debug.
  45244. * @param scene Defines the scene the ray needs to be rendered in
  45245. * @param color Defines the color the ray needs to be rendered in
  45246. */
  45247. show(scene: Scene, color?: Color3): void;
  45248. /**
  45249. * Hides the ray we are debugging.
  45250. */
  45251. hide(): void;
  45252. private _render;
  45253. /**
  45254. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  45255. * @param mesh Defines the mesh we want the helper attached to
  45256. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  45257. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  45258. * @param length Defines the length of the ray
  45259. */
  45260. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  45261. /**
  45262. * Detach the ray helper from the mesh it has previously been attached to.
  45263. */
  45264. detachFromMesh(): void;
  45265. private _updateToMesh;
  45266. /**
  45267. * Dispose the helper and release its associated resources.
  45268. */
  45269. dispose(): void;
  45270. }
  45271. }
  45272. declare module "babylonjs/Debug/skeletonViewer" {
  45273. import { Color3 } from "babylonjs/Maths/math.color";
  45274. import { Scene } from "babylonjs/scene";
  45275. import { Nullable } from "babylonjs/types";
  45276. import { Skeleton } from "babylonjs/Bones/skeleton";
  45277. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45278. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  45279. /**
  45280. * Class used to render a debug view of a given skeleton
  45281. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  45282. */
  45283. export class SkeletonViewer {
  45284. /** defines the skeleton to render */
  45285. skeleton: Skeleton;
  45286. /** defines the mesh attached to the skeleton */
  45287. mesh: AbstractMesh;
  45288. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45289. autoUpdateBonesMatrices: boolean;
  45290. /** defines the rendering group id to use with the viewer */
  45291. renderingGroupId: number;
  45292. /** Gets or sets the color used to render the skeleton */
  45293. color: Color3;
  45294. private _scene;
  45295. private _debugLines;
  45296. private _debugMesh;
  45297. private _isEnabled;
  45298. private _renderFunction;
  45299. private _utilityLayer;
  45300. /**
  45301. * Returns the mesh used to render the bones
  45302. */
  45303. readonly debugMesh: Nullable<LinesMesh>;
  45304. /**
  45305. * Creates a new SkeletonViewer
  45306. * @param skeleton defines the skeleton to render
  45307. * @param mesh defines the mesh attached to the skeleton
  45308. * @param scene defines the hosting scene
  45309. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  45310. * @param renderingGroupId defines the rendering group id to use with the viewer
  45311. */
  45312. constructor(
  45313. /** defines the skeleton to render */
  45314. skeleton: Skeleton,
  45315. /** defines the mesh attached to the skeleton */
  45316. mesh: AbstractMesh, scene: Scene,
  45317. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  45318. autoUpdateBonesMatrices?: boolean,
  45319. /** defines the rendering group id to use with the viewer */
  45320. renderingGroupId?: number);
  45321. /** Gets or sets a boolean indicating if the viewer is enabled */
  45322. isEnabled: boolean;
  45323. private _getBonePosition;
  45324. private _getLinesForBonesWithLength;
  45325. private _getLinesForBonesNoLength;
  45326. /** Update the viewer to sync with current skeleton state */
  45327. update(): void;
  45328. /** Release associated resources */
  45329. dispose(): void;
  45330. }
  45331. }
  45332. declare module "babylonjs/Debug/index" {
  45333. export * from "babylonjs/Debug/axesViewer";
  45334. export * from "babylonjs/Debug/boneAxesViewer";
  45335. export * from "babylonjs/Debug/debugLayer";
  45336. export * from "babylonjs/Debug/physicsViewer";
  45337. export * from "babylonjs/Debug/rayHelper";
  45338. export * from "babylonjs/Debug/skeletonViewer";
  45339. }
  45340. declare module "babylonjs/Engines/nullEngine" {
  45341. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  45342. import { Scene } from "babylonjs/scene";
  45343. import { Engine } from "babylonjs/Engines/engine";
  45344. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  45345. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  45346. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  45347. import { Effect } from "babylonjs/Materials/effect";
  45348. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  45349. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45350. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  45351. /**
  45352. * Options to create the null engine
  45353. */
  45354. export class NullEngineOptions {
  45355. /**
  45356. * Render width (Default: 512)
  45357. */
  45358. renderWidth: number;
  45359. /**
  45360. * Render height (Default: 256)
  45361. */
  45362. renderHeight: number;
  45363. /**
  45364. * Texture size (Default: 512)
  45365. */
  45366. textureSize: number;
  45367. /**
  45368. * If delta time between frames should be constant
  45369. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45370. */
  45371. deterministicLockstep: boolean;
  45372. /**
  45373. * Maximum about of steps between frames (Default: 4)
  45374. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45375. */
  45376. lockstepMaxSteps: number;
  45377. }
  45378. /**
  45379. * The null engine class provides support for headless version of babylon.js.
  45380. * This can be used in server side scenario or for testing purposes
  45381. */
  45382. export class NullEngine extends Engine {
  45383. private _options;
  45384. /**
  45385. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  45386. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45387. * @returns true if engine is in deterministic lock step mode
  45388. */
  45389. isDeterministicLockStep(): boolean;
  45390. /**
  45391. * Gets the max steps when engine is running in deterministic lock step
  45392. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  45393. * @returns the max steps
  45394. */
  45395. getLockstepMaxSteps(): number;
  45396. /**
  45397. * Gets the current hardware scaling level.
  45398. * By default the hardware scaling level is computed from the window device ratio.
  45399. * 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.
  45400. * @returns a number indicating the current hardware scaling level
  45401. */
  45402. getHardwareScalingLevel(): number;
  45403. constructor(options?: NullEngineOptions);
  45404. /**
  45405. * Creates a vertex buffer
  45406. * @param vertices the data for the vertex buffer
  45407. * @returns the new WebGL static buffer
  45408. */
  45409. createVertexBuffer(vertices: FloatArray): DataBuffer;
  45410. /**
  45411. * Creates a new index buffer
  45412. * @param indices defines the content of the index buffer
  45413. * @param updatable defines if the index buffer must be updatable
  45414. * @returns a new webGL buffer
  45415. */
  45416. createIndexBuffer(indices: IndicesArray): DataBuffer;
  45417. /**
  45418. * Clear the current render buffer or the current render target (if any is set up)
  45419. * @param color defines the color to use
  45420. * @param backBuffer defines if the back buffer must be cleared
  45421. * @param depth defines if the depth buffer must be cleared
  45422. * @param stencil defines if the stencil buffer must be cleared
  45423. */
  45424. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  45425. /**
  45426. * Gets the current render width
  45427. * @param useScreen defines if screen size must be used (or the current render target if any)
  45428. * @returns a number defining the current render width
  45429. */
  45430. getRenderWidth(useScreen?: boolean): number;
  45431. /**
  45432. * Gets the current render height
  45433. * @param useScreen defines if screen size must be used (or the current render target if any)
  45434. * @returns a number defining the current render height
  45435. */
  45436. getRenderHeight(useScreen?: boolean): number;
  45437. /**
  45438. * Set the WebGL's viewport
  45439. * @param viewport defines the viewport element to be used
  45440. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  45441. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  45442. */
  45443. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  45444. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  45445. /**
  45446. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  45447. * @param pipelineContext defines the pipeline context to use
  45448. * @param uniformsNames defines the list of uniform names
  45449. * @returns an array of webGL uniform locations
  45450. */
  45451. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  45452. /**
  45453. * Gets the lsit of active attributes for a given webGL program
  45454. * @param pipelineContext defines the pipeline context to use
  45455. * @param attributesNames defines the list of attribute names to get
  45456. * @returns an array of indices indicating the offset of each attribute
  45457. */
  45458. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  45459. /**
  45460. * Binds an effect to the webGL context
  45461. * @param effect defines the effect to bind
  45462. */
  45463. bindSamplers(effect: Effect): void;
  45464. /**
  45465. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  45466. * @param effect defines the effect to activate
  45467. */
  45468. enableEffect(effect: Effect): void;
  45469. /**
  45470. * Set various states to the webGL context
  45471. * @param culling defines backface culling state
  45472. * @param zOffset defines the value to apply to zOffset (0 by default)
  45473. * @param force defines if states must be applied even if cache is up to date
  45474. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  45475. */
  45476. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  45477. /**
  45478. * Set the value of an uniform to an array of int32
  45479. * @param uniform defines the webGL uniform location where to store the value
  45480. * @param array defines the array of int32 to store
  45481. */
  45482. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  45483. /**
  45484. * Set the value of an uniform to an array of int32 (stored as vec2)
  45485. * @param uniform defines the webGL uniform location where to store the value
  45486. * @param array defines the array of int32 to store
  45487. */
  45488. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  45489. /**
  45490. * Set the value of an uniform to an array of int32 (stored as vec3)
  45491. * @param uniform defines the webGL uniform location where to store the value
  45492. * @param array defines the array of int32 to store
  45493. */
  45494. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  45495. /**
  45496. * Set the value of an uniform to an array of int32 (stored as vec4)
  45497. * @param uniform defines the webGL uniform location where to store the value
  45498. * @param array defines the array of int32 to store
  45499. */
  45500. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  45501. /**
  45502. * Set the value of an uniform to an array of float32
  45503. * @param uniform defines the webGL uniform location where to store the value
  45504. * @param array defines the array of float32 to store
  45505. */
  45506. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  45507. /**
  45508. * Set the value of an uniform to an array of float32 (stored as vec2)
  45509. * @param uniform defines the webGL uniform location where to store the value
  45510. * @param array defines the array of float32 to store
  45511. */
  45512. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  45513. /**
  45514. * Set the value of an uniform to an array of float32 (stored as vec3)
  45515. * @param uniform defines the webGL uniform location where to store the value
  45516. * @param array defines the array of float32 to store
  45517. */
  45518. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  45519. /**
  45520. * Set the value of an uniform to an array of float32 (stored as vec4)
  45521. * @param uniform defines the webGL uniform location where to store the value
  45522. * @param array defines the array of float32 to store
  45523. */
  45524. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  45525. /**
  45526. * Set the value of an uniform to an array of number
  45527. * @param uniform defines the webGL uniform location where to store the value
  45528. * @param array defines the array of number to store
  45529. */
  45530. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  45531. /**
  45532. * Set the value of an uniform to an array of number (stored as vec2)
  45533. * @param uniform defines the webGL uniform location where to store the value
  45534. * @param array defines the array of number to store
  45535. */
  45536. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  45537. /**
  45538. * Set the value of an uniform to an array of number (stored as vec3)
  45539. * @param uniform defines the webGL uniform location where to store the value
  45540. * @param array defines the array of number to store
  45541. */
  45542. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  45543. /**
  45544. * Set the value of an uniform to an array of number (stored as vec4)
  45545. * @param uniform defines the webGL uniform location where to store the value
  45546. * @param array defines the array of number to store
  45547. */
  45548. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  45549. /**
  45550. * Set the value of an uniform to an array of float32 (stored as matrices)
  45551. * @param uniform defines the webGL uniform location where to store the value
  45552. * @param matrices defines the array of float32 to store
  45553. */
  45554. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  45555. /**
  45556. * Set the value of an uniform to a matrix (3x3)
  45557. * @param uniform defines the webGL uniform location where to store the value
  45558. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  45559. */
  45560. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45561. /**
  45562. * Set the value of an uniform to a matrix (2x2)
  45563. * @param uniform defines the webGL uniform location where to store the value
  45564. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  45565. */
  45566. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  45567. /**
  45568. * Set the value of an uniform to a number (float)
  45569. * @param uniform defines the webGL uniform location where to store the value
  45570. * @param value defines the float number to store
  45571. */
  45572. setFloat(uniform: WebGLUniformLocation, value: number): void;
  45573. /**
  45574. * Set the value of an uniform to a vec2
  45575. * @param uniform defines the webGL uniform location where to store the value
  45576. * @param x defines the 1st component of the value
  45577. * @param y defines the 2nd component of the value
  45578. */
  45579. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  45580. /**
  45581. * Set the value of an uniform to a vec3
  45582. * @param uniform defines the webGL uniform location where to store the value
  45583. * @param x defines the 1st component of the value
  45584. * @param y defines the 2nd component of the value
  45585. * @param z defines the 3rd component of the value
  45586. */
  45587. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  45588. /**
  45589. * Set the value of an uniform to a boolean
  45590. * @param uniform defines the webGL uniform location where to store the value
  45591. * @param bool defines the boolean to store
  45592. */
  45593. setBool(uniform: WebGLUniformLocation, bool: number): void;
  45594. /**
  45595. * Set the value of an uniform to a vec4
  45596. * @param uniform defines the webGL uniform location where to store the value
  45597. * @param x defines the 1st component of the value
  45598. * @param y defines the 2nd component of the value
  45599. * @param z defines the 3rd component of the value
  45600. * @param w defines the 4th component of the value
  45601. */
  45602. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  45603. /**
  45604. * Sets the current alpha mode
  45605. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  45606. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  45607. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  45608. */
  45609. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  45610. /**
  45611. * Bind webGl buffers directly to the webGL context
  45612. * @param vertexBuffers defines the vertex buffer to bind
  45613. * @param indexBuffer defines the index buffer to bind
  45614. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  45615. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  45616. * @param effect defines the effect associated with the vertex buffer
  45617. */
  45618. bindBuffers(vertexBuffers: {
  45619. [key: string]: VertexBuffer;
  45620. }, indexBuffer: DataBuffer, effect: Effect): void;
  45621. /**
  45622. * Force the entire cache to be cleared
  45623. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  45624. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  45625. */
  45626. wipeCaches(bruteForce?: boolean): void;
  45627. /**
  45628. * Send a draw order
  45629. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  45630. * @param indexStart defines the starting index
  45631. * @param indexCount defines the number of index to draw
  45632. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45633. */
  45634. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  45635. /**
  45636. * Draw a list of indexed primitives
  45637. * @param fillMode defines the primitive to use
  45638. * @param indexStart defines the starting index
  45639. * @param indexCount defines the number of index to draw
  45640. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45641. */
  45642. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  45643. /**
  45644. * Draw a list of unindexed primitives
  45645. * @param fillMode defines the primitive to use
  45646. * @param verticesStart defines the index of first vertex to draw
  45647. * @param verticesCount defines the count of vertices to draw
  45648. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  45649. */
  45650. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  45651. /** @hidden */
  45652. _createTexture(): WebGLTexture;
  45653. /** @hidden */
  45654. _releaseTexture(texture: InternalTexture): void;
  45655. /**
  45656. * Usually called from Texture.ts.
  45657. * Passed information to create a WebGLTexture
  45658. * @param urlArg defines a value which contains one of the following:
  45659. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  45660. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  45661. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  45662. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  45663. * @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)
  45664. * @param scene needed for loading to the correct scene
  45665. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  45666. * @param onLoad optional callback to be called upon successful completion
  45667. * @param onError optional callback to be called upon failure
  45668. * @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
  45669. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  45670. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  45671. * @param forcedExtension defines the extension to use to pick the right loader
  45672. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  45673. * @returns a InternalTexture for assignment back into BABYLON.Texture
  45674. */
  45675. 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;
  45676. /**
  45677. * Creates a new render target texture
  45678. * @param size defines the size of the texture
  45679. * @param options defines the options used to create the texture
  45680. * @returns a new render target texture stored in an InternalTexture
  45681. */
  45682. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  45683. /**
  45684. * Update the sampling mode of a given texture
  45685. * @param samplingMode defines the required sampling mode
  45686. * @param texture defines the texture to update
  45687. */
  45688. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  45689. /**
  45690. * Binds the frame buffer to the specified texture.
  45691. * @param texture The texture to render to or null for the default canvas
  45692. * @param faceIndex The face of the texture to render to in case of cube texture
  45693. * @param requiredWidth The width of the target to render to
  45694. * @param requiredHeight The height of the target to render to
  45695. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  45696. * @param depthStencilTexture The depth stencil texture to use to render
  45697. * @param lodLevel defines le lod level to bind to the frame buffer
  45698. */
  45699. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  45700. /**
  45701. * Unbind the current render target texture from the webGL context
  45702. * @param texture defines the render target texture to unbind
  45703. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  45704. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  45705. */
  45706. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  45707. /**
  45708. * Creates a dynamic vertex buffer
  45709. * @param vertices the data for the dynamic vertex buffer
  45710. * @returns the new WebGL dynamic buffer
  45711. */
  45712. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  45713. /**
  45714. * Update the content of a dynamic texture
  45715. * @param texture defines the texture to update
  45716. * @param canvas defines the canvas containing the source
  45717. * @param invertY defines if data must be stored with Y axis inverted
  45718. * @param premulAlpha defines if alpha is stored as premultiplied
  45719. * @param format defines the format of the data
  45720. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  45721. */
  45722. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  45723. /**
  45724. * Gets a boolean indicating if all created effects are ready
  45725. * @returns true if all effects are ready
  45726. */
  45727. areAllEffectsReady(): boolean;
  45728. /**
  45729. * @hidden
  45730. * Get the current error code of the webGL context
  45731. * @returns the error code
  45732. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  45733. */
  45734. getError(): number;
  45735. /** @hidden */
  45736. _getUnpackAlignement(): number;
  45737. /** @hidden */
  45738. _unpackFlipY(value: boolean): void;
  45739. /**
  45740. * Update a dynamic index buffer
  45741. * @param indexBuffer defines the target index buffer
  45742. * @param indices defines the data to update
  45743. * @param offset defines the offset in the target index buffer where update should start
  45744. */
  45745. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  45746. /**
  45747. * Updates a dynamic vertex buffer.
  45748. * @param vertexBuffer the vertex buffer to update
  45749. * @param vertices the data used to update the vertex buffer
  45750. * @param byteOffset the byte offset of the data (optional)
  45751. * @param byteLength the byte length of the data (optional)
  45752. */
  45753. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  45754. /** @hidden */
  45755. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  45756. /** @hidden */
  45757. _bindTexture(channel: number, texture: InternalTexture): void;
  45758. protected _deleteBuffer(buffer: WebGLBuffer): void;
  45759. /**
  45760. * 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
  45761. */
  45762. releaseEffects(): void;
  45763. displayLoadingUI(): void;
  45764. hideLoadingUI(): void;
  45765. /** @hidden */
  45766. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45767. /** @hidden */
  45768. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45769. /** @hidden */
  45770. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  45771. /** @hidden */
  45772. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  45773. }
  45774. }
  45775. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  45776. import { Nullable, int } from "babylonjs/types";
  45777. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  45778. /** @hidden */
  45779. export class _OcclusionDataStorage {
  45780. /** @hidden */
  45781. occlusionInternalRetryCounter: number;
  45782. /** @hidden */
  45783. isOcclusionQueryInProgress: boolean;
  45784. /** @hidden */
  45785. isOccluded: boolean;
  45786. /** @hidden */
  45787. occlusionRetryCount: number;
  45788. /** @hidden */
  45789. occlusionType: number;
  45790. /** @hidden */
  45791. occlusionQueryAlgorithmType: number;
  45792. }
  45793. module "babylonjs/Engines/engine" {
  45794. interface Engine {
  45795. /**
  45796. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  45797. * @return the new query
  45798. */
  45799. createQuery(): WebGLQuery;
  45800. /**
  45801. * Delete and release a webGL query
  45802. * @param query defines the query to delete
  45803. * @return the current engine
  45804. */
  45805. deleteQuery(query: WebGLQuery): Engine;
  45806. /**
  45807. * Check if a given query has resolved and got its value
  45808. * @param query defines the query to check
  45809. * @returns true if the query got its value
  45810. */
  45811. isQueryResultAvailable(query: WebGLQuery): boolean;
  45812. /**
  45813. * Gets the value of a given query
  45814. * @param query defines the query to check
  45815. * @returns the value of the query
  45816. */
  45817. getQueryResult(query: WebGLQuery): number;
  45818. /**
  45819. * Initiates an occlusion query
  45820. * @param algorithmType defines the algorithm to use
  45821. * @param query defines the query to use
  45822. * @returns the current engine
  45823. * @see http://doc.babylonjs.com/features/occlusionquery
  45824. */
  45825. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  45826. /**
  45827. * Ends an occlusion query
  45828. * @see http://doc.babylonjs.com/features/occlusionquery
  45829. * @param algorithmType defines the algorithm to use
  45830. * @returns the current engine
  45831. */
  45832. endOcclusionQuery(algorithmType: number): Engine;
  45833. /**
  45834. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  45835. * Please note that only one query can be issued at a time
  45836. * @returns a time token used to track the time span
  45837. */
  45838. startTimeQuery(): Nullable<_TimeToken>;
  45839. /**
  45840. * Ends a time query
  45841. * @param token defines the token used to measure the time span
  45842. * @returns the time spent (in ns)
  45843. */
  45844. endTimeQuery(token: _TimeToken): int;
  45845. /** @hidden */
  45846. _currentNonTimestampToken: Nullable<_TimeToken>;
  45847. /** @hidden */
  45848. _createTimeQuery(): WebGLQuery;
  45849. /** @hidden */
  45850. _deleteTimeQuery(query: WebGLQuery): void;
  45851. /** @hidden */
  45852. _getGlAlgorithmType(algorithmType: number): number;
  45853. /** @hidden */
  45854. _getTimeQueryResult(query: WebGLQuery): any;
  45855. /** @hidden */
  45856. _getTimeQueryAvailability(query: WebGLQuery): any;
  45857. }
  45858. }
  45859. module "babylonjs/Meshes/abstractMesh" {
  45860. interface AbstractMesh {
  45861. /**
  45862. * Backing filed
  45863. * @hidden
  45864. */
  45865. __occlusionDataStorage: _OcclusionDataStorage;
  45866. /**
  45867. * Access property
  45868. * @hidden
  45869. */
  45870. _occlusionDataStorage: _OcclusionDataStorage;
  45871. /**
  45872. * 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.
  45873. * The default value is -1 which means don't break the query and wait till the result
  45874. * @see http://doc.babylonjs.com/features/occlusionquery
  45875. */
  45876. occlusionRetryCount: number;
  45877. /**
  45878. * 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:
  45879. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  45880. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  45881. * * 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.
  45882. * @see http://doc.babylonjs.com/features/occlusionquery
  45883. */
  45884. occlusionType: number;
  45885. /**
  45886. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  45887. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  45888. * * 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.
  45889. * @see http://doc.babylonjs.com/features/occlusionquery
  45890. */
  45891. occlusionQueryAlgorithmType: number;
  45892. /**
  45893. * 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
  45894. * @see http://doc.babylonjs.com/features/occlusionquery
  45895. */
  45896. isOccluded: boolean;
  45897. /**
  45898. * Flag to check the progress status of the query
  45899. * @see http://doc.babylonjs.com/features/occlusionquery
  45900. */
  45901. isOcclusionQueryInProgress: boolean;
  45902. }
  45903. }
  45904. }
  45905. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  45906. import { Nullable } from "babylonjs/types";
  45907. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  45908. /** @hidden */
  45909. export var _forceTransformFeedbackToBundle: boolean;
  45910. module "babylonjs/Engines/engine" {
  45911. interface Engine {
  45912. /**
  45913. * Creates a webGL transform feedback object
  45914. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  45915. * @returns the webGL transform feedback object
  45916. */
  45917. createTransformFeedback(): WebGLTransformFeedback;
  45918. /**
  45919. * Delete a webGL transform feedback object
  45920. * @param value defines the webGL transform feedback object to delete
  45921. */
  45922. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  45923. /**
  45924. * Bind a webGL transform feedback object to the webgl context
  45925. * @param value defines the webGL transform feedback object to bind
  45926. */
  45927. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  45928. /**
  45929. * Begins a transform feedback operation
  45930. * @param usePoints defines if points or triangles must be used
  45931. */
  45932. beginTransformFeedback(usePoints: boolean): void;
  45933. /**
  45934. * Ends a transform feedback operation
  45935. */
  45936. endTransformFeedback(): void;
  45937. /**
  45938. * Specify the varyings to use with transform feedback
  45939. * @param program defines the associated webGL program
  45940. * @param value defines the list of strings representing the varying names
  45941. */
  45942. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  45943. /**
  45944. * Bind a webGL buffer for a transform feedback operation
  45945. * @param value defines the webGL buffer to bind
  45946. */
  45947. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  45948. }
  45949. }
  45950. }
  45951. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  45952. import { Scene } from "babylonjs/scene";
  45953. import { Engine } from "babylonjs/Engines/engine";
  45954. import { Texture } from "babylonjs/Materials/Textures/texture";
  45955. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45956. import "babylonjs/Engines/Extensions/engine.multiRender";
  45957. /**
  45958. * Creation options of the multi render target texture.
  45959. */
  45960. export interface IMultiRenderTargetOptions {
  45961. /**
  45962. * Define if the texture needs to create mip maps after render.
  45963. */
  45964. generateMipMaps?: boolean;
  45965. /**
  45966. * Define the types of all the draw buffers we want to create
  45967. */
  45968. types?: number[];
  45969. /**
  45970. * Define the sampling modes of all the draw buffers we want to create
  45971. */
  45972. samplingModes?: number[];
  45973. /**
  45974. * Define if a depth buffer is required
  45975. */
  45976. generateDepthBuffer?: boolean;
  45977. /**
  45978. * Define if a stencil buffer is required
  45979. */
  45980. generateStencilBuffer?: boolean;
  45981. /**
  45982. * Define if a depth texture is required instead of a depth buffer
  45983. */
  45984. generateDepthTexture?: boolean;
  45985. /**
  45986. * Define the number of desired draw buffers
  45987. */
  45988. textureCount?: number;
  45989. /**
  45990. * Define if aspect ratio should be adapted to the texture or stay the scene one
  45991. */
  45992. doNotChangeAspectRatio?: boolean;
  45993. /**
  45994. * Define the default type of the buffers we are creating
  45995. */
  45996. defaultType?: number;
  45997. }
  45998. /**
  45999. * A multi render target, like a render target provides the ability to render to a texture.
  46000. * Unlike the render target, it can render to several draw buffers in one draw.
  46001. * This is specially interesting in deferred rendering or for any effects requiring more than
  46002. * just one color from a single pass.
  46003. */
  46004. export class MultiRenderTarget extends RenderTargetTexture {
  46005. private _internalTextures;
  46006. private _textures;
  46007. private _multiRenderTargetOptions;
  46008. /**
  46009. * Get if draw buffers are currently supported by the used hardware and browser.
  46010. */
  46011. readonly isSupported: boolean;
  46012. /**
  46013. * Get the list of textures generated by the multi render target.
  46014. */
  46015. readonly textures: Texture[];
  46016. /**
  46017. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  46018. */
  46019. readonly depthTexture: Texture;
  46020. /**
  46021. * Set the wrapping mode on U of all the textures we are rendering to.
  46022. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46023. */
  46024. wrapU: number;
  46025. /**
  46026. * Set the wrapping mode on V of all the textures we are rendering to.
  46027. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  46028. */
  46029. wrapV: number;
  46030. /**
  46031. * Instantiate a new multi render target texture.
  46032. * A multi render target, like a render target provides the ability to render to a texture.
  46033. * Unlike the render target, it can render to several draw buffers in one draw.
  46034. * This is specially interesting in deferred rendering or for any effects requiring more than
  46035. * just one color from a single pass.
  46036. * @param name Define the name of the texture
  46037. * @param size Define the size of the buffers to render to
  46038. * @param count Define the number of target we are rendering into
  46039. * @param scene Define the scene the texture belongs to
  46040. * @param options Define the options used to create the multi render target
  46041. */
  46042. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  46043. /** @hidden */
  46044. _rebuild(): void;
  46045. private _createInternalTextures;
  46046. private _createTextures;
  46047. /**
  46048. * Define the number of samples used if MSAA is enabled.
  46049. */
  46050. samples: number;
  46051. /**
  46052. * Resize all the textures in the multi render target.
  46053. * Be carrefull as it will recreate all the data in the new texture.
  46054. * @param size Define the new size
  46055. */
  46056. resize(size: any): void;
  46057. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  46058. /**
  46059. * Dispose the render targets and their associated resources
  46060. */
  46061. dispose(): void;
  46062. /**
  46063. * Release all the underlying texture used as draw buffers.
  46064. */
  46065. releaseInternalTextures(): void;
  46066. }
  46067. }
  46068. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  46069. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46070. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  46071. import { Nullable } from "babylonjs/types";
  46072. module "babylonjs/Engines/thinEngine" {
  46073. interface ThinEngine {
  46074. /**
  46075. * Unbind a list of render target textures from the webGL context
  46076. * This is used only when drawBuffer extension or webGL2 are active
  46077. * @param textures defines the render target textures to unbind
  46078. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  46079. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  46080. */
  46081. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  46082. /**
  46083. * Create a multi render target texture
  46084. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  46085. * @param size defines the size of the texture
  46086. * @param options defines the creation options
  46087. * @returns the cube texture as an InternalTexture
  46088. */
  46089. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  46090. /**
  46091. * Update the sample count for a given multiple render target texture
  46092. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  46093. * @param textures defines the textures to update
  46094. * @param samples defines the sample count to set
  46095. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  46096. */
  46097. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  46098. }
  46099. }
  46100. }
  46101. declare module "babylonjs/Engines/Extensions/index" {
  46102. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  46103. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  46104. export * from "babylonjs/Engines/Extensions/engine.multiview";
  46105. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  46106. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  46107. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  46108. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  46109. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  46110. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  46111. export * from "babylonjs/Engines/Extensions/engine.webVR";
  46112. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  46113. }
  46114. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  46115. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46116. /** @hidden */
  46117. export var rgbdEncodePixelShader: {
  46118. name: string;
  46119. shader: string;
  46120. };
  46121. }
  46122. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  46123. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46124. /** @hidden */
  46125. export var rgbdDecodePixelShader: {
  46126. name: string;
  46127. shader: string;
  46128. };
  46129. }
  46130. declare module "babylonjs/Misc/environmentTextureTools" {
  46131. import { Nullable } from "babylonjs/types";
  46132. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  46133. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46134. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  46135. import "babylonjs/Engines/Extensions/engine.renderTarget";
  46136. import "babylonjs/Shaders/rgbdEncode.fragment";
  46137. import "babylonjs/Shaders/rgbdDecode.fragment";
  46138. /**
  46139. * Raw texture data and descriptor sufficient for WebGL texture upload
  46140. */
  46141. export interface EnvironmentTextureInfo {
  46142. /**
  46143. * Version of the environment map
  46144. */
  46145. version: number;
  46146. /**
  46147. * Width of image
  46148. */
  46149. width: number;
  46150. /**
  46151. * Irradiance information stored in the file.
  46152. */
  46153. irradiance: any;
  46154. /**
  46155. * Specular information stored in the file.
  46156. */
  46157. specular: any;
  46158. }
  46159. /**
  46160. * Defines One Image in the file. It requires only the position in the file
  46161. * as well as the length.
  46162. */
  46163. interface BufferImageData {
  46164. /**
  46165. * Length of the image data.
  46166. */
  46167. length: number;
  46168. /**
  46169. * Position of the data from the null terminator delimiting the end of the JSON.
  46170. */
  46171. position: number;
  46172. }
  46173. /**
  46174. * Defines the specular data enclosed in the file.
  46175. * This corresponds to the version 1 of the data.
  46176. */
  46177. export interface EnvironmentTextureSpecularInfoV1 {
  46178. /**
  46179. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  46180. */
  46181. specularDataPosition?: number;
  46182. /**
  46183. * This contains all the images data needed to reconstruct the cubemap.
  46184. */
  46185. mipmaps: Array<BufferImageData>;
  46186. /**
  46187. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  46188. */
  46189. lodGenerationScale: number;
  46190. }
  46191. /**
  46192. * Sets of helpers addressing the serialization and deserialization of environment texture
  46193. * stored in a BabylonJS env file.
  46194. * Those files are usually stored as .env files.
  46195. */
  46196. export class EnvironmentTextureTools {
  46197. /**
  46198. * Magic number identifying the env file.
  46199. */
  46200. private static _MagicBytes;
  46201. /**
  46202. * Gets the environment info from an env file.
  46203. * @param data The array buffer containing the .env bytes.
  46204. * @returns the environment file info (the json header) if successfully parsed.
  46205. */
  46206. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  46207. /**
  46208. * Creates an environment texture from a loaded cube texture.
  46209. * @param texture defines the cube texture to convert in env file
  46210. * @return a promise containing the environment data if succesfull.
  46211. */
  46212. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  46213. /**
  46214. * Creates a JSON representation of the spherical data.
  46215. * @param texture defines the texture containing the polynomials
  46216. * @return the JSON representation of the spherical info
  46217. */
  46218. private static _CreateEnvTextureIrradiance;
  46219. /**
  46220. * Creates the ArrayBufferViews used for initializing environment texture image data.
  46221. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  46222. * @param info parameters that determine what views will be created for accessing the underlying buffer
  46223. * @return the views described by info providing access to the underlying buffer
  46224. */
  46225. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  46226. /**
  46227. * Uploads the texture info contained in the env file to the GPU.
  46228. * @param texture defines the internal texture to upload to
  46229. * @param arrayBuffer defines the buffer cotaining the data to load
  46230. * @param info defines the texture info retrieved through the GetEnvInfo method
  46231. * @returns a promise
  46232. */
  46233. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  46234. /**
  46235. * Uploads the levels of image data to the GPU.
  46236. * @param texture defines the internal texture to upload to
  46237. * @param imageData defines the array buffer views of image data [mipmap][face]
  46238. * @returns a promise
  46239. */
  46240. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  46241. /**
  46242. * Uploads spherical polynomials information to the texture.
  46243. * @param texture defines the texture we are trying to upload the information to
  46244. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  46245. */
  46246. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  46247. /** @hidden */
  46248. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  46249. }
  46250. }
  46251. declare module "babylonjs/Maths/math.vertexFormat" {
  46252. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  46253. /**
  46254. * Contains position and normal vectors for a vertex
  46255. */
  46256. export class PositionNormalVertex {
  46257. /** the position of the vertex (defaut: 0,0,0) */
  46258. position: Vector3;
  46259. /** the normal of the vertex (defaut: 0,1,0) */
  46260. normal: Vector3;
  46261. /**
  46262. * Creates a PositionNormalVertex
  46263. * @param position the position of the vertex (defaut: 0,0,0)
  46264. * @param normal the normal of the vertex (defaut: 0,1,0)
  46265. */
  46266. constructor(
  46267. /** the position of the vertex (defaut: 0,0,0) */
  46268. position?: Vector3,
  46269. /** the normal of the vertex (defaut: 0,1,0) */
  46270. normal?: Vector3);
  46271. /**
  46272. * Clones the PositionNormalVertex
  46273. * @returns the cloned PositionNormalVertex
  46274. */
  46275. clone(): PositionNormalVertex;
  46276. }
  46277. /**
  46278. * Contains position, normal and uv vectors for a vertex
  46279. */
  46280. export class PositionNormalTextureVertex {
  46281. /** the position of the vertex (defaut: 0,0,0) */
  46282. position: Vector3;
  46283. /** the normal of the vertex (defaut: 0,1,0) */
  46284. normal: Vector3;
  46285. /** the uv of the vertex (default: 0,0) */
  46286. uv: Vector2;
  46287. /**
  46288. * Creates a PositionNormalTextureVertex
  46289. * @param position the position of the vertex (defaut: 0,0,0)
  46290. * @param normal the normal of the vertex (defaut: 0,1,0)
  46291. * @param uv the uv of the vertex (default: 0,0)
  46292. */
  46293. constructor(
  46294. /** the position of the vertex (defaut: 0,0,0) */
  46295. position?: Vector3,
  46296. /** the normal of the vertex (defaut: 0,1,0) */
  46297. normal?: Vector3,
  46298. /** the uv of the vertex (default: 0,0) */
  46299. uv?: Vector2);
  46300. /**
  46301. * Clones the PositionNormalTextureVertex
  46302. * @returns the cloned PositionNormalTextureVertex
  46303. */
  46304. clone(): PositionNormalTextureVertex;
  46305. }
  46306. }
  46307. declare module "babylonjs/Maths/math" {
  46308. export * from "babylonjs/Maths/math.axis";
  46309. export * from "babylonjs/Maths/math.color";
  46310. export * from "babylonjs/Maths/math.constants";
  46311. export * from "babylonjs/Maths/math.frustum";
  46312. export * from "babylonjs/Maths/math.path";
  46313. export * from "babylonjs/Maths/math.plane";
  46314. export * from "babylonjs/Maths/math.size";
  46315. export * from "babylonjs/Maths/math.vector";
  46316. export * from "babylonjs/Maths/math.vertexFormat";
  46317. export * from "babylonjs/Maths/math.viewport";
  46318. }
  46319. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  46320. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46321. /** @hidden */
  46322. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  46323. private _genericAttributeLocation;
  46324. private _varyingLocationCount;
  46325. private _varyingLocationMap;
  46326. private _replacements;
  46327. private _textureCount;
  46328. private _uniforms;
  46329. lineProcessor(line: string): string;
  46330. attributeProcessor(attribute: string): string;
  46331. varyingProcessor(varying: string, isFragment: boolean): string;
  46332. uniformProcessor(uniform: string): string;
  46333. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  46334. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  46335. }
  46336. }
  46337. declare module "babylonjs/Engines/nativeEngine" {
  46338. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  46339. import { Engine } from "babylonjs/Engines/engine";
  46340. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  46341. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  46342. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46343. import { Effect } from "babylonjs/Materials/effect";
  46344. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  46345. import { Color4, Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  46346. import { Scene } from "babylonjs/scene";
  46347. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  46348. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  46349. /**
  46350. * Container for accessors for natively-stored mesh data buffers.
  46351. */
  46352. class NativeDataBuffer extends DataBuffer {
  46353. /**
  46354. * Accessor value used to identify/retrieve a natively-stored index buffer.
  46355. */
  46356. nativeIndexBuffer?: any;
  46357. /**
  46358. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  46359. */
  46360. nativeVertexBuffer?: any;
  46361. }
  46362. /** @hidden */
  46363. export class NativeEngine extends Engine {
  46364. private readonly _native;
  46365. getHardwareScalingLevel(): number;
  46366. constructor();
  46367. /**
  46368. * Can be used to override the current requestAnimationFrame requester.
  46369. * @hidden
  46370. */
  46371. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  46372. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  46373. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  46374. createVertexBuffer(data: DataArray): NativeDataBuffer;
  46375. recordVertexArrayObject(vertexBuffers: {
  46376. [key: string]: VertexBuffer;
  46377. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  46378. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46379. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  46380. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  46381. /**
  46382. * Draw a list of indexed primitives
  46383. * @param fillMode defines the primitive to use
  46384. * @param indexStart defines the starting index
  46385. * @param indexCount defines the number of index to draw
  46386. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46387. */
  46388. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  46389. /**
  46390. * Draw a list of unindexed primitives
  46391. * @param fillMode defines the primitive to use
  46392. * @param verticesStart defines the index of first vertex to draw
  46393. * @param verticesCount defines the count of vertices to draw
  46394. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  46395. */
  46396. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  46397. createPipelineContext(): IPipelineContext;
  46398. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  46399. /** @hidden */
  46400. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  46401. /** @hidden */
  46402. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  46403. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46404. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  46405. protected _setProgram(program: WebGLProgram): void;
  46406. _releaseEffect(effect: Effect): void;
  46407. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  46408. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  46409. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  46410. bindSamplers(effect: Effect): void;
  46411. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  46412. getRenderWidth(useScreen?: boolean): number;
  46413. getRenderHeight(useScreen?: boolean): number;
  46414. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  46415. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  46416. /**
  46417. * Set the z offset to apply to current rendering
  46418. * @param value defines the offset to apply
  46419. */
  46420. setZOffset(value: number): void;
  46421. /**
  46422. * Gets the current value of the zOffset
  46423. * @returns the current zOffset state
  46424. */
  46425. getZOffset(): number;
  46426. /**
  46427. * Enable or disable depth buffering
  46428. * @param enable defines the state to set
  46429. */
  46430. setDepthBuffer(enable: boolean): void;
  46431. /**
  46432. * Gets a boolean indicating if depth writing is enabled
  46433. * @returns the current depth writing state
  46434. */
  46435. getDepthWrite(): boolean;
  46436. /**
  46437. * Enable or disable depth writing
  46438. * @param enable defines the state to set
  46439. */
  46440. setDepthWrite(enable: boolean): void;
  46441. /**
  46442. * Enable or disable color writing
  46443. * @param enable defines the state to set
  46444. */
  46445. setColorWrite(enable: boolean): void;
  46446. /**
  46447. * Gets a boolean indicating if color writing is enabled
  46448. * @returns the current color writing state
  46449. */
  46450. getColorWrite(): boolean;
  46451. /**
  46452. * Sets alpha constants used by some alpha blending modes
  46453. * @param r defines the red component
  46454. * @param g defines the green component
  46455. * @param b defines the blue component
  46456. * @param a defines the alpha component
  46457. */
  46458. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  46459. /**
  46460. * Sets the current alpha mode
  46461. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  46462. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  46463. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46464. */
  46465. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  46466. /**
  46467. * Gets the current alpha mode
  46468. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  46469. * @returns the current alpha mode
  46470. */
  46471. getAlphaMode(): number;
  46472. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  46473. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  46474. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  46475. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  46476. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  46477. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  46478. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  46479. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  46480. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  46481. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  46482. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  46483. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  46484. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  46485. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46486. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  46487. setFloat(uniform: WebGLUniformLocation, value: number): void;
  46488. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  46489. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  46490. setBool(uniform: WebGLUniformLocation, bool: number): void;
  46491. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  46492. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  46493. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  46494. wipeCaches(bruteForce?: boolean): void;
  46495. _createTexture(): WebGLTexture;
  46496. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  46497. /**
  46498. * Usually called from BABYLON.Texture.ts.
  46499. * Passed information to create a WebGLTexture
  46500. * @param urlArg defines a value which contains one of the following:
  46501. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  46502. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  46503. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  46504. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  46505. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  46506. * @param scene needed for loading to the correct scene
  46507. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  46508. * @param onLoad optional callback to be called upon successful completion
  46509. * @param onError optional callback to be called upon failure
  46510. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  46511. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  46512. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  46513. * @param forcedExtension defines the extension to use to pick the right loader
  46514. * @returns a InternalTexture for assignment back into BABYLON.Texture
  46515. */
  46516. 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;
  46517. /**
  46518. * Creates a cube texture
  46519. * @param rootUrl defines the url where the files to load is located
  46520. * @param scene defines the current scene
  46521. * @param files defines the list of files to load (1 per face)
  46522. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  46523. * @param onLoad defines an optional callback raised when the texture is loaded
  46524. * @param onError defines an optional callback raised if there is an issue to load the texture
  46525. * @param format defines the format of the data
  46526. * @param forcedExtension defines the extension to use to pick the right loader
  46527. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  46528. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  46529. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  46530. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  46531. * @returns the cube texture as an InternalTexture
  46532. */
  46533. 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;
  46534. private _getSamplingFilter;
  46535. private static _GetNativeTextureFormat;
  46536. createRenderTargetTexture(size: number | {
  46537. width: number;
  46538. height: number;
  46539. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  46540. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  46541. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  46542. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  46543. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  46544. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  46545. /**
  46546. * Updates a dynamic vertex buffer.
  46547. * @param vertexBuffer the vertex buffer to update
  46548. * @param data the data used to update the vertex buffer
  46549. * @param byteOffset the byte offset of the data (optional)
  46550. * @param byteLength the byte length of the data (optional)
  46551. */
  46552. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  46553. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  46554. private _updateAnisotropicLevel;
  46555. private _getAddressMode;
  46556. /** @hidden */
  46557. _bindTexture(channel: number, texture: InternalTexture): void;
  46558. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  46559. releaseEffects(): void;
  46560. /** @hidden */
  46561. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46562. /** @hidden */
  46563. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46564. /** @hidden */
  46565. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  46566. /** @hidden */
  46567. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  46568. }
  46569. }
  46570. declare module "babylonjs/Engines/index" {
  46571. export * from "babylonjs/Engines/constants";
  46572. export * from "babylonjs/Engines/engineCapabilities";
  46573. export * from "babylonjs/Engines/instancingAttributeInfo";
  46574. export * from "babylonjs/Engines/thinEngine";
  46575. export * from "babylonjs/Engines/engine";
  46576. export * from "babylonjs/Engines/engineStore";
  46577. export * from "babylonjs/Engines/nullEngine";
  46578. export * from "babylonjs/Engines/Extensions/index";
  46579. export * from "babylonjs/Engines/IPipelineContext";
  46580. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  46581. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  46582. export * from "babylonjs/Engines/nativeEngine";
  46583. }
  46584. declare module "babylonjs/Events/clipboardEvents" {
  46585. /**
  46586. * Gather the list of clipboard event types as constants.
  46587. */
  46588. export class ClipboardEventTypes {
  46589. /**
  46590. * The clipboard event is fired when a copy command is active (pressed).
  46591. */
  46592. static readonly COPY: number;
  46593. /**
  46594. * The clipboard event is fired when a cut command is active (pressed).
  46595. */
  46596. static readonly CUT: number;
  46597. /**
  46598. * The clipboard event is fired when a paste command is active (pressed).
  46599. */
  46600. static readonly PASTE: number;
  46601. }
  46602. /**
  46603. * This class is used to store clipboard related info for the onClipboardObservable event.
  46604. */
  46605. export class ClipboardInfo {
  46606. /**
  46607. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46608. */
  46609. type: number;
  46610. /**
  46611. * Defines the related dom event
  46612. */
  46613. event: ClipboardEvent;
  46614. /**
  46615. *Creates an instance of ClipboardInfo.
  46616. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  46617. * @param event Defines the related dom event
  46618. */
  46619. constructor(
  46620. /**
  46621. * Defines the type of event (BABYLON.ClipboardEventTypes)
  46622. */
  46623. type: number,
  46624. /**
  46625. * Defines the related dom event
  46626. */
  46627. event: ClipboardEvent);
  46628. /**
  46629. * Get the clipboard event's type from the keycode.
  46630. * @param keyCode Defines the keyCode for the current keyboard event.
  46631. * @return {number}
  46632. */
  46633. static GetTypeFromCharacter(keyCode: number): number;
  46634. }
  46635. }
  46636. declare module "babylonjs/Events/index" {
  46637. export * from "babylonjs/Events/keyboardEvents";
  46638. export * from "babylonjs/Events/pointerEvents";
  46639. export * from "babylonjs/Events/clipboardEvents";
  46640. }
  46641. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  46642. import { Scene } from "babylonjs/scene";
  46643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46644. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46645. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46646. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46647. /**
  46648. * Google Daydream controller
  46649. */
  46650. export class DaydreamController extends WebVRController {
  46651. /**
  46652. * Base Url for the controller model.
  46653. */
  46654. static MODEL_BASE_URL: string;
  46655. /**
  46656. * File name for the controller model.
  46657. */
  46658. static MODEL_FILENAME: string;
  46659. /**
  46660. * Gamepad Id prefix used to identify Daydream Controller.
  46661. */
  46662. static readonly GAMEPAD_ID_PREFIX: string;
  46663. /**
  46664. * Creates a new DaydreamController from a gamepad
  46665. * @param vrGamepad the gamepad that the controller should be created from
  46666. */
  46667. constructor(vrGamepad: any);
  46668. /**
  46669. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46670. * @param scene scene in which to add meshes
  46671. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46672. */
  46673. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46674. /**
  46675. * Called once for each button that changed state since the last frame
  46676. * @param buttonIdx Which button index changed
  46677. * @param state New state of the button
  46678. * @param changes Which properties on the state changed since last frame
  46679. */
  46680. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46681. }
  46682. }
  46683. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  46684. import { Scene } from "babylonjs/scene";
  46685. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46686. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  46687. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  46688. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46689. /**
  46690. * Gear VR Controller
  46691. */
  46692. export class GearVRController extends WebVRController {
  46693. /**
  46694. * Base Url for the controller model.
  46695. */
  46696. static MODEL_BASE_URL: string;
  46697. /**
  46698. * File name for the controller model.
  46699. */
  46700. static MODEL_FILENAME: string;
  46701. /**
  46702. * Gamepad Id prefix used to identify this controller.
  46703. */
  46704. static readonly GAMEPAD_ID_PREFIX: string;
  46705. private readonly _buttonIndexToObservableNameMap;
  46706. /**
  46707. * Creates a new GearVRController from a gamepad
  46708. * @param vrGamepad the gamepad that the controller should be created from
  46709. */
  46710. constructor(vrGamepad: any);
  46711. /**
  46712. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  46713. * @param scene scene in which to add meshes
  46714. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  46715. */
  46716. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  46717. /**
  46718. * Called once for each button that changed state since the last frame
  46719. * @param buttonIdx Which button index changed
  46720. * @param state New state of the button
  46721. * @param changes Which properties on the state changed since last frame
  46722. */
  46723. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  46724. }
  46725. }
  46726. declare module "babylonjs/Gamepads/Controllers/index" {
  46727. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  46728. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  46729. export * from "babylonjs/Gamepads/Controllers/genericController";
  46730. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  46731. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  46732. export * from "babylonjs/Gamepads/Controllers/viveController";
  46733. export * from "babylonjs/Gamepads/Controllers/webVRController";
  46734. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  46735. }
  46736. declare module "babylonjs/Gamepads/index" {
  46737. export * from "babylonjs/Gamepads/Controllers/index";
  46738. export * from "babylonjs/Gamepads/gamepad";
  46739. export * from "babylonjs/Gamepads/gamepadManager";
  46740. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  46741. export * from "babylonjs/Gamepads/xboxGamepad";
  46742. export * from "babylonjs/Gamepads/dualShockGamepad";
  46743. }
  46744. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  46745. import { Scene } from "babylonjs/scene";
  46746. import { Vector4 } from "babylonjs/Maths/math.vector";
  46747. import { Color4 } from "babylonjs/Maths/math.color";
  46748. import { Mesh } from "babylonjs/Meshes/mesh";
  46749. import { Nullable } from "babylonjs/types";
  46750. /**
  46751. * Class containing static functions to help procedurally build meshes
  46752. */
  46753. export class PolyhedronBuilder {
  46754. /**
  46755. * Creates a polyhedron mesh
  46756. * * 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
  46757. * * The parameter `size` (positive float, default 1) sets the polygon size
  46758. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  46759. * * 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`
  46760. * * 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
  46761. * * 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)`)
  46762. * * 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
  46763. * * 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
  46764. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  46765. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  46766. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46767. * @param name defines the name of the mesh
  46768. * @param options defines the options used to create the mesh
  46769. * @param scene defines the hosting scene
  46770. * @returns the polyhedron mesh
  46771. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  46772. */
  46773. static CreatePolyhedron(name: string, options: {
  46774. type?: number;
  46775. size?: number;
  46776. sizeX?: number;
  46777. sizeY?: number;
  46778. sizeZ?: number;
  46779. custom?: any;
  46780. faceUV?: Vector4[];
  46781. faceColors?: Color4[];
  46782. flat?: boolean;
  46783. updatable?: boolean;
  46784. sideOrientation?: number;
  46785. frontUVs?: Vector4;
  46786. backUVs?: Vector4;
  46787. }, scene?: Nullable<Scene>): Mesh;
  46788. }
  46789. }
  46790. declare module "babylonjs/Gizmos/scaleGizmo" {
  46791. import { Observable } from "babylonjs/Misc/observable";
  46792. import { Nullable } from "babylonjs/types";
  46793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46794. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46795. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  46796. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46797. /**
  46798. * Gizmo that enables scaling a mesh along 3 axis
  46799. */
  46800. export class ScaleGizmo extends Gizmo {
  46801. /**
  46802. * Internal gizmo used for interactions on the x axis
  46803. */
  46804. xGizmo: AxisScaleGizmo;
  46805. /**
  46806. * Internal gizmo used for interactions on the y axis
  46807. */
  46808. yGizmo: AxisScaleGizmo;
  46809. /**
  46810. * Internal gizmo used for interactions on the z axis
  46811. */
  46812. zGizmo: AxisScaleGizmo;
  46813. /**
  46814. * Internal gizmo used to scale all axis equally
  46815. */
  46816. uniformScaleGizmo: AxisScaleGizmo;
  46817. private _meshAttached;
  46818. private _updateGizmoRotationToMatchAttachedMesh;
  46819. private _snapDistance;
  46820. private _scaleRatio;
  46821. private _uniformScalingMesh;
  46822. private _octahedron;
  46823. /** Fires an event when any of it's sub gizmos are dragged */
  46824. onDragStartObservable: Observable<unknown>;
  46825. /** Fires an event when any of it's sub gizmos are released from dragging */
  46826. onDragEndObservable: Observable<unknown>;
  46827. attachedMesh: Nullable<AbstractMesh>;
  46828. /**
  46829. * Creates a ScaleGizmo
  46830. * @param gizmoLayer The utility layer the gizmo will be added to
  46831. */
  46832. constructor(gizmoLayer?: UtilityLayerRenderer);
  46833. updateGizmoRotationToMatchAttachedMesh: boolean;
  46834. /**
  46835. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46836. */
  46837. snapDistance: number;
  46838. /**
  46839. * Ratio for the scale of the gizmo (Default: 1)
  46840. */
  46841. scaleRatio: number;
  46842. /**
  46843. * Disposes of the gizmo
  46844. */
  46845. dispose(): void;
  46846. }
  46847. }
  46848. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  46849. import { Observable } from "babylonjs/Misc/observable";
  46850. import { Nullable } from "babylonjs/types";
  46851. import { Vector3 } from "babylonjs/Maths/math.vector";
  46852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46853. import { Mesh } from "babylonjs/Meshes/mesh";
  46854. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  46855. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46856. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46857. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  46858. import { Color3 } from "babylonjs/Maths/math.color";
  46859. /**
  46860. * Single axis scale gizmo
  46861. */
  46862. export class AxisScaleGizmo extends Gizmo {
  46863. /**
  46864. * Drag behavior responsible for the gizmos dragging interactions
  46865. */
  46866. dragBehavior: PointerDragBehavior;
  46867. private _pointerObserver;
  46868. /**
  46869. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  46870. */
  46871. snapDistance: number;
  46872. /**
  46873. * Event that fires each time the gizmo snaps to a new location.
  46874. * * snapDistance is the the change in distance
  46875. */
  46876. onSnapObservable: Observable<{
  46877. snapDistance: number;
  46878. }>;
  46879. /**
  46880. * If the scaling operation should be done on all axis (default: false)
  46881. */
  46882. uniformScaling: boolean;
  46883. private _isEnabled;
  46884. private _parent;
  46885. private _arrow;
  46886. private _coloredMaterial;
  46887. private _hoverMaterial;
  46888. /**
  46889. * Creates an AxisScaleGizmo
  46890. * @param gizmoLayer The utility layer the gizmo will be added to
  46891. * @param dragAxis The axis which the gizmo will be able to scale on
  46892. * @param color The color of the gizmo
  46893. */
  46894. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  46895. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  46896. /**
  46897. * If the gizmo is enabled
  46898. */
  46899. isEnabled: boolean;
  46900. /**
  46901. * Disposes of the gizmo
  46902. */
  46903. dispose(): void;
  46904. /**
  46905. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  46906. * @param mesh The mesh to replace the default mesh of the gizmo
  46907. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  46908. */
  46909. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  46910. }
  46911. }
  46912. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  46913. import { Observable } from "babylonjs/Misc/observable";
  46914. import { Nullable } from "babylonjs/types";
  46915. import { Vector3 } from "babylonjs/Maths/math.vector";
  46916. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46917. import { Mesh } from "babylonjs/Meshes/mesh";
  46918. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  46919. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  46920. import { Color3 } from "babylonjs/Maths/math.color";
  46921. import "babylonjs/Meshes/Builders/boxBuilder";
  46922. /**
  46923. * Bounding box gizmo
  46924. */
  46925. export class BoundingBoxGizmo extends Gizmo {
  46926. private _lineBoundingBox;
  46927. private _rotateSpheresParent;
  46928. private _scaleBoxesParent;
  46929. private _boundingDimensions;
  46930. private _renderObserver;
  46931. private _pointerObserver;
  46932. private _scaleDragSpeed;
  46933. private _tmpQuaternion;
  46934. private _tmpVector;
  46935. private _tmpRotationMatrix;
  46936. /**
  46937. * 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)
  46938. */
  46939. ignoreChildren: boolean;
  46940. /**
  46941. * 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)
  46942. */
  46943. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  46944. /**
  46945. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  46946. */
  46947. rotationSphereSize: number;
  46948. /**
  46949. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  46950. */
  46951. scaleBoxSize: number;
  46952. /**
  46953. * 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)
  46954. */
  46955. fixedDragMeshScreenSize: boolean;
  46956. /**
  46957. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  46958. */
  46959. fixedDragMeshScreenSizeDistanceFactor: number;
  46960. /**
  46961. * Fired when a rotation sphere or scale box is dragged
  46962. */
  46963. onDragStartObservable: Observable<{}>;
  46964. /**
  46965. * Fired when a scale box is dragged
  46966. */
  46967. onScaleBoxDragObservable: Observable<{}>;
  46968. /**
  46969. * Fired when a scale box drag is ended
  46970. */
  46971. onScaleBoxDragEndObservable: Observable<{}>;
  46972. /**
  46973. * Fired when a rotation sphere is dragged
  46974. */
  46975. onRotationSphereDragObservable: Observable<{}>;
  46976. /**
  46977. * Fired when a rotation sphere drag is ended
  46978. */
  46979. onRotationSphereDragEndObservable: Observable<{}>;
  46980. /**
  46981. * 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)
  46982. */
  46983. scalePivot: Nullable<Vector3>;
  46984. /**
  46985. * Mesh used as a pivot to rotate the attached mesh
  46986. */
  46987. private _anchorMesh;
  46988. private _existingMeshScale;
  46989. private _dragMesh;
  46990. private pointerDragBehavior;
  46991. private coloredMaterial;
  46992. private hoverColoredMaterial;
  46993. /**
  46994. * Sets the color of the bounding box gizmo
  46995. * @param color the color to set
  46996. */
  46997. setColor(color: Color3): void;
  46998. /**
  46999. * Creates an BoundingBoxGizmo
  47000. * @param gizmoLayer The utility layer the gizmo will be added to
  47001. * @param color The color of the gizmo
  47002. */
  47003. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  47004. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47005. private _selectNode;
  47006. /**
  47007. * Updates the bounding box information for the Gizmo
  47008. */
  47009. updateBoundingBox(): void;
  47010. private _updateRotationSpheres;
  47011. private _updateScaleBoxes;
  47012. /**
  47013. * Enables rotation on the specified axis and disables rotation on the others
  47014. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  47015. */
  47016. setEnabledRotationAxis(axis: string): void;
  47017. /**
  47018. * Enables/disables scaling
  47019. * @param enable if scaling should be enabled
  47020. */
  47021. setEnabledScaling(enable: boolean): void;
  47022. private _updateDummy;
  47023. /**
  47024. * Enables a pointer drag behavior on the bounding box of the gizmo
  47025. */
  47026. enableDragBehavior(): void;
  47027. /**
  47028. * Disposes of the gizmo
  47029. */
  47030. dispose(): void;
  47031. /**
  47032. * 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)
  47033. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  47034. * @returns the bounding box mesh with the passed in mesh as a child
  47035. */
  47036. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  47037. /**
  47038. * CustomMeshes are not supported by this gizmo
  47039. * @param mesh The mesh to replace the default mesh of the gizmo
  47040. */
  47041. setCustomMesh(mesh: Mesh): void;
  47042. }
  47043. }
  47044. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  47045. import { Observable } from "babylonjs/Misc/observable";
  47046. import { Nullable } from "babylonjs/types";
  47047. import { Vector3 } from "babylonjs/Maths/math.vector";
  47048. import { Color3 } from "babylonjs/Maths/math.color";
  47049. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47050. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47051. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47052. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47053. import "babylonjs/Meshes/Builders/linesBuilder";
  47054. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47055. /**
  47056. * Single plane rotation gizmo
  47057. */
  47058. export class PlaneRotationGizmo extends Gizmo {
  47059. /**
  47060. * Drag behavior responsible for the gizmos dragging interactions
  47061. */
  47062. dragBehavior: PointerDragBehavior;
  47063. private _pointerObserver;
  47064. /**
  47065. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  47066. */
  47067. snapDistance: number;
  47068. /**
  47069. * Event that fires each time the gizmo snaps to a new location.
  47070. * * snapDistance is the the change in distance
  47071. */
  47072. onSnapObservable: Observable<{
  47073. snapDistance: number;
  47074. }>;
  47075. private _isEnabled;
  47076. private _parent;
  47077. /**
  47078. * Creates a PlaneRotationGizmo
  47079. * @param gizmoLayer The utility layer the gizmo will be added to
  47080. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  47081. * @param color The color of the gizmo
  47082. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47083. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47084. */
  47085. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  47086. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47087. /**
  47088. * If the gizmo is enabled
  47089. */
  47090. isEnabled: boolean;
  47091. /**
  47092. * Disposes of the gizmo
  47093. */
  47094. dispose(): void;
  47095. }
  47096. }
  47097. declare module "babylonjs/Gizmos/rotationGizmo" {
  47098. import { Observable } from "babylonjs/Misc/observable";
  47099. import { Nullable } from "babylonjs/types";
  47100. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47101. import { Mesh } from "babylonjs/Meshes/mesh";
  47102. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47103. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  47104. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47105. /**
  47106. * Gizmo that enables rotating a mesh along 3 axis
  47107. */
  47108. export class RotationGizmo extends Gizmo {
  47109. /**
  47110. * Internal gizmo used for interactions on the x axis
  47111. */
  47112. xGizmo: PlaneRotationGizmo;
  47113. /**
  47114. * Internal gizmo used for interactions on the y axis
  47115. */
  47116. yGizmo: PlaneRotationGizmo;
  47117. /**
  47118. * Internal gizmo used for interactions on the z axis
  47119. */
  47120. zGizmo: PlaneRotationGizmo;
  47121. /** Fires an event when any of it's sub gizmos are dragged */
  47122. onDragStartObservable: Observable<unknown>;
  47123. /** Fires an event when any of it's sub gizmos are released from dragging */
  47124. onDragEndObservable: Observable<unknown>;
  47125. private _meshAttached;
  47126. attachedMesh: Nullable<AbstractMesh>;
  47127. /**
  47128. * Creates a RotationGizmo
  47129. * @param gizmoLayer The utility layer the gizmo will be added to
  47130. * @param tessellation Amount of tessellation to be used when creating rotation circles
  47131. * @param useEulerRotation Use and update Euler angle instead of quaternion
  47132. */
  47133. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  47134. updateGizmoRotationToMatchAttachedMesh: boolean;
  47135. /**
  47136. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47137. */
  47138. snapDistance: number;
  47139. /**
  47140. * Ratio for the scale of the gizmo (Default: 1)
  47141. */
  47142. scaleRatio: number;
  47143. /**
  47144. * Disposes of the gizmo
  47145. */
  47146. dispose(): void;
  47147. /**
  47148. * CustomMeshes are not supported by this gizmo
  47149. * @param mesh The mesh to replace the default mesh of the gizmo
  47150. */
  47151. setCustomMesh(mesh: Mesh): void;
  47152. }
  47153. }
  47154. declare module "babylonjs/Gizmos/gizmoManager" {
  47155. import { Observable } from "babylonjs/Misc/observable";
  47156. import { Nullable } from "babylonjs/types";
  47157. import { Scene, IDisposable } from "babylonjs/scene";
  47158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47159. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47160. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  47161. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  47162. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47163. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  47164. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  47165. /**
  47166. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  47167. */
  47168. export class GizmoManager implements IDisposable {
  47169. private scene;
  47170. /**
  47171. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  47172. */
  47173. gizmos: {
  47174. positionGizmo: Nullable<PositionGizmo>;
  47175. rotationGizmo: Nullable<RotationGizmo>;
  47176. scaleGizmo: Nullable<ScaleGizmo>;
  47177. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  47178. };
  47179. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  47180. clearGizmoOnEmptyPointerEvent: boolean;
  47181. /** Fires an event when the manager is attached to a mesh */
  47182. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  47183. private _gizmosEnabled;
  47184. private _pointerObserver;
  47185. private _attachedMesh;
  47186. private _boundingBoxColor;
  47187. private _defaultUtilityLayer;
  47188. private _defaultKeepDepthUtilityLayer;
  47189. /**
  47190. * When bounding box gizmo is enabled, this can be used to track drag/end events
  47191. */
  47192. boundingBoxDragBehavior: SixDofDragBehavior;
  47193. /**
  47194. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  47195. */
  47196. attachableMeshes: Nullable<Array<AbstractMesh>>;
  47197. /**
  47198. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  47199. */
  47200. usePointerToAttachGizmos: boolean;
  47201. /**
  47202. * Utility layer that the bounding box gizmo belongs to
  47203. */
  47204. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  47205. /**
  47206. * Utility layer that all gizmos besides bounding box belong to
  47207. */
  47208. readonly utilityLayer: UtilityLayerRenderer;
  47209. /**
  47210. * Instatiates a gizmo manager
  47211. * @param scene the scene to overlay the gizmos on top of
  47212. */
  47213. constructor(scene: Scene);
  47214. /**
  47215. * Attaches a set of gizmos to the specified mesh
  47216. * @param mesh The mesh the gizmo's should be attached to
  47217. */
  47218. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  47219. /**
  47220. * If the position gizmo is enabled
  47221. */
  47222. positionGizmoEnabled: boolean;
  47223. /**
  47224. * If the rotation gizmo is enabled
  47225. */
  47226. rotationGizmoEnabled: boolean;
  47227. /**
  47228. * If the scale gizmo is enabled
  47229. */
  47230. scaleGizmoEnabled: boolean;
  47231. /**
  47232. * If the boundingBox gizmo is enabled
  47233. */
  47234. boundingBoxGizmoEnabled: boolean;
  47235. /**
  47236. * Disposes of the gizmo manager
  47237. */
  47238. dispose(): void;
  47239. }
  47240. }
  47241. declare module "babylonjs/Lights/directionalLight" {
  47242. import { Camera } from "babylonjs/Cameras/camera";
  47243. import { Scene } from "babylonjs/scene";
  47244. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47245. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47246. import { Light } from "babylonjs/Lights/light";
  47247. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47248. import { Effect } from "babylonjs/Materials/effect";
  47249. /**
  47250. * A directional light is defined by a direction (what a surprise!).
  47251. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  47252. * 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.
  47253. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47254. */
  47255. export class DirectionalLight extends ShadowLight {
  47256. private _shadowFrustumSize;
  47257. /**
  47258. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  47259. */
  47260. /**
  47261. * Specifies a fix frustum size for the shadow generation.
  47262. */
  47263. shadowFrustumSize: number;
  47264. private _shadowOrthoScale;
  47265. /**
  47266. * Gets the shadow projection scale against the optimal computed one.
  47267. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47268. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47269. */
  47270. /**
  47271. * Sets the shadow projection scale against the optimal computed one.
  47272. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  47273. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  47274. */
  47275. shadowOrthoScale: number;
  47276. /**
  47277. * Automatically compute the projection matrix to best fit (including all the casters)
  47278. * on each frame.
  47279. */
  47280. autoUpdateExtends: boolean;
  47281. private _orthoLeft;
  47282. private _orthoRight;
  47283. private _orthoTop;
  47284. private _orthoBottom;
  47285. /**
  47286. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  47287. * The directional light is emitted from everywhere in the given direction.
  47288. * It can cast shadows.
  47289. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47290. * @param name The friendly name of the light
  47291. * @param direction The direction of the light
  47292. * @param scene The scene the light belongs to
  47293. */
  47294. constructor(name: string, direction: Vector3, scene: Scene);
  47295. /**
  47296. * Returns the string "DirectionalLight".
  47297. * @return The class name
  47298. */
  47299. getClassName(): string;
  47300. /**
  47301. * Returns the integer 1.
  47302. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47303. */
  47304. getTypeID(): number;
  47305. /**
  47306. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  47307. * Returns the DirectionalLight Shadow projection matrix.
  47308. */
  47309. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47310. /**
  47311. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  47312. * Returns the DirectionalLight Shadow projection matrix.
  47313. */
  47314. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  47315. /**
  47316. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  47317. * Returns the DirectionalLight Shadow projection matrix.
  47318. */
  47319. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47320. protected _buildUniformLayout(): void;
  47321. /**
  47322. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  47323. * @param effect The effect to update
  47324. * @param lightIndex The index of the light in the effect to update
  47325. * @returns The directional light
  47326. */
  47327. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  47328. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  47329. /**
  47330. * Gets the minZ used for shadow according to both the scene and the light.
  47331. *
  47332. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47333. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47334. * @param activeCamera The camera we are returning the min for
  47335. * @returns the depth min z
  47336. */
  47337. getDepthMinZ(activeCamera: Camera): number;
  47338. /**
  47339. * Gets the maxZ used for shadow according to both the scene and the light.
  47340. *
  47341. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  47342. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  47343. * @param activeCamera The camera we are returning the max for
  47344. * @returns the depth max z
  47345. */
  47346. getDepthMaxZ(activeCamera: Camera): number;
  47347. /**
  47348. * Prepares the list of defines specific to the light type.
  47349. * @param defines the list of defines
  47350. * @param lightIndex defines the index of the light for the effect
  47351. */
  47352. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47353. }
  47354. }
  47355. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  47356. import { Mesh } from "babylonjs/Meshes/mesh";
  47357. /**
  47358. * Class containing static functions to help procedurally build meshes
  47359. */
  47360. export class HemisphereBuilder {
  47361. /**
  47362. * Creates a hemisphere mesh
  47363. * @param name defines the name of the mesh
  47364. * @param options defines the options used to create the mesh
  47365. * @param scene defines the hosting scene
  47366. * @returns the hemisphere mesh
  47367. */
  47368. static CreateHemisphere(name: string, options: {
  47369. segments?: number;
  47370. diameter?: number;
  47371. sideOrientation?: number;
  47372. }, scene: any): Mesh;
  47373. }
  47374. }
  47375. declare module "babylonjs/Lights/spotLight" {
  47376. import { Nullable } from "babylonjs/types";
  47377. import { Scene } from "babylonjs/scene";
  47378. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47380. import { Effect } from "babylonjs/Materials/effect";
  47381. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47382. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  47383. /**
  47384. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47385. * These values define a cone of light starting from the position, emitting toward the direction.
  47386. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47387. * and the exponent defines the speed of the decay of the light with distance (reach).
  47388. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47389. */
  47390. export class SpotLight extends ShadowLight {
  47391. private _angle;
  47392. private _innerAngle;
  47393. private _cosHalfAngle;
  47394. private _lightAngleScale;
  47395. private _lightAngleOffset;
  47396. /**
  47397. * Gets the cone angle of the spot light in Radians.
  47398. */
  47399. /**
  47400. * Sets the cone angle of the spot light in Radians.
  47401. */
  47402. angle: number;
  47403. /**
  47404. * Only used in gltf falloff mode, this defines the angle where
  47405. * the directional falloff will start before cutting at angle which could be seen
  47406. * as outer angle.
  47407. */
  47408. /**
  47409. * Only used in gltf falloff mode, this defines the angle where
  47410. * the directional falloff will start before cutting at angle which could be seen
  47411. * as outer angle.
  47412. */
  47413. innerAngle: number;
  47414. private _shadowAngleScale;
  47415. /**
  47416. * Allows scaling the angle of the light for shadow generation only.
  47417. */
  47418. /**
  47419. * Allows scaling the angle of the light for shadow generation only.
  47420. */
  47421. shadowAngleScale: number;
  47422. /**
  47423. * The light decay speed with the distance from the emission spot.
  47424. */
  47425. exponent: number;
  47426. private _projectionTextureMatrix;
  47427. /**
  47428. * Allows reading the projecton texture
  47429. */
  47430. readonly projectionTextureMatrix: Matrix;
  47431. protected _projectionTextureLightNear: number;
  47432. /**
  47433. * Gets the near clip of the Spotlight for texture projection.
  47434. */
  47435. /**
  47436. * Sets the near clip of the Spotlight for texture projection.
  47437. */
  47438. projectionTextureLightNear: number;
  47439. protected _projectionTextureLightFar: number;
  47440. /**
  47441. * Gets the far clip of the Spotlight for texture projection.
  47442. */
  47443. /**
  47444. * Sets the far clip of the Spotlight for texture projection.
  47445. */
  47446. projectionTextureLightFar: number;
  47447. protected _projectionTextureUpDirection: Vector3;
  47448. /**
  47449. * Gets the Up vector of the Spotlight for texture projection.
  47450. */
  47451. /**
  47452. * Sets the Up vector of the Spotlight for texture projection.
  47453. */
  47454. projectionTextureUpDirection: Vector3;
  47455. private _projectionTexture;
  47456. /**
  47457. * Gets the projection texture of the light.
  47458. */
  47459. /**
  47460. * Sets the projection texture of the light.
  47461. */
  47462. projectionTexture: Nullable<BaseTexture>;
  47463. private _projectionTextureViewLightDirty;
  47464. private _projectionTextureProjectionLightDirty;
  47465. private _projectionTextureDirty;
  47466. private _projectionTextureViewTargetVector;
  47467. private _projectionTextureViewLightMatrix;
  47468. private _projectionTextureProjectionLightMatrix;
  47469. private _projectionTextureScalingMatrix;
  47470. /**
  47471. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47472. * It can cast shadows.
  47473. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47474. * @param name The light friendly name
  47475. * @param position The position of the spot light in the scene
  47476. * @param direction The direction of the light in the scene
  47477. * @param angle The cone angle of the light in Radians
  47478. * @param exponent The light decay speed with the distance from the emission spot
  47479. * @param scene The scene the lights belongs to
  47480. */
  47481. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  47482. /**
  47483. * Returns the string "SpotLight".
  47484. * @returns the class name
  47485. */
  47486. getClassName(): string;
  47487. /**
  47488. * Returns the integer 2.
  47489. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47490. */
  47491. getTypeID(): number;
  47492. /**
  47493. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47494. */
  47495. protected _setDirection(value: Vector3): void;
  47496. /**
  47497. * Overrides the position setter to recompute the projection texture view light Matrix.
  47498. */
  47499. protected _setPosition(value: Vector3): void;
  47500. /**
  47501. * 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.
  47502. * Returns the SpotLight.
  47503. */
  47504. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  47505. protected _computeProjectionTextureViewLightMatrix(): void;
  47506. protected _computeProjectionTextureProjectionLightMatrix(): void;
  47507. /**
  47508. * Main function for light texture projection matrix computing.
  47509. */
  47510. protected _computeProjectionTextureMatrix(): void;
  47511. protected _buildUniformLayout(): void;
  47512. private _computeAngleValues;
  47513. /**
  47514. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47515. * @param effect The effect to update
  47516. * @param lightIndex The index of the light in the effect to update
  47517. * @returns The spot light
  47518. */
  47519. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  47520. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  47521. /**
  47522. * Disposes the light and the associated resources.
  47523. */
  47524. dispose(): void;
  47525. /**
  47526. * Prepares the list of defines specific to the light type.
  47527. * @param defines the list of defines
  47528. * @param lightIndex defines the index of the light for the effect
  47529. */
  47530. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  47531. }
  47532. }
  47533. declare module "babylonjs/Gizmos/lightGizmo" {
  47534. import { Nullable } from "babylonjs/types";
  47535. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47536. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47537. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47538. import { Light } from "babylonjs/Lights/light";
  47539. /**
  47540. * Gizmo that enables viewing a light
  47541. */
  47542. export class LightGizmo extends Gizmo {
  47543. private _lightMesh;
  47544. private _material;
  47545. private cachedPosition;
  47546. private cachedForward;
  47547. /**
  47548. * Creates a LightGizmo
  47549. * @param gizmoLayer The utility layer the gizmo will be added to
  47550. */
  47551. constructor(gizmoLayer?: UtilityLayerRenderer);
  47552. private _light;
  47553. /**
  47554. * The light that the gizmo is attached to
  47555. */
  47556. light: Nullable<Light>;
  47557. /**
  47558. * Gets the material used to render the light gizmo
  47559. */
  47560. readonly material: StandardMaterial;
  47561. /**
  47562. * @hidden
  47563. * Updates the gizmo to match the attached mesh's position/rotation
  47564. */
  47565. protected _update(): void;
  47566. private static _Scale;
  47567. /**
  47568. * Creates the lines for a light mesh
  47569. */
  47570. private static _createLightLines;
  47571. /**
  47572. * Disposes of the light gizmo
  47573. */
  47574. dispose(): void;
  47575. private static _CreateHemisphericLightMesh;
  47576. private static _CreatePointLightMesh;
  47577. private static _CreateSpotLightMesh;
  47578. private static _CreateDirectionalLightMesh;
  47579. }
  47580. }
  47581. declare module "babylonjs/Gizmos/index" {
  47582. export * from "babylonjs/Gizmos/axisDragGizmo";
  47583. export * from "babylonjs/Gizmos/axisScaleGizmo";
  47584. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  47585. export * from "babylonjs/Gizmos/gizmo";
  47586. export * from "babylonjs/Gizmos/gizmoManager";
  47587. export * from "babylonjs/Gizmos/planeRotationGizmo";
  47588. export * from "babylonjs/Gizmos/positionGizmo";
  47589. export * from "babylonjs/Gizmos/rotationGizmo";
  47590. export * from "babylonjs/Gizmos/scaleGizmo";
  47591. export * from "babylonjs/Gizmos/lightGizmo";
  47592. export * from "babylonjs/Gizmos/planeDragGizmo";
  47593. }
  47594. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  47595. /** @hidden */
  47596. export var backgroundFragmentDeclaration: {
  47597. name: string;
  47598. shader: string;
  47599. };
  47600. }
  47601. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  47602. /** @hidden */
  47603. export var backgroundUboDeclaration: {
  47604. name: string;
  47605. shader: string;
  47606. };
  47607. }
  47608. declare module "babylonjs/Shaders/background.fragment" {
  47609. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  47610. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47611. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  47612. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  47613. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47614. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47616. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  47617. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  47618. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  47619. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  47620. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  47621. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  47622. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  47623. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  47624. /** @hidden */
  47625. export var backgroundPixelShader: {
  47626. name: string;
  47627. shader: string;
  47628. };
  47629. }
  47630. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  47631. /** @hidden */
  47632. export var backgroundVertexDeclaration: {
  47633. name: string;
  47634. shader: string;
  47635. };
  47636. }
  47637. declare module "babylonjs/Shaders/background.vertex" {
  47638. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  47639. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  47640. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47641. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  47642. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  47643. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  47644. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  47645. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  47646. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  47647. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  47648. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  47649. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  47650. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  47651. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  47652. /** @hidden */
  47653. export var backgroundVertexShader: {
  47654. name: string;
  47655. shader: string;
  47656. };
  47657. }
  47658. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  47659. import { Nullable, int, float } from "babylonjs/types";
  47660. import { Scene } from "babylonjs/scene";
  47661. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  47662. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47663. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47664. import { Mesh } from "babylonjs/Meshes/mesh";
  47665. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  47666. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47667. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47668. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47669. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  47670. import { Color3 } from "babylonjs/Maths/math.color";
  47671. import "babylonjs/Shaders/background.fragment";
  47672. import "babylonjs/Shaders/background.vertex";
  47673. /**
  47674. * Background material used to create an efficient environement around your scene.
  47675. */
  47676. export class BackgroundMaterial extends PushMaterial {
  47677. /**
  47678. * Standard reflectance value at parallel view angle.
  47679. */
  47680. static StandardReflectance0: number;
  47681. /**
  47682. * Standard reflectance value at grazing angle.
  47683. */
  47684. static StandardReflectance90: number;
  47685. protected _primaryColor: Color3;
  47686. /**
  47687. * Key light Color (multiply against the environement texture)
  47688. */
  47689. primaryColor: Color3;
  47690. protected __perceptualColor: Nullable<Color3>;
  47691. /**
  47692. * Experimental Internal Use Only.
  47693. *
  47694. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  47695. * This acts as a helper to set the primary color to a more "human friendly" value.
  47696. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  47697. * output color as close as possible from the chosen value.
  47698. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  47699. * part of lighting setup.)
  47700. */
  47701. _perceptualColor: Nullable<Color3>;
  47702. protected _primaryColorShadowLevel: float;
  47703. /**
  47704. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  47705. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  47706. */
  47707. primaryColorShadowLevel: float;
  47708. protected _primaryColorHighlightLevel: float;
  47709. /**
  47710. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  47711. * The primary color is used at the level chosen to define what the white area would look.
  47712. */
  47713. primaryColorHighlightLevel: float;
  47714. protected _reflectionTexture: Nullable<BaseTexture>;
  47715. /**
  47716. * Reflection Texture used in the material.
  47717. * Should be author in a specific way for the best result (refer to the documentation).
  47718. */
  47719. reflectionTexture: Nullable<BaseTexture>;
  47720. protected _reflectionBlur: float;
  47721. /**
  47722. * Reflection Texture level of blur.
  47723. *
  47724. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  47725. * texture twice.
  47726. */
  47727. reflectionBlur: float;
  47728. protected _diffuseTexture: Nullable<BaseTexture>;
  47729. /**
  47730. * Diffuse Texture used in the material.
  47731. * Should be author in a specific way for the best result (refer to the documentation).
  47732. */
  47733. diffuseTexture: Nullable<BaseTexture>;
  47734. protected _shadowLights: Nullable<IShadowLight[]>;
  47735. /**
  47736. * Specify the list of lights casting shadow on the material.
  47737. * All scene shadow lights will be included if null.
  47738. */
  47739. shadowLights: Nullable<IShadowLight[]>;
  47740. protected _shadowLevel: float;
  47741. /**
  47742. * Helps adjusting the shadow to a softer level if required.
  47743. * 0 means black shadows and 1 means no shadows.
  47744. */
  47745. shadowLevel: float;
  47746. protected _sceneCenter: Vector3;
  47747. /**
  47748. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  47749. * It is usually zero but might be interesting to modify according to your setup.
  47750. */
  47751. sceneCenter: Vector3;
  47752. protected _opacityFresnel: boolean;
  47753. /**
  47754. * This helps specifying that the material is falling off to the sky box at grazing angle.
  47755. * This helps ensuring a nice transition when the camera goes under the ground.
  47756. */
  47757. opacityFresnel: boolean;
  47758. protected _reflectionFresnel: boolean;
  47759. /**
  47760. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  47761. * This helps adding a mirror texture on the ground.
  47762. */
  47763. reflectionFresnel: boolean;
  47764. protected _reflectionFalloffDistance: number;
  47765. /**
  47766. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  47767. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  47768. */
  47769. reflectionFalloffDistance: number;
  47770. protected _reflectionAmount: number;
  47771. /**
  47772. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  47773. */
  47774. reflectionAmount: number;
  47775. protected _reflectionReflectance0: number;
  47776. /**
  47777. * This specifies the weight of the reflection at grazing angle.
  47778. */
  47779. reflectionReflectance0: number;
  47780. protected _reflectionReflectance90: number;
  47781. /**
  47782. * This specifies the weight of the reflection at a perpendicular point of view.
  47783. */
  47784. reflectionReflectance90: number;
  47785. /**
  47786. * Sets the reflection reflectance fresnel values according to the default standard
  47787. * empirically know to work well :-)
  47788. */
  47789. reflectionStandardFresnelWeight: number;
  47790. protected _useRGBColor: boolean;
  47791. /**
  47792. * Helps to directly use the maps channels instead of their level.
  47793. */
  47794. useRGBColor: boolean;
  47795. protected _enableNoise: boolean;
  47796. /**
  47797. * This helps reducing the banding effect that could occur on the background.
  47798. */
  47799. enableNoise: boolean;
  47800. /**
  47801. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  47802. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  47803. * Recommended to be keep at 1.0 except for special cases.
  47804. */
  47805. fovMultiplier: number;
  47806. private _fovMultiplier;
  47807. /**
  47808. * Enable the FOV adjustment feature controlled by fovMultiplier.
  47809. */
  47810. useEquirectangularFOV: boolean;
  47811. private _maxSimultaneousLights;
  47812. /**
  47813. * Number of Simultaneous lights allowed on the material.
  47814. */
  47815. maxSimultaneousLights: int;
  47816. /**
  47817. * Default configuration related to image processing available in the Background Material.
  47818. */
  47819. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  47820. /**
  47821. * Keep track of the image processing observer to allow dispose and replace.
  47822. */
  47823. private _imageProcessingObserver;
  47824. /**
  47825. * Attaches a new image processing configuration to the PBR Material.
  47826. * @param configuration (if null the scene configuration will be use)
  47827. */
  47828. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  47829. /**
  47830. * Gets the image processing configuration used either in this material.
  47831. */
  47832. /**
  47833. * Sets the Default image processing configuration used either in the this material.
  47834. *
  47835. * If sets to null, the scene one is in use.
  47836. */
  47837. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  47838. /**
  47839. * Gets wether the color curves effect is enabled.
  47840. */
  47841. /**
  47842. * Sets wether the color curves effect is enabled.
  47843. */
  47844. cameraColorCurvesEnabled: boolean;
  47845. /**
  47846. * Gets wether the color grading effect is enabled.
  47847. */
  47848. /**
  47849. * Gets wether the color grading effect is enabled.
  47850. */
  47851. cameraColorGradingEnabled: boolean;
  47852. /**
  47853. * Gets wether tonemapping is enabled or not.
  47854. */
  47855. /**
  47856. * Sets wether tonemapping is enabled or not
  47857. */
  47858. cameraToneMappingEnabled: boolean;
  47859. /**
  47860. * The camera exposure used on this material.
  47861. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47862. * This corresponds to a photographic exposure.
  47863. */
  47864. /**
  47865. * The camera exposure used on this material.
  47866. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47867. * This corresponds to a photographic exposure.
  47868. */
  47869. cameraExposure: float;
  47870. /**
  47871. * Gets The camera contrast used on this material.
  47872. */
  47873. /**
  47874. * Sets The camera contrast used on this material.
  47875. */
  47876. cameraContrast: float;
  47877. /**
  47878. * Gets the Color Grading 2D Lookup Texture.
  47879. */
  47880. /**
  47881. * Sets the Color Grading 2D Lookup Texture.
  47882. */
  47883. cameraColorGradingTexture: Nullable<BaseTexture>;
  47884. /**
  47885. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47886. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47887. * 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;
  47888. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47889. */
  47890. /**
  47891. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47892. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47893. * 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;
  47894. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47895. */
  47896. cameraColorCurves: Nullable<ColorCurves>;
  47897. /**
  47898. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  47899. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  47900. */
  47901. switchToBGR: boolean;
  47902. private _renderTargets;
  47903. private _reflectionControls;
  47904. private _white;
  47905. private _primaryShadowColor;
  47906. private _primaryHighlightColor;
  47907. /**
  47908. * Instantiates a Background Material in the given scene
  47909. * @param name The friendly name of the material
  47910. * @param scene The scene to add the material to
  47911. */
  47912. constructor(name: string, scene: Scene);
  47913. /**
  47914. * Gets a boolean indicating that current material needs to register RTT
  47915. */
  47916. readonly hasRenderTargetTextures: boolean;
  47917. /**
  47918. * The entire material has been created in order to prevent overdraw.
  47919. * @returns false
  47920. */
  47921. needAlphaTesting(): boolean;
  47922. /**
  47923. * The entire material has been created in order to prevent overdraw.
  47924. * @returns true if blending is enable
  47925. */
  47926. needAlphaBlending(): boolean;
  47927. /**
  47928. * Checks wether the material is ready to be rendered for a given mesh.
  47929. * @param mesh The mesh to render
  47930. * @param subMesh The submesh to check against
  47931. * @param useInstances Specify wether or not the material is used with instances
  47932. * @returns true if all the dependencies are ready (Textures, Effects...)
  47933. */
  47934. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47935. /**
  47936. * Compute the primary color according to the chosen perceptual color.
  47937. */
  47938. private _computePrimaryColorFromPerceptualColor;
  47939. /**
  47940. * Compute the highlights and shadow colors according to their chosen levels.
  47941. */
  47942. private _computePrimaryColors;
  47943. /**
  47944. * Build the uniform buffer used in the material.
  47945. */
  47946. buildUniformLayout(): void;
  47947. /**
  47948. * Unbind the material.
  47949. */
  47950. unbind(): void;
  47951. /**
  47952. * Bind only the world matrix to the material.
  47953. * @param world The world matrix to bind.
  47954. */
  47955. bindOnlyWorldMatrix(world: Matrix): void;
  47956. /**
  47957. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  47958. * @param world The world matrix to bind.
  47959. * @param subMesh The submesh to bind for.
  47960. */
  47961. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47962. /**
  47963. * Checks to see if a texture is used in the material.
  47964. * @param texture - Base texture to use.
  47965. * @returns - Boolean specifying if a texture is used in the material.
  47966. */
  47967. hasTexture(texture: BaseTexture): boolean;
  47968. /**
  47969. * Dispose the material.
  47970. * @param forceDisposeEffect Force disposal of the associated effect.
  47971. * @param forceDisposeTextures Force disposal of the associated textures.
  47972. */
  47973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47974. /**
  47975. * Clones the material.
  47976. * @param name The cloned name.
  47977. * @returns The cloned material.
  47978. */
  47979. clone(name: string): BackgroundMaterial;
  47980. /**
  47981. * Serializes the current material to its JSON representation.
  47982. * @returns The JSON representation.
  47983. */
  47984. serialize(): any;
  47985. /**
  47986. * Gets the class name of the material
  47987. * @returns "BackgroundMaterial"
  47988. */
  47989. getClassName(): string;
  47990. /**
  47991. * Parse a JSON input to create back a background material.
  47992. * @param source The JSON data to parse
  47993. * @param scene The scene to create the parsed material in
  47994. * @param rootUrl The root url of the assets the material depends upon
  47995. * @returns the instantiated BackgroundMaterial.
  47996. */
  47997. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  47998. }
  47999. }
  48000. declare module "babylonjs/Helpers/environmentHelper" {
  48001. import { Observable } from "babylonjs/Misc/observable";
  48002. import { Nullable } from "babylonjs/types";
  48003. import { Scene } from "babylonjs/scene";
  48004. import { Vector3 } from "babylonjs/Maths/math.vector";
  48005. import { Color3 } from "babylonjs/Maths/math.color";
  48006. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48007. import { Mesh } from "babylonjs/Meshes/mesh";
  48008. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48009. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  48010. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48011. import "babylonjs/Meshes/Builders/planeBuilder";
  48012. import "babylonjs/Meshes/Builders/boxBuilder";
  48013. /**
  48014. * Represents the different options available during the creation of
  48015. * a Environment helper.
  48016. *
  48017. * This can control the default ground, skybox and image processing setup of your scene.
  48018. */
  48019. export interface IEnvironmentHelperOptions {
  48020. /**
  48021. * Specifies wether or not to create a ground.
  48022. * True by default.
  48023. */
  48024. createGround: boolean;
  48025. /**
  48026. * Specifies the ground size.
  48027. * 15 by default.
  48028. */
  48029. groundSize: number;
  48030. /**
  48031. * The texture used on the ground for the main color.
  48032. * Comes from the BabylonJS CDN by default.
  48033. *
  48034. * Remarks: Can be either a texture or a url.
  48035. */
  48036. groundTexture: string | BaseTexture;
  48037. /**
  48038. * The color mixed in the ground texture by default.
  48039. * BabylonJS clearColor by default.
  48040. */
  48041. groundColor: Color3;
  48042. /**
  48043. * Specifies the ground opacity.
  48044. * 1 by default.
  48045. */
  48046. groundOpacity: number;
  48047. /**
  48048. * Enables the ground to receive shadows.
  48049. * True by default.
  48050. */
  48051. enableGroundShadow: boolean;
  48052. /**
  48053. * Helps preventing the shadow to be fully black on the ground.
  48054. * 0.5 by default.
  48055. */
  48056. groundShadowLevel: number;
  48057. /**
  48058. * Creates a mirror texture attach to the ground.
  48059. * false by default.
  48060. */
  48061. enableGroundMirror: boolean;
  48062. /**
  48063. * Specifies the ground mirror size ratio.
  48064. * 0.3 by default as the default kernel is 64.
  48065. */
  48066. groundMirrorSizeRatio: number;
  48067. /**
  48068. * Specifies the ground mirror blur kernel size.
  48069. * 64 by default.
  48070. */
  48071. groundMirrorBlurKernel: number;
  48072. /**
  48073. * Specifies the ground mirror visibility amount.
  48074. * 1 by default
  48075. */
  48076. groundMirrorAmount: number;
  48077. /**
  48078. * Specifies the ground mirror reflectance weight.
  48079. * This uses the standard weight of the background material to setup the fresnel effect
  48080. * of the mirror.
  48081. * 1 by default.
  48082. */
  48083. groundMirrorFresnelWeight: number;
  48084. /**
  48085. * Specifies the ground mirror Falloff distance.
  48086. * This can helps reducing the size of the reflection.
  48087. * 0 by Default.
  48088. */
  48089. groundMirrorFallOffDistance: number;
  48090. /**
  48091. * Specifies the ground mirror texture type.
  48092. * Unsigned Int by Default.
  48093. */
  48094. groundMirrorTextureType: number;
  48095. /**
  48096. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  48097. * the shown objects.
  48098. */
  48099. groundYBias: number;
  48100. /**
  48101. * Specifies wether or not to create a skybox.
  48102. * True by default.
  48103. */
  48104. createSkybox: boolean;
  48105. /**
  48106. * Specifies the skybox size.
  48107. * 20 by default.
  48108. */
  48109. skyboxSize: number;
  48110. /**
  48111. * The texture used on the skybox for the main color.
  48112. * Comes from the BabylonJS CDN by default.
  48113. *
  48114. * Remarks: Can be either a texture or a url.
  48115. */
  48116. skyboxTexture: string | BaseTexture;
  48117. /**
  48118. * The color mixed in the skybox texture by default.
  48119. * BabylonJS clearColor by default.
  48120. */
  48121. skyboxColor: Color3;
  48122. /**
  48123. * The background rotation around the Y axis of the scene.
  48124. * This helps aligning the key lights of your scene with the background.
  48125. * 0 by default.
  48126. */
  48127. backgroundYRotation: number;
  48128. /**
  48129. * Compute automatically the size of the elements to best fit with the scene.
  48130. */
  48131. sizeAuto: boolean;
  48132. /**
  48133. * Default position of the rootMesh if autoSize is not true.
  48134. */
  48135. rootPosition: Vector3;
  48136. /**
  48137. * Sets up the image processing in the scene.
  48138. * true by default.
  48139. */
  48140. setupImageProcessing: boolean;
  48141. /**
  48142. * The texture used as your environment texture in the scene.
  48143. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  48144. *
  48145. * Remarks: Can be either a texture or a url.
  48146. */
  48147. environmentTexture: string | BaseTexture;
  48148. /**
  48149. * The value of the exposure to apply to the scene.
  48150. * 0.6 by default if setupImageProcessing is true.
  48151. */
  48152. cameraExposure: number;
  48153. /**
  48154. * The value of the contrast to apply to the scene.
  48155. * 1.6 by default if setupImageProcessing is true.
  48156. */
  48157. cameraContrast: number;
  48158. /**
  48159. * Specifies wether or not tonemapping should be enabled in the scene.
  48160. * true by default if setupImageProcessing is true.
  48161. */
  48162. toneMappingEnabled: boolean;
  48163. }
  48164. /**
  48165. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  48166. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  48167. * It also helps with the default setup of your imageProcessing configuration.
  48168. */
  48169. export class EnvironmentHelper {
  48170. /**
  48171. * Default ground texture URL.
  48172. */
  48173. private static _groundTextureCDNUrl;
  48174. /**
  48175. * Default skybox texture URL.
  48176. */
  48177. private static _skyboxTextureCDNUrl;
  48178. /**
  48179. * Default environment texture URL.
  48180. */
  48181. private static _environmentTextureCDNUrl;
  48182. /**
  48183. * Creates the default options for the helper.
  48184. */
  48185. private static _getDefaultOptions;
  48186. private _rootMesh;
  48187. /**
  48188. * Gets the root mesh created by the helper.
  48189. */
  48190. readonly rootMesh: Mesh;
  48191. private _skybox;
  48192. /**
  48193. * Gets the skybox created by the helper.
  48194. */
  48195. readonly skybox: Nullable<Mesh>;
  48196. private _skyboxTexture;
  48197. /**
  48198. * Gets the skybox texture created by the helper.
  48199. */
  48200. readonly skyboxTexture: Nullable<BaseTexture>;
  48201. private _skyboxMaterial;
  48202. /**
  48203. * Gets the skybox material created by the helper.
  48204. */
  48205. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  48206. private _ground;
  48207. /**
  48208. * Gets the ground mesh created by the helper.
  48209. */
  48210. readonly ground: Nullable<Mesh>;
  48211. private _groundTexture;
  48212. /**
  48213. * Gets the ground texture created by the helper.
  48214. */
  48215. readonly groundTexture: Nullable<BaseTexture>;
  48216. private _groundMirror;
  48217. /**
  48218. * Gets the ground mirror created by the helper.
  48219. */
  48220. readonly groundMirror: Nullable<MirrorTexture>;
  48221. /**
  48222. * Gets the ground mirror render list to helps pushing the meshes
  48223. * you wish in the ground reflection.
  48224. */
  48225. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  48226. private _groundMaterial;
  48227. /**
  48228. * Gets the ground material created by the helper.
  48229. */
  48230. readonly groundMaterial: Nullable<BackgroundMaterial>;
  48231. /**
  48232. * Stores the creation options.
  48233. */
  48234. private readonly _scene;
  48235. private _options;
  48236. /**
  48237. * This observable will be notified with any error during the creation of the environment,
  48238. * mainly texture creation errors.
  48239. */
  48240. onErrorObservable: Observable<{
  48241. message?: string;
  48242. exception?: any;
  48243. }>;
  48244. /**
  48245. * constructor
  48246. * @param options Defines the options we want to customize the helper
  48247. * @param scene The scene to add the material to
  48248. */
  48249. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  48250. /**
  48251. * Updates the background according to the new options
  48252. * @param options
  48253. */
  48254. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  48255. /**
  48256. * Sets the primary color of all the available elements.
  48257. * @param color the main color to affect to the ground and the background
  48258. */
  48259. setMainColor(color: Color3): void;
  48260. /**
  48261. * Setup the image processing according to the specified options.
  48262. */
  48263. private _setupImageProcessing;
  48264. /**
  48265. * Setup the environment texture according to the specified options.
  48266. */
  48267. private _setupEnvironmentTexture;
  48268. /**
  48269. * Setup the background according to the specified options.
  48270. */
  48271. private _setupBackground;
  48272. /**
  48273. * Get the scene sizes according to the setup.
  48274. */
  48275. private _getSceneSize;
  48276. /**
  48277. * Setup the ground according to the specified options.
  48278. */
  48279. private _setupGround;
  48280. /**
  48281. * Setup the ground material according to the specified options.
  48282. */
  48283. private _setupGroundMaterial;
  48284. /**
  48285. * Setup the ground diffuse texture according to the specified options.
  48286. */
  48287. private _setupGroundDiffuseTexture;
  48288. /**
  48289. * Setup the ground mirror texture according to the specified options.
  48290. */
  48291. private _setupGroundMirrorTexture;
  48292. /**
  48293. * Setup the ground to receive the mirror texture.
  48294. */
  48295. private _setupMirrorInGroundMaterial;
  48296. /**
  48297. * Setup the skybox according to the specified options.
  48298. */
  48299. private _setupSkybox;
  48300. /**
  48301. * Setup the skybox material according to the specified options.
  48302. */
  48303. private _setupSkyboxMaterial;
  48304. /**
  48305. * Setup the skybox reflection texture according to the specified options.
  48306. */
  48307. private _setupSkyboxReflectionTexture;
  48308. private _errorHandler;
  48309. /**
  48310. * Dispose all the elements created by the Helper.
  48311. */
  48312. dispose(): void;
  48313. }
  48314. }
  48315. declare module "babylonjs/Helpers/photoDome" {
  48316. import { Observable } from "babylonjs/Misc/observable";
  48317. import { Nullable } from "babylonjs/types";
  48318. import { Scene } from "babylonjs/scene";
  48319. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48320. import { Mesh } from "babylonjs/Meshes/mesh";
  48321. import { Texture } from "babylonjs/Materials/Textures/texture";
  48322. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48323. import "babylonjs/Meshes/Builders/sphereBuilder";
  48324. /**
  48325. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  48326. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  48327. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  48328. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48329. */
  48330. export class PhotoDome extends TransformNode {
  48331. /**
  48332. * Define the image as a Monoscopic panoramic 360 image.
  48333. */
  48334. static readonly MODE_MONOSCOPIC: number;
  48335. /**
  48336. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48337. */
  48338. static readonly MODE_TOPBOTTOM: number;
  48339. /**
  48340. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48341. */
  48342. static readonly MODE_SIDEBYSIDE: number;
  48343. private _useDirectMapping;
  48344. /**
  48345. * The texture being displayed on the sphere
  48346. */
  48347. protected _photoTexture: Texture;
  48348. /**
  48349. * Gets or sets the texture being displayed on the sphere
  48350. */
  48351. photoTexture: Texture;
  48352. /**
  48353. * Observable raised when an error occured while loading the 360 image
  48354. */
  48355. onLoadErrorObservable: Observable<string>;
  48356. /**
  48357. * The skybox material
  48358. */
  48359. protected _material: BackgroundMaterial;
  48360. /**
  48361. * The surface used for the skybox
  48362. */
  48363. protected _mesh: Mesh;
  48364. /**
  48365. * Gets the mesh used for the skybox.
  48366. */
  48367. readonly mesh: Mesh;
  48368. /**
  48369. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48370. * Also see the options.resolution property.
  48371. */
  48372. fovMultiplier: number;
  48373. private _imageMode;
  48374. /**
  48375. * Gets or set the current video mode for the video. It can be:
  48376. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  48377. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  48378. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  48379. */
  48380. imageMode: number;
  48381. /**
  48382. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  48383. * @param name Element's name, child elements will append suffixes for their own names.
  48384. * @param urlsOfPhoto defines the url of the photo to display
  48385. * @param options defines an object containing optional or exposed sub element properties
  48386. * @param onError defines a callback called when an error occured while loading the texture
  48387. */
  48388. constructor(name: string, urlOfPhoto: string, options: {
  48389. resolution?: number;
  48390. size?: number;
  48391. useDirectMapping?: boolean;
  48392. faceForward?: boolean;
  48393. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  48394. private _onBeforeCameraRenderObserver;
  48395. private _changeImageMode;
  48396. /**
  48397. * Releases resources associated with this node.
  48398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48400. */
  48401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48402. }
  48403. }
  48404. declare module "babylonjs/Misc/rgbdTextureTools" {
  48405. import "babylonjs/Shaders/rgbdDecode.fragment";
  48406. import { Texture } from "babylonjs/Materials/Textures/texture";
  48407. /**
  48408. * Class used to host RGBD texture specific utilities
  48409. */
  48410. export class RGBDTextureTools {
  48411. /**
  48412. * Expand the RGBD Texture from RGBD to Half Float if possible.
  48413. * @param texture the texture to expand.
  48414. */
  48415. static ExpandRGBDTexture(texture: Texture): void;
  48416. }
  48417. }
  48418. declare module "babylonjs/Misc/brdfTextureTools" {
  48419. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48420. import { Scene } from "babylonjs/scene";
  48421. /**
  48422. * Class used to host texture specific utilities
  48423. */
  48424. export class BRDFTextureTools {
  48425. /**
  48426. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  48427. * @param scene defines the hosting scene
  48428. * @returns the environment BRDF texture
  48429. */
  48430. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  48431. private static _environmentBRDFBase64Texture;
  48432. }
  48433. }
  48434. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  48435. import { Nullable } from "babylonjs/types";
  48436. import { Color3 } from "babylonjs/Maths/math.color";
  48437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48438. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48439. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48440. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48441. import { Engine } from "babylonjs/Engines/engine";
  48442. import { Scene } from "babylonjs/scene";
  48443. /**
  48444. * @hidden
  48445. */
  48446. export interface IMaterialClearCoatDefines {
  48447. CLEARCOAT: boolean;
  48448. CLEARCOAT_DEFAULTIOR: boolean;
  48449. CLEARCOAT_TEXTURE: boolean;
  48450. CLEARCOAT_TEXTUREDIRECTUV: number;
  48451. CLEARCOAT_BUMP: boolean;
  48452. CLEARCOAT_BUMPDIRECTUV: number;
  48453. CLEARCOAT_TINT: boolean;
  48454. CLEARCOAT_TINT_TEXTURE: boolean;
  48455. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  48456. /** @hidden */
  48457. _areTexturesDirty: boolean;
  48458. }
  48459. /**
  48460. * Define the code related to the clear coat parameters of the pbr material.
  48461. */
  48462. export class PBRClearCoatConfiguration {
  48463. /**
  48464. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48465. * The default fits with a polyurethane material.
  48466. */
  48467. private static readonly _DefaultIndexOfRefraction;
  48468. private _isEnabled;
  48469. /**
  48470. * Defines if the clear coat is enabled in the material.
  48471. */
  48472. isEnabled: boolean;
  48473. /**
  48474. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  48475. */
  48476. intensity: number;
  48477. /**
  48478. * Defines the clear coat layer roughness.
  48479. */
  48480. roughness: number;
  48481. private _indexOfRefraction;
  48482. /**
  48483. * Defines the index of refraction of the clear coat.
  48484. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  48485. * The default fits with a polyurethane material.
  48486. * Changing the default value is more performance intensive.
  48487. */
  48488. indexOfRefraction: number;
  48489. private _texture;
  48490. /**
  48491. * Stores the clear coat values in a texture.
  48492. */
  48493. texture: Nullable<BaseTexture>;
  48494. private _bumpTexture;
  48495. /**
  48496. * Define the clear coat specific bump texture.
  48497. */
  48498. bumpTexture: Nullable<BaseTexture>;
  48499. private _isTintEnabled;
  48500. /**
  48501. * Defines if the clear coat tint is enabled in the material.
  48502. */
  48503. isTintEnabled: boolean;
  48504. /**
  48505. * Defines the clear coat tint of the material.
  48506. * This is only use if tint is enabled
  48507. */
  48508. tintColor: Color3;
  48509. /**
  48510. * Defines the distance at which the tint color should be found in the
  48511. * clear coat media.
  48512. * This is only use if tint is enabled
  48513. */
  48514. tintColorAtDistance: number;
  48515. /**
  48516. * Defines the clear coat layer thickness.
  48517. * This is only use if tint is enabled
  48518. */
  48519. tintThickness: number;
  48520. private _tintTexture;
  48521. /**
  48522. * Stores the clear tint values in a texture.
  48523. * rgb is tint
  48524. * a is a thickness factor
  48525. */
  48526. tintTexture: Nullable<BaseTexture>;
  48527. /** @hidden */
  48528. private _internalMarkAllSubMeshesAsTexturesDirty;
  48529. /** @hidden */
  48530. _markAllSubMeshesAsTexturesDirty(): void;
  48531. /**
  48532. * Instantiate a new istance of clear coat configuration.
  48533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48534. */
  48535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48536. /**
  48537. * Gets wehter the submesh is ready to be used or not.
  48538. * @param defines the list of "defines" to update.
  48539. * @param scene defines the scene the material belongs to.
  48540. * @param engine defines the engine the material belongs to.
  48541. * @param disableBumpMap defines wether the material disables bump or not.
  48542. * @returns - boolean indicating that the submesh is ready or not.
  48543. */
  48544. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  48545. /**
  48546. * Checks to see if a texture is used in the material.
  48547. * @param defines the list of "defines" to update.
  48548. * @param scene defines the scene to the material belongs to.
  48549. */
  48550. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  48551. /**
  48552. * Binds the material data.
  48553. * @param uniformBuffer defines the Uniform buffer to fill in.
  48554. * @param scene defines the scene the material belongs to.
  48555. * @param engine defines the engine the material belongs to.
  48556. * @param disableBumpMap defines wether the material disables bump or not.
  48557. * @param isFrozen defines wether the material is frozen or not.
  48558. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  48559. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  48560. */
  48561. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  48562. /**
  48563. * Checks to see if a texture is used in the material.
  48564. * @param texture - Base texture to use.
  48565. * @returns - Boolean specifying if a texture is used in the material.
  48566. */
  48567. hasTexture(texture: BaseTexture): boolean;
  48568. /**
  48569. * Returns an array of the actively used textures.
  48570. * @param activeTextures Array of BaseTextures
  48571. */
  48572. getActiveTextures(activeTextures: BaseTexture[]): void;
  48573. /**
  48574. * Returns the animatable textures.
  48575. * @param animatables Array of animatable textures.
  48576. */
  48577. getAnimatables(animatables: IAnimatable[]): void;
  48578. /**
  48579. * Disposes the resources of the material.
  48580. * @param forceDisposeTextures - Forces the disposal of all textures.
  48581. */
  48582. dispose(forceDisposeTextures?: boolean): void;
  48583. /**
  48584. * Get the current class name of the texture useful for serialization or dynamic coding.
  48585. * @returns "PBRClearCoatConfiguration"
  48586. */
  48587. getClassName(): string;
  48588. /**
  48589. * Add fallbacks to the effect fallbacks list.
  48590. * @param defines defines the Base texture to use.
  48591. * @param fallbacks defines the current fallback list.
  48592. * @param currentRank defines the current fallback rank.
  48593. * @returns the new fallback rank.
  48594. */
  48595. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48596. /**
  48597. * Add the required uniforms to the current list.
  48598. * @param uniforms defines the current uniform list.
  48599. */
  48600. static AddUniforms(uniforms: string[]): void;
  48601. /**
  48602. * Add the required samplers to the current list.
  48603. * @param samplers defines the current sampler list.
  48604. */
  48605. static AddSamplers(samplers: string[]): void;
  48606. /**
  48607. * Add the required uniforms to the current buffer.
  48608. * @param uniformBuffer defines the current uniform buffer.
  48609. */
  48610. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48611. /**
  48612. * Makes a duplicate of the current configuration into another one.
  48613. * @param clearCoatConfiguration define the config where to copy the info
  48614. */
  48615. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  48616. /**
  48617. * Serializes this clear coat configuration.
  48618. * @returns - An object with the serialized config.
  48619. */
  48620. serialize(): any;
  48621. /**
  48622. * Parses a anisotropy Configuration from a serialized object.
  48623. * @param source - Serialized object.
  48624. * @param scene Defines the scene we are parsing for
  48625. * @param rootUrl Defines the rootUrl to load from
  48626. */
  48627. parse(source: any, scene: Scene, rootUrl: string): void;
  48628. }
  48629. }
  48630. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  48631. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48632. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48633. import { Vector2 } from "babylonjs/Maths/math.vector";
  48634. import { Scene } from "babylonjs/scene";
  48635. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48636. import { Nullable } from "babylonjs/types";
  48637. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48638. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48639. /**
  48640. * @hidden
  48641. */
  48642. export interface IMaterialAnisotropicDefines {
  48643. ANISOTROPIC: boolean;
  48644. ANISOTROPIC_TEXTURE: boolean;
  48645. ANISOTROPIC_TEXTUREDIRECTUV: number;
  48646. MAINUV1: boolean;
  48647. _areTexturesDirty: boolean;
  48648. _needUVs: boolean;
  48649. }
  48650. /**
  48651. * Define the code related to the anisotropic parameters of the pbr material.
  48652. */
  48653. export class PBRAnisotropicConfiguration {
  48654. private _isEnabled;
  48655. /**
  48656. * Defines if the anisotropy is enabled in the material.
  48657. */
  48658. isEnabled: boolean;
  48659. /**
  48660. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  48661. */
  48662. intensity: number;
  48663. /**
  48664. * Defines if the effect is along the tangents, bitangents or in between.
  48665. * By default, the effect is "strectching" the highlights along the tangents.
  48666. */
  48667. direction: Vector2;
  48668. private _texture;
  48669. /**
  48670. * Stores the anisotropy values in a texture.
  48671. * rg is direction (like normal from -1 to 1)
  48672. * b is a intensity
  48673. */
  48674. texture: Nullable<BaseTexture>;
  48675. /** @hidden */
  48676. private _internalMarkAllSubMeshesAsTexturesDirty;
  48677. /** @hidden */
  48678. _markAllSubMeshesAsTexturesDirty(): void;
  48679. /**
  48680. * Instantiate a new istance of anisotropy configuration.
  48681. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48682. */
  48683. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48684. /**
  48685. * Specifies that the submesh is ready to be used.
  48686. * @param defines the list of "defines" to update.
  48687. * @param scene defines the scene the material belongs to.
  48688. * @returns - boolean indicating that the submesh is ready or not.
  48689. */
  48690. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  48691. /**
  48692. * Checks to see if a texture is used in the material.
  48693. * @param defines the list of "defines" to update.
  48694. * @param mesh the mesh we are preparing the defines for.
  48695. * @param scene defines the scene the material belongs to.
  48696. */
  48697. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  48698. /**
  48699. * Binds the material data.
  48700. * @param uniformBuffer defines the Uniform buffer to fill in.
  48701. * @param scene defines the scene the material belongs to.
  48702. * @param isFrozen defines wether the material is frozen or not.
  48703. */
  48704. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48705. /**
  48706. * Checks to see if a texture is used in the material.
  48707. * @param texture - Base texture to use.
  48708. * @returns - Boolean specifying if a texture is used in the material.
  48709. */
  48710. hasTexture(texture: BaseTexture): boolean;
  48711. /**
  48712. * Returns an array of the actively used textures.
  48713. * @param activeTextures Array of BaseTextures
  48714. */
  48715. getActiveTextures(activeTextures: BaseTexture[]): void;
  48716. /**
  48717. * Returns the animatable textures.
  48718. * @param animatables Array of animatable textures.
  48719. */
  48720. getAnimatables(animatables: IAnimatable[]): void;
  48721. /**
  48722. * Disposes the resources of the material.
  48723. * @param forceDisposeTextures - Forces the disposal of all textures.
  48724. */
  48725. dispose(forceDisposeTextures?: boolean): void;
  48726. /**
  48727. * Get the current class name of the texture useful for serialization or dynamic coding.
  48728. * @returns "PBRAnisotropicConfiguration"
  48729. */
  48730. getClassName(): string;
  48731. /**
  48732. * Add fallbacks to the effect fallbacks list.
  48733. * @param defines defines the Base texture to use.
  48734. * @param fallbacks defines the current fallback list.
  48735. * @param currentRank defines the current fallback rank.
  48736. * @returns the new fallback rank.
  48737. */
  48738. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48739. /**
  48740. * Add the required uniforms to the current list.
  48741. * @param uniforms defines the current uniform list.
  48742. */
  48743. static AddUniforms(uniforms: string[]): void;
  48744. /**
  48745. * Add the required uniforms to the current buffer.
  48746. * @param uniformBuffer defines the current uniform buffer.
  48747. */
  48748. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  48749. /**
  48750. * Add the required samplers to the current list.
  48751. * @param samplers defines the current sampler list.
  48752. */
  48753. static AddSamplers(samplers: string[]): void;
  48754. /**
  48755. * Makes a duplicate of the current configuration into another one.
  48756. * @param anisotropicConfiguration define the config where to copy the info
  48757. */
  48758. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  48759. /**
  48760. * Serializes this anisotropy configuration.
  48761. * @returns - An object with the serialized config.
  48762. */
  48763. serialize(): any;
  48764. /**
  48765. * Parses a anisotropy Configuration from a serialized object.
  48766. * @param source - Serialized object.
  48767. * @param scene Defines the scene we are parsing for
  48768. * @param rootUrl Defines the rootUrl to load from
  48769. */
  48770. parse(source: any, scene: Scene, rootUrl: string): void;
  48771. }
  48772. }
  48773. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  48774. import { Scene } from "babylonjs/scene";
  48775. /**
  48776. * @hidden
  48777. */
  48778. export interface IMaterialBRDFDefines {
  48779. BRDF_V_HEIGHT_CORRELATED: boolean;
  48780. MS_BRDF_ENERGY_CONSERVATION: boolean;
  48781. SPHERICAL_HARMONICS: boolean;
  48782. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  48783. /** @hidden */
  48784. _areMiscDirty: boolean;
  48785. }
  48786. /**
  48787. * Define the code related to the BRDF parameters of the pbr material.
  48788. */
  48789. export class PBRBRDFConfiguration {
  48790. /**
  48791. * Default value used for the energy conservation.
  48792. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48793. */
  48794. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  48795. /**
  48796. * Default value used for the Smith Visibility Height Correlated mode.
  48797. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  48798. */
  48799. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  48800. /**
  48801. * Default value used for the IBL diffuse part.
  48802. * This can help switching back to the polynomials mode globally which is a tiny bit
  48803. * less GPU intensive at the drawback of a lower quality.
  48804. */
  48805. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  48806. /**
  48807. * Default value used for activating energy conservation for the specular workflow.
  48808. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48809. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48810. */
  48811. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  48812. private _useEnergyConservation;
  48813. /**
  48814. * Defines if the material uses energy conservation.
  48815. */
  48816. useEnergyConservation: boolean;
  48817. private _useSmithVisibilityHeightCorrelated;
  48818. /**
  48819. * LEGACY Mode set to false
  48820. * Defines if the material uses height smith correlated visibility term.
  48821. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  48822. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  48823. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  48824. * Not relying on height correlated will also disable energy conservation.
  48825. */
  48826. useSmithVisibilityHeightCorrelated: boolean;
  48827. private _useSphericalHarmonics;
  48828. /**
  48829. * LEGACY Mode set to false
  48830. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  48831. * diffuse part of the IBL.
  48832. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  48833. * to the ground truth.
  48834. */
  48835. useSphericalHarmonics: boolean;
  48836. private _useSpecularGlossinessInputEnergyConservation;
  48837. /**
  48838. * Defines if the material uses energy conservation, when the specular workflow is active.
  48839. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  48840. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  48841. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  48842. */
  48843. useSpecularGlossinessInputEnergyConservation: boolean;
  48844. /** @hidden */
  48845. private _internalMarkAllSubMeshesAsMiscDirty;
  48846. /** @hidden */
  48847. _markAllSubMeshesAsMiscDirty(): void;
  48848. /**
  48849. * Instantiate a new istance of clear coat configuration.
  48850. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  48851. */
  48852. constructor(markAllSubMeshesAsMiscDirty: () => void);
  48853. /**
  48854. * Checks to see if a texture is used in the material.
  48855. * @param defines the list of "defines" to update.
  48856. */
  48857. prepareDefines(defines: IMaterialBRDFDefines): void;
  48858. /**
  48859. * Get the current class name of the texture useful for serialization or dynamic coding.
  48860. * @returns "PBRClearCoatConfiguration"
  48861. */
  48862. getClassName(): string;
  48863. /**
  48864. * Makes a duplicate of the current configuration into another one.
  48865. * @param brdfConfiguration define the config where to copy the info
  48866. */
  48867. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  48868. /**
  48869. * Serializes this BRDF configuration.
  48870. * @returns - An object with the serialized config.
  48871. */
  48872. serialize(): any;
  48873. /**
  48874. * Parses a anisotropy Configuration from a serialized object.
  48875. * @param source - Serialized object.
  48876. * @param scene Defines the scene we are parsing for
  48877. * @param rootUrl Defines the rootUrl to load from
  48878. */
  48879. parse(source: any, scene: Scene, rootUrl: string): void;
  48880. }
  48881. }
  48882. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  48883. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  48884. import { Color3 } from "babylonjs/Maths/math.color";
  48885. import { Scene } from "babylonjs/scene";
  48886. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48887. import { Nullable } from "babylonjs/types";
  48888. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  48889. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  48890. /**
  48891. * @hidden
  48892. */
  48893. export interface IMaterialSheenDefines {
  48894. SHEEN: boolean;
  48895. SHEEN_TEXTURE: boolean;
  48896. SHEEN_TEXTUREDIRECTUV: number;
  48897. SHEEN_LINKWITHALBEDO: boolean;
  48898. /** @hidden */
  48899. _areTexturesDirty: boolean;
  48900. }
  48901. /**
  48902. * Define the code related to the Sheen parameters of the pbr material.
  48903. */
  48904. export class PBRSheenConfiguration {
  48905. private _isEnabled;
  48906. /**
  48907. * Defines if the material uses sheen.
  48908. */
  48909. isEnabled: boolean;
  48910. private _linkSheenWithAlbedo;
  48911. /**
  48912. * Defines if the sheen is linked to the sheen color.
  48913. */
  48914. linkSheenWithAlbedo: boolean;
  48915. /**
  48916. * Defines the sheen intensity.
  48917. */
  48918. intensity: number;
  48919. /**
  48920. * Defines the sheen color.
  48921. */
  48922. color: Color3;
  48923. private _texture;
  48924. /**
  48925. * Stores the sheen tint values in a texture.
  48926. * rgb is tint
  48927. * a is a intensity
  48928. */
  48929. texture: Nullable<BaseTexture>;
  48930. /** @hidden */
  48931. private _internalMarkAllSubMeshesAsTexturesDirty;
  48932. /** @hidden */
  48933. _markAllSubMeshesAsTexturesDirty(): void;
  48934. /**
  48935. * Instantiate a new istance of clear coat configuration.
  48936. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  48937. */
  48938. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  48939. /**
  48940. * Specifies that the submesh is ready to be used.
  48941. * @param defines the list of "defines" to update.
  48942. * @param scene defines the scene the material belongs to.
  48943. * @returns - boolean indicating that the submesh is ready or not.
  48944. */
  48945. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  48946. /**
  48947. * Checks to see if a texture is used in the material.
  48948. * @param defines the list of "defines" to update.
  48949. * @param scene defines the scene the material belongs to.
  48950. */
  48951. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  48952. /**
  48953. * Binds the material data.
  48954. * @param uniformBuffer defines the Uniform buffer to fill in.
  48955. * @param scene defines the scene the material belongs to.
  48956. * @param isFrozen defines wether the material is frozen or not.
  48957. */
  48958. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  48959. /**
  48960. * Checks to see if a texture is used in the material.
  48961. * @param texture - Base texture to use.
  48962. * @returns - Boolean specifying if a texture is used in the material.
  48963. */
  48964. hasTexture(texture: BaseTexture): boolean;
  48965. /**
  48966. * Returns an array of the actively used textures.
  48967. * @param activeTextures Array of BaseTextures
  48968. */
  48969. getActiveTextures(activeTextures: BaseTexture[]): void;
  48970. /**
  48971. * Returns the animatable textures.
  48972. * @param animatables Array of animatable textures.
  48973. */
  48974. getAnimatables(animatables: IAnimatable[]): void;
  48975. /**
  48976. * Disposes the resources of the material.
  48977. * @param forceDisposeTextures - Forces the disposal of all textures.
  48978. */
  48979. dispose(forceDisposeTextures?: boolean): void;
  48980. /**
  48981. * Get the current class name of the texture useful for serialization or dynamic coding.
  48982. * @returns "PBRSheenConfiguration"
  48983. */
  48984. getClassName(): string;
  48985. /**
  48986. * Add fallbacks to the effect fallbacks list.
  48987. * @param defines defines the Base texture to use.
  48988. * @param fallbacks defines the current fallback list.
  48989. * @param currentRank defines the current fallback rank.
  48990. * @returns the new fallback rank.
  48991. */
  48992. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  48993. /**
  48994. * Add the required uniforms to the current list.
  48995. * @param uniforms defines the current uniform list.
  48996. */
  48997. static AddUniforms(uniforms: string[]): void;
  48998. /**
  48999. * Add the required uniforms to the current buffer.
  49000. * @param uniformBuffer defines the current uniform buffer.
  49001. */
  49002. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49003. /**
  49004. * Add the required samplers to the current list.
  49005. * @param samplers defines the current sampler list.
  49006. */
  49007. static AddSamplers(samplers: string[]): void;
  49008. /**
  49009. * Makes a duplicate of the current configuration into another one.
  49010. * @param sheenConfiguration define the config where to copy the info
  49011. */
  49012. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  49013. /**
  49014. * Serializes this BRDF configuration.
  49015. * @returns - An object with the serialized config.
  49016. */
  49017. serialize(): any;
  49018. /**
  49019. * Parses a anisotropy Configuration from a serialized object.
  49020. * @param source - Serialized object.
  49021. * @param scene Defines the scene we are parsing for
  49022. * @param rootUrl Defines the rootUrl to load from
  49023. */
  49024. parse(source: any, scene: Scene, rootUrl: string): void;
  49025. }
  49026. }
  49027. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  49028. import { Nullable } from "babylonjs/types";
  49029. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49030. import { Color3 } from "babylonjs/Maths/math.color";
  49031. import { SmartArray } from "babylonjs/Misc/smartArray";
  49032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49033. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49034. import { Effect } from "babylonjs/Materials/effect";
  49035. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  49036. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  49037. import { Engine } from "babylonjs/Engines/engine";
  49038. import { Scene } from "babylonjs/scene";
  49039. /**
  49040. * @hidden
  49041. */
  49042. export interface IMaterialSubSurfaceDefines {
  49043. SUBSURFACE: boolean;
  49044. SS_REFRACTION: boolean;
  49045. SS_TRANSLUCENCY: boolean;
  49046. SS_SCATERRING: boolean;
  49047. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49048. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49049. SS_REFRACTIONMAP_3D: boolean;
  49050. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49051. SS_LODINREFRACTIONALPHA: boolean;
  49052. SS_GAMMAREFRACTION: boolean;
  49053. SS_RGBDREFRACTION: boolean;
  49054. SS_LINEARSPECULARREFRACTION: boolean;
  49055. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49056. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49057. /** @hidden */
  49058. _areTexturesDirty: boolean;
  49059. }
  49060. /**
  49061. * Define the code related to the sub surface parameters of the pbr material.
  49062. */
  49063. export class PBRSubSurfaceConfiguration {
  49064. private _isRefractionEnabled;
  49065. /**
  49066. * Defines if the refraction is enabled in the material.
  49067. */
  49068. isRefractionEnabled: boolean;
  49069. private _isTranslucencyEnabled;
  49070. /**
  49071. * Defines if the translucency is enabled in the material.
  49072. */
  49073. isTranslucencyEnabled: boolean;
  49074. private _isScatteringEnabled;
  49075. /**
  49076. * Defines the refraction intensity of the material.
  49077. * The refraction when enabled replaces the Diffuse part of the material.
  49078. * The intensity helps transitionning between diffuse and refraction.
  49079. */
  49080. refractionIntensity: number;
  49081. /**
  49082. * Defines the translucency intensity of the material.
  49083. * When translucency has been enabled, this defines how much of the "translucency"
  49084. * is addded to the diffuse part of the material.
  49085. */
  49086. translucencyIntensity: number;
  49087. /**
  49088. * Defines the scattering intensity of the material.
  49089. * When scattering has been enabled, this defines how much of the "scattered light"
  49090. * is addded to the diffuse part of the material.
  49091. */
  49092. scatteringIntensity: number;
  49093. private _thicknessTexture;
  49094. /**
  49095. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  49096. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  49097. * 0 would mean minimumThickness
  49098. * 1 would mean maximumThickness
  49099. * The other channels might be use as a mask to vary the different effects intensity.
  49100. */
  49101. thicknessTexture: Nullable<BaseTexture>;
  49102. private _refractionTexture;
  49103. /**
  49104. * Defines the texture to use for refraction.
  49105. */
  49106. refractionTexture: Nullable<BaseTexture>;
  49107. private _indexOfRefraction;
  49108. /**
  49109. * Defines the index of refraction used in the material.
  49110. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  49111. */
  49112. indexOfRefraction: number;
  49113. private _invertRefractionY;
  49114. /**
  49115. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  49116. */
  49117. invertRefractionY: boolean;
  49118. private _linkRefractionWithTransparency;
  49119. /**
  49120. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  49121. * Materials half opaque for instance using refraction could benefit from this control.
  49122. */
  49123. linkRefractionWithTransparency: boolean;
  49124. /**
  49125. * Defines the minimum thickness stored in the thickness map.
  49126. * If no thickness map is defined, this value will be used to simulate thickness.
  49127. */
  49128. minimumThickness: number;
  49129. /**
  49130. * Defines the maximum thickness stored in the thickness map.
  49131. */
  49132. maximumThickness: number;
  49133. /**
  49134. * Defines the volume tint of the material.
  49135. * This is used for both translucency and scattering.
  49136. */
  49137. tintColor: Color3;
  49138. /**
  49139. * Defines the distance at which the tint color should be found in the media.
  49140. * This is used for refraction only.
  49141. */
  49142. tintColorAtDistance: number;
  49143. /**
  49144. * Defines how far each channel transmit through the media.
  49145. * It is defined as a color to simplify it selection.
  49146. */
  49147. diffusionDistance: Color3;
  49148. private _useMaskFromThicknessTexture;
  49149. /**
  49150. * Stores the intensity of the different subsurface effects in the thickness texture.
  49151. * * the green channel is the translucency intensity.
  49152. * * the blue channel is the scattering intensity.
  49153. * * the alpha channel is the refraction intensity.
  49154. */
  49155. useMaskFromThicknessTexture: boolean;
  49156. /** @hidden */
  49157. private _internalMarkAllSubMeshesAsTexturesDirty;
  49158. /** @hidden */
  49159. _markAllSubMeshesAsTexturesDirty(): void;
  49160. /**
  49161. * Instantiate a new istance of sub surface configuration.
  49162. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  49163. */
  49164. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  49165. /**
  49166. * Gets wehter the submesh is ready to be used or not.
  49167. * @param defines the list of "defines" to update.
  49168. * @param scene defines the scene the material belongs to.
  49169. * @returns - boolean indicating that the submesh is ready or not.
  49170. */
  49171. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  49172. /**
  49173. * Checks to see if a texture is used in the material.
  49174. * @param defines the list of "defines" to update.
  49175. * @param scene defines the scene to the material belongs to.
  49176. */
  49177. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  49178. /**
  49179. * Binds the material data.
  49180. * @param uniformBuffer defines the Uniform buffer to fill in.
  49181. * @param scene defines the scene the material belongs to.
  49182. * @param engine defines the engine the material belongs to.
  49183. * @param isFrozen defines wether the material is frozen or not.
  49184. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  49185. */
  49186. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  49187. /**
  49188. * Unbinds the material from the mesh.
  49189. * @param activeEffect defines the effect that should be unbound from.
  49190. * @returns true if unbound, otherwise false
  49191. */
  49192. unbind(activeEffect: Effect): boolean;
  49193. /**
  49194. * Returns the texture used for refraction or null if none is used.
  49195. * @param scene defines the scene the material belongs to.
  49196. * @returns - Refraction texture if present. If no refraction texture and refraction
  49197. * is linked with transparency, returns environment texture. Otherwise, returns null.
  49198. */
  49199. private _getRefractionTexture;
  49200. /**
  49201. * Returns true if alpha blending should be disabled.
  49202. */
  49203. readonly disableAlphaBlending: boolean;
  49204. /**
  49205. * Fills the list of render target textures.
  49206. * @param renderTargets the list of render targets to update
  49207. */
  49208. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  49209. /**
  49210. * Checks to see if a texture is used in the material.
  49211. * @param texture - Base texture to use.
  49212. * @returns - Boolean specifying if a texture is used in the material.
  49213. */
  49214. hasTexture(texture: BaseTexture): boolean;
  49215. /**
  49216. * Gets a boolean indicating that current material needs to register RTT
  49217. * @returns true if this uses a render target otherwise false.
  49218. */
  49219. hasRenderTargetTextures(): boolean;
  49220. /**
  49221. * Returns an array of the actively used textures.
  49222. * @param activeTextures Array of BaseTextures
  49223. */
  49224. getActiveTextures(activeTextures: BaseTexture[]): void;
  49225. /**
  49226. * Returns the animatable textures.
  49227. * @param animatables Array of animatable textures.
  49228. */
  49229. getAnimatables(animatables: IAnimatable[]): void;
  49230. /**
  49231. * Disposes the resources of the material.
  49232. * @param forceDisposeTextures - Forces the disposal of all textures.
  49233. */
  49234. dispose(forceDisposeTextures?: boolean): void;
  49235. /**
  49236. * Get the current class name of the texture useful for serialization or dynamic coding.
  49237. * @returns "PBRSubSurfaceConfiguration"
  49238. */
  49239. getClassName(): string;
  49240. /**
  49241. * Add fallbacks to the effect fallbacks list.
  49242. * @param defines defines the Base texture to use.
  49243. * @param fallbacks defines the current fallback list.
  49244. * @param currentRank defines the current fallback rank.
  49245. * @returns the new fallback rank.
  49246. */
  49247. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  49248. /**
  49249. * Add the required uniforms to the current list.
  49250. * @param uniforms defines the current uniform list.
  49251. */
  49252. static AddUniforms(uniforms: string[]): void;
  49253. /**
  49254. * Add the required samplers to the current list.
  49255. * @param samplers defines the current sampler list.
  49256. */
  49257. static AddSamplers(samplers: string[]): void;
  49258. /**
  49259. * Add the required uniforms to the current buffer.
  49260. * @param uniformBuffer defines the current uniform buffer.
  49261. */
  49262. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  49263. /**
  49264. * Makes a duplicate of the current configuration into another one.
  49265. * @param configuration define the config where to copy the info
  49266. */
  49267. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  49268. /**
  49269. * Serializes this Sub Surface configuration.
  49270. * @returns - An object with the serialized config.
  49271. */
  49272. serialize(): any;
  49273. /**
  49274. * Parses a anisotropy Configuration from a serialized object.
  49275. * @param source - Serialized object.
  49276. * @param scene Defines the scene we are parsing for
  49277. * @param rootUrl Defines the rootUrl to load from
  49278. */
  49279. parse(source: any, scene: Scene, rootUrl: string): void;
  49280. }
  49281. }
  49282. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  49283. /** @hidden */
  49284. export var pbrFragmentDeclaration: {
  49285. name: string;
  49286. shader: string;
  49287. };
  49288. }
  49289. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  49290. /** @hidden */
  49291. export var pbrUboDeclaration: {
  49292. name: string;
  49293. shader: string;
  49294. };
  49295. }
  49296. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  49297. /** @hidden */
  49298. export var pbrFragmentExtraDeclaration: {
  49299. name: string;
  49300. shader: string;
  49301. };
  49302. }
  49303. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  49304. /** @hidden */
  49305. export var pbrFragmentSamplersDeclaration: {
  49306. name: string;
  49307. shader: string;
  49308. };
  49309. }
  49310. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  49311. /** @hidden */
  49312. export var pbrHelperFunctions: {
  49313. name: string;
  49314. shader: string;
  49315. };
  49316. }
  49317. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  49318. /** @hidden */
  49319. export var harmonicsFunctions: {
  49320. name: string;
  49321. shader: string;
  49322. };
  49323. }
  49324. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  49325. /** @hidden */
  49326. export var pbrDirectLightingSetupFunctions: {
  49327. name: string;
  49328. shader: string;
  49329. };
  49330. }
  49331. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  49332. /** @hidden */
  49333. export var pbrDirectLightingFalloffFunctions: {
  49334. name: string;
  49335. shader: string;
  49336. };
  49337. }
  49338. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  49339. /** @hidden */
  49340. export var pbrBRDFFunctions: {
  49341. name: string;
  49342. shader: string;
  49343. };
  49344. }
  49345. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  49346. /** @hidden */
  49347. export var pbrDirectLightingFunctions: {
  49348. name: string;
  49349. shader: string;
  49350. };
  49351. }
  49352. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  49353. /** @hidden */
  49354. export var pbrIBLFunctions: {
  49355. name: string;
  49356. shader: string;
  49357. };
  49358. }
  49359. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  49360. /** @hidden */
  49361. export var pbrDebug: {
  49362. name: string;
  49363. shader: string;
  49364. };
  49365. }
  49366. declare module "babylonjs/Shaders/pbr.fragment" {
  49367. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  49368. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49369. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  49370. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49371. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49372. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  49373. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  49374. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  49375. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49376. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  49377. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49378. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  49379. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  49380. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  49381. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49382. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  49383. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  49384. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  49385. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  49386. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  49387. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  49388. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  49389. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  49390. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  49391. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  49392. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  49393. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  49394. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  49395. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  49396. /** @hidden */
  49397. export var pbrPixelShader: {
  49398. name: string;
  49399. shader: string;
  49400. };
  49401. }
  49402. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  49403. /** @hidden */
  49404. export var pbrVertexDeclaration: {
  49405. name: string;
  49406. shader: string;
  49407. };
  49408. }
  49409. declare module "babylonjs/Shaders/pbr.vertex" {
  49410. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  49411. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  49412. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49413. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  49414. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  49415. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  49416. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  49417. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  49418. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  49419. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  49420. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  49421. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  49422. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  49423. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  49424. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  49425. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  49426. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  49427. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  49428. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  49429. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  49430. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  49431. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  49432. /** @hidden */
  49433. export var pbrVertexShader: {
  49434. name: string;
  49435. shader: string;
  49436. };
  49437. }
  49438. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  49439. import { Nullable } from "babylonjs/types";
  49440. import { Scene } from "babylonjs/scene";
  49441. import { Matrix } from "babylonjs/Maths/math.vector";
  49442. import { SubMesh } from "babylonjs/Meshes/subMesh";
  49443. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49444. import { Mesh } from "babylonjs/Meshes/mesh";
  49445. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  49446. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  49447. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  49448. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  49449. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  49450. import { Color3 } from "babylonjs/Maths/math.color";
  49451. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  49452. import { Material } from "babylonjs/Materials/material";
  49453. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  49454. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  49455. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49456. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  49457. import "babylonjs/Shaders/pbr.fragment";
  49458. import "babylonjs/Shaders/pbr.vertex";
  49459. /**
  49460. * Manages the defines for the PBR Material.
  49461. * @hidden
  49462. */
  49463. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  49464. PBR: boolean;
  49465. MAINUV1: boolean;
  49466. MAINUV2: boolean;
  49467. UV1: boolean;
  49468. UV2: boolean;
  49469. ALBEDO: boolean;
  49470. ALBEDODIRECTUV: number;
  49471. VERTEXCOLOR: boolean;
  49472. AMBIENT: boolean;
  49473. AMBIENTDIRECTUV: number;
  49474. AMBIENTINGRAYSCALE: boolean;
  49475. OPACITY: boolean;
  49476. VERTEXALPHA: boolean;
  49477. OPACITYDIRECTUV: number;
  49478. OPACITYRGB: boolean;
  49479. ALPHATEST: boolean;
  49480. DEPTHPREPASS: boolean;
  49481. ALPHABLEND: boolean;
  49482. ALPHAFROMALBEDO: boolean;
  49483. ALPHATESTVALUE: string;
  49484. SPECULAROVERALPHA: boolean;
  49485. RADIANCEOVERALPHA: boolean;
  49486. ALPHAFRESNEL: boolean;
  49487. LINEARALPHAFRESNEL: boolean;
  49488. PREMULTIPLYALPHA: boolean;
  49489. EMISSIVE: boolean;
  49490. EMISSIVEDIRECTUV: number;
  49491. REFLECTIVITY: boolean;
  49492. REFLECTIVITYDIRECTUV: number;
  49493. SPECULARTERM: boolean;
  49494. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  49495. MICROSURFACEAUTOMATIC: boolean;
  49496. LODBASEDMICROSFURACE: boolean;
  49497. MICROSURFACEMAP: boolean;
  49498. MICROSURFACEMAPDIRECTUV: number;
  49499. METALLICWORKFLOW: boolean;
  49500. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  49501. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  49502. METALLNESSSTOREINMETALMAPBLUE: boolean;
  49503. AOSTOREINMETALMAPRED: boolean;
  49504. ENVIRONMENTBRDF: boolean;
  49505. ENVIRONMENTBRDF_RGBD: boolean;
  49506. NORMAL: boolean;
  49507. TANGENT: boolean;
  49508. BUMP: boolean;
  49509. BUMPDIRECTUV: number;
  49510. OBJECTSPACE_NORMALMAP: boolean;
  49511. PARALLAX: boolean;
  49512. PARALLAXOCCLUSION: boolean;
  49513. NORMALXYSCALE: boolean;
  49514. LIGHTMAP: boolean;
  49515. LIGHTMAPDIRECTUV: number;
  49516. USELIGHTMAPASSHADOWMAP: boolean;
  49517. GAMMALIGHTMAP: boolean;
  49518. RGBDLIGHTMAP: boolean;
  49519. REFLECTION: boolean;
  49520. REFLECTIONMAP_3D: boolean;
  49521. REFLECTIONMAP_SPHERICAL: boolean;
  49522. REFLECTIONMAP_PLANAR: boolean;
  49523. REFLECTIONMAP_CUBIC: boolean;
  49524. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  49525. REFLECTIONMAP_PROJECTION: boolean;
  49526. REFLECTIONMAP_SKYBOX: boolean;
  49527. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  49528. REFLECTIONMAP_EXPLICIT: boolean;
  49529. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  49530. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  49531. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  49532. INVERTCUBICMAP: boolean;
  49533. USESPHERICALFROMREFLECTIONMAP: boolean;
  49534. USEIRRADIANCEMAP: boolean;
  49535. SPHERICAL_HARMONICS: boolean;
  49536. USESPHERICALINVERTEX: boolean;
  49537. REFLECTIONMAP_OPPOSITEZ: boolean;
  49538. LODINREFLECTIONALPHA: boolean;
  49539. GAMMAREFLECTION: boolean;
  49540. RGBDREFLECTION: boolean;
  49541. LINEARSPECULARREFLECTION: boolean;
  49542. RADIANCEOCCLUSION: boolean;
  49543. HORIZONOCCLUSION: boolean;
  49544. INSTANCES: boolean;
  49545. NUM_BONE_INFLUENCERS: number;
  49546. BonesPerMesh: number;
  49547. BONETEXTURE: boolean;
  49548. NONUNIFORMSCALING: boolean;
  49549. MORPHTARGETS: boolean;
  49550. MORPHTARGETS_NORMAL: boolean;
  49551. MORPHTARGETS_TANGENT: boolean;
  49552. MORPHTARGETS_UV: boolean;
  49553. NUM_MORPH_INFLUENCERS: number;
  49554. IMAGEPROCESSING: boolean;
  49555. VIGNETTE: boolean;
  49556. VIGNETTEBLENDMODEMULTIPLY: boolean;
  49557. VIGNETTEBLENDMODEOPAQUE: boolean;
  49558. TONEMAPPING: boolean;
  49559. TONEMAPPING_ACES: boolean;
  49560. CONTRAST: boolean;
  49561. COLORCURVES: boolean;
  49562. COLORGRADING: boolean;
  49563. COLORGRADING3D: boolean;
  49564. SAMPLER3DGREENDEPTH: boolean;
  49565. SAMPLER3DBGRMAP: boolean;
  49566. IMAGEPROCESSINGPOSTPROCESS: boolean;
  49567. EXPOSURE: boolean;
  49568. MULTIVIEW: boolean;
  49569. USEPHYSICALLIGHTFALLOFF: boolean;
  49570. USEGLTFLIGHTFALLOFF: boolean;
  49571. TWOSIDEDLIGHTING: boolean;
  49572. SHADOWFLOAT: boolean;
  49573. CLIPPLANE: boolean;
  49574. CLIPPLANE2: boolean;
  49575. CLIPPLANE3: boolean;
  49576. CLIPPLANE4: boolean;
  49577. POINTSIZE: boolean;
  49578. FOG: boolean;
  49579. LOGARITHMICDEPTH: boolean;
  49580. FORCENORMALFORWARD: boolean;
  49581. SPECULARAA: boolean;
  49582. CLEARCOAT: boolean;
  49583. CLEARCOAT_DEFAULTIOR: boolean;
  49584. CLEARCOAT_TEXTURE: boolean;
  49585. CLEARCOAT_TEXTUREDIRECTUV: number;
  49586. CLEARCOAT_BUMP: boolean;
  49587. CLEARCOAT_BUMPDIRECTUV: number;
  49588. CLEARCOAT_TINT: boolean;
  49589. CLEARCOAT_TINT_TEXTURE: boolean;
  49590. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  49591. ANISOTROPIC: boolean;
  49592. ANISOTROPIC_TEXTURE: boolean;
  49593. ANISOTROPIC_TEXTUREDIRECTUV: number;
  49594. BRDF_V_HEIGHT_CORRELATED: boolean;
  49595. MS_BRDF_ENERGY_CONSERVATION: boolean;
  49596. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  49597. SHEEN: boolean;
  49598. SHEEN_TEXTURE: boolean;
  49599. SHEEN_TEXTUREDIRECTUV: number;
  49600. SHEEN_LINKWITHALBEDO: boolean;
  49601. SUBSURFACE: boolean;
  49602. SS_REFRACTION: boolean;
  49603. SS_TRANSLUCENCY: boolean;
  49604. SS_SCATERRING: boolean;
  49605. SS_THICKNESSANDMASK_TEXTURE: boolean;
  49606. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  49607. SS_REFRACTIONMAP_3D: boolean;
  49608. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  49609. SS_LODINREFRACTIONALPHA: boolean;
  49610. SS_GAMMAREFRACTION: boolean;
  49611. SS_RGBDREFRACTION: boolean;
  49612. SS_LINEARSPECULARREFRACTION: boolean;
  49613. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  49614. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  49615. UNLIT: boolean;
  49616. DEBUGMODE: number;
  49617. /**
  49618. * Initializes the PBR Material defines.
  49619. */
  49620. constructor();
  49621. /**
  49622. * Resets the PBR Material defines.
  49623. */
  49624. reset(): void;
  49625. }
  49626. /**
  49627. * The Physically based material base class of BJS.
  49628. *
  49629. * This offers the main features of a standard PBR material.
  49630. * For more information, please refer to the documentation :
  49631. * https://doc.babylonjs.com/how_to/physically_based_rendering
  49632. */
  49633. export abstract class PBRBaseMaterial extends PushMaterial {
  49634. /**
  49635. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  49636. */
  49637. static readonly PBRMATERIAL_OPAQUE: number;
  49638. /**
  49639. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  49640. */
  49641. static readonly PBRMATERIAL_ALPHATEST: number;
  49642. /**
  49643. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49644. */
  49645. static readonly PBRMATERIAL_ALPHABLEND: number;
  49646. /**
  49647. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  49648. * They are also discarded below the alpha cutoff threshold to improve performances.
  49649. */
  49650. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  49651. /**
  49652. * Defines the default value of how much AO map is occluding the analytical lights
  49653. * (point spot...).
  49654. */
  49655. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  49656. /**
  49657. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  49658. */
  49659. static readonly LIGHTFALLOFF_PHYSICAL: number;
  49660. /**
  49661. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  49662. * to enhance interoperability with other engines.
  49663. */
  49664. static readonly LIGHTFALLOFF_GLTF: number;
  49665. /**
  49666. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  49667. * to enhance interoperability with other materials.
  49668. */
  49669. static readonly LIGHTFALLOFF_STANDARD: number;
  49670. /**
  49671. * Intensity of the direct lights e.g. the four lights available in your scene.
  49672. * This impacts both the direct diffuse and specular highlights.
  49673. */
  49674. protected _directIntensity: number;
  49675. /**
  49676. * Intensity of the emissive part of the material.
  49677. * This helps controlling the emissive effect without modifying the emissive color.
  49678. */
  49679. protected _emissiveIntensity: number;
  49680. /**
  49681. * Intensity of the environment e.g. how much the environment will light the object
  49682. * either through harmonics for rough material or through the refelction for shiny ones.
  49683. */
  49684. protected _environmentIntensity: number;
  49685. /**
  49686. * This is a special control allowing the reduction of the specular highlights coming from the
  49687. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  49688. */
  49689. protected _specularIntensity: number;
  49690. /**
  49691. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  49692. */
  49693. private _lightingInfos;
  49694. /**
  49695. * Debug Control allowing disabling the bump map on this material.
  49696. */
  49697. protected _disableBumpMap: boolean;
  49698. /**
  49699. * AKA Diffuse Texture in standard nomenclature.
  49700. */
  49701. protected _albedoTexture: Nullable<BaseTexture>;
  49702. /**
  49703. * AKA Occlusion Texture in other nomenclature.
  49704. */
  49705. protected _ambientTexture: Nullable<BaseTexture>;
  49706. /**
  49707. * AKA Occlusion Texture Intensity in other nomenclature.
  49708. */
  49709. protected _ambientTextureStrength: number;
  49710. /**
  49711. * Defines how much the AO map is occluding the analytical lights (point spot...).
  49712. * 1 means it completely occludes it
  49713. * 0 mean it has no impact
  49714. */
  49715. protected _ambientTextureImpactOnAnalyticalLights: number;
  49716. /**
  49717. * Stores the alpha values in a texture.
  49718. */
  49719. protected _opacityTexture: Nullable<BaseTexture>;
  49720. /**
  49721. * Stores the reflection values in a texture.
  49722. */
  49723. protected _reflectionTexture: Nullable<BaseTexture>;
  49724. /**
  49725. * Stores the emissive values in a texture.
  49726. */
  49727. protected _emissiveTexture: Nullable<BaseTexture>;
  49728. /**
  49729. * AKA Specular texture in other nomenclature.
  49730. */
  49731. protected _reflectivityTexture: Nullable<BaseTexture>;
  49732. /**
  49733. * Used to switch from specular/glossiness to metallic/roughness workflow.
  49734. */
  49735. protected _metallicTexture: Nullable<BaseTexture>;
  49736. /**
  49737. * Specifies the metallic scalar of the metallic/roughness workflow.
  49738. * Can also be used to scale the metalness values of the metallic texture.
  49739. */
  49740. protected _metallic: Nullable<number>;
  49741. /**
  49742. * Specifies the roughness scalar of the metallic/roughness workflow.
  49743. * Can also be used to scale the roughness values of the metallic texture.
  49744. */
  49745. protected _roughness: Nullable<number>;
  49746. /**
  49747. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  49748. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  49749. */
  49750. protected _microSurfaceTexture: Nullable<BaseTexture>;
  49751. /**
  49752. * Stores surface normal data used to displace a mesh in a texture.
  49753. */
  49754. protected _bumpTexture: Nullable<BaseTexture>;
  49755. /**
  49756. * Stores the pre-calculated light information of a mesh in a texture.
  49757. */
  49758. protected _lightmapTexture: Nullable<BaseTexture>;
  49759. /**
  49760. * The color of a material in ambient lighting.
  49761. */
  49762. protected _ambientColor: Color3;
  49763. /**
  49764. * AKA Diffuse Color in other nomenclature.
  49765. */
  49766. protected _albedoColor: Color3;
  49767. /**
  49768. * AKA Specular Color in other nomenclature.
  49769. */
  49770. protected _reflectivityColor: Color3;
  49771. /**
  49772. * The color applied when light is reflected from a material.
  49773. */
  49774. protected _reflectionColor: Color3;
  49775. /**
  49776. * The color applied when light is emitted from a material.
  49777. */
  49778. protected _emissiveColor: Color3;
  49779. /**
  49780. * AKA Glossiness in other nomenclature.
  49781. */
  49782. protected _microSurface: number;
  49783. /**
  49784. * Specifies that the material will use the light map as a show map.
  49785. */
  49786. protected _useLightmapAsShadowmap: boolean;
  49787. /**
  49788. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  49789. * makes the reflect vector face the model (under horizon).
  49790. */
  49791. protected _useHorizonOcclusion: boolean;
  49792. /**
  49793. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  49794. * too much the area relying on ambient texture to define their ambient occlusion.
  49795. */
  49796. protected _useRadianceOcclusion: boolean;
  49797. /**
  49798. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  49799. */
  49800. protected _useAlphaFromAlbedoTexture: boolean;
  49801. /**
  49802. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  49803. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  49804. */
  49805. protected _useSpecularOverAlpha: boolean;
  49806. /**
  49807. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  49808. */
  49809. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  49810. /**
  49811. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  49812. */
  49813. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  49814. /**
  49815. * Specifies if the metallic texture contains the roughness information in its green channel.
  49816. */
  49817. protected _useRoughnessFromMetallicTextureGreen: boolean;
  49818. /**
  49819. * Specifies if the metallic texture contains the metallness information in its blue channel.
  49820. */
  49821. protected _useMetallnessFromMetallicTextureBlue: boolean;
  49822. /**
  49823. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  49824. */
  49825. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  49826. /**
  49827. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  49828. */
  49829. protected _useAmbientInGrayScale: boolean;
  49830. /**
  49831. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  49832. * The material will try to infer what glossiness each pixel should be.
  49833. */
  49834. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  49835. /**
  49836. * Defines the falloff type used in this material.
  49837. * It by default is Physical.
  49838. */
  49839. protected _lightFalloff: number;
  49840. /**
  49841. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  49842. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  49843. */
  49844. protected _useRadianceOverAlpha: boolean;
  49845. /**
  49846. * Allows using an object space normal map (instead of tangent space).
  49847. */
  49848. protected _useObjectSpaceNormalMap: boolean;
  49849. /**
  49850. * Allows using the bump map in parallax mode.
  49851. */
  49852. protected _useParallax: boolean;
  49853. /**
  49854. * Allows using the bump map in parallax occlusion mode.
  49855. */
  49856. protected _useParallaxOcclusion: boolean;
  49857. /**
  49858. * Controls the scale bias of the parallax mode.
  49859. */
  49860. protected _parallaxScaleBias: number;
  49861. /**
  49862. * If sets to true, disables all the lights affecting the material.
  49863. */
  49864. protected _disableLighting: boolean;
  49865. /**
  49866. * Number of Simultaneous lights allowed on the material.
  49867. */
  49868. protected _maxSimultaneousLights: number;
  49869. /**
  49870. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  49871. */
  49872. protected _invertNormalMapX: boolean;
  49873. /**
  49874. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  49875. */
  49876. protected _invertNormalMapY: boolean;
  49877. /**
  49878. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  49879. */
  49880. protected _twoSidedLighting: boolean;
  49881. /**
  49882. * Defines the alpha limits in alpha test mode.
  49883. */
  49884. protected _alphaCutOff: number;
  49885. /**
  49886. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  49887. */
  49888. protected _forceAlphaTest: boolean;
  49889. /**
  49890. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49891. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  49892. */
  49893. protected _useAlphaFresnel: boolean;
  49894. /**
  49895. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  49896. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  49897. */
  49898. protected _useLinearAlphaFresnel: boolean;
  49899. /**
  49900. * The transparency mode of the material.
  49901. */
  49902. protected _transparencyMode: Nullable<number>;
  49903. /**
  49904. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  49905. * from cos thetav and roughness:
  49906. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  49907. */
  49908. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  49909. /**
  49910. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  49911. */
  49912. protected _forceIrradianceInFragment: boolean;
  49913. /**
  49914. * Force normal to face away from face.
  49915. */
  49916. protected _forceNormalForward: boolean;
  49917. /**
  49918. * Enables specular anti aliasing in the PBR shader.
  49919. * It will both interacts on the Geometry for analytical and IBL lighting.
  49920. * It also prefilter the roughness map based on the bump values.
  49921. */
  49922. protected _enableSpecularAntiAliasing: boolean;
  49923. /**
  49924. * Default configuration related to image processing available in the PBR Material.
  49925. */
  49926. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  49927. /**
  49928. * Keep track of the image processing observer to allow dispose and replace.
  49929. */
  49930. private _imageProcessingObserver;
  49931. /**
  49932. * Attaches a new image processing configuration to the PBR Material.
  49933. * @param configuration
  49934. */
  49935. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  49936. /**
  49937. * Stores the available render targets.
  49938. */
  49939. private _renderTargets;
  49940. /**
  49941. * Sets the global ambient color for the material used in lighting calculations.
  49942. */
  49943. private _globalAmbientColor;
  49944. /**
  49945. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  49946. */
  49947. private _useLogarithmicDepth;
  49948. /**
  49949. * If set to true, no lighting calculations will be applied.
  49950. */
  49951. private _unlit;
  49952. private _debugMode;
  49953. /**
  49954. * @hidden
  49955. * This is reserved for the inspector.
  49956. * Defines the material debug mode.
  49957. * It helps seeing only some components of the material while troubleshooting.
  49958. */
  49959. debugMode: number;
  49960. /**
  49961. * @hidden
  49962. * This is reserved for the inspector.
  49963. * Specify from where on screen the debug mode should start.
  49964. * The value goes from -1 (full screen) to 1 (not visible)
  49965. * It helps with side by side comparison against the final render
  49966. * This defaults to -1
  49967. */
  49968. private debugLimit;
  49969. /**
  49970. * @hidden
  49971. * This is reserved for the inspector.
  49972. * As the default viewing range might not be enough (if the ambient is really small for instance)
  49973. * You can use the factor to better multiply the final value.
  49974. */
  49975. private debugFactor;
  49976. /**
  49977. * Defines the clear coat layer parameters for the material.
  49978. */
  49979. readonly clearCoat: PBRClearCoatConfiguration;
  49980. /**
  49981. * Defines the anisotropic parameters for the material.
  49982. */
  49983. readonly anisotropy: PBRAnisotropicConfiguration;
  49984. /**
  49985. * Defines the BRDF parameters for the material.
  49986. */
  49987. readonly brdf: PBRBRDFConfiguration;
  49988. /**
  49989. * Defines the Sheen parameters for the material.
  49990. */
  49991. readonly sheen: PBRSheenConfiguration;
  49992. /**
  49993. * Defines the SubSurface parameters for the material.
  49994. */
  49995. readonly subSurface: PBRSubSurfaceConfiguration;
  49996. /**
  49997. * Custom callback helping to override the default shader used in the material.
  49998. */
  49999. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  50000. protected _rebuildInParallel: boolean;
  50001. /**
  50002. * Instantiates a new PBRMaterial instance.
  50003. *
  50004. * @param name The material name
  50005. * @param scene The scene the material will be use in.
  50006. */
  50007. constructor(name: string, scene: Scene);
  50008. /**
  50009. * Gets a boolean indicating that current material needs to register RTT
  50010. */
  50011. readonly hasRenderTargetTextures: boolean;
  50012. /**
  50013. * Gets the name of the material class.
  50014. */
  50015. getClassName(): string;
  50016. /**
  50017. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50018. */
  50019. /**
  50020. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  50021. */
  50022. useLogarithmicDepth: boolean;
  50023. /**
  50024. * Gets the current transparency mode.
  50025. */
  50026. /**
  50027. * Sets the transparency mode of the material.
  50028. *
  50029. * | Value | Type | Description |
  50030. * | ----- | ----------------------------------- | ----------- |
  50031. * | 0 | OPAQUE | |
  50032. * | 1 | ALPHATEST | |
  50033. * | 2 | ALPHABLEND | |
  50034. * | 3 | ALPHATESTANDBLEND | |
  50035. *
  50036. */
  50037. transparencyMode: Nullable<number>;
  50038. /**
  50039. * Returns true if alpha blending should be disabled.
  50040. */
  50041. private readonly _disableAlphaBlending;
  50042. /**
  50043. * Specifies whether or not this material should be rendered in alpha blend mode.
  50044. */
  50045. needAlphaBlending(): boolean;
  50046. /**
  50047. * Specifies if the mesh will require alpha blending.
  50048. * @param mesh - BJS mesh.
  50049. */
  50050. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  50051. /**
  50052. * Specifies whether or not this material should be rendered in alpha test mode.
  50053. */
  50054. needAlphaTesting(): boolean;
  50055. /**
  50056. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  50057. */
  50058. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  50059. /**
  50060. * Gets the texture used for the alpha test.
  50061. */
  50062. getAlphaTestTexture(): Nullable<BaseTexture>;
  50063. /**
  50064. * Specifies that the submesh is ready to be used.
  50065. * @param mesh - BJS mesh.
  50066. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  50067. * @param useInstances - Specifies that instances should be used.
  50068. * @returns - boolean indicating that the submesh is ready or not.
  50069. */
  50070. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  50071. /**
  50072. * Specifies if the material uses metallic roughness workflow.
  50073. * @returns boolean specifiying if the material uses metallic roughness workflow.
  50074. */
  50075. isMetallicWorkflow(): boolean;
  50076. private _prepareEffect;
  50077. private _prepareDefines;
  50078. /**
  50079. * Force shader compilation
  50080. */
  50081. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  50082. clipPlane: boolean;
  50083. }>): void;
  50084. /**
  50085. * Initializes the uniform buffer layout for the shader.
  50086. */
  50087. buildUniformLayout(): void;
  50088. /**
  50089. * Unbinds the material from the mesh
  50090. */
  50091. unbind(): void;
  50092. /**
  50093. * Binds the submesh data.
  50094. * @param world - The world matrix.
  50095. * @param mesh - The BJS mesh.
  50096. * @param subMesh - A submesh of the BJS mesh.
  50097. */
  50098. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  50099. /**
  50100. * Returns the animatable textures.
  50101. * @returns - Array of animatable textures.
  50102. */
  50103. getAnimatables(): IAnimatable[];
  50104. /**
  50105. * Returns the texture used for reflections.
  50106. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  50107. */
  50108. private _getReflectionTexture;
  50109. /**
  50110. * Returns an array of the actively used textures.
  50111. * @returns - Array of BaseTextures
  50112. */
  50113. getActiveTextures(): BaseTexture[];
  50114. /**
  50115. * Checks to see if a texture is used in the material.
  50116. * @param texture - Base texture to use.
  50117. * @returns - Boolean specifying if a texture is used in the material.
  50118. */
  50119. hasTexture(texture: BaseTexture): boolean;
  50120. /**
  50121. * Disposes the resources of the material.
  50122. * @param forceDisposeEffect - Forces the disposal of effects.
  50123. * @param forceDisposeTextures - Forces the disposal of all textures.
  50124. */
  50125. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  50126. }
  50127. }
  50128. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  50129. import { Nullable } from "babylonjs/types";
  50130. import { Scene } from "babylonjs/scene";
  50131. import { Color3 } from "babylonjs/Maths/math.color";
  50132. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  50133. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  50134. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50135. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50136. /**
  50137. * The Physically based material of BJS.
  50138. *
  50139. * This offers the main features of a standard PBR material.
  50140. * For more information, please refer to the documentation :
  50141. * https://doc.babylonjs.com/how_to/physically_based_rendering
  50142. */
  50143. export class PBRMaterial extends PBRBaseMaterial {
  50144. /**
  50145. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  50146. */
  50147. static readonly PBRMATERIAL_OPAQUE: number;
  50148. /**
  50149. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  50150. */
  50151. static readonly PBRMATERIAL_ALPHATEST: number;
  50152. /**
  50153. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50154. */
  50155. static readonly PBRMATERIAL_ALPHABLEND: number;
  50156. /**
  50157. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  50158. * They are also discarded below the alpha cutoff threshold to improve performances.
  50159. */
  50160. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  50161. /**
  50162. * Defines the default value of how much AO map is occluding the analytical lights
  50163. * (point spot...).
  50164. */
  50165. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  50166. /**
  50167. * Intensity of the direct lights e.g. the four lights available in your scene.
  50168. * This impacts both the direct diffuse and specular highlights.
  50169. */
  50170. directIntensity: number;
  50171. /**
  50172. * Intensity of the emissive part of the material.
  50173. * This helps controlling the emissive effect without modifying the emissive color.
  50174. */
  50175. emissiveIntensity: number;
  50176. /**
  50177. * Intensity of the environment e.g. how much the environment will light the object
  50178. * either through harmonics for rough material or through the refelction for shiny ones.
  50179. */
  50180. environmentIntensity: number;
  50181. /**
  50182. * This is a special control allowing the reduction of the specular highlights coming from the
  50183. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50184. */
  50185. specularIntensity: number;
  50186. /**
  50187. * Debug Control allowing disabling the bump map on this material.
  50188. */
  50189. disableBumpMap: boolean;
  50190. /**
  50191. * AKA Diffuse Texture in standard nomenclature.
  50192. */
  50193. albedoTexture: BaseTexture;
  50194. /**
  50195. * AKA Occlusion Texture in other nomenclature.
  50196. */
  50197. ambientTexture: BaseTexture;
  50198. /**
  50199. * AKA Occlusion Texture Intensity in other nomenclature.
  50200. */
  50201. ambientTextureStrength: number;
  50202. /**
  50203. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50204. * 1 means it completely occludes it
  50205. * 0 mean it has no impact
  50206. */
  50207. ambientTextureImpactOnAnalyticalLights: number;
  50208. /**
  50209. * Stores the alpha values in a texture.
  50210. */
  50211. opacityTexture: BaseTexture;
  50212. /**
  50213. * Stores the reflection values in a texture.
  50214. */
  50215. reflectionTexture: Nullable<BaseTexture>;
  50216. /**
  50217. * Stores the emissive values in a texture.
  50218. */
  50219. emissiveTexture: BaseTexture;
  50220. /**
  50221. * AKA Specular texture in other nomenclature.
  50222. */
  50223. reflectivityTexture: BaseTexture;
  50224. /**
  50225. * Used to switch from specular/glossiness to metallic/roughness workflow.
  50226. */
  50227. metallicTexture: BaseTexture;
  50228. /**
  50229. * Specifies the metallic scalar of the metallic/roughness workflow.
  50230. * Can also be used to scale the metalness values of the metallic texture.
  50231. */
  50232. metallic: Nullable<number>;
  50233. /**
  50234. * Specifies the roughness scalar of the metallic/roughness workflow.
  50235. * Can also be used to scale the roughness values of the metallic texture.
  50236. */
  50237. roughness: Nullable<number>;
  50238. /**
  50239. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  50240. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  50241. */
  50242. microSurfaceTexture: BaseTexture;
  50243. /**
  50244. * Stores surface normal data used to displace a mesh in a texture.
  50245. */
  50246. bumpTexture: BaseTexture;
  50247. /**
  50248. * Stores the pre-calculated light information of a mesh in a texture.
  50249. */
  50250. lightmapTexture: BaseTexture;
  50251. /**
  50252. * Stores the refracted light information in a texture.
  50253. */
  50254. refractionTexture: Nullable<BaseTexture>;
  50255. /**
  50256. * The color of a material in ambient lighting.
  50257. */
  50258. ambientColor: Color3;
  50259. /**
  50260. * AKA Diffuse Color in other nomenclature.
  50261. */
  50262. albedoColor: Color3;
  50263. /**
  50264. * AKA Specular Color in other nomenclature.
  50265. */
  50266. reflectivityColor: Color3;
  50267. /**
  50268. * The color reflected from the material.
  50269. */
  50270. reflectionColor: Color3;
  50271. /**
  50272. * The color emitted from the material.
  50273. */
  50274. emissiveColor: Color3;
  50275. /**
  50276. * AKA Glossiness in other nomenclature.
  50277. */
  50278. microSurface: number;
  50279. /**
  50280. * source material index of refraction (IOR)' / 'destination material IOR.
  50281. */
  50282. indexOfRefraction: number;
  50283. /**
  50284. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50285. */
  50286. invertRefractionY: boolean;
  50287. /**
  50288. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50289. * Materials half opaque for instance using refraction could benefit from this control.
  50290. */
  50291. linkRefractionWithTransparency: boolean;
  50292. /**
  50293. * If true, the light map contains occlusion information instead of lighting info.
  50294. */
  50295. useLightmapAsShadowmap: boolean;
  50296. /**
  50297. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50298. */
  50299. useAlphaFromAlbedoTexture: boolean;
  50300. /**
  50301. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50302. */
  50303. forceAlphaTest: boolean;
  50304. /**
  50305. * Defines the alpha limits in alpha test mode.
  50306. */
  50307. alphaCutOff: number;
  50308. /**
  50309. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  50310. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50311. */
  50312. useSpecularOverAlpha: boolean;
  50313. /**
  50314. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50315. */
  50316. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  50317. /**
  50318. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50319. */
  50320. useRoughnessFromMetallicTextureAlpha: boolean;
  50321. /**
  50322. * Specifies if the metallic texture contains the roughness information in its green channel.
  50323. */
  50324. useRoughnessFromMetallicTextureGreen: boolean;
  50325. /**
  50326. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50327. */
  50328. useMetallnessFromMetallicTextureBlue: boolean;
  50329. /**
  50330. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50331. */
  50332. useAmbientOcclusionFromMetallicTextureRed: boolean;
  50333. /**
  50334. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50335. */
  50336. useAmbientInGrayScale: boolean;
  50337. /**
  50338. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50339. * The material will try to infer what glossiness each pixel should be.
  50340. */
  50341. useAutoMicroSurfaceFromReflectivityMap: boolean;
  50342. /**
  50343. * BJS is using an harcoded light falloff based on a manually sets up range.
  50344. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50345. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50346. */
  50347. /**
  50348. * BJS is using an harcoded light falloff based on a manually sets up range.
  50349. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  50350. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  50351. */
  50352. usePhysicalLightFalloff: boolean;
  50353. /**
  50354. * In order to support the falloff compatibility with gltf, a special mode has been added
  50355. * to reproduce the gltf light falloff.
  50356. */
  50357. /**
  50358. * In order to support the falloff compatibility with gltf, a special mode has been added
  50359. * to reproduce the gltf light falloff.
  50360. */
  50361. useGLTFLightFalloff: boolean;
  50362. /**
  50363. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50364. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50365. */
  50366. useRadianceOverAlpha: boolean;
  50367. /**
  50368. * Allows using an object space normal map (instead of tangent space).
  50369. */
  50370. useObjectSpaceNormalMap: boolean;
  50371. /**
  50372. * Allows using the bump map in parallax mode.
  50373. */
  50374. useParallax: boolean;
  50375. /**
  50376. * Allows using the bump map in parallax occlusion mode.
  50377. */
  50378. useParallaxOcclusion: boolean;
  50379. /**
  50380. * Controls the scale bias of the parallax mode.
  50381. */
  50382. parallaxScaleBias: number;
  50383. /**
  50384. * If sets to true, disables all the lights affecting the material.
  50385. */
  50386. disableLighting: boolean;
  50387. /**
  50388. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  50389. */
  50390. forceIrradianceInFragment: boolean;
  50391. /**
  50392. * Number of Simultaneous lights allowed on the material.
  50393. */
  50394. maxSimultaneousLights: number;
  50395. /**
  50396. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50397. */
  50398. invertNormalMapX: boolean;
  50399. /**
  50400. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50401. */
  50402. invertNormalMapY: boolean;
  50403. /**
  50404. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50405. */
  50406. twoSidedLighting: boolean;
  50407. /**
  50408. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50409. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50410. */
  50411. useAlphaFresnel: boolean;
  50412. /**
  50413. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50414. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50415. */
  50416. useLinearAlphaFresnel: boolean;
  50417. /**
  50418. * Let user defines the brdf lookup texture used for IBL.
  50419. * A default 8bit version is embedded but you could point at :
  50420. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  50421. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  50422. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  50423. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  50424. */
  50425. environmentBRDFTexture: Nullable<BaseTexture>;
  50426. /**
  50427. * Force normal to face away from face.
  50428. */
  50429. forceNormalForward: boolean;
  50430. /**
  50431. * Enables specular anti aliasing in the PBR shader.
  50432. * It will both interacts on the Geometry for analytical and IBL lighting.
  50433. * It also prefilter the roughness map based on the bump values.
  50434. */
  50435. enableSpecularAntiAliasing: boolean;
  50436. /**
  50437. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50438. * makes the reflect vector face the model (under horizon).
  50439. */
  50440. useHorizonOcclusion: boolean;
  50441. /**
  50442. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50443. * too much the area relying on ambient texture to define their ambient occlusion.
  50444. */
  50445. useRadianceOcclusion: boolean;
  50446. /**
  50447. * If set to true, no lighting calculations will be applied.
  50448. */
  50449. unlit: boolean;
  50450. /**
  50451. * Gets the image processing configuration used either in this material.
  50452. */
  50453. /**
  50454. * Sets the Default image processing configuration used either in the this material.
  50455. *
  50456. * If sets to null, the scene one is in use.
  50457. */
  50458. imageProcessingConfiguration: ImageProcessingConfiguration;
  50459. /**
  50460. * Gets wether the color curves effect is enabled.
  50461. */
  50462. /**
  50463. * Sets wether the color curves effect is enabled.
  50464. */
  50465. cameraColorCurvesEnabled: boolean;
  50466. /**
  50467. * Gets wether the color grading effect is enabled.
  50468. */
  50469. /**
  50470. * Gets wether the color grading effect is enabled.
  50471. */
  50472. cameraColorGradingEnabled: boolean;
  50473. /**
  50474. * Gets wether tonemapping is enabled or not.
  50475. */
  50476. /**
  50477. * Sets wether tonemapping is enabled or not
  50478. */
  50479. cameraToneMappingEnabled: boolean;
  50480. /**
  50481. * The camera exposure used on this material.
  50482. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50483. * This corresponds to a photographic exposure.
  50484. */
  50485. /**
  50486. * The camera exposure used on this material.
  50487. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  50488. * This corresponds to a photographic exposure.
  50489. */
  50490. cameraExposure: number;
  50491. /**
  50492. * Gets The camera contrast used on this material.
  50493. */
  50494. /**
  50495. * Sets The camera contrast used on this material.
  50496. */
  50497. cameraContrast: number;
  50498. /**
  50499. * Gets the Color Grading 2D Lookup Texture.
  50500. */
  50501. /**
  50502. * Sets the Color Grading 2D Lookup Texture.
  50503. */
  50504. cameraColorGradingTexture: Nullable<BaseTexture>;
  50505. /**
  50506. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50507. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50508. * 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;
  50509. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50510. */
  50511. /**
  50512. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  50513. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  50514. * 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;
  50515. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  50516. */
  50517. cameraColorCurves: Nullable<ColorCurves>;
  50518. /**
  50519. * Instantiates a new PBRMaterial instance.
  50520. *
  50521. * @param name The material name
  50522. * @param scene The scene the material will be use in.
  50523. */
  50524. constructor(name: string, scene: Scene);
  50525. /**
  50526. * Returns the name of this material class.
  50527. */
  50528. getClassName(): string;
  50529. /**
  50530. * Makes a duplicate of the current material.
  50531. * @param name - name to use for the new material.
  50532. */
  50533. clone(name: string): PBRMaterial;
  50534. /**
  50535. * Serializes this PBR Material.
  50536. * @returns - An object with the serialized material.
  50537. */
  50538. serialize(): any;
  50539. /**
  50540. * Parses a PBR Material from a serialized object.
  50541. * @param source - Serialized object.
  50542. * @param scene - BJS scene instance.
  50543. * @param rootUrl - url for the scene object
  50544. * @returns - PBRMaterial
  50545. */
  50546. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  50547. }
  50548. }
  50549. declare module "babylonjs/Misc/dds" {
  50550. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  50551. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50552. import { Nullable } from "babylonjs/types";
  50553. import { Scene } from "babylonjs/scene";
  50554. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  50555. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  50556. /**
  50557. * Direct draw surface info
  50558. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  50559. */
  50560. export interface DDSInfo {
  50561. /**
  50562. * Width of the texture
  50563. */
  50564. width: number;
  50565. /**
  50566. * Width of the texture
  50567. */
  50568. height: number;
  50569. /**
  50570. * Number of Mipmaps for the texture
  50571. * @see https://en.wikipedia.org/wiki/Mipmap
  50572. */
  50573. mipmapCount: number;
  50574. /**
  50575. * If the textures format is a known fourCC format
  50576. * @see https://www.fourcc.org/
  50577. */
  50578. isFourCC: boolean;
  50579. /**
  50580. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  50581. */
  50582. isRGB: boolean;
  50583. /**
  50584. * If the texture is a lumincance format
  50585. */
  50586. isLuminance: boolean;
  50587. /**
  50588. * If this is a cube texture
  50589. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  50590. */
  50591. isCube: boolean;
  50592. /**
  50593. * If the texture is a compressed format eg. FOURCC_DXT1
  50594. */
  50595. isCompressed: boolean;
  50596. /**
  50597. * The dxgiFormat of the texture
  50598. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  50599. */
  50600. dxgiFormat: number;
  50601. /**
  50602. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  50603. */
  50604. textureType: number;
  50605. /**
  50606. * Sphericle polynomial created for the dds texture
  50607. */
  50608. sphericalPolynomial?: SphericalPolynomial;
  50609. }
  50610. /**
  50611. * Class used to provide DDS decompression tools
  50612. */
  50613. export class DDSTools {
  50614. /**
  50615. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  50616. */
  50617. static StoreLODInAlphaChannel: boolean;
  50618. /**
  50619. * Gets DDS information from an array buffer
  50620. * @param arrayBuffer defines the array buffer to read data from
  50621. * @returns the DDS information
  50622. */
  50623. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  50624. private static _FloatView;
  50625. private static _Int32View;
  50626. private static _ToHalfFloat;
  50627. private static _FromHalfFloat;
  50628. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  50629. private static _GetHalfFloatRGBAArrayBuffer;
  50630. private static _GetFloatRGBAArrayBuffer;
  50631. private static _GetFloatAsUIntRGBAArrayBuffer;
  50632. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  50633. private static _GetRGBAArrayBuffer;
  50634. private static _ExtractLongWordOrder;
  50635. private static _GetRGBArrayBuffer;
  50636. private static _GetLuminanceArrayBuffer;
  50637. /**
  50638. * Uploads DDS Levels to a Babylon Texture
  50639. * @hidden
  50640. */
  50641. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  50642. }
  50643. module "babylonjs/Engines/thinEngine" {
  50644. interface ThinEngine {
  50645. /**
  50646. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  50647. * @param rootUrl defines the url where the file to load is located
  50648. * @param scene defines the current scene
  50649. * @param lodScale defines scale to apply to the mip map selection
  50650. * @param lodOffset defines offset to apply to the mip map selection
  50651. * @param onLoad defines an optional callback raised when the texture is loaded
  50652. * @param onError defines an optional callback raised if there is an issue to load the texture
  50653. * @param format defines the format of the data
  50654. * @param forcedExtension defines the extension to use to pick the right loader
  50655. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  50656. * @returns the cube texture as an InternalTexture
  50657. */
  50658. 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;
  50659. }
  50660. }
  50661. }
  50662. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  50663. import { Nullable } from "babylonjs/types";
  50664. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50665. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50666. /**
  50667. * Implementation of the DDS Texture Loader.
  50668. * @hidden
  50669. */
  50670. export class _DDSTextureLoader implements IInternalTextureLoader {
  50671. /**
  50672. * Defines wether the loader supports cascade loading the different faces.
  50673. */
  50674. readonly supportCascades: boolean;
  50675. /**
  50676. * This returns if the loader support the current file information.
  50677. * @param extension defines the file extension of the file being loaded
  50678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50679. * @param fallback defines the fallback internal texture if any
  50680. * @param isBase64 defines whether the texture is encoded as a base64
  50681. * @param isBuffer defines whether the texture data are stored as a buffer
  50682. * @returns true if the loader can load the specified file
  50683. */
  50684. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50685. /**
  50686. * Transform the url before loading if required.
  50687. * @param rootUrl the url of the texture
  50688. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50689. * @returns the transformed texture
  50690. */
  50691. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50692. /**
  50693. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50694. * @param rootUrl the url of the texture
  50695. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50696. * @returns the fallback texture
  50697. */
  50698. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50699. /**
  50700. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50701. * @param data contains the texture data
  50702. * @param texture defines the BabylonJS internal texture
  50703. * @param createPolynomials will be true if polynomials have been requested
  50704. * @param onLoad defines the callback to trigger once the texture is ready
  50705. * @param onError defines the callback to trigger in case of error
  50706. */
  50707. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50708. /**
  50709. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50710. * @param data contains the texture data
  50711. * @param texture defines the BabylonJS internal texture
  50712. * @param callback defines the method to call once ready to upload
  50713. */
  50714. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50715. }
  50716. }
  50717. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  50718. import { Nullable } from "babylonjs/types";
  50719. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50720. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50721. /**
  50722. * Implementation of the ENV Texture Loader.
  50723. * @hidden
  50724. */
  50725. export class _ENVTextureLoader implements IInternalTextureLoader {
  50726. /**
  50727. * Defines wether the loader supports cascade loading the different faces.
  50728. */
  50729. readonly supportCascades: boolean;
  50730. /**
  50731. * This returns if the loader support the current file information.
  50732. * @param extension defines the file extension of the file being loaded
  50733. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50734. * @param fallback defines the fallback internal texture if any
  50735. * @param isBase64 defines whether the texture is encoded as a base64
  50736. * @param isBuffer defines whether the texture data are stored as a buffer
  50737. * @returns true if the loader can load the specified file
  50738. */
  50739. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50740. /**
  50741. * Transform the url before loading if required.
  50742. * @param rootUrl the url of the texture
  50743. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50744. * @returns the transformed texture
  50745. */
  50746. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50747. /**
  50748. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50749. * @param rootUrl the url of the texture
  50750. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50751. * @returns the fallback texture
  50752. */
  50753. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50754. /**
  50755. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50756. * @param data contains the texture data
  50757. * @param texture defines the BabylonJS internal texture
  50758. * @param createPolynomials will be true if polynomials have been requested
  50759. * @param onLoad defines the callback to trigger once the texture is ready
  50760. * @param onError defines the callback to trigger in case of error
  50761. */
  50762. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50763. /**
  50764. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50765. * @param data contains the texture data
  50766. * @param texture defines the BabylonJS internal texture
  50767. * @param callback defines the method to call once ready to upload
  50768. */
  50769. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  50770. }
  50771. }
  50772. declare module "babylonjs/Misc/khronosTextureContainer" {
  50773. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50774. /**
  50775. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  50776. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  50777. */
  50778. export class KhronosTextureContainer {
  50779. /** contents of the KTX container file */
  50780. arrayBuffer: any;
  50781. private static HEADER_LEN;
  50782. private static COMPRESSED_2D;
  50783. private static COMPRESSED_3D;
  50784. private static TEX_2D;
  50785. private static TEX_3D;
  50786. /**
  50787. * Gets the openGL type
  50788. */
  50789. glType: number;
  50790. /**
  50791. * Gets the openGL type size
  50792. */
  50793. glTypeSize: number;
  50794. /**
  50795. * Gets the openGL format
  50796. */
  50797. glFormat: number;
  50798. /**
  50799. * Gets the openGL internal format
  50800. */
  50801. glInternalFormat: number;
  50802. /**
  50803. * Gets the base internal format
  50804. */
  50805. glBaseInternalFormat: number;
  50806. /**
  50807. * Gets image width in pixel
  50808. */
  50809. pixelWidth: number;
  50810. /**
  50811. * Gets image height in pixel
  50812. */
  50813. pixelHeight: number;
  50814. /**
  50815. * Gets image depth in pixels
  50816. */
  50817. pixelDepth: number;
  50818. /**
  50819. * Gets the number of array elements
  50820. */
  50821. numberOfArrayElements: number;
  50822. /**
  50823. * Gets the number of faces
  50824. */
  50825. numberOfFaces: number;
  50826. /**
  50827. * Gets the number of mipmap levels
  50828. */
  50829. numberOfMipmapLevels: number;
  50830. /**
  50831. * Gets the bytes of key value data
  50832. */
  50833. bytesOfKeyValueData: number;
  50834. /**
  50835. * Gets the load type
  50836. */
  50837. loadType: number;
  50838. /**
  50839. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  50840. */
  50841. isInvalid: boolean;
  50842. /**
  50843. * Creates a new KhronosTextureContainer
  50844. * @param arrayBuffer contents of the KTX container file
  50845. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  50846. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  50847. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  50848. */
  50849. constructor(
  50850. /** contents of the KTX container file */
  50851. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  50852. /**
  50853. * Uploads KTX content to a Babylon Texture.
  50854. * It is assumed that the texture has already been created & is currently bound
  50855. * @hidden
  50856. */
  50857. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  50858. private _upload2DCompressedLevels;
  50859. }
  50860. }
  50861. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  50862. import { Nullable } from "babylonjs/types";
  50863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  50864. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  50865. /**
  50866. * Implementation of the KTX Texture Loader.
  50867. * @hidden
  50868. */
  50869. export class _KTXTextureLoader implements IInternalTextureLoader {
  50870. /**
  50871. * Defines wether the loader supports cascade loading the different faces.
  50872. */
  50873. readonly supportCascades: boolean;
  50874. /**
  50875. * This returns if the loader support the current file information.
  50876. * @param extension defines the file extension of the file being loaded
  50877. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50878. * @param fallback defines the fallback internal texture if any
  50879. * @param isBase64 defines whether the texture is encoded as a base64
  50880. * @param isBuffer defines whether the texture data are stored as a buffer
  50881. * @returns true if the loader can load the specified file
  50882. */
  50883. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  50884. /**
  50885. * Transform the url before loading if required.
  50886. * @param rootUrl the url of the texture
  50887. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50888. * @returns the transformed texture
  50889. */
  50890. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  50891. /**
  50892. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  50893. * @param rootUrl the url of the texture
  50894. * @param textureFormatInUse defines the current compressed format in use iun the engine
  50895. * @returns the fallback texture
  50896. */
  50897. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  50898. /**
  50899. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  50900. * @param data contains the texture data
  50901. * @param texture defines the BabylonJS internal texture
  50902. * @param createPolynomials will be true if polynomials have been requested
  50903. * @param onLoad defines the callback to trigger once the texture is ready
  50904. * @param onError defines the callback to trigger in case of error
  50905. */
  50906. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  50907. /**
  50908. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  50909. * @param data contains the texture data
  50910. * @param texture defines the BabylonJS internal texture
  50911. * @param callback defines the method to call once ready to upload
  50912. */
  50913. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  50914. }
  50915. }
  50916. declare module "babylonjs/Cameras/XR/webXRDefaultExperience" {
  50917. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  50918. import { Scene } from "babylonjs/scene";
  50919. import { WebXRInput } from "babylonjs/Cameras/XR/webXRInput";
  50920. import { WebXRControllerModelLoader } from "babylonjs/Cameras/XR/webXRControllerModelLoader";
  50921. import { WebXRControllerPointerSelection } from "babylonjs/Cameras/XR/webXRControllerPointerSelection";
  50922. import { WebXRControllerTeleportation } from "babylonjs/Cameras/XR/webXRControllerTeleportation";
  50923. import { WebXRManagedOutputCanvas } from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  50924. import { WebXREnterExitUI } from "babylonjs/Cameras/XR/webXREnterExitUI";
  50925. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50926. /**
  50927. * Options for the default xr helper
  50928. */
  50929. export class WebXRDefaultExperienceOptions {
  50930. /**
  50931. * Floor meshes that should be used for teleporting
  50932. */
  50933. floorMeshes: Array<AbstractMesh>;
  50934. }
  50935. /**
  50936. * Default experience which provides a similar setup to the previous webVRExperience
  50937. */
  50938. export class WebXRDefaultExperience {
  50939. /**
  50940. * Base experience
  50941. */
  50942. baseExperience: WebXRExperienceHelper;
  50943. /**
  50944. * Input experience extension
  50945. */
  50946. input: WebXRInput;
  50947. /**
  50948. * Loads the controller models
  50949. */
  50950. controllerModelLoader: WebXRControllerModelLoader;
  50951. /**
  50952. * Enables laser pointer and selection
  50953. */
  50954. pointerSelection: WebXRControllerPointerSelection;
  50955. /**
  50956. * Enables teleportation
  50957. */
  50958. teleportation: WebXRControllerTeleportation;
  50959. /**
  50960. * Enables ui for enetering/exiting xr
  50961. */
  50962. enterExitUI: WebXREnterExitUI;
  50963. /**
  50964. * Default output canvas xr should render to
  50965. */
  50966. outputCanvas: WebXRManagedOutputCanvas;
  50967. /**
  50968. * Creates the default xr experience
  50969. * @param scene scene
  50970. * @param options options for basic configuration
  50971. * @returns resulting WebXRDefaultExperience
  50972. */
  50973. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  50974. private constructor();
  50975. /**
  50976. * DIsposes of the experience helper
  50977. */
  50978. dispose(): void;
  50979. }
  50980. }
  50981. declare module "babylonjs/Helpers/sceneHelpers" {
  50982. import { Nullable } from "babylonjs/types";
  50983. import { Mesh } from "babylonjs/Meshes/mesh";
  50984. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50985. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  50986. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  50987. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  50988. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  50989. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  50990. import "babylonjs/Meshes/Builders/boxBuilder";
  50991. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/Cameras/XR/webXRDefaultExperience";
  50992. /** @hidden */
  50993. export var _forceSceneHelpersToBundle: boolean;
  50994. module "babylonjs/scene" {
  50995. interface Scene {
  50996. /**
  50997. * Creates a default light for the scene.
  50998. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  50999. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  51000. */
  51001. createDefaultLight(replace?: boolean): void;
  51002. /**
  51003. * Creates a default camera for the scene.
  51004. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  51005. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51006. * @param replace has default false, when true replaces the active camera in the scene
  51007. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  51008. */
  51009. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51010. /**
  51011. * Creates a default camera and a default light.
  51012. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  51013. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  51014. * @param replace has the default false, when true replaces the active camera/light in the scene
  51015. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  51016. */
  51017. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  51018. /**
  51019. * Creates a new sky box
  51020. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  51021. * @param environmentTexture defines the texture to use as environment texture
  51022. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  51023. * @param scale defines the overall scale of the skybox
  51024. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  51025. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  51026. * @returns a new mesh holding the sky box
  51027. */
  51028. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  51029. /**
  51030. * Creates a new environment
  51031. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  51032. * @param options defines the options you can use to configure the environment
  51033. * @returns the new EnvironmentHelper
  51034. */
  51035. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  51036. /**
  51037. * Creates a new VREXperienceHelper
  51038. * @see http://doc.babylonjs.com/how_to/webvr_helper
  51039. * @param webVROptions defines the options used to create the new VREXperienceHelper
  51040. * @returns a new VREXperienceHelper
  51041. */
  51042. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  51043. /**
  51044. * Creates a new WebXRDefaultExperience
  51045. * @see http://doc.babylonjs.com/how_to/webxr
  51046. * @param options experience options
  51047. * @returns a promise for a new WebXRDefaultExperience
  51048. */
  51049. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51050. }
  51051. }
  51052. }
  51053. declare module "babylonjs/Helpers/videoDome" {
  51054. import { Scene } from "babylonjs/scene";
  51055. import { TransformNode } from "babylonjs/Meshes/transformNode";
  51056. import { Mesh } from "babylonjs/Meshes/mesh";
  51057. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  51058. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51059. import "babylonjs/Meshes/Builders/sphereBuilder";
  51060. /**
  51061. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  51062. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  51063. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  51064. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  51065. */
  51066. export class VideoDome extends TransformNode {
  51067. /**
  51068. * Define the video source as a Monoscopic panoramic 360 video.
  51069. */
  51070. static readonly MODE_MONOSCOPIC: number;
  51071. /**
  51072. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51073. */
  51074. static readonly MODE_TOPBOTTOM: number;
  51075. /**
  51076. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51077. */
  51078. static readonly MODE_SIDEBYSIDE: number;
  51079. private _halfDome;
  51080. private _useDirectMapping;
  51081. /**
  51082. * The video texture being displayed on the sphere
  51083. */
  51084. protected _videoTexture: VideoTexture;
  51085. /**
  51086. * Gets the video texture being displayed on the sphere
  51087. */
  51088. readonly videoTexture: VideoTexture;
  51089. /**
  51090. * The skybox material
  51091. */
  51092. protected _material: BackgroundMaterial;
  51093. /**
  51094. * The surface used for the skybox
  51095. */
  51096. protected _mesh: Mesh;
  51097. /**
  51098. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  51099. */
  51100. private _halfDomeMask;
  51101. /**
  51102. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51103. * Also see the options.resolution property.
  51104. */
  51105. fovMultiplier: number;
  51106. private _videoMode;
  51107. /**
  51108. * Gets or set the current video mode for the video. It can be:
  51109. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  51110. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  51111. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  51112. */
  51113. videoMode: number;
  51114. /**
  51115. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  51116. *
  51117. */
  51118. /**
  51119. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  51120. */
  51121. halfDome: boolean;
  51122. /**
  51123. * Oberserver used in Stereoscopic VR Mode.
  51124. */
  51125. private _onBeforeCameraRenderObserver;
  51126. /**
  51127. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  51128. * @param name Element's name, child elements will append suffixes for their own names.
  51129. * @param urlsOrVideo defines the url(s) or the video element to use
  51130. * @param options An object containing optional or exposed sub element properties
  51131. */
  51132. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  51133. resolution?: number;
  51134. clickToPlay?: boolean;
  51135. autoPlay?: boolean;
  51136. loop?: boolean;
  51137. size?: number;
  51138. poster?: string;
  51139. faceForward?: boolean;
  51140. useDirectMapping?: boolean;
  51141. halfDomeMode?: boolean;
  51142. }, scene: Scene);
  51143. private _changeVideoMode;
  51144. /**
  51145. * Releases resources associated with this node.
  51146. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  51147. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  51148. */
  51149. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  51150. }
  51151. }
  51152. declare module "babylonjs/Helpers/index" {
  51153. export * from "babylonjs/Helpers/environmentHelper";
  51154. export * from "babylonjs/Helpers/photoDome";
  51155. export * from "babylonjs/Helpers/sceneHelpers";
  51156. export * from "babylonjs/Helpers/videoDome";
  51157. }
  51158. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  51159. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51160. import { IDisposable } from "babylonjs/scene";
  51161. import { Engine } from "babylonjs/Engines/engine";
  51162. /**
  51163. * This class can be used to get instrumentation data from a Babylon engine
  51164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51165. */
  51166. export class EngineInstrumentation implements IDisposable {
  51167. /**
  51168. * Define the instrumented engine.
  51169. */
  51170. engine: Engine;
  51171. private _captureGPUFrameTime;
  51172. private _gpuFrameTimeToken;
  51173. private _gpuFrameTime;
  51174. private _captureShaderCompilationTime;
  51175. private _shaderCompilationTime;
  51176. private _onBeginFrameObserver;
  51177. private _onEndFrameObserver;
  51178. private _onBeforeShaderCompilationObserver;
  51179. private _onAfterShaderCompilationObserver;
  51180. /**
  51181. * Gets the perf counter used for GPU frame time
  51182. */
  51183. readonly gpuFrameTimeCounter: PerfCounter;
  51184. /**
  51185. * Gets the GPU frame time capture status
  51186. */
  51187. /**
  51188. * Enable or disable the GPU frame time capture
  51189. */
  51190. captureGPUFrameTime: boolean;
  51191. /**
  51192. * Gets the perf counter used for shader compilation time
  51193. */
  51194. readonly shaderCompilationTimeCounter: PerfCounter;
  51195. /**
  51196. * Gets the shader compilation time capture status
  51197. */
  51198. /**
  51199. * Enable or disable the shader compilation time capture
  51200. */
  51201. captureShaderCompilationTime: boolean;
  51202. /**
  51203. * Instantiates a new engine instrumentation.
  51204. * This class can be used to get instrumentation data from a Babylon engine
  51205. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  51206. * @param engine Defines the engine to instrument
  51207. */
  51208. constructor(
  51209. /**
  51210. * Define the instrumented engine.
  51211. */
  51212. engine: Engine);
  51213. /**
  51214. * Dispose and release associated resources.
  51215. */
  51216. dispose(): void;
  51217. }
  51218. }
  51219. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  51220. import { Scene, IDisposable } from "babylonjs/scene";
  51221. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  51222. /**
  51223. * This class can be used to get instrumentation data from a Babylon engine
  51224. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51225. */
  51226. export class SceneInstrumentation implements IDisposable {
  51227. /**
  51228. * Defines the scene to instrument
  51229. */
  51230. scene: Scene;
  51231. private _captureActiveMeshesEvaluationTime;
  51232. private _activeMeshesEvaluationTime;
  51233. private _captureRenderTargetsRenderTime;
  51234. private _renderTargetsRenderTime;
  51235. private _captureFrameTime;
  51236. private _frameTime;
  51237. private _captureRenderTime;
  51238. private _renderTime;
  51239. private _captureInterFrameTime;
  51240. private _interFrameTime;
  51241. private _captureParticlesRenderTime;
  51242. private _particlesRenderTime;
  51243. private _captureSpritesRenderTime;
  51244. private _spritesRenderTime;
  51245. private _capturePhysicsTime;
  51246. private _physicsTime;
  51247. private _captureAnimationsTime;
  51248. private _animationsTime;
  51249. private _captureCameraRenderTime;
  51250. private _cameraRenderTime;
  51251. private _onBeforeActiveMeshesEvaluationObserver;
  51252. private _onAfterActiveMeshesEvaluationObserver;
  51253. private _onBeforeRenderTargetsRenderObserver;
  51254. private _onAfterRenderTargetsRenderObserver;
  51255. private _onAfterRenderObserver;
  51256. private _onBeforeDrawPhaseObserver;
  51257. private _onAfterDrawPhaseObserver;
  51258. private _onBeforeAnimationsObserver;
  51259. private _onBeforeParticlesRenderingObserver;
  51260. private _onAfterParticlesRenderingObserver;
  51261. private _onBeforeSpritesRenderingObserver;
  51262. private _onAfterSpritesRenderingObserver;
  51263. private _onBeforePhysicsObserver;
  51264. private _onAfterPhysicsObserver;
  51265. private _onAfterAnimationsObserver;
  51266. private _onBeforeCameraRenderObserver;
  51267. private _onAfterCameraRenderObserver;
  51268. /**
  51269. * Gets the perf counter used for active meshes evaluation time
  51270. */
  51271. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  51272. /**
  51273. * Gets the active meshes evaluation time capture status
  51274. */
  51275. /**
  51276. * Enable or disable the active meshes evaluation time capture
  51277. */
  51278. captureActiveMeshesEvaluationTime: boolean;
  51279. /**
  51280. * Gets the perf counter used for render targets render time
  51281. */
  51282. readonly renderTargetsRenderTimeCounter: PerfCounter;
  51283. /**
  51284. * Gets the render targets render time capture status
  51285. */
  51286. /**
  51287. * Enable or disable the render targets render time capture
  51288. */
  51289. captureRenderTargetsRenderTime: boolean;
  51290. /**
  51291. * Gets the perf counter used for particles render time
  51292. */
  51293. readonly particlesRenderTimeCounter: PerfCounter;
  51294. /**
  51295. * Gets the particles render time capture status
  51296. */
  51297. /**
  51298. * Enable or disable the particles render time capture
  51299. */
  51300. captureParticlesRenderTime: boolean;
  51301. /**
  51302. * Gets the perf counter used for sprites render time
  51303. */
  51304. readonly spritesRenderTimeCounter: PerfCounter;
  51305. /**
  51306. * Gets the sprites render time capture status
  51307. */
  51308. /**
  51309. * Enable or disable the sprites render time capture
  51310. */
  51311. captureSpritesRenderTime: boolean;
  51312. /**
  51313. * Gets the perf counter used for physics time
  51314. */
  51315. readonly physicsTimeCounter: PerfCounter;
  51316. /**
  51317. * Gets the physics time capture status
  51318. */
  51319. /**
  51320. * Enable or disable the physics time capture
  51321. */
  51322. capturePhysicsTime: boolean;
  51323. /**
  51324. * Gets the perf counter used for animations time
  51325. */
  51326. readonly animationsTimeCounter: PerfCounter;
  51327. /**
  51328. * Gets the animations time capture status
  51329. */
  51330. /**
  51331. * Enable or disable the animations time capture
  51332. */
  51333. captureAnimationsTime: boolean;
  51334. /**
  51335. * Gets the perf counter used for frame time capture
  51336. */
  51337. readonly frameTimeCounter: PerfCounter;
  51338. /**
  51339. * Gets the frame time capture status
  51340. */
  51341. /**
  51342. * Enable or disable the frame time capture
  51343. */
  51344. captureFrameTime: boolean;
  51345. /**
  51346. * Gets the perf counter used for inter-frames time capture
  51347. */
  51348. readonly interFrameTimeCounter: PerfCounter;
  51349. /**
  51350. * Gets the inter-frames time capture status
  51351. */
  51352. /**
  51353. * Enable or disable the inter-frames time capture
  51354. */
  51355. captureInterFrameTime: boolean;
  51356. /**
  51357. * Gets the perf counter used for render time capture
  51358. */
  51359. readonly renderTimeCounter: PerfCounter;
  51360. /**
  51361. * Gets the render time capture status
  51362. */
  51363. /**
  51364. * Enable or disable the render time capture
  51365. */
  51366. captureRenderTime: boolean;
  51367. /**
  51368. * Gets the perf counter used for camera render time capture
  51369. */
  51370. readonly cameraRenderTimeCounter: PerfCounter;
  51371. /**
  51372. * Gets the camera render time capture status
  51373. */
  51374. /**
  51375. * Enable or disable the camera render time capture
  51376. */
  51377. captureCameraRenderTime: boolean;
  51378. /**
  51379. * Gets the perf counter used for draw calls
  51380. */
  51381. readonly drawCallsCounter: PerfCounter;
  51382. /**
  51383. * Instantiates a new scene instrumentation.
  51384. * This class can be used to get instrumentation data from a Babylon engine
  51385. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  51386. * @param scene Defines the scene to instrument
  51387. */
  51388. constructor(
  51389. /**
  51390. * Defines the scene to instrument
  51391. */
  51392. scene: Scene);
  51393. /**
  51394. * Dispose and release associated resources.
  51395. */
  51396. dispose(): void;
  51397. }
  51398. }
  51399. declare module "babylonjs/Instrumentation/index" {
  51400. export * from "babylonjs/Instrumentation/engineInstrumentation";
  51401. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  51402. export * from "babylonjs/Instrumentation/timeToken";
  51403. }
  51404. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  51405. /** @hidden */
  51406. export var glowMapGenerationPixelShader: {
  51407. name: string;
  51408. shader: string;
  51409. };
  51410. }
  51411. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  51412. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51413. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  51414. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  51415. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51416. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  51417. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51418. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51419. /** @hidden */
  51420. export var glowMapGenerationVertexShader: {
  51421. name: string;
  51422. shader: string;
  51423. };
  51424. }
  51425. declare module "babylonjs/Layers/effectLayer" {
  51426. import { Observable } from "babylonjs/Misc/observable";
  51427. import { Nullable } from "babylonjs/types";
  51428. import { Camera } from "babylonjs/Cameras/camera";
  51429. import { Scene } from "babylonjs/scene";
  51430. import { ISize } from "babylonjs/Maths/math.size";
  51431. import { Color4 } from "babylonjs/Maths/math.color";
  51432. import { Engine } from "babylonjs/Engines/engine";
  51433. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51434. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51435. import { Mesh } from "babylonjs/Meshes/mesh";
  51436. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  51437. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51438. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51439. import { Effect } from "babylonjs/Materials/effect";
  51440. import { Material } from "babylonjs/Materials/material";
  51441. import "babylonjs/Shaders/glowMapGeneration.fragment";
  51442. import "babylonjs/Shaders/glowMapGeneration.vertex";
  51443. /**
  51444. * Effect layer options. This helps customizing the behaviour
  51445. * of the effect layer.
  51446. */
  51447. export interface IEffectLayerOptions {
  51448. /**
  51449. * Multiplication factor apply to the canvas size to compute the render target size
  51450. * used to generated the objects (the smaller the faster).
  51451. */
  51452. mainTextureRatio: number;
  51453. /**
  51454. * Enforces a fixed size texture to ensure effect stability across devices.
  51455. */
  51456. mainTextureFixedSize?: number;
  51457. /**
  51458. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  51459. */
  51460. alphaBlendingMode: number;
  51461. /**
  51462. * The camera attached to the layer.
  51463. */
  51464. camera: Nullable<Camera>;
  51465. /**
  51466. * The rendering group to draw the layer in.
  51467. */
  51468. renderingGroupId: number;
  51469. }
  51470. /**
  51471. * The effect layer Helps adding post process effect blended with the main pass.
  51472. *
  51473. * This can be for instance use to generate glow or higlight effects on the scene.
  51474. *
  51475. * The effect layer class can not be used directly and is intented to inherited from to be
  51476. * customized per effects.
  51477. */
  51478. export abstract class EffectLayer {
  51479. private _vertexBuffers;
  51480. private _indexBuffer;
  51481. private _cachedDefines;
  51482. private _effectLayerMapGenerationEffect;
  51483. private _effectLayerOptions;
  51484. private _mergeEffect;
  51485. protected _scene: Scene;
  51486. protected _engine: Engine;
  51487. protected _maxSize: number;
  51488. protected _mainTextureDesiredSize: ISize;
  51489. protected _mainTexture: RenderTargetTexture;
  51490. protected _shouldRender: boolean;
  51491. protected _postProcesses: PostProcess[];
  51492. protected _textures: BaseTexture[];
  51493. protected _emissiveTextureAndColor: {
  51494. texture: Nullable<BaseTexture>;
  51495. color: Color4;
  51496. };
  51497. /**
  51498. * The name of the layer
  51499. */
  51500. name: string;
  51501. /**
  51502. * The clear color of the texture used to generate the glow map.
  51503. */
  51504. neutralColor: Color4;
  51505. /**
  51506. * Specifies wether the highlight layer is enabled or not.
  51507. */
  51508. isEnabled: boolean;
  51509. /**
  51510. * Gets the camera attached to the layer.
  51511. */
  51512. readonly camera: Nullable<Camera>;
  51513. /**
  51514. * Gets the rendering group id the layer should render in.
  51515. */
  51516. renderingGroupId: number;
  51517. /**
  51518. * An event triggered when the effect layer has been disposed.
  51519. */
  51520. onDisposeObservable: Observable<EffectLayer>;
  51521. /**
  51522. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  51523. */
  51524. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  51525. /**
  51526. * An event triggered when the generated texture is being merged in the scene.
  51527. */
  51528. onBeforeComposeObservable: Observable<EffectLayer>;
  51529. /**
  51530. * An event triggered when the generated texture has been merged in the scene.
  51531. */
  51532. onAfterComposeObservable: Observable<EffectLayer>;
  51533. /**
  51534. * An event triggered when the efffect layer changes its size.
  51535. */
  51536. onSizeChangedObservable: Observable<EffectLayer>;
  51537. /** @hidden */
  51538. static _SceneComponentInitialization: (scene: Scene) => void;
  51539. /**
  51540. * Instantiates a new effect Layer and references it in the scene.
  51541. * @param name The name of the layer
  51542. * @param scene The scene to use the layer in
  51543. */
  51544. constructor(
  51545. /** The Friendly of the effect in the scene */
  51546. name: string, scene: Scene);
  51547. /**
  51548. * Get the effect name of the layer.
  51549. * @return The effect name
  51550. */
  51551. abstract getEffectName(): string;
  51552. /**
  51553. * Checks for the readiness of the element composing the layer.
  51554. * @param subMesh the mesh to check for
  51555. * @param useInstances specify wether or not to use instances to render the mesh
  51556. * @return true if ready otherwise, false
  51557. */
  51558. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51559. /**
  51560. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51561. * @returns true if the effect requires stencil during the main canvas render pass.
  51562. */
  51563. abstract needStencil(): boolean;
  51564. /**
  51565. * Create the merge effect. This is the shader use to blit the information back
  51566. * to the main canvas at the end of the scene rendering.
  51567. * @returns The effect containing the shader used to merge the effect on the main canvas
  51568. */
  51569. protected abstract _createMergeEffect(): Effect;
  51570. /**
  51571. * Creates the render target textures and post processes used in the effect layer.
  51572. */
  51573. protected abstract _createTextureAndPostProcesses(): void;
  51574. /**
  51575. * Implementation specific of rendering the generating effect on the main canvas.
  51576. * @param effect The effect used to render through
  51577. */
  51578. protected abstract _internalRender(effect: Effect): void;
  51579. /**
  51580. * Sets the required values for both the emissive texture and and the main color.
  51581. */
  51582. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51583. /**
  51584. * Free any resources and references associated to a mesh.
  51585. * Internal use
  51586. * @param mesh The mesh to free.
  51587. */
  51588. abstract _disposeMesh(mesh: Mesh): void;
  51589. /**
  51590. * Serializes this layer (Glow or Highlight for example)
  51591. * @returns a serialized layer object
  51592. */
  51593. abstract serialize?(): any;
  51594. /**
  51595. * Initializes the effect layer with the required options.
  51596. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  51597. */
  51598. protected _init(options: Partial<IEffectLayerOptions>): void;
  51599. /**
  51600. * Generates the index buffer of the full screen quad blending to the main canvas.
  51601. */
  51602. private _generateIndexBuffer;
  51603. /**
  51604. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  51605. */
  51606. private _generateVertexBuffer;
  51607. /**
  51608. * Sets the main texture desired size which is the closest power of two
  51609. * of the engine canvas size.
  51610. */
  51611. private _setMainTextureSize;
  51612. /**
  51613. * Creates the main texture for the effect layer.
  51614. */
  51615. protected _createMainTexture(): void;
  51616. /**
  51617. * Adds specific effects defines.
  51618. * @param defines The defines to add specifics to.
  51619. */
  51620. protected _addCustomEffectDefines(defines: string[]): void;
  51621. /**
  51622. * Checks for the readiness of the element composing the layer.
  51623. * @param subMesh the mesh to check for
  51624. * @param useInstances specify wether or not to use instances to render the mesh
  51625. * @param emissiveTexture the associated emissive texture used to generate the glow
  51626. * @return true if ready otherwise, false
  51627. */
  51628. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  51629. /**
  51630. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  51631. */
  51632. render(): void;
  51633. /**
  51634. * Determine if a given mesh will be used in the current effect.
  51635. * @param mesh mesh to test
  51636. * @returns true if the mesh will be used
  51637. */
  51638. hasMesh(mesh: AbstractMesh): boolean;
  51639. /**
  51640. * Returns true if the layer contains information to display, otherwise false.
  51641. * @returns true if the glow layer should be rendered
  51642. */
  51643. shouldRender(): boolean;
  51644. /**
  51645. * Returns true if the mesh should render, otherwise false.
  51646. * @param mesh The mesh to render
  51647. * @returns true if it should render otherwise false
  51648. */
  51649. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  51650. /**
  51651. * Returns true if the mesh can be rendered, otherwise false.
  51652. * @param mesh The mesh to render
  51653. * @param material The material used on the mesh
  51654. * @returns true if it can be rendered otherwise false
  51655. */
  51656. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51657. /**
  51658. * Returns true if the mesh should render, otherwise false.
  51659. * @param mesh The mesh to render
  51660. * @returns true if it should render otherwise false
  51661. */
  51662. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  51663. /**
  51664. * Renders the submesh passed in parameter to the generation map.
  51665. */
  51666. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  51667. /**
  51668. * Rebuild the required buffers.
  51669. * @hidden Internal use only.
  51670. */
  51671. _rebuild(): void;
  51672. /**
  51673. * Dispose only the render target textures and post process.
  51674. */
  51675. private _disposeTextureAndPostProcesses;
  51676. /**
  51677. * Dispose the highlight layer and free resources.
  51678. */
  51679. dispose(): void;
  51680. /**
  51681. * Gets the class name of the effect layer
  51682. * @returns the string with the class name of the effect layer
  51683. */
  51684. getClassName(): string;
  51685. /**
  51686. * Creates an effect layer from parsed effect layer data
  51687. * @param parsedEffectLayer defines effect layer data
  51688. * @param scene defines the current scene
  51689. * @param rootUrl defines the root URL containing the effect layer information
  51690. * @returns a parsed effect Layer
  51691. */
  51692. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  51693. }
  51694. }
  51695. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  51696. import { Scene } from "babylonjs/scene";
  51697. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  51698. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51699. import { AbstractScene } from "babylonjs/abstractScene";
  51700. module "babylonjs/abstractScene" {
  51701. interface AbstractScene {
  51702. /**
  51703. * The list of effect layers (highlights/glow) added to the scene
  51704. * @see http://doc.babylonjs.com/how_to/highlight_layer
  51705. * @see http://doc.babylonjs.com/how_to/glow_layer
  51706. */
  51707. effectLayers: Array<EffectLayer>;
  51708. /**
  51709. * Removes the given effect layer from this scene.
  51710. * @param toRemove defines the effect layer to remove
  51711. * @returns the index of the removed effect layer
  51712. */
  51713. removeEffectLayer(toRemove: EffectLayer): number;
  51714. /**
  51715. * Adds the given effect layer to this scene
  51716. * @param newEffectLayer defines the effect layer to add
  51717. */
  51718. addEffectLayer(newEffectLayer: EffectLayer): void;
  51719. }
  51720. }
  51721. /**
  51722. * Defines the layer scene component responsible to manage any effect layers
  51723. * in a given scene.
  51724. */
  51725. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  51726. /**
  51727. * The component name helpfull to identify the component in the list of scene components.
  51728. */
  51729. readonly name: string;
  51730. /**
  51731. * The scene the component belongs to.
  51732. */
  51733. scene: Scene;
  51734. private _engine;
  51735. private _renderEffects;
  51736. private _needStencil;
  51737. private _previousStencilState;
  51738. /**
  51739. * Creates a new instance of the component for the given scene
  51740. * @param scene Defines the scene to register the component in
  51741. */
  51742. constructor(scene: Scene);
  51743. /**
  51744. * Registers the component in a given scene
  51745. */
  51746. register(): void;
  51747. /**
  51748. * Rebuilds the elements related to this component in case of
  51749. * context lost for instance.
  51750. */
  51751. rebuild(): void;
  51752. /**
  51753. * Serializes the component data to the specified json object
  51754. * @param serializationObject The object to serialize to
  51755. */
  51756. serialize(serializationObject: any): void;
  51757. /**
  51758. * Adds all the elements from the container to the scene
  51759. * @param container the container holding the elements
  51760. */
  51761. addFromContainer(container: AbstractScene): void;
  51762. /**
  51763. * Removes all the elements in the container from the scene
  51764. * @param container contains the elements to remove
  51765. * @param dispose if the removed element should be disposed (default: false)
  51766. */
  51767. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  51768. /**
  51769. * Disposes the component and the associated ressources.
  51770. */
  51771. dispose(): void;
  51772. private _isReadyForMesh;
  51773. private _renderMainTexture;
  51774. private _setStencil;
  51775. private _setStencilBack;
  51776. private _draw;
  51777. private _drawCamera;
  51778. private _drawRenderingGroup;
  51779. }
  51780. }
  51781. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  51782. /** @hidden */
  51783. export var glowMapMergePixelShader: {
  51784. name: string;
  51785. shader: string;
  51786. };
  51787. }
  51788. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  51789. /** @hidden */
  51790. export var glowMapMergeVertexShader: {
  51791. name: string;
  51792. shader: string;
  51793. };
  51794. }
  51795. declare module "babylonjs/Layers/glowLayer" {
  51796. import { Nullable } from "babylonjs/types";
  51797. import { Camera } from "babylonjs/Cameras/camera";
  51798. import { Scene } from "babylonjs/scene";
  51799. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51800. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51801. import { Mesh } from "babylonjs/Meshes/mesh";
  51802. import { Texture } from "babylonjs/Materials/Textures/texture";
  51803. import { Effect } from "babylonjs/Materials/effect";
  51804. import { Material } from "babylonjs/Materials/material";
  51805. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  51806. import { Color4 } from "babylonjs/Maths/math.color";
  51807. import "babylonjs/Shaders/glowMapMerge.fragment";
  51808. import "babylonjs/Shaders/glowMapMerge.vertex";
  51809. import "babylonjs/Layers/effectLayerSceneComponent";
  51810. module "babylonjs/abstractScene" {
  51811. interface AbstractScene {
  51812. /**
  51813. * Return a the first highlight layer of the scene with a given name.
  51814. * @param name The name of the highlight layer to look for.
  51815. * @return The highlight layer if found otherwise null.
  51816. */
  51817. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  51818. }
  51819. }
  51820. /**
  51821. * Glow layer options. This helps customizing the behaviour
  51822. * of the glow layer.
  51823. */
  51824. export interface IGlowLayerOptions {
  51825. /**
  51826. * Multiplication factor apply to the canvas size to compute the render target size
  51827. * used to generated the glowing objects (the smaller the faster).
  51828. */
  51829. mainTextureRatio: number;
  51830. /**
  51831. * Enforces a fixed size texture to ensure resize independant blur.
  51832. */
  51833. mainTextureFixedSize?: number;
  51834. /**
  51835. * How big is the kernel of the blur texture.
  51836. */
  51837. blurKernelSize: number;
  51838. /**
  51839. * The camera attached to the layer.
  51840. */
  51841. camera: Nullable<Camera>;
  51842. /**
  51843. * Enable MSAA by chosing the number of samples.
  51844. */
  51845. mainTextureSamples?: number;
  51846. /**
  51847. * The rendering group to draw the layer in.
  51848. */
  51849. renderingGroupId: number;
  51850. }
  51851. /**
  51852. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  51853. *
  51854. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  51855. * glowy meshes to your scene.
  51856. *
  51857. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  51858. */
  51859. export class GlowLayer extends EffectLayer {
  51860. /**
  51861. * Effect Name of the layer.
  51862. */
  51863. static readonly EffectName: string;
  51864. /**
  51865. * The default blur kernel size used for the glow.
  51866. */
  51867. static DefaultBlurKernelSize: number;
  51868. /**
  51869. * The default texture size ratio used for the glow.
  51870. */
  51871. static DefaultTextureRatio: number;
  51872. /**
  51873. * Sets the kernel size of the blur.
  51874. */
  51875. /**
  51876. * Gets the kernel size of the blur.
  51877. */
  51878. blurKernelSize: number;
  51879. /**
  51880. * Sets the glow intensity.
  51881. */
  51882. /**
  51883. * Gets the glow intensity.
  51884. */
  51885. intensity: number;
  51886. private _options;
  51887. private _intensity;
  51888. private _horizontalBlurPostprocess1;
  51889. private _verticalBlurPostprocess1;
  51890. private _horizontalBlurPostprocess2;
  51891. private _verticalBlurPostprocess2;
  51892. private _blurTexture1;
  51893. private _blurTexture2;
  51894. private _postProcesses1;
  51895. private _postProcesses2;
  51896. private _includedOnlyMeshes;
  51897. private _excludedMeshes;
  51898. /**
  51899. * Callback used to let the user override the color selection on a per mesh basis
  51900. */
  51901. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  51902. /**
  51903. * Callback used to let the user override the texture selection on a per mesh basis
  51904. */
  51905. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  51906. /**
  51907. * Instantiates a new glow Layer and references it to the scene.
  51908. * @param name The name of the layer
  51909. * @param scene The scene to use the layer in
  51910. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  51911. */
  51912. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  51913. /**
  51914. * Get the effect name of the layer.
  51915. * @return The effect name
  51916. */
  51917. getEffectName(): string;
  51918. /**
  51919. * Create the merge effect. This is the shader use to blit the information back
  51920. * to the main canvas at the end of the scene rendering.
  51921. */
  51922. protected _createMergeEffect(): Effect;
  51923. /**
  51924. * Creates the render target textures and post processes used in the glow layer.
  51925. */
  51926. protected _createTextureAndPostProcesses(): void;
  51927. /**
  51928. * Checks for the readiness of the element composing the layer.
  51929. * @param subMesh the mesh to check for
  51930. * @param useInstances specify wether or not to use instances to render the mesh
  51931. * @param emissiveTexture the associated emissive texture used to generate the glow
  51932. * @return true if ready otherwise, false
  51933. */
  51934. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  51935. /**
  51936. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  51937. */
  51938. needStencil(): boolean;
  51939. /**
  51940. * Returns true if the mesh can be rendered, otherwise false.
  51941. * @param mesh The mesh to render
  51942. * @param material The material used on the mesh
  51943. * @returns true if it can be rendered otherwise false
  51944. */
  51945. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  51946. /**
  51947. * Implementation specific of rendering the generating effect on the main canvas.
  51948. * @param effect The effect used to render through
  51949. */
  51950. protected _internalRender(effect: Effect): void;
  51951. /**
  51952. * Sets the required values for both the emissive texture and and the main color.
  51953. */
  51954. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  51955. /**
  51956. * Returns true if the mesh should render, otherwise false.
  51957. * @param mesh The mesh to render
  51958. * @returns true if it should render otherwise false
  51959. */
  51960. protected _shouldRenderMesh(mesh: Mesh): boolean;
  51961. /**
  51962. * Adds specific effects defines.
  51963. * @param defines The defines to add specifics to.
  51964. */
  51965. protected _addCustomEffectDefines(defines: string[]): void;
  51966. /**
  51967. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  51968. * @param mesh The mesh to exclude from the glow layer
  51969. */
  51970. addExcludedMesh(mesh: Mesh): void;
  51971. /**
  51972. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  51973. * @param mesh The mesh to remove
  51974. */
  51975. removeExcludedMesh(mesh: Mesh): void;
  51976. /**
  51977. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  51978. * @param mesh The mesh to include in the glow layer
  51979. */
  51980. addIncludedOnlyMesh(mesh: Mesh): void;
  51981. /**
  51982. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  51983. * @param mesh The mesh to remove
  51984. */
  51985. removeIncludedOnlyMesh(mesh: Mesh): void;
  51986. /**
  51987. * Determine if a given mesh will be used in the glow layer
  51988. * @param mesh The mesh to test
  51989. * @returns true if the mesh will be highlighted by the current glow layer
  51990. */
  51991. hasMesh(mesh: AbstractMesh): boolean;
  51992. /**
  51993. * Free any resources and references associated to a mesh.
  51994. * Internal use
  51995. * @param mesh The mesh to free.
  51996. * @hidden
  51997. */
  51998. _disposeMesh(mesh: Mesh): void;
  51999. /**
  52000. * Gets the class name of the effect layer
  52001. * @returns the string with the class name of the effect layer
  52002. */
  52003. getClassName(): string;
  52004. /**
  52005. * Serializes this glow layer
  52006. * @returns a serialized glow layer object
  52007. */
  52008. serialize(): any;
  52009. /**
  52010. * Creates a Glow Layer from parsed glow layer data
  52011. * @param parsedGlowLayer defines glow layer data
  52012. * @param scene defines the current scene
  52013. * @param rootUrl defines the root URL containing the glow layer information
  52014. * @returns a parsed Glow Layer
  52015. */
  52016. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  52017. }
  52018. }
  52019. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  52020. /** @hidden */
  52021. export var glowBlurPostProcessPixelShader: {
  52022. name: string;
  52023. shader: string;
  52024. };
  52025. }
  52026. declare module "babylonjs/Layers/highlightLayer" {
  52027. import { Observable } from "babylonjs/Misc/observable";
  52028. import { Nullable } from "babylonjs/types";
  52029. import { Camera } from "babylonjs/Cameras/camera";
  52030. import { Scene } from "babylonjs/scene";
  52031. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52033. import { Mesh } from "babylonjs/Meshes/mesh";
  52034. import { Effect } from "babylonjs/Materials/effect";
  52035. import { Material } from "babylonjs/Materials/material";
  52036. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  52037. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  52038. import "babylonjs/Shaders/glowMapMerge.fragment";
  52039. import "babylonjs/Shaders/glowMapMerge.vertex";
  52040. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  52041. module "babylonjs/abstractScene" {
  52042. interface AbstractScene {
  52043. /**
  52044. * Return a the first highlight layer of the scene with a given name.
  52045. * @param name The name of the highlight layer to look for.
  52046. * @return The highlight layer if found otherwise null.
  52047. */
  52048. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  52049. }
  52050. }
  52051. /**
  52052. * Highlight layer options. This helps customizing the behaviour
  52053. * of the highlight layer.
  52054. */
  52055. export interface IHighlightLayerOptions {
  52056. /**
  52057. * Multiplication factor apply to the canvas size to compute the render target size
  52058. * used to generated the glowing objects (the smaller the faster).
  52059. */
  52060. mainTextureRatio: number;
  52061. /**
  52062. * Enforces a fixed size texture to ensure resize independant blur.
  52063. */
  52064. mainTextureFixedSize?: number;
  52065. /**
  52066. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  52067. * of the picture to blur (the smaller the faster).
  52068. */
  52069. blurTextureSizeRatio: number;
  52070. /**
  52071. * How big in texel of the blur texture is the vertical blur.
  52072. */
  52073. blurVerticalSize: number;
  52074. /**
  52075. * How big in texel of the blur texture is the horizontal blur.
  52076. */
  52077. blurHorizontalSize: number;
  52078. /**
  52079. * Alpha blending mode used to apply the blur. Default is combine.
  52080. */
  52081. alphaBlendingMode: number;
  52082. /**
  52083. * The camera attached to the layer.
  52084. */
  52085. camera: Nullable<Camera>;
  52086. /**
  52087. * Should we display highlight as a solid stroke?
  52088. */
  52089. isStroke?: boolean;
  52090. /**
  52091. * The rendering group to draw the layer in.
  52092. */
  52093. renderingGroupId: number;
  52094. }
  52095. /**
  52096. * The highlight layer Helps adding a glow effect around a mesh.
  52097. *
  52098. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  52099. * glowy meshes to your scene.
  52100. *
  52101. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  52102. */
  52103. export class HighlightLayer extends EffectLayer {
  52104. name: string;
  52105. /**
  52106. * Effect Name of the highlight layer.
  52107. */
  52108. static readonly EffectName: string;
  52109. /**
  52110. * The neutral color used during the preparation of the glow effect.
  52111. * This is black by default as the blend operation is a blend operation.
  52112. */
  52113. static NeutralColor: Color4;
  52114. /**
  52115. * Stencil value used for glowing meshes.
  52116. */
  52117. static GlowingMeshStencilReference: number;
  52118. /**
  52119. * Stencil value used for the other meshes in the scene.
  52120. */
  52121. static NormalMeshStencilReference: number;
  52122. /**
  52123. * Specifies whether or not the inner glow is ACTIVE in the layer.
  52124. */
  52125. innerGlow: boolean;
  52126. /**
  52127. * Specifies whether or not the outer glow is ACTIVE in the layer.
  52128. */
  52129. outerGlow: boolean;
  52130. /**
  52131. * Specifies the horizontal size of the blur.
  52132. */
  52133. /**
  52134. * Gets the horizontal size of the blur.
  52135. */
  52136. blurHorizontalSize: number;
  52137. /**
  52138. * Specifies the vertical size of the blur.
  52139. */
  52140. /**
  52141. * Gets the vertical size of the blur.
  52142. */
  52143. blurVerticalSize: number;
  52144. /**
  52145. * An event triggered when the highlight layer is being blurred.
  52146. */
  52147. onBeforeBlurObservable: Observable<HighlightLayer>;
  52148. /**
  52149. * An event triggered when the highlight layer has been blurred.
  52150. */
  52151. onAfterBlurObservable: Observable<HighlightLayer>;
  52152. private _instanceGlowingMeshStencilReference;
  52153. private _options;
  52154. private _downSamplePostprocess;
  52155. private _horizontalBlurPostprocess;
  52156. private _verticalBlurPostprocess;
  52157. private _blurTexture;
  52158. private _meshes;
  52159. private _excludedMeshes;
  52160. /**
  52161. * Instantiates a new highlight Layer and references it to the scene..
  52162. * @param name The name of the layer
  52163. * @param scene The scene to use the layer in
  52164. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  52165. */
  52166. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  52167. /**
  52168. * Get the effect name of the layer.
  52169. * @return The effect name
  52170. */
  52171. getEffectName(): string;
  52172. /**
  52173. * Create the merge effect. This is the shader use to blit the information back
  52174. * to the main canvas at the end of the scene rendering.
  52175. */
  52176. protected _createMergeEffect(): Effect;
  52177. /**
  52178. * Creates the render target textures and post processes used in the highlight layer.
  52179. */
  52180. protected _createTextureAndPostProcesses(): void;
  52181. /**
  52182. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  52183. */
  52184. needStencil(): boolean;
  52185. /**
  52186. * Checks for the readiness of the element composing the layer.
  52187. * @param subMesh the mesh to check for
  52188. * @param useInstances specify wether or not to use instances to render the mesh
  52189. * @param emissiveTexture the associated emissive texture used to generate the glow
  52190. * @return true if ready otherwise, false
  52191. */
  52192. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  52193. /**
  52194. * Implementation specific of rendering the generating effect on the main canvas.
  52195. * @param effect The effect used to render through
  52196. */
  52197. protected _internalRender(effect: Effect): void;
  52198. /**
  52199. * Returns true if the layer contains information to display, otherwise false.
  52200. */
  52201. shouldRender(): boolean;
  52202. /**
  52203. * Returns true if the mesh should render, otherwise false.
  52204. * @param mesh The mesh to render
  52205. * @returns true if it should render otherwise false
  52206. */
  52207. protected _shouldRenderMesh(mesh: Mesh): boolean;
  52208. /**
  52209. * Sets the required values for both the emissive texture and and the main color.
  52210. */
  52211. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  52212. /**
  52213. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  52214. * @param mesh The mesh to exclude from the highlight layer
  52215. */
  52216. addExcludedMesh(mesh: Mesh): void;
  52217. /**
  52218. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  52219. * @param mesh The mesh to highlight
  52220. */
  52221. removeExcludedMesh(mesh: Mesh): void;
  52222. /**
  52223. * Determine if a given mesh will be highlighted by the current HighlightLayer
  52224. * @param mesh mesh to test
  52225. * @returns true if the mesh will be highlighted by the current HighlightLayer
  52226. */
  52227. hasMesh(mesh: AbstractMesh): boolean;
  52228. /**
  52229. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  52230. * @param mesh The mesh to highlight
  52231. * @param color The color of the highlight
  52232. * @param glowEmissiveOnly Extract the glow from the emissive texture
  52233. */
  52234. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  52235. /**
  52236. * Remove a mesh from the highlight layer in order to make it stop glowing.
  52237. * @param mesh The mesh to highlight
  52238. */
  52239. removeMesh(mesh: Mesh): void;
  52240. /**
  52241. * Force the stencil to the normal expected value for none glowing parts
  52242. */
  52243. private _defaultStencilReference;
  52244. /**
  52245. * Free any resources and references associated to a mesh.
  52246. * Internal use
  52247. * @param mesh The mesh to free.
  52248. * @hidden
  52249. */
  52250. _disposeMesh(mesh: Mesh): void;
  52251. /**
  52252. * Dispose the highlight layer and free resources.
  52253. */
  52254. dispose(): void;
  52255. /**
  52256. * Gets the class name of the effect layer
  52257. * @returns the string with the class name of the effect layer
  52258. */
  52259. getClassName(): string;
  52260. /**
  52261. * Serializes this Highlight layer
  52262. * @returns a serialized Highlight layer object
  52263. */
  52264. serialize(): any;
  52265. /**
  52266. * Creates a Highlight layer from parsed Highlight layer data
  52267. * @param parsedHightlightLayer defines the Highlight layer data
  52268. * @param scene defines the current scene
  52269. * @param rootUrl defines the root URL containing the Highlight layer information
  52270. * @returns a parsed Highlight layer
  52271. */
  52272. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  52273. }
  52274. }
  52275. declare module "babylonjs/Layers/layerSceneComponent" {
  52276. import { Scene } from "babylonjs/scene";
  52277. import { ISceneComponent } from "babylonjs/sceneComponent";
  52278. import { Layer } from "babylonjs/Layers/layer";
  52279. import { AbstractScene } from "babylonjs/abstractScene";
  52280. module "babylonjs/abstractScene" {
  52281. interface AbstractScene {
  52282. /**
  52283. * The list of layers (background and foreground) of the scene
  52284. */
  52285. layers: Array<Layer>;
  52286. }
  52287. }
  52288. /**
  52289. * Defines the layer scene component responsible to manage any layers
  52290. * in a given scene.
  52291. */
  52292. export class LayerSceneComponent implements ISceneComponent {
  52293. /**
  52294. * The component name helpfull to identify the component in the list of scene components.
  52295. */
  52296. readonly name: string;
  52297. /**
  52298. * The scene the component belongs to.
  52299. */
  52300. scene: Scene;
  52301. private _engine;
  52302. /**
  52303. * Creates a new instance of the component for the given scene
  52304. * @param scene Defines the scene to register the component in
  52305. */
  52306. constructor(scene: Scene);
  52307. /**
  52308. * Registers the component in a given scene
  52309. */
  52310. register(): void;
  52311. /**
  52312. * Rebuilds the elements related to this component in case of
  52313. * context lost for instance.
  52314. */
  52315. rebuild(): void;
  52316. /**
  52317. * Disposes the component and the associated ressources.
  52318. */
  52319. dispose(): void;
  52320. private _draw;
  52321. private _drawCameraPredicate;
  52322. private _drawCameraBackground;
  52323. private _drawCameraForeground;
  52324. private _drawRenderTargetPredicate;
  52325. private _drawRenderTargetBackground;
  52326. private _drawRenderTargetForeground;
  52327. /**
  52328. * Adds all the elements from the container to the scene
  52329. * @param container the container holding the elements
  52330. */
  52331. addFromContainer(container: AbstractScene): void;
  52332. /**
  52333. * Removes all the elements in the container from the scene
  52334. * @param container contains the elements to remove
  52335. * @param dispose if the removed element should be disposed (default: false)
  52336. */
  52337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52338. }
  52339. }
  52340. declare module "babylonjs/Shaders/layer.fragment" {
  52341. /** @hidden */
  52342. export var layerPixelShader: {
  52343. name: string;
  52344. shader: string;
  52345. };
  52346. }
  52347. declare module "babylonjs/Shaders/layer.vertex" {
  52348. /** @hidden */
  52349. export var layerVertexShader: {
  52350. name: string;
  52351. shader: string;
  52352. };
  52353. }
  52354. declare module "babylonjs/Layers/layer" {
  52355. import { Observable } from "babylonjs/Misc/observable";
  52356. import { Nullable } from "babylonjs/types";
  52357. import { Scene } from "babylonjs/scene";
  52358. import { Vector2 } from "babylonjs/Maths/math.vector";
  52359. import { Color4 } from "babylonjs/Maths/math.color";
  52360. import { Texture } from "babylonjs/Materials/Textures/texture";
  52361. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  52362. import "babylonjs/Shaders/layer.fragment";
  52363. import "babylonjs/Shaders/layer.vertex";
  52364. /**
  52365. * This represents a full screen 2d layer.
  52366. * This can be useful to display a picture in the background of your scene for instance.
  52367. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52368. */
  52369. export class Layer {
  52370. /**
  52371. * Define the name of the layer.
  52372. */
  52373. name: string;
  52374. /**
  52375. * Define the texture the layer should display.
  52376. */
  52377. texture: Nullable<Texture>;
  52378. /**
  52379. * Is the layer in background or foreground.
  52380. */
  52381. isBackground: boolean;
  52382. /**
  52383. * Define the color of the layer (instead of texture).
  52384. */
  52385. color: Color4;
  52386. /**
  52387. * Define the scale of the layer in order to zoom in out of the texture.
  52388. */
  52389. scale: Vector2;
  52390. /**
  52391. * Define an offset for the layer in order to shift the texture.
  52392. */
  52393. offset: Vector2;
  52394. /**
  52395. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  52396. */
  52397. alphaBlendingMode: number;
  52398. /**
  52399. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  52400. * Alpha test will not mix with the background color in case of transparency.
  52401. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  52402. */
  52403. alphaTest: boolean;
  52404. /**
  52405. * Define a mask to restrict the layer to only some of the scene cameras.
  52406. */
  52407. layerMask: number;
  52408. /**
  52409. * Define the list of render target the layer is visible into.
  52410. */
  52411. renderTargetTextures: RenderTargetTexture[];
  52412. /**
  52413. * Define if the layer is only used in renderTarget or if it also
  52414. * renders in the main frame buffer of the canvas.
  52415. */
  52416. renderOnlyInRenderTargetTextures: boolean;
  52417. private _scene;
  52418. private _vertexBuffers;
  52419. private _indexBuffer;
  52420. private _effect;
  52421. private _alphaTestEffect;
  52422. /**
  52423. * An event triggered when the layer is disposed.
  52424. */
  52425. onDisposeObservable: Observable<Layer>;
  52426. private _onDisposeObserver;
  52427. /**
  52428. * Back compatibility with callback before the onDisposeObservable existed.
  52429. * The set callback will be triggered when the layer has been disposed.
  52430. */
  52431. onDispose: () => void;
  52432. /**
  52433. * An event triggered before rendering the scene
  52434. */
  52435. onBeforeRenderObservable: Observable<Layer>;
  52436. private _onBeforeRenderObserver;
  52437. /**
  52438. * Back compatibility with callback before the onBeforeRenderObservable existed.
  52439. * The set callback will be triggered just before rendering the layer.
  52440. */
  52441. onBeforeRender: () => void;
  52442. /**
  52443. * An event triggered after rendering the scene
  52444. */
  52445. onAfterRenderObservable: Observable<Layer>;
  52446. private _onAfterRenderObserver;
  52447. /**
  52448. * Back compatibility with callback before the onAfterRenderObservable existed.
  52449. * The set callback will be triggered just after rendering the layer.
  52450. */
  52451. onAfterRender: () => void;
  52452. /**
  52453. * Instantiates a new layer.
  52454. * This represents a full screen 2d layer.
  52455. * This can be useful to display a picture in the background of your scene for instance.
  52456. * @see https://www.babylonjs-playground.com/#08A2BS#1
  52457. * @param name Define the name of the layer in the scene
  52458. * @param imgUrl Define the url of the texture to display in the layer
  52459. * @param scene Define the scene the layer belongs to
  52460. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  52461. * @param color Defines a color for the layer
  52462. */
  52463. constructor(
  52464. /**
  52465. * Define the name of the layer.
  52466. */
  52467. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  52468. private _createIndexBuffer;
  52469. /** @hidden */
  52470. _rebuild(): void;
  52471. /**
  52472. * Renders the layer in the scene.
  52473. */
  52474. render(): void;
  52475. /**
  52476. * Disposes and releases the associated ressources.
  52477. */
  52478. dispose(): void;
  52479. }
  52480. }
  52481. declare module "babylonjs/Layers/index" {
  52482. export * from "babylonjs/Layers/effectLayer";
  52483. export * from "babylonjs/Layers/effectLayerSceneComponent";
  52484. export * from "babylonjs/Layers/glowLayer";
  52485. export * from "babylonjs/Layers/highlightLayer";
  52486. export * from "babylonjs/Layers/layer";
  52487. export * from "babylonjs/Layers/layerSceneComponent";
  52488. }
  52489. declare module "babylonjs/Shaders/lensFlare.fragment" {
  52490. /** @hidden */
  52491. export var lensFlarePixelShader: {
  52492. name: string;
  52493. shader: string;
  52494. };
  52495. }
  52496. declare module "babylonjs/Shaders/lensFlare.vertex" {
  52497. /** @hidden */
  52498. export var lensFlareVertexShader: {
  52499. name: string;
  52500. shader: string;
  52501. };
  52502. }
  52503. declare module "babylonjs/LensFlares/lensFlareSystem" {
  52504. import { Scene } from "babylonjs/scene";
  52505. import { Vector3 } from "babylonjs/Maths/math.vector";
  52506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52507. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  52508. import "babylonjs/Shaders/lensFlare.fragment";
  52509. import "babylonjs/Shaders/lensFlare.vertex";
  52510. import { Viewport } from "babylonjs/Maths/math.viewport";
  52511. /**
  52512. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52513. * It is usually composed of several `lensFlare`.
  52514. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52515. */
  52516. export class LensFlareSystem {
  52517. /**
  52518. * Define the name of the lens flare system
  52519. */
  52520. name: string;
  52521. /**
  52522. * List of lens flares used in this system.
  52523. */
  52524. lensFlares: LensFlare[];
  52525. /**
  52526. * Define a limit from the border the lens flare can be visible.
  52527. */
  52528. borderLimit: number;
  52529. /**
  52530. * Define a viewport border we do not want to see the lens flare in.
  52531. */
  52532. viewportBorder: number;
  52533. /**
  52534. * Define a predicate which could limit the list of meshes able to occlude the effect.
  52535. */
  52536. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  52537. /**
  52538. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  52539. */
  52540. layerMask: number;
  52541. /**
  52542. * Define the id of the lens flare system in the scene.
  52543. * (equal to name by default)
  52544. */
  52545. id: string;
  52546. private _scene;
  52547. private _emitter;
  52548. private _vertexBuffers;
  52549. private _indexBuffer;
  52550. private _effect;
  52551. private _positionX;
  52552. private _positionY;
  52553. private _isEnabled;
  52554. /** @hidden */
  52555. static _SceneComponentInitialization: (scene: Scene) => void;
  52556. /**
  52557. * Instantiates a lens flare system.
  52558. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  52559. * It is usually composed of several `lensFlare`.
  52560. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52561. * @param name Define the name of the lens flare system in the scene
  52562. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  52563. * @param scene Define the scene the lens flare system belongs to
  52564. */
  52565. constructor(
  52566. /**
  52567. * Define the name of the lens flare system
  52568. */
  52569. name: string, emitter: any, scene: Scene);
  52570. /**
  52571. * Define if the lens flare system is enabled.
  52572. */
  52573. isEnabled: boolean;
  52574. /**
  52575. * Get the scene the effects belongs to.
  52576. * @returns the scene holding the lens flare system
  52577. */
  52578. getScene(): Scene;
  52579. /**
  52580. * Get the emitter of the lens flare system.
  52581. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52582. * @returns the emitter of the lens flare system
  52583. */
  52584. getEmitter(): any;
  52585. /**
  52586. * Set the emitter of the lens flare system.
  52587. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  52588. * @param newEmitter Define the new emitter of the system
  52589. */
  52590. setEmitter(newEmitter: any): void;
  52591. /**
  52592. * Get the lens flare system emitter position.
  52593. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  52594. * @returns the position
  52595. */
  52596. getEmitterPosition(): Vector3;
  52597. /**
  52598. * @hidden
  52599. */
  52600. computeEffectivePosition(globalViewport: Viewport): boolean;
  52601. /** @hidden */
  52602. _isVisible(): boolean;
  52603. /**
  52604. * @hidden
  52605. */
  52606. render(): boolean;
  52607. /**
  52608. * Dispose and release the lens flare with its associated resources.
  52609. */
  52610. dispose(): void;
  52611. /**
  52612. * Parse a lens flare system from a JSON repressentation
  52613. * @param parsedLensFlareSystem Define the JSON to parse
  52614. * @param scene Define the scene the parsed system should be instantiated in
  52615. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  52616. * @returns the parsed system
  52617. */
  52618. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  52619. /**
  52620. * Serialize the current Lens Flare System into a JSON representation.
  52621. * @returns the serialized JSON
  52622. */
  52623. serialize(): any;
  52624. }
  52625. }
  52626. declare module "babylonjs/LensFlares/lensFlare" {
  52627. import { Nullable } from "babylonjs/types";
  52628. import { Color3 } from "babylonjs/Maths/math.color";
  52629. import { Texture } from "babylonjs/Materials/Textures/texture";
  52630. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52631. /**
  52632. * This represents one of the lens effect in a `lensFlareSystem`.
  52633. * It controls one of the indiviual texture used in the effect.
  52634. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52635. */
  52636. export class LensFlare {
  52637. /**
  52638. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52639. */
  52640. size: number;
  52641. /**
  52642. * 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.
  52643. */
  52644. position: number;
  52645. /**
  52646. * Define the lens color.
  52647. */
  52648. color: Color3;
  52649. /**
  52650. * Define the lens texture.
  52651. */
  52652. texture: Nullable<Texture>;
  52653. /**
  52654. * Define the alpha mode to render this particular lens.
  52655. */
  52656. alphaMode: number;
  52657. private _system;
  52658. /**
  52659. * Creates a new Lens Flare.
  52660. * This represents one of the lens effect in a `lensFlareSystem`.
  52661. * It controls one of the indiviual texture used in the effect.
  52662. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52663. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  52664. * @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.
  52665. * @param color Define the lens color
  52666. * @param imgUrl Define the lens texture url
  52667. * @param system Define the `lensFlareSystem` this flare is part of
  52668. * @returns The newly created Lens Flare
  52669. */
  52670. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  52671. /**
  52672. * Instantiates a new Lens Flare.
  52673. * This represents one of the lens effect in a `lensFlareSystem`.
  52674. * It controls one of the indiviual texture used in the effect.
  52675. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52676. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  52677. * @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.
  52678. * @param color Define the lens color
  52679. * @param imgUrl Define the lens texture url
  52680. * @param system Define the `lensFlareSystem` this flare is part of
  52681. */
  52682. constructor(
  52683. /**
  52684. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  52685. */
  52686. size: number,
  52687. /**
  52688. * 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.
  52689. */
  52690. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  52691. /**
  52692. * Dispose and release the lens flare with its associated resources.
  52693. */
  52694. dispose(): void;
  52695. }
  52696. }
  52697. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  52698. import { Nullable } from "babylonjs/types";
  52699. import { Scene } from "babylonjs/scene";
  52700. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52701. import { AbstractScene } from "babylonjs/abstractScene";
  52702. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  52703. module "babylonjs/abstractScene" {
  52704. interface AbstractScene {
  52705. /**
  52706. * The list of lens flare system added to the scene
  52707. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  52708. */
  52709. lensFlareSystems: Array<LensFlareSystem>;
  52710. /**
  52711. * Removes the given lens flare system from this scene.
  52712. * @param toRemove The lens flare system to remove
  52713. * @returns The index of the removed lens flare system
  52714. */
  52715. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  52716. /**
  52717. * Adds the given lens flare system to this scene
  52718. * @param newLensFlareSystem The lens flare system to add
  52719. */
  52720. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  52721. /**
  52722. * Gets a lens flare system using its name
  52723. * @param name defines the name to look for
  52724. * @returns the lens flare system or null if not found
  52725. */
  52726. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  52727. /**
  52728. * Gets a lens flare system using its id
  52729. * @param id defines the id to look for
  52730. * @returns the lens flare system or null if not found
  52731. */
  52732. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  52733. }
  52734. }
  52735. /**
  52736. * Defines the lens flare scene component responsible to manage any lens flares
  52737. * in a given scene.
  52738. */
  52739. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  52740. /**
  52741. * The component name helpfull to identify the component in the list of scene components.
  52742. */
  52743. readonly name: string;
  52744. /**
  52745. * The scene the component belongs to.
  52746. */
  52747. scene: Scene;
  52748. /**
  52749. * Creates a new instance of the component for the given scene
  52750. * @param scene Defines the scene to register the component in
  52751. */
  52752. constructor(scene: Scene);
  52753. /**
  52754. * Registers the component in a given scene
  52755. */
  52756. register(): void;
  52757. /**
  52758. * Rebuilds the elements related to this component in case of
  52759. * context lost for instance.
  52760. */
  52761. rebuild(): void;
  52762. /**
  52763. * Adds all the elements from the container to the scene
  52764. * @param container the container holding the elements
  52765. */
  52766. addFromContainer(container: AbstractScene): void;
  52767. /**
  52768. * Removes all the elements in the container from the scene
  52769. * @param container contains the elements to remove
  52770. * @param dispose if the removed element should be disposed (default: false)
  52771. */
  52772. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52773. /**
  52774. * Serializes the component data to the specified json object
  52775. * @param serializationObject The object to serialize to
  52776. */
  52777. serialize(serializationObject: any): void;
  52778. /**
  52779. * Disposes the component and the associated ressources.
  52780. */
  52781. dispose(): void;
  52782. private _draw;
  52783. }
  52784. }
  52785. declare module "babylonjs/LensFlares/index" {
  52786. export * from "babylonjs/LensFlares/lensFlare";
  52787. export * from "babylonjs/LensFlares/lensFlareSystem";
  52788. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  52789. }
  52790. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  52791. import { Scene } from "babylonjs/scene";
  52792. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  52793. import { AbstractScene } from "babylonjs/abstractScene";
  52794. /**
  52795. * Defines the shadow generator component responsible to manage any shadow generators
  52796. * in a given scene.
  52797. */
  52798. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  52799. /**
  52800. * The component name helpfull to identify the component in the list of scene components.
  52801. */
  52802. readonly name: string;
  52803. /**
  52804. * The scene the component belongs to.
  52805. */
  52806. scene: Scene;
  52807. /**
  52808. * Creates a new instance of the component for the given scene
  52809. * @param scene Defines the scene to register the component in
  52810. */
  52811. constructor(scene: Scene);
  52812. /**
  52813. * Registers the component in a given scene
  52814. */
  52815. register(): void;
  52816. /**
  52817. * Rebuilds the elements related to this component in case of
  52818. * context lost for instance.
  52819. */
  52820. rebuild(): void;
  52821. /**
  52822. * Serializes the component data to the specified json object
  52823. * @param serializationObject The object to serialize to
  52824. */
  52825. serialize(serializationObject: any): void;
  52826. /**
  52827. * Adds all the elements from the container to the scene
  52828. * @param container the container holding the elements
  52829. */
  52830. addFromContainer(container: AbstractScene): void;
  52831. /**
  52832. * Removes all the elements in the container from the scene
  52833. * @param container contains the elements to remove
  52834. * @param dispose if the removed element should be disposed (default: false)
  52835. */
  52836. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  52837. /**
  52838. * Rebuilds the elements related to this component in case of
  52839. * context lost for instance.
  52840. */
  52841. dispose(): void;
  52842. private _gatherRenderTargets;
  52843. }
  52844. }
  52845. declare module "babylonjs/Lights/Shadows/index" {
  52846. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  52847. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  52848. }
  52849. declare module "babylonjs/Lights/pointLight" {
  52850. import { Scene } from "babylonjs/scene";
  52851. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  52852. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52853. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  52854. import { Effect } from "babylonjs/Materials/effect";
  52855. /**
  52856. * A point light is a light defined by an unique point in world space.
  52857. * The light is emitted in every direction from this point.
  52858. * A good example of a point light is a standard light bulb.
  52859. * Documentation: https://doc.babylonjs.com/babylon101/lights
  52860. */
  52861. export class PointLight extends ShadowLight {
  52862. private _shadowAngle;
  52863. /**
  52864. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52865. * This specifies what angle the shadow will use to be created.
  52866. *
  52867. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52868. */
  52869. /**
  52870. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52871. * This specifies what angle the shadow will use to be created.
  52872. *
  52873. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  52874. */
  52875. shadowAngle: number;
  52876. /**
  52877. * Gets the direction if it has been set.
  52878. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52879. */
  52880. /**
  52881. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  52882. */
  52883. direction: Vector3;
  52884. /**
  52885. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  52886. * A PointLight emits the light in every direction.
  52887. * It can cast shadows.
  52888. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  52889. * ```javascript
  52890. * var pointLight = new PointLight("pl", camera.position, scene);
  52891. * ```
  52892. * Documentation : https://doc.babylonjs.com/babylon101/lights
  52893. * @param name The light friendly name
  52894. * @param position The position of the point light in the scene
  52895. * @param scene The scene the lights belongs to
  52896. */
  52897. constructor(name: string, position: Vector3, scene: Scene);
  52898. /**
  52899. * Returns the string "PointLight"
  52900. * @returns the class name
  52901. */
  52902. getClassName(): string;
  52903. /**
  52904. * Returns the integer 0.
  52905. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  52906. */
  52907. getTypeID(): number;
  52908. /**
  52909. * Specifies wether or not the shadowmap should be a cube texture.
  52910. * @returns true if the shadowmap needs to be a cube texture.
  52911. */
  52912. needCube(): boolean;
  52913. /**
  52914. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  52915. * @param faceIndex The index of the face we are computed the direction to generate shadow
  52916. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  52917. */
  52918. getShadowDirection(faceIndex?: number): Vector3;
  52919. /**
  52920. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  52921. * - fov = PI / 2
  52922. * - aspect ratio : 1.0
  52923. * - z-near and far equal to the active camera minZ and maxZ.
  52924. * Returns the PointLight.
  52925. */
  52926. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  52927. protected _buildUniformLayout(): void;
  52928. /**
  52929. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  52930. * @param effect The effect to update
  52931. * @param lightIndex The index of the light in the effect to update
  52932. * @returns The point light
  52933. */
  52934. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  52935. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  52936. /**
  52937. * Prepares the list of defines specific to the light type.
  52938. * @param defines the list of defines
  52939. * @param lightIndex defines the index of the light for the effect
  52940. */
  52941. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  52942. }
  52943. }
  52944. declare module "babylonjs/Lights/index" {
  52945. export * from "babylonjs/Lights/light";
  52946. export * from "babylonjs/Lights/shadowLight";
  52947. export * from "babylonjs/Lights/Shadows/index";
  52948. export * from "babylonjs/Lights/directionalLight";
  52949. export * from "babylonjs/Lights/hemisphericLight";
  52950. export * from "babylonjs/Lights/pointLight";
  52951. export * from "babylonjs/Lights/spotLight";
  52952. }
  52953. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  52954. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  52955. /**
  52956. * Header information of HDR texture files.
  52957. */
  52958. export interface HDRInfo {
  52959. /**
  52960. * The height of the texture in pixels.
  52961. */
  52962. height: number;
  52963. /**
  52964. * The width of the texture in pixels.
  52965. */
  52966. width: number;
  52967. /**
  52968. * The index of the beginning of the data in the binary file.
  52969. */
  52970. dataPosition: number;
  52971. }
  52972. /**
  52973. * This groups tools to convert HDR texture to native colors array.
  52974. */
  52975. export class HDRTools {
  52976. private static Ldexp;
  52977. private static Rgbe2float;
  52978. private static readStringLine;
  52979. /**
  52980. * Reads header information from an RGBE texture stored in a native array.
  52981. * More information on this format are available here:
  52982. * https://en.wikipedia.org/wiki/RGBE_image_format
  52983. *
  52984. * @param uint8array The binary file stored in native array.
  52985. * @return The header information.
  52986. */
  52987. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  52988. /**
  52989. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  52990. * This RGBE texture needs to store the information as a panorama.
  52991. *
  52992. * More information on this format are available here:
  52993. * https://en.wikipedia.org/wiki/RGBE_image_format
  52994. *
  52995. * @param buffer The binary file stored in an array buffer.
  52996. * @param size The expected size of the extracted cubemap.
  52997. * @return The Cube Map information.
  52998. */
  52999. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  53000. /**
  53001. * Returns the pixels data extracted from an RGBE texture.
  53002. * This pixels will be stored left to right up to down in the R G B order in one array.
  53003. *
  53004. * More information on this format are available here:
  53005. * https://en.wikipedia.org/wiki/RGBE_image_format
  53006. *
  53007. * @param uint8array The binary file stored in an array buffer.
  53008. * @param hdrInfo The header information of the file.
  53009. * @return The pixels data in RGB right to left up to down order.
  53010. */
  53011. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  53012. private static RGBE_ReadPixels_RLE;
  53013. }
  53014. }
  53015. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  53016. import { Nullable } from "babylonjs/types";
  53017. import { Scene } from "babylonjs/scene";
  53018. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  53019. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53020. import "babylonjs/Engines/Extensions/engine.rawTexture";
  53021. /**
  53022. * This represents a texture coming from an HDR input.
  53023. *
  53024. * The only supported format is currently panorama picture stored in RGBE format.
  53025. * Example of such files can be found on HDRLib: http://hdrlib.com/
  53026. */
  53027. export class HDRCubeTexture extends BaseTexture {
  53028. private static _facesMapping;
  53029. private _generateHarmonics;
  53030. private _noMipmap;
  53031. private _textureMatrix;
  53032. private _size;
  53033. private _onLoad;
  53034. private _onError;
  53035. /**
  53036. * The texture URL.
  53037. */
  53038. url: string;
  53039. /**
  53040. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  53041. */
  53042. coordinatesMode: number;
  53043. protected _isBlocking: boolean;
  53044. /**
  53045. * Sets wether or not the texture is blocking during loading.
  53046. */
  53047. /**
  53048. * Gets wether or not the texture is blocking during loading.
  53049. */
  53050. isBlocking: boolean;
  53051. protected _rotationY: number;
  53052. /**
  53053. * Sets texture matrix rotation angle around Y axis in radians.
  53054. */
  53055. /**
  53056. * Gets texture matrix rotation angle around Y axis radians.
  53057. */
  53058. rotationY: number;
  53059. /**
  53060. * Gets or sets the center of the bounding box associated with the cube texture
  53061. * It must define where the camera used to render the texture was set
  53062. */
  53063. boundingBoxPosition: Vector3;
  53064. private _boundingBoxSize;
  53065. /**
  53066. * Gets or sets the size of the bounding box associated with the cube texture
  53067. * When defined, the cubemap will switch to local mode
  53068. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  53069. * @example https://www.babylonjs-playground.com/#RNASML
  53070. */
  53071. boundingBoxSize: Vector3;
  53072. /**
  53073. * Instantiates an HDRTexture from the following parameters.
  53074. *
  53075. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  53076. * @param scene The scene the texture will be used in
  53077. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  53078. * @param noMipmap Forces to not generate the mipmap if true
  53079. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  53080. * @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)
  53081. * @param reserved Reserved flag for internal use.
  53082. */
  53083. 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>);
  53084. /**
  53085. * Get the current class name of the texture useful for serialization or dynamic coding.
  53086. * @returns "HDRCubeTexture"
  53087. */
  53088. getClassName(): string;
  53089. /**
  53090. * Occurs when the file is raw .hdr file.
  53091. */
  53092. private loadTexture;
  53093. clone(): HDRCubeTexture;
  53094. delayLoad(): void;
  53095. /**
  53096. * Get the texture reflection matrix used to rotate/transform the reflection.
  53097. * @returns the reflection matrix
  53098. */
  53099. getReflectionTextureMatrix(): Matrix;
  53100. /**
  53101. * Set the texture reflection matrix used to rotate/transform the reflection.
  53102. * @param value Define the reflection matrix to set
  53103. */
  53104. setReflectionTextureMatrix(value: Matrix): void;
  53105. /**
  53106. * Parses a JSON representation of an HDR Texture in order to create the texture
  53107. * @param parsedTexture Define the JSON representation
  53108. * @param scene Define the scene the texture should be created in
  53109. * @param rootUrl Define the root url in case we need to load relative dependencies
  53110. * @returns the newly created texture after parsing
  53111. */
  53112. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  53113. serialize(): any;
  53114. }
  53115. }
  53116. declare module "babylonjs/Physics/physicsEngine" {
  53117. import { Nullable } from "babylonjs/types";
  53118. import { Vector3 } from "babylonjs/Maths/math.vector";
  53119. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53120. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  53121. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  53122. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53123. /**
  53124. * Class used to control physics engine
  53125. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53126. */
  53127. export class PhysicsEngine implements IPhysicsEngine {
  53128. private _physicsPlugin;
  53129. /**
  53130. * Global value used to control the smallest number supported by the simulation
  53131. */
  53132. static Epsilon: number;
  53133. private _impostors;
  53134. private _joints;
  53135. /**
  53136. * Gets the gravity vector used by the simulation
  53137. */
  53138. gravity: Vector3;
  53139. /**
  53140. * Factory used to create the default physics plugin.
  53141. * @returns The default physics plugin
  53142. */
  53143. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  53144. /**
  53145. * Creates a new Physics Engine
  53146. * @param gravity defines the gravity vector used by the simulation
  53147. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  53148. */
  53149. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  53150. /**
  53151. * Sets the gravity vector used by the simulation
  53152. * @param gravity defines the gravity vector to use
  53153. */
  53154. setGravity(gravity: Vector3): void;
  53155. /**
  53156. * Set the time step of the physics engine.
  53157. * Default is 1/60.
  53158. * To slow it down, enter 1/600 for example.
  53159. * To speed it up, 1/30
  53160. * @param newTimeStep defines the new timestep to apply to this world.
  53161. */
  53162. setTimeStep(newTimeStep?: number): void;
  53163. /**
  53164. * Get the time step of the physics engine.
  53165. * @returns the current time step
  53166. */
  53167. getTimeStep(): number;
  53168. /**
  53169. * Release all resources
  53170. */
  53171. dispose(): void;
  53172. /**
  53173. * Gets the name of the current physics plugin
  53174. * @returns the name of the plugin
  53175. */
  53176. getPhysicsPluginName(): string;
  53177. /**
  53178. * Adding a new impostor for the impostor tracking.
  53179. * This will be done by the impostor itself.
  53180. * @param impostor the impostor to add
  53181. */
  53182. addImpostor(impostor: PhysicsImpostor): void;
  53183. /**
  53184. * Remove an impostor from the engine.
  53185. * This impostor and its mesh will not longer be updated by the physics engine.
  53186. * @param impostor the impostor to remove
  53187. */
  53188. removeImpostor(impostor: PhysicsImpostor): void;
  53189. /**
  53190. * Add a joint to the physics engine
  53191. * @param mainImpostor defines the main impostor to which the joint is added.
  53192. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  53193. * @param joint defines the joint that will connect both impostors.
  53194. */
  53195. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53196. /**
  53197. * Removes a joint from the simulation
  53198. * @param mainImpostor defines the impostor used with the joint
  53199. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  53200. * @param joint defines the joint to remove
  53201. */
  53202. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  53203. /**
  53204. * Called by the scene. No need to call it.
  53205. * @param delta defines the timespam between frames
  53206. */
  53207. _step(delta: number): void;
  53208. /**
  53209. * Gets the current plugin used to run the simulation
  53210. * @returns current plugin
  53211. */
  53212. getPhysicsPlugin(): IPhysicsEnginePlugin;
  53213. /**
  53214. * Gets the list of physic impostors
  53215. * @returns an array of PhysicsImpostor
  53216. */
  53217. getImpostors(): Array<PhysicsImpostor>;
  53218. /**
  53219. * Gets the impostor for a physics enabled object
  53220. * @param object defines the object impersonated by the impostor
  53221. * @returns the PhysicsImpostor or null if not found
  53222. */
  53223. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  53224. /**
  53225. * Gets the impostor for a physics body object
  53226. * @param body defines physics body used by the impostor
  53227. * @returns the PhysicsImpostor or null if not found
  53228. */
  53229. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  53230. /**
  53231. * Does a raycast in the physics world
  53232. * @param from when should the ray start?
  53233. * @param to when should the ray end?
  53234. * @returns PhysicsRaycastResult
  53235. */
  53236. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53237. }
  53238. }
  53239. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  53240. import { Nullable } from "babylonjs/types";
  53241. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53242. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53243. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53244. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53245. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53246. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53247. /** @hidden */
  53248. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  53249. private _useDeltaForWorldStep;
  53250. world: any;
  53251. name: string;
  53252. private _physicsMaterials;
  53253. private _fixedTimeStep;
  53254. private _cannonRaycastResult;
  53255. private _raycastResult;
  53256. private _physicsBodysToRemoveAfterStep;
  53257. BJSCANNON: any;
  53258. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  53259. setGravity(gravity: Vector3): void;
  53260. setTimeStep(timeStep: number): void;
  53261. getTimeStep(): number;
  53262. executeStep(delta: number): void;
  53263. private _removeMarkedPhysicsBodiesFromWorld;
  53264. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53265. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53266. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53267. private _processChildMeshes;
  53268. removePhysicsBody(impostor: PhysicsImpostor): void;
  53269. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53270. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53271. private _addMaterial;
  53272. private _checkWithEpsilon;
  53273. private _createShape;
  53274. private _createHeightmap;
  53275. private _minus90X;
  53276. private _plus90X;
  53277. private _tmpPosition;
  53278. private _tmpDeltaPosition;
  53279. private _tmpUnityRotation;
  53280. private _updatePhysicsBodyTransformation;
  53281. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53282. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53283. isSupported(): boolean;
  53284. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53285. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53286. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53287. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53288. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53289. getBodyMass(impostor: PhysicsImpostor): number;
  53290. getBodyFriction(impostor: PhysicsImpostor): number;
  53291. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53292. getBodyRestitution(impostor: PhysicsImpostor): number;
  53293. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53294. sleepBody(impostor: PhysicsImpostor): void;
  53295. wakeUpBody(impostor: PhysicsImpostor): void;
  53296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  53297. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53298. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53299. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53300. getRadius(impostor: PhysicsImpostor): number;
  53301. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53302. dispose(): void;
  53303. private _extendNamespace;
  53304. /**
  53305. * Does a raycast in the physics world
  53306. * @param from when should the ray start?
  53307. * @param to when should the ray end?
  53308. * @returns PhysicsRaycastResult
  53309. */
  53310. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53311. }
  53312. }
  53313. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  53314. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53315. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53316. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53317. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53318. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  53319. import { Nullable } from "babylonjs/types";
  53320. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53321. /** @hidden */
  53322. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  53323. world: any;
  53324. name: string;
  53325. BJSOIMO: any;
  53326. private _raycastResult;
  53327. constructor(iterations?: number, oimoInjection?: any);
  53328. setGravity(gravity: Vector3): void;
  53329. setTimeStep(timeStep: number): void;
  53330. getTimeStep(): number;
  53331. private _tmpImpostorsArray;
  53332. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53333. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53334. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53335. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53336. private _tmpPositionVector;
  53337. removePhysicsBody(impostor: PhysicsImpostor): void;
  53338. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53339. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53340. isSupported(): boolean;
  53341. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53342. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53343. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53344. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53345. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53346. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53347. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53348. getBodyMass(impostor: PhysicsImpostor): number;
  53349. getBodyFriction(impostor: PhysicsImpostor): number;
  53350. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53351. getBodyRestitution(impostor: PhysicsImpostor): number;
  53352. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53353. sleepBody(impostor: PhysicsImpostor): void;
  53354. wakeUpBody(impostor: PhysicsImpostor): void;
  53355. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53356. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  53357. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  53358. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53359. getRadius(impostor: PhysicsImpostor): number;
  53360. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53361. dispose(): void;
  53362. /**
  53363. * Does a raycast in the physics world
  53364. * @param from when should the ray start?
  53365. * @param to when should the ray end?
  53366. * @returns PhysicsRaycastResult
  53367. */
  53368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53369. }
  53370. }
  53371. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53372. import { Nullable } from "babylonjs/types";
  53373. import { Scene } from "babylonjs/scene";
  53374. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53375. import { Color4 } from "babylonjs/Maths/math.color";
  53376. import { Mesh } from "babylonjs/Meshes/mesh";
  53377. /**
  53378. * Class containing static functions to help procedurally build meshes
  53379. */
  53380. export class RibbonBuilder {
  53381. /**
  53382. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53383. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53384. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53385. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53386. * * 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
  53387. * * 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
  53388. * * 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
  53389. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53390. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53391. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53392. * * 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
  53393. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53394. * * 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
  53395. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53397. * @param name defines the name of the mesh
  53398. * @param options defines the options used to create the mesh
  53399. * @param scene defines the hosting scene
  53400. * @returns the ribbon mesh
  53401. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53402. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53403. */
  53404. static CreateRibbon(name: string, options: {
  53405. pathArray: Vector3[][];
  53406. closeArray?: boolean;
  53407. closePath?: boolean;
  53408. offset?: number;
  53409. updatable?: boolean;
  53410. sideOrientation?: number;
  53411. frontUVs?: Vector4;
  53412. backUVs?: Vector4;
  53413. instance?: Mesh;
  53414. invertUV?: boolean;
  53415. uvs?: Vector2[];
  53416. colors?: Color4[];
  53417. }, scene?: Nullable<Scene>): Mesh;
  53418. }
  53419. }
  53420. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53421. import { Nullable } from "babylonjs/types";
  53422. import { Scene } from "babylonjs/scene";
  53423. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53424. import { Mesh } from "babylonjs/Meshes/mesh";
  53425. /**
  53426. * Class containing static functions to help procedurally build meshes
  53427. */
  53428. export class ShapeBuilder {
  53429. /**
  53430. * 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.
  53431. * * 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.
  53432. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53433. * * 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.
  53434. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53435. * * 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
  53436. * * 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
  53437. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53438. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53439. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53440. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53441. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53442. * @param name defines the name of the mesh
  53443. * @param options defines the options used to create the mesh
  53444. * @param scene defines the hosting scene
  53445. * @returns the extruded shape mesh
  53446. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53447. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53448. */
  53449. static ExtrudeShape(name: string, options: {
  53450. shape: Vector3[];
  53451. path: Vector3[];
  53452. scale?: number;
  53453. rotation?: number;
  53454. cap?: number;
  53455. updatable?: boolean;
  53456. sideOrientation?: number;
  53457. frontUVs?: Vector4;
  53458. backUVs?: Vector4;
  53459. instance?: Mesh;
  53460. invertUV?: boolean;
  53461. }, scene?: Nullable<Scene>): Mesh;
  53462. /**
  53463. * Creates an custom extruded shape mesh.
  53464. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53465. * * 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.
  53466. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53467. * * 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
  53468. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53469. * * 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
  53470. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53471. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53472. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53473. * * 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
  53474. * * 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
  53475. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53476. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53477. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53478. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53479. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53480. * @param name defines the name of the mesh
  53481. * @param options defines the options used to create the mesh
  53482. * @param scene defines the hosting scene
  53483. * @returns the custom extruded shape mesh
  53484. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53485. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53486. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53487. */
  53488. static ExtrudeShapeCustom(name: string, options: {
  53489. shape: Vector3[];
  53490. path: Vector3[];
  53491. scaleFunction?: any;
  53492. rotationFunction?: any;
  53493. ribbonCloseArray?: boolean;
  53494. ribbonClosePath?: boolean;
  53495. cap?: number;
  53496. updatable?: boolean;
  53497. sideOrientation?: number;
  53498. frontUVs?: Vector4;
  53499. backUVs?: Vector4;
  53500. instance?: Mesh;
  53501. invertUV?: boolean;
  53502. }, scene?: Nullable<Scene>): Mesh;
  53503. private static _ExtrudeShapeGeneric;
  53504. }
  53505. }
  53506. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  53507. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  53508. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  53509. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53510. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  53511. import { Nullable } from "babylonjs/types";
  53512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53513. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  53514. /**
  53515. * AmmoJS Physics plugin
  53516. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  53517. * @see https://github.com/kripken/ammo.js/
  53518. */
  53519. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  53520. private _useDeltaForWorldStep;
  53521. /**
  53522. * Reference to the Ammo library
  53523. */
  53524. bjsAMMO: any;
  53525. /**
  53526. * Created ammoJS world which physics bodies are added to
  53527. */
  53528. world: any;
  53529. /**
  53530. * Name of the plugin
  53531. */
  53532. name: string;
  53533. private _timeStep;
  53534. private _fixedTimeStep;
  53535. private _maxSteps;
  53536. private _tmpQuaternion;
  53537. private _tmpAmmoTransform;
  53538. private _tmpAmmoQuaternion;
  53539. private _tmpAmmoConcreteContactResultCallback;
  53540. private _collisionConfiguration;
  53541. private _dispatcher;
  53542. private _overlappingPairCache;
  53543. private _solver;
  53544. private _softBodySolver;
  53545. private _tmpAmmoVectorA;
  53546. private _tmpAmmoVectorB;
  53547. private _tmpAmmoVectorC;
  53548. private _tmpAmmoVectorD;
  53549. private _tmpContactCallbackResult;
  53550. private _tmpAmmoVectorRCA;
  53551. private _tmpAmmoVectorRCB;
  53552. private _raycastResult;
  53553. private static readonly DISABLE_COLLISION_FLAG;
  53554. private static readonly KINEMATIC_FLAG;
  53555. private static readonly DISABLE_DEACTIVATION_FLAG;
  53556. /**
  53557. * Initializes the ammoJS plugin
  53558. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  53559. * @param ammoInjection can be used to inject your own ammo reference
  53560. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  53561. */
  53562. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  53563. /**
  53564. * Sets the gravity of the physics world (m/(s^2))
  53565. * @param gravity Gravity to set
  53566. */
  53567. setGravity(gravity: Vector3): void;
  53568. /**
  53569. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  53570. * @param timeStep timestep to use in seconds
  53571. */
  53572. setTimeStep(timeStep: number): void;
  53573. /**
  53574. * 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)
  53575. * @param fixedTimeStep fixedTimeStep to use in seconds
  53576. */
  53577. setFixedTimeStep(fixedTimeStep: number): void;
  53578. /**
  53579. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  53580. * @param maxSteps the maximum number of steps by the physics engine per frame
  53581. */
  53582. setMaxSteps(maxSteps: number): void;
  53583. /**
  53584. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  53585. * @returns the current timestep in seconds
  53586. */
  53587. getTimeStep(): number;
  53588. private _isImpostorInContact;
  53589. private _isImpostorPairInContact;
  53590. private _stepSimulation;
  53591. /**
  53592. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  53593. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  53594. * After the step the babylon meshes are set to the position of the physics imposters
  53595. * @param delta amount of time to step forward
  53596. * @param impostors array of imposters to update before/after the step
  53597. */
  53598. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  53599. /**
  53600. * Update babylon mesh to match physics world object
  53601. * @param impostor imposter to match
  53602. */
  53603. private _afterSoftStep;
  53604. /**
  53605. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53606. * @param impostor imposter to match
  53607. */
  53608. private _ropeStep;
  53609. /**
  53610. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  53611. * @param impostor imposter to match
  53612. */
  53613. private _softbodyOrClothStep;
  53614. private _tmpVector;
  53615. private _tmpMatrix;
  53616. /**
  53617. * Applies an impulse on the imposter
  53618. * @param impostor imposter to apply impulse to
  53619. * @param force amount of force to be applied to the imposter
  53620. * @param contactPoint the location to apply the impulse on the imposter
  53621. */
  53622. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53623. /**
  53624. * Applies a force on the imposter
  53625. * @param impostor imposter to apply force
  53626. * @param force amount of force to be applied to the imposter
  53627. * @param contactPoint the location to apply the force on the imposter
  53628. */
  53629. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  53630. /**
  53631. * Creates a physics body using the plugin
  53632. * @param impostor the imposter to create the physics body on
  53633. */
  53634. generatePhysicsBody(impostor: PhysicsImpostor): void;
  53635. /**
  53636. * Removes the physics body from the imposter and disposes of the body's memory
  53637. * @param impostor imposter to remove the physics body from
  53638. */
  53639. removePhysicsBody(impostor: PhysicsImpostor): void;
  53640. /**
  53641. * Generates a joint
  53642. * @param impostorJoint the imposter joint to create the joint with
  53643. */
  53644. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  53645. /**
  53646. * Removes a joint
  53647. * @param impostorJoint the imposter joint to remove the joint from
  53648. */
  53649. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  53650. private _addMeshVerts;
  53651. /**
  53652. * Initialise the soft body vertices to match its object's (mesh) vertices
  53653. * Softbody vertices (nodes) are in world space and to match this
  53654. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  53655. * @param impostor to create the softbody for
  53656. */
  53657. private _softVertexData;
  53658. /**
  53659. * Create an impostor's soft body
  53660. * @param impostor to create the softbody for
  53661. */
  53662. private _createSoftbody;
  53663. /**
  53664. * Create cloth for an impostor
  53665. * @param impostor to create the softbody for
  53666. */
  53667. private _createCloth;
  53668. /**
  53669. * Create rope for an impostor
  53670. * @param impostor to create the softbody for
  53671. */
  53672. private _createRope;
  53673. private _addHullVerts;
  53674. private _createShape;
  53675. /**
  53676. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  53677. * @param impostor imposter containing the physics body and babylon object
  53678. */
  53679. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  53680. /**
  53681. * Sets the babylon object's position/rotation from the physics body's position/rotation
  53682. * @param impostor imposter containing the physics body and babylon object
  53683. * @param newPosition new position
  53684. * @param newRotation new rotation
  53685. */
  53686. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  53687. /**
  53688. * If this plugin is supported
  53689. * @returns true if its supported
  53690. */
  53691. isSupported(): boolean;
  53692. /**
  53693. * Sets the linear velocity of the physics body
  53694. * @param impostor imposter to set the velocity on
  53695. * @param velocity velocity to set
  53696. */
  53697. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53698. /**
  53699. * Sets the angular velocity of the physics body
  53700. * @param impostor imposter to set the velocity on
  53701. * @param velocity velocity to set
  53702. */
  53703. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  53704. /**
  53705. * gets the linear velocity
  53706. * @param impostor imposter to get linear velocity from
  53707. * @returns linear velocity
  53708. */
  53709. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53710. /**
  53711. * gets the angular velocity
  53712. * @param impostor imposter to get angular velocity from
  53713. * @returns angular velocity
  53714. */
  53715. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  53716. /**
  53717. * Sets the mass of physics body
  53718. * @param impostor imposter to set the mass on
  53719. * @param mass mass to set
  53720. */
  53721. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  53722. /**
  53723. * Gets the mass of the physics body
  53724. * @param impostor imposter to get the mass from
  53725. * @returns mass
  53726. */
  53727. getBodyMass(impostor: PhysicsImpostor): number;
  53728. /**
  53729. * Gets friction of the impostor
  53730. * @param impostor impostor to get friction from
  53731. * @returns friction value
  53732. */
  53733. getBodyFriction(impostor: PhysicsImpostor): number;
  53734. /**
  53735. * Sets friction of the impostor
  53736. * @param impostor impostor to set friction on
  53737. * @param friction friction value
  53738. */
  53739. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  53740. /**
  53741. * Gets restitution of the impostor
  53742. * @param impostor impostor to get restitution from
  53743. * @returns restitution value
  53744. */
  53745. getBodyRestitution(impostor: PhysicsImpostor): number;
  53746. /**
  53747. * Sets resitution of the impostor
  53748. * @param impostor impostor to set resitution on
  53749. * @param restitution resitution value
  53750. */
  53751. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  53752. /**
  53753. * Gets pressure inside the impostor
  53754. * @param impostor impostor to get pressure from
  53755. * @returns pressure value
  53756. */
  53757. getBodyPressure(impostor: PhysicsImpostor): number;
  53758. /**
  53759. * Sets pressure inside a soft body impostor
  53760. * Cloth and rope must remain 0 pressure
  53761. * @param impostor impostor to set pressure on
  53762. * @param pressure pressure value
  53763. */
  53764. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  53765. /**
  53766. * Gets stiffness of the impostor
  53767. * @param impostor impostor to get stiffness from
  53768. * @returns pressure value
  53769. */
  53770. getBodyStiffness(impostor: PhysicsImpostor): number;
  53771. /**
  53772. * Sets stiffness of the impostor
  53773. * @param impostor impostor to set stiffness on
  53774. * @param stiffness stiffness value from 0 to 1
  53775. */
  53776. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  53777. /**
  53778. * Gets velocityIterations of the impostor
  53779. * @param impostor impostor to get velocity iterations from
  53780. * @returns velocityIterations value
  53781. */
  53782. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  53783. /**
  53784. * Sets velocityIterations of the impostor
  53785. * @param impostor impostor to set velocity iterations on
  53786. * @param velocityIterations velocityIterations value
  53787. */
  53788. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  53789. /**
  53790. * Gets positionIterations of the impostor
  53791. * @param impostor impostor to get position iterations from
  53792. * @returns positionIterations value
  53793. */
  53794. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  53795. /**
  53796. * Sets positionIterations of the impostor
  53797. * @param impostor impostor to set position on
  53798. * @param positionIterations positionIterations value
  53799. */
  53800. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  53801. /**
  53802. * Append an anchor to a cloth object
  53803. * @param impostor is the cloth impostor to add anchor to
  53804. * @param otherImpostor is the rigid impostor to anchor to
  53805. * @param width ratio across width from 0 to 1
  53806. * @param height ratio up height from 0 to 1
  53807. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  53808. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53809. */
  53810. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53811. /**
  53812. * Append an hook to a rope object
  53813. * @param impostor is the rope impostor to add hook to
  53814. * @param otherImpostor is the rigid impostor to hook to
  53815. * @param length ratio along the rope from 0 to 1
  53816. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  53817. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  53818. */
  53819. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  53820. /**
  53821. * Sleeps the physics body and stops it from being active
  53822. * @param impostor impostor to sleep
  53823. */
  53824. sleepBody(impostor: PhysicsImpostor): void;
  53825. /**
  53826. * Activates the physics body
  53827. * @param impostor impostor to activate
  53828. */
  53829. wakeUpBody(impostor: PhysicsImpostor): void;
  53830. /**
  53831. * Updates the distance parameters of the joint
  53832. * @param joint joint to update
  53833. * @param maxDistance maximum distance of the joint
  53834. * @param minDistance minimum distance of the joint
  53835. */
  53836. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  53837. /**
  53838. * Sets a motor on the joint
  53839. * @param joint joint to set motor on
  53840. * @param speed speed of the motor
  53841. * @param maxForce maximum force of the motor
  53842. * @param motorIndex index of the motor
  53843. */
  53844. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  53845. /**
  53846. * Sets the motors limit
  53847. * @param joint joint to set limit on
  53848. * @param upperLimit upper limit
  53849. * @param lowerLimit lower limit
  53850. */
  53851. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  53852. /**
  53853. * Syncs the position and rotation of a mesh with the impostor
  53854. * @param mesh mesh to sync
  53855. * @param impostor impostor to update the mesh with
  53856. */
  53857. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  53858. /**
  53859. * Gets the radius of the impostor
  53860. * @param impostor impostor to get radius from
  53861. * @returns the radius
  53862. */
  53863. getRadius(impostor: PhysicsImpostor): number;
  53864. /**
  53865. * Gets the box size of the impostor
  53866. * @param impostor impostor to get box size from
  53867. * @param result the resulting box size
  53868. */
  53869. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  53870. /**
  53871. * Disposes of the impostor
  53872. */
  53873. dispose(): void;
  53874. /**
  53875. * Does a raycast in the physics world
  53876. * @param from when should the ray start?
  53877. * @param to when should the ray end?
  53878. * @returns PhysicsRaycastResult
  53879. */
  53880. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  53881. }
  53882. }
  53883. declare module "babylonjs/Probes/reflectionProbe" {
  53884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53885. import { Vector3 } from "babylonjs/Maths/math.vector";
  53886. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53887. import { Nullable } from "babylonjs/types";
  53888. import { Scene } from "babylonjs/scene";
  53889. module "babylonjs/abstractScene" {
  53890. interface AbstractScene {
  53891. /**
  53892. * The list of reflection probes added to the scene
  53893. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53894. */
  53895. reflectionProbes: Array<ReflectionProbe>;
  53896. /**
  53897. * Removes the given reflection probe from this scene.
  53898. * @param toRemove The reflection probe to remove
  53899. * @returns The index of the removed reflection probe
  53900. */
  53901. removeReflectionProbe(toRemove: ReflectionProbe): number;
  53902. /**
  53903. * Adds the given reflection probe to this scene.
  53904. * @param newReflectionProbe The reflection probe to add
  53905. */
  53906. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  53907. }
  53908. }
  53909. /**
  53910. * Class used to generate realtime reflection / refraction cube textures
  53911. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  53912. */
  53913. export class ReflectionProbe {
  53914. /** defines the name of the probe */
  53915. name: string;
  53916. private _scene;
  53917. private _renderTargetTexture;
  53918. private _projectionMatrix;
  53919. private _viewMatrix;
  53920. private _target;
  53921. private _add;
  53922. private _attachedMesh;
  53923. private _invertYAxis;
  53924. /** Gets or sets probe position (center of the cube map) */
  53925. position: Vector3;
  53926. /**
  53927. * Creates a new reflection probe
  53928. * @param name defines the name of the probe
  53929. * @param size defines the texture resolution (for each face)
  53930. * @param scene defines the hosting scene
  53931. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  53932. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  53933. */
  53934. constructor(
  53935. /** defines the name of the probe */
  53936. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  53937. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  53938. samples: number;
  53939. /** Gets or sets the refresh rate to use (on every frame by default) */
  53940. refreshRate: number;
  53941. /**
  53942. * Gets the hosting scene
  53943. * @returns a Scene
  53944. */
  53945. getScene(): Scene;
  53946. /** Gets the internal CubeTexture used to render to */
  53947. readonly cubeTexture: RenderTargetTexture;
  53948. /** Gets the list of meshes to render */
  53949. readonly renderList: Nullable<AbstractMesh[]>;
  53950. /**
  53951. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  53952. * @param mesh defines the mesh to attach to
  53953. */
  53954. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  53955. /**
  53956. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  53957. * @param renderingGroupId The rendering group id corresponding to its index
  53958. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  53959. */
  53960. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  53961. /**
  53962. * Clean all associated resources
  53963. */
  53964. dispose(): void;
  53965. /**
  53966. * Converts the reflection probe information to a readable string for debug purpose.
  53967. * @param fullDetails Supports for multiple levels of logging within scene loading
  53968. * @returns the human readable reflection probe info
  53969. */
  53970. toString(fullDetails?: boolean): string;
  53971. /**
  53972. * Get the class name of the relfection probe.
  53973. * @returns "ReflectionProbe"
  53974. */
  53975. getClassName(): string;
  53976. /**
  53977. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  53978. * @returns The JSON representation of the texture
  53979. */
  53980. serialize(): any;
  53981. /**
  53982. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  53983. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  53984. * @param scene Define the scene the parsed reflection probe should be instantiated in
  53985. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  53986. * @returns The parsed reflection probe if successful
  53987. */
  53988. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  53989. }
  53990. }
  53991. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  53992. /** @hidden */
  53993. export var _BabylonLoaderRegistered: boolean;
  53994. }
  53995. declare module "babylonjs/Loading/Plugins/index" {
  53996. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  53997. }
  53998. declare module "babylonjs/Loading/index" {
  53999. export * from "babylonjs/Loading/loadingScreen";
  54000. export * from "babylonjs/Loading/Plugins/index";
  54001. export * from "babylonjs/Loading/sceneLoader";
  54002. export * from "babylonjs/Loading/sceneLoaderFlags";
  54003. }
  54004. declare module "babylonjs/Materials/Background/index" {
  54005. export * from "babylonjs/Materials/Background/backgroundMaterial";
  54006. }
  54007. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  54008. import { Scene } from "babylonjs/scene";
  54009. import { Color3 } from "babylonjs/Maths/math.color";
  54010. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54012. /**
  54013. * The Physically based simple base material of BJS.
  54014. *
  54015. * This enables better naming and convention enforcements on top of the pbrMaterial.
  54016. * It is used as the base class for both the specGloss and metalRough conventions.
  54017. */
  54018. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  54019. /**
  54020. * Number of Simultaneous lights allowed on the material.
  54021. */
  54022. maxSimultaneousLights: number;
  54023. /**
  54024. * If sets to true, disables all the lights affecting the material.
  54025. */
  54026. disableLighting: boolean;
  54027. /**
  54028. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  54029. */
  54030. environmentTexture: BaseTexture;
  54031. /**
  54032. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54033. */
  54034. invertNormalMapX: boolean;
  54035. /**
  54036. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54037. */
  54038. invertNormalMapY: boolean;
  54039. /**
  54040. * Normal map used in the model.
  54041. */
  54042. normalTexture: BaseTexture;
  54043. /**
  54044. * Emissivie color used to self-illuminate the model.
  54045. */
  54046. emissiveColor: Color3;
  54047. /**
  54048. * Emissivie texture used to self-illuminate the model.
  54049. */
  54050. emissiveTexture: BaseTexture;
  54051. /**
  54052. * Occlusion Channel Strenght.
  54053. */
  54054. occlusionStrength: number;
  54055. /**
  54056. * Occlusion Texture of the material (adding extra occlusion effects).
  54057. */
  54058. occlusionTexture: BaseTexture;
  54059. /**
  54060. * Defines the alpha limits in alpha test mode.
  54061. */
  54062. alphaCutOff: number;
  54063. /**
  54064. * Gets the current double sided mode.
  54065. */
  54066. /**
  54067. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54068. */
  54069. doubleSided: boolean;
  54070. /**
  54071. * Stores the pre-calculated light information of a mesh in a texture.
  54072. */
  54073. lightmapTexture: BaseTexture;
  54074. /**
  54075. * If true, the light map contains occlusion information instead of lighting info.
  54076. */
  54077. useLightmapAsShadowmap: boolean;
  54078. /**
  54079. * Instantiates a new PBRMaterial instance.
  54080. *
  54081. * @param name The material name
  54082. * @param scene The scene the material will be use in.
  54083. */
  54084. constructor(name: string, scene: Scene);
  54085. getClassName(): string;
  54086. }
  54087. }
  54088. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  54089. import { Scene } from "babylonjs/scene";
  54090. import { Color3 } from "babylonjs/Maths/math.color";
  54091. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54092. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54093. /**
  54094. * The PBR material of BJS following the metal roughness convention.
  54095. *
  54096. * This fits to the PBR convention in the GLTF definition:
  54097. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  54098. */
  54099. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  54100. /**
  54101. * The base color has two different interpretations depending on the value of metalness.
  54102. * When the material is a metal, the base color is the specific measured reflectance value
  54103. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  54104. * of the material.
  54105. */
  54106. baseColor: Color3;
  54107. /**
  54108. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  54109. * well as opacity information in the alpha channel.
  54110. */
  54111. baseTexture: BaseTexture;
  54112. /**
  54113. * Specifies the metallic scalar value of the material.
  54114. * Can also be used to scale the metalness values of the metallic texture.
  54115. */
  54116. metallic: number;
  54117. /**
  54118. * Specifies the roughness scalar value of the material.
  54119. * Can also be used to scale the roughness values of the metallic texture.
  54120. */
  54121. roughness: number;
  54122. /**
  54123. * Texture containing both the metallic value in the B channel and the
  54124. * roughness value in the G channel to keep better precision.
  54125. */
  54126. metallicRoughnessTexture: BaseTexture;
  54127. /**
  54128. * Instantiates a new PBRMetalRoughnessMaterial instance.
  54129. *
  54130. * @param name The material name
  54131. * @param scene The scene the material will be use in.
  54132. */
  54133. constructor(name: string, scene: Scene);
  54134. /**
  54135. * Return the currrent class name of the material.
  54136. */
  54137. getClassName(): string;
  54138. /**
  54139. * Makes a duplicate of the current material.
  54140. * @param name - name to use for the new material.
  54141. */
  54142. clone(name: string): PBRMetallicRoughnessMaterial;
  54143. /**
  54144. * Serialize the material to a parsable JSON object.
  54145. */
  54146. serialize(): any;
  54147. /**
  54148. * Parses a JSON object correponding to the serialize function.
  54149. */
  54150. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  54151. }
  54152. }
  54153. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  54154. import { Scene } from "babylonjs/scene";
  54155. import { Color3 } from "babylonjs/Maths/math.color";
  54156. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54157. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54158. /**
  54159. * The PBR material of BJS following the specular glossiness convention.
  54160. *
  54161. * This fits to the PBR convention in the GLTF definition:
  54162. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  54163. */
  54164. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  54165. /**
  54166. * Specifies the diffuse color of the material.
  54167. */
  54168. diffuseColor: Color3;
  54169. /**
  54170. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  54171. * channel.
  54172. */
  54173. diffuseTexture: BaseTexture;
  54174. /**
  54175. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  54176. */
  54177. specularColor: Color3;
  54178. /**
  54179. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  54180. */
  54181. glossiness: number;
  54182. /**
  54183. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  54184. */
  54185. specularGlossinessTexture: BaseTexture;
  54186. /**
  54187. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  54188. *
  54189. * @param name The material name
  54190. * @param scene The scene the material will be use in.
  54191. */
  54192. constructor(name: string, scene: Scene);
  54193. /**
  54194. * Return the currrent class name of the material.
  54195. */
  54196. getClassName(): string;
  54197. /**
  54198. * Makes a duplicate of the current material.
  54199. * @param name - name to use for the new material.
  54200. */
  54201. clone(name: string): PBRSpecularGlossinessMaterial;
  54202. /**
  54203. * Serialize the material to a parsable JSON object.
  54204. */
  54205. serialize(): any;
  54206. /**
  54207. * Parses a JSON object correponding to the serialize function.
  54208. */
  54209. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  54210. }
  54211. }
  54212. declare module "babylonjs/Materials/PBR/index" {
  54213. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54214. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  54215. export * from "babylonjs/Materials/PBR/pbrMaterial";
  54216. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  54217. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  54218. }
  54219. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  54220. import { Nullable } from "babylonjs/types";
  54221. import { Scene } from "babylonjs/scene";
  54222. import { Matrix } from "babylonjs/Maths/math.vector";
  54223. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54224. /**
  54225. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  54226. * It can help converting any input color in a desired output one. This can then be used to create effects
  54227. * from sepia, black and white to sixties or futuristic rendering...
  54228. *
  54229. * The only supported format is currently 3dl.
  54230. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  54231. */
  54232. export class ColorGradingTexture extends BaseTexture {
  54233. /**
  54234. * The current texture matrix. (will always be identity in color grading texture)
  54235. */
  54236. private _textureMatrix;
  54237. /**
  54238. * The texture URL.
  54239. */
  54240. url: string;
  54241. /**
  54242. * Empty line regex stored for GC.
  54243. */
  54244. private static _noneEmptyLineRegex;
  54245. private _engine;
  54246. /**
  54247. * Instantiates a ColorGradingTexture from the following parameters.
  54248. *
  54249. * @param url The location of the color gradind data (currently only supporting 3dl)
  54250. * @param scene The scene the texture will be used in
  54251. */
  54252. constructor(url: string, scene: Scene);
  54253. /**
  54254. * Returns the texture matrix used in most of the material.
  54255. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  54256. */
  54257. getTextureMatrix(): Matrix;
  54258. /**
  54259. * Occurs when the file being loaded is a .3dl LUT file.
  54260. */
  54261. private load3dlTexture;
  54262. /**
  54263. * Starts the loading process of the texture.
  54264. */
  54265. private loadTexture;
  54266. /**
  54267. * Clones the color gradind texture.
  54268. */
  54269. clone(): ColorGradingTexture;
  54270. /**
  54271. * Called during delayed load for textures.
  54272. */
  54273. delayLoad(): void;
  54274. /**
  54275. * Parses a color grading texture serialized by Babylon.
  54276. * @param parsedTexture The texture information being parsedTexture
  54277. * @param scene The scene to load the texture in
  54278. * @param rootUrl The root url of the data assets to load
  54279. * @return A color gradind texture
  54280. */
  54281. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  54282. /**
  54283. * Serializes the LUT texture to json format.
  54284. */
  54285. serialize(): any;
  54286. }
  54287. }
  54288. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  54289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54290. import { Scene } from "babylonjs/scene";
  54291. import { Nullable } from "babylonjs/types";
  54292. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54293. /**
  54294. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  54295. */
  54296. export class EquiRectangularCubeTexture extends BaseTexture {
  54297. /** The six faces of the cube. */
  54298. private static _FacesMapping;
  54299. private _noMipmap;
  54300. private _onLoad;
  54301. private _onError;
  54302. /** The size of the cubemap. */
  54303. private _size;
  54304. /** The buffer of the image. */
  54305. private _buffer;
  54306. /** The width of the input image. */
  54307. private _width;
  54308. /** The height of the input image. */
  54309. private _height;
  54310. /** The URL to the image. */
  54311. url: string;
  54312. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  54313. coordinatesMode: number;
  54314. /**
  54315. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  54316. * @param url The location of the image
  54317. * @param scene The scene the texture will be used in
  54318. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  54319. * @param noMipmap Forces to not generate the mipmap if true
  54320. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  54321. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  54322. * @param onLoad — defines a callback called when texture is loaded
  54323. * @param onError — defines a callback called if there is an error
  54324. */
  54325. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  54326. /**
  54327. * Load the image data, by putting the image on a canvas and extracting its buffer.
  54328. */
  54329. private loadImage;
  54330. /**
  54331. * Convert the image buffer into a cubemap and create a CubeTexture.
  54332. */
  54333. private loadTexture;
  54334. /**
  54335. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  54336. * @param buffer The ArrayBuffer that should be converted.
  54337. * @returns The buffer as Float32Array.
  54338. */
  54339. private getFloat32ArrayFromArrayBuffer;
  54340. /**
  54341. * Get the current class name of the texture useful for serialization or dynamic coding.
  54342. * @returns "EquiRectangularCubeTexture"
  54343. */
  54344. getClassName(): string;
  54345. /**
  54346. * Create a clone of the current EquiRectangularCubeTexture and return it.
  54347. * @returns A clone of the current EquiRectangularCubeTexture.
  54348. */
  54349. clone(): EquiRectangularCubeTexture;
  54350. }
  54351. }
  54352. declare module "babylonjs/Misc/tga" {
  54353. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54354. /**
  54355. * Based on jsTGALoader - Javascript loader for TGA file
  54356. * By Vincent Thibault
  54357. * @see http://blog.robrowser.com/javascript-tga-loader.html
  54358. */
  54359. export class TGATools {
  54360. private static _TYPE_INDEXED;
  54361. private static _TYPE_RGB;
  54362. private static _TYPE_GREY;
  54363. private static _TYPE_RLE_INDEXED;
  54364. private static _TYPE_RLE_RGB;
  54365. private static _TYPE_RLE_GREY;
  54366. private static _ORIGIN_MASK;
  54367. private static _ORIGIN_SHIFT;
  54368. private static _ORIGIN_BL;
  54369. private static _ORIGIN_BR;
  54370. private static _ORIGIN_UL;
  54371. private static _ORIGIN_UR;
  54372. /**
  54373. * Gets the header of a TGA file
  54374. * @param data defines the TGA data
  54375. * @returns the header
  54376. */
  54377. static GetTGAHeader(data: Uint8Array): any;
  54378. /**
  54379. * Uploads TGA content to a Babylon Texture
  54380. * @hidden
  54381. */
  54382. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  54383. /** @hidden */
  54384. 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;
  54385. /** @hidden */
  54386. 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;
  54387. /** @hidden */
  54388. 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;
  54389. /** @hidden */
  54390. 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;
  54391. /** @hidden */
  54392. 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;
  54393. /** @hidden */
  54394. 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;
  54395. }
  54396. }
  54397. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  54398. import { Nullable } from "babylonjs/types";
  54399. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54400. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54401. /**
  54402. * Implementation of the TGA Texture Loader.
  54403. * @hidden
  54404. */
  54405. export class _TGATextureLoader implements IInternalTextureLoader {
  54406. /**
  54407. * Defines wether the loader supports cascade loading the different faces.
  54408. */
  54409. readonly supportCascades: boolean;
  54410. /**
  54411. * This returns if the loader support the current file information.
  54412. * @param extension defines the file extension of the file being loaded
  54413. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54414. * @param fallback defines the fallback internal texture if any
  54415. * @param isBase64 defines whether the texture is encoded as a base64
  54416. * @param isBuffer defines whether the texture data are stored as a buffer
  54417. * @returns true if the loader can load the specified file
  54418. */
  54419. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54420. /**
  54421. * Transform the url before loading if required.
  54422. * @param rootUrl the url of the texture
  54423. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54424. * @returns the transformed texture
  54425. */
  54426. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54427. /**
  54428. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54429. * @param rootUrl the url of the texture
  54430. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54431. * @returns the fallback texture
  54432. */
  54433. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54434. /**
  54435. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54436. * @param data contains the texture data
  54437. * @param texture defines the BabylonJS internal texture
  54438. * @param createPolynomials will be true if polynomials have been requested
  54439. * @param onLoad defines the callback to trigger once the texture is ready
  54440. * @param onError defines the callback to trigger in case of error
  54441. */
  54442. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54443. /**
  54444. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54445. * @param data contains the texture data
  54446. * @param texture defines the BabylonJS internal texture
  54447. * @param callback defines the method to call once ready to upload
  54448. */
  54449. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54450. }
  54451. }
  54452. declare module "babylonjs/Misc/basis" {
  54453. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54454. /**
  54455. * Info about the .basis files
  54456. */
  54457. class BasisFileInfo {
  54458. /**
  54459. * If the file has alpha
  54460. */
  54461. hasAlpha: boolean;
  54462. /**
  54463. * Info about each image of the basis file
  54464. */
  54465. images: Array<{
  54466. levels: Array<{
  54467. width: number;
  54468. height: number;
  54469. transcodedPixels: ArrayBufferView;
  54470. }>;
  54471. }>;
  54472. }
  54473. /**
  54474. * Result of transcoding a basis file
  54475. */
  54476. class TranscodeResult {
  54477. /**
  54478. * Info about the .basis file
  54479. */
  54480. fileInfo: BasisFileInfo;
  54481. /**
  54482. * Format to use when loading the file
  54483. */
  54484. format: number;
  54485. }
  54486. /**
  54487. * Configuration options for the Basis transcoder
  54488. */
  54489. export class BasisTranscodeConfiguration {
  54490. /**
  54491. * Supported compression formats used to determine the supported output format of the transcoder
  54492. */
  54493. supportedCompressionFormats?: {
  54494. /**
  54495. * etc1 compression format
  54496. */
  54497. etc1?: boolean;
  54498. /**
  54499. * s3tc compression format
  54500. */
  54501. s3tc?: boolean;
  54502. /**
  54503. * pvrtc compression format
  54504. */
  54505. pvrtc?: boolean;
  54506. /**
  54507. * etc2 compression format
  54508. */
  54509. etc2?: boolean;
  54510. };
  54511. /**
  54512. * If mipmap levels should be loaded for transcoded images (Default: true)
  54513. */
  54514. loadMipmapLevels?: boolean;
  54515. /**
  54516. * Index of a single image to load (Default: all images)
  54517. */
  54518. loadSingleImage?: number;
  54519. }
  54520. /**
  54521. * Used to load .Basis files
  54522. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  54523. */
  54524. export class BasisTools {
  54525. private static _IgnoreSupportedFormats;
  54526. /**
  54527. * URL to use when loading the basis transcoder
  54528. */
  54529. static JSModuleURL: string;
  54530. /**
  54531. * URL to use when loading the wasm module for the transcoder
  54532. */
  54533. static WasmModuleURL: string;
  54534. /**
  54535. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  54536. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  54537. * @returns internal format corresponding to the Basis format
  54538. */
  54539. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  54540. private static _WorkerPromise;
  54541. private static _Worker;
  54542. private static _actionId;
  54543. private static _CreateWorkerAsync;
  54544. /**
  54545. * Transcodes a loaded image file to compressed pixel data
  54546. * @param imageData image data to transcode
  54547. * @param config configuration options for the transcoding
  54548. * @returns a promise resulting in the transcoded image
  54549. */
  54550. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  54551. /**
  54552. * Loads a texture from the transcode result
  54553. * @param texture texture load to
  54554. * @param transcodeResult the result of transcoding the basis file to load from
  54555. */
  54556. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  54557. }
  54558. }
  54559. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  54560. import { Nullable } from "babylonjs/types";
  54561. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54562. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54563. /**
  54564. * Loader for .basis file format
  54565. */
  54566. export class _BasisTextureLoader implements IInternalTextureLoader {
  54567. /**
  54568. * Defines whether the loader supports cascade loading the different faces.
  54569. */
  54570. readonly supportCascades: boolean;
  54571. /**
  54572. * This returns if the loader support the current file information.
  54573. * @param extension defines the file extension of the file being loaded
  54574. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54575. * @param fallback defines the fallback internal texture if any
  54576. * @param isBase64 defines whether the texture is encoded as a base64
  54577. * @param isBuffer defines whether the texture data are stored as a buffer
  54578. * @returns true if the loader can load the specified file
  54579. */
  54580. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  54581. /**
  54582. * Transform the url before loading if required.
  54583. * @param rootUrl the url of the texture
  54584. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54585. * @returns the transformed texture
  54586. */
  54587. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  54588. /**
  54589. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54590. * @param rootUrl the url of the texture
  54591. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54592. * @returns the fallback texture
  54593. */
  54594. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  54595. /**
  54596. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  54597. * @param data contains the texture data
  54598. * @param texture defines the BabylonJS internal texture
  54599. * @param createPolynomials will be true if polynomials have been requested
  54600. * @param onLoad defines the callback to trigger once the texture is ready
  54601. * @param onError defines the callback to trigger in case of error
  54602. */
  54603. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54604. /**
  54605. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54606. * @param data contains the texture data
  54607. * @param texture defines the BabylonJS internal texture
  54608. * @param callback defines the method to call once ready to upload
  54609. */
  54610. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54611. }
  54612. }
  54613. declare module "babylonjs/Materials/Textures/Loaders/index" {
  54614. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  54615. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  54616. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  54617. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  54618. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  54619. }
  54620. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  54621. import { Scene } from "babylonjs/scene";
  54622. import { Texture } from "babylonjs/Materials/Textures/texture";
  54623. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54624. /**
  54625. * 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.
  54626. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54627. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54628. */
  54629. export class CustomProceduralTexture extends ProceduralTexture {
  54630. private _animate;
  54631. private _time;
  54632. private _config;
  54633. private _texturePath;
  54634. /**
  54635. * Instantiates a new Custom Procedural Texture.
  54636. * 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.
  54637. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54638. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54639. * @param name Define the name of the texture
  54640. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54641. * @param size Define the size of the texture to create
  54642. * @param scene Define the scene the texture belongs to
  54643. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54644. * @param generateMipMaps Define if the texture should creates mip maps or not
  54645. */
  54646. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54647. private _loadJson;
  54648. /**
  54649. * Is the texture ready to be used ? (rendered at least once)
  54650. * @returns true if ready, otherwise, false.
  54651. */
  54652. isReady(): boolean;
  54653. /**
  54654. * Render the texture to its associated render target.
  54655. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54656. */
  54657. render(useCameraPostProcess?: boolean): void;
  54658. /**
  54659. * Update the list of dependant textures samplers in the shader.
  54660. */
  54661. updateTextures(): void;
  54662. /**
  54663. * Update the uniform values of the procedural texture in the shader.
  54664. */
  54665. updateShaderUniforms(): void;
  54666. /**
  54667. * Define if the texture animates or not.
  54668. */
  54669. animate: boolean;
  54670. }
  54671. }
  54672. declare module "babylonjs/Shaders/noise.fragment" {
  54673. /** @hidden */
  54674. export var noisePixelShader: {
  54675. name: string;
  54676. shader: string;
  54677. };
  54678. }
  54679. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  54680. import { Nullable } from "babylonjs/types";
  54681. import { Scene } from "babylonjs/scene";
  54682. import { Texture } from "babylonjs/Materials/Textures/texture";
  54683. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54684. import "babylonjs/Shaders/noise.fragment";
  54685. /**
  54686. * Class used to generate noise procedural textures
  54687. */
  54688. export class NoiseProceduralTexture extends ProceduralTexture {
  54689. private _time;
  54690. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54691. brightness: number;
  54692. /** Defines the number of octaves to process */
  54693. octaves: number;
  54694. /** Defines the level of persistence (0.8 by default) */
  54695. persistence: number;
  54696. /** Gets or sets animation speed factor (default is 1) */
  54697. animationSpeedFactor: number;
  54698. /**
  54699. * Creates a new NoiseProceduralTexture
  54700. * @param name defines the name fo the texture
  54701. * @param size defines the size of the texture (default is 256)
  54702. * @param scene defines the hosting scene
  54703. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54704. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54705. */
  54706. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  54707. private _updateShaderUniforms;
  54708. protected _getDefines(): string;
  54709. /** Generate the current state of the procedural texture */
  54710. render(useCameraPostProcess?: boolean): void;
  54711. /**
  54712. * Serializes this noise procedural texture
  54713. * @returns a serialized noise procedural texture object
  54714. */
  54715. serialize(): any;
  54716. /**
  54717. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54718. * @param parsedTexture defines parsed texture data
  54719. * @param scene defines the current scene
  54720. * @param rootUrl defines the root URL containing noise procedural texture information
  54721. * @returns a parsed NoiseProceduralTexture
  54722. */
  54723. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  54724. }
  54725. }
  54726. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  54727. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  54728. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  54729. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  54730. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  54731. }
  54732. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  54733. import { Nullable } from "babylonjs/types";
  54734. import { Scene } from "babylonjs/scene";
  54735. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54736. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54737. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  54738. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54739. /**
  54740. * Raw cube texture where the raw buffers are passed in
  54741. */
  54742. export class RawCubeTexture extends CubeTexture {
  54743. /**
  54744. * Creates a cube texture where the raw buffers are passed in.
  54745. * @param scene defines the scene the texture is attached to
  54746. * @param data defines the array of data to use to create each face
  54747. * @param size defines the size of the textures
  54748. * @param format defines the format of the data
  54749. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  54750. * @param generateMipMaps defines if the engine should generate the mip levels
  54751. * @param invertY defines if data must be stored with Y axis inverted
  54752. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  54753. * @param compression defines the compression used (null by default)
  54754. */
  54755. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  54756. /**
  54757. * Updates the raw cube texture.
  54758. * @param data defines the data to store
  54759. * @param format defines the data format
  54760. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  54761. * @param invertY defines if data must be stored with Y axis inverted
  54762. * @param compression defines the compression used (null by default)
  54763. * @param level defines which level of the texture to update
  54764. */
  54765. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  54766. /**
  54767. * Updates a raw cube texture with RGBD encoded data.
  54768. * @param data defines the array of data [mipmap][face] to use to create each face
  54769. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  54770. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  54771. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  54772. * @returns a promsie that resolves when the operation is complete
  54773. */
  54774. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  54775. /**
  54776. * Clones the raw cube texture.
  54777. * @return a new cube texture
  54778. */
  54779. clone(): CubeTexture;
  54780. /** @hidden */
  54781. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  54782. }
  54783. }
  54784. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  54785. import { Scene } from "babylonjs/scene";
  54786. import { Texture } from "babylonjs/Materials/Textures/texture";
  54787. import "babylonjs/Engines/Extensions/engine.rawTexture";
  54788. /**
  54789. * Class used to store 3D textures containing user data
  54790. */
  54791. export class RawTexture3D extends Texture {
  54792. /** Gets or sets the texture format to use */
  54793. format: number;
  54794. private _engine;
  54795. /**
  54796. * Create a new RawTexture3D
  54797. * @param data defines the data of the texture
  54798. * @param width defines the width of the texture
  54799. * @param height defines the height of the texture
  54800. * @param depth defines the depth of the texture
  54801. * @param format defines the texture format to use
  54802. * @param scene defines the hosting scene
  54803. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  54804. * @param invertY defines if texture must be stored with Y axis inverted
  54805. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  54806. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  54807. */
  54808. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  54809. /** Gets or sets the texture format to use */
  54810. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  54811. /**
  54812. * Update the texture with new data
  54813. * @param data defines the data to store in the texture
  54814. */
  54815. update(data: ArrayBufferView): void;
  54816. }
  54817. }
  54818. declare module "babylonjs/Materials/Textures/refractionTexture" {
  54819. import { Scene } from "babylonjs/scene";
  54820. import { Plane } from "babylonjs/Maths/math.plane";
  54821. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54822. /**
  54823. * Creates a refraction texture used by refraction channel of the standard material.
  54824. * It is like a mirror but to see through a material.
  54825. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54826. */
  54827. export class RefractionTexture extends RenderTargetTexture {
  54828. /**
  54829. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  54830. * 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.
  54831. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54832. */
  54833. refractionPlane: Plane;
  54834. /**
  54835. * Define how deep under the surface we should see.
  54836. */
  54837. depth: number;
  54838. /**
  54839. * Creates a refraction texture used by refraction channel of the standard material.
  54840. * It is like a mirror but to see through a material.
  54841. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  54842. * @param name Define the texture name
  54843. * @param size Define the size of the underlying texture
  54844. * @param scene Define the scene the refraction belongs to
  54845. * @param generateMipMaps Define if we need to generate mips level for the refraction
  54846. */
  54847. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  54848. /**
  54849. * Clone the refraction texture.
  54850. * @returns the cloned texture
  54851. */
  54852. clone(): RefractionTexture;
  54853. /**
  54854. * Serialize the texture to a JSON representation you could use in Parse later on
  54855. * @returns the serialized JSON representation
  54856. */
  54857. serialize(): any;
  54858. }
  54859. }
  54860. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  54861. import { Nullable } from "babylonjs/types";
  54862. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54863. import { Matrix } from "babylonjs/Maths/math.vector";
  54864. import { Engine } from "babylonjs/Engines/engine";
  54865. import { Scene } from "babylonjs/scene";
  54866. /**
  54867. * Defines the options related to the creation of an HtmlElementTexture
  54868. */
  54869. export interface IHtmlElementTextureOptions {
  54870. /**
  54871. * Defines wether mip maps should be created or not.
  54872. */
  54873. generateMipMaps?: boolean;
  54874. /**
  54875. * Defines the sampling mode of the texture.
  54876. */
  54877. samplingMode?: number;
  54878. /**
  54879. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  54880. */
  54881. engine: Nullable<Engine>;
  54882. /**
  54883. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  54884. */
  54885. scene: Nullable<Scene>;
  54886. }
  54887. /**
  54888. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  54889. * To be as efficient as possible depending on your constraints nothing aside the first upload
  54890. * is automatically managed.
  54891. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  54892. * in your application.
  54893. *
  54894. * As the update is not automatic, you need to call them manually.
  54895. */
  54896. export class HtmlElementTexture extends BaseTexture {
  54897. /**
  54898. * The texture URL.
  54899. */
  54900. element: HTMLVideoElement | HTMLCanvasElement;
  54901. private static readonly DefaultOptions;
  54902. private _textureMatrix;
  54903. private _engine;
  54904. private _isVideo;
  54905. private _generateMipMaps;
  54906. private _samplingMode;
  54907. /**
  54908. * Instantiates a HtmlElementTexture from the following parameters.
  54909. *
  54910. * @param name Defines the name of the texture
  54911. * @param element Defines the video or canvas the texture is filled with
  54912. * @param options Defines the other none mandatory texture creation options
  54913. */
  54914. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  54915. private _createInternalTexture;
  54916. /**
  54917. * Returns the texture matrix used in most of the material.
  54918. */
  54919. getTextureMatrix(): Matrix;
  54920. /**
  54921. * Updates the content of the texture.
  54922. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  54923. */
  54924. update(invertY?: Nullable<boolean>): void;
  54925. }
  54926. }
  54927. declare module "babylonjs/Materials/Textures/index" {
  54928. export * from "babylonjs/Materials/Textures/baseTexture";
  54929. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  54930. export * from "babylonjs/Materials/Textures/cubeTexture";
  54931. export * from "babylonjs/Materials/Textures/dynamicTexture";
  54932. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  54933. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  54934. export * from "babylonjs/Materials/Textures/internalTexture";
  54935. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  54936. export * from "babylonjs/Materials/Textures/Loaders/index";
  54937. export * from "babylonjs/Materials/Textures/mirrorTexture";
  54938. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  54939. export * from "babylonjs/Materials/Textures/Procedurals/index";
  54940. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  54941. export * from "babylonjs/Materials/Textures/rawTexture";
  54942. export * from "babylonjs/Materials/Textures/rawTexture3D";
  54943. export * from "babylonjs/Materials/Textures/refractionTexture";
  54944. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  54945. export * from "babylonjs/Materials/Textures/texture";
  54946. export * from "babylonjs/Materials/Textures/videoTexture";
  54947. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  54948. }
  54949. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  54950. /**
  54951. * Enum used to define the target of a block
  54952. */
  54953. export enum NodeMaterialBlockTargets {
  54954. /** Vertex shader */
  54955. Vertex = 1,
  54956. /** Fragment shader */
  54957. Fragment = 2,
  54958. /** Neutral */
  54959. Neutral = 4,
  54960. /** Vertex and Fragment */
  54961. VertexAndFragment = 3
  54962. }
  54963. }
  54964. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  54965. /**
  54966. * Defines the kind of connection point for node based material
  54967. */
  54968. export enum NodeMaterialBlockConnectionPointTypes {
  54969. /** Float */
  54970. Float = 1,
  54971. /** Int */
  54972. Int = 2,
  54973. /** Vector2 */
  54974. Vector2 = 4,
  54975. /** Vector3 */
  54976. Vector3 = 8,
  54977. /** Vector4 */
  54978. Vector4 = 16,
  54979. /** Color3 */
  54980. Color3 = 32,
  54981. /** Color4 */
  54982. Color4 = 64,
  54983. /** Matrix */
  54984. Matrix = 128,
  54985. /** Detect type based on connection */
  54986. AutoDetect = 1024,
  54987. /** Output type that will be defined by input type */
  54988. BasedOnInput = 2048
  54989. }
  54990. }
  54991. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  54992. /**
  54993. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  54994. */
  54995. export enum NodeMaterialBlockConnectionPointMode {
  54996. /** Value is an uniform */
  54997. Uniform = 0,
  54998. /** Value is a mesh attribute */
  54999. Attribute = 1,
  55000. /** Value is a varying between vertex and fragment shaders */
  55001. Varying = 2,
  55002. /** Mode is undefined */
  55003. Undefined = 3
  55004. }
  55005. }
  55006. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  55007. /**
  55008. * Enum used to define system values e.g. values automatically provided by the system
  55009. */
  55010. export enum NodeMaterialSystemValues {
  55011. /** World */
  55012. World = 1,
  55013. /** View */
  55014. View = 2,
  55015. /** Projection */
  55016. Projection = 3,
  55017. /** ViewProjection */
  55018. ViewProjection = 4,
  55019. /** WorldView */
  55020. WorldView = 5,
  55021. /** WorldViewProjection */
  55022. WorldViewProjection = 6,
  55023. /** CameraPosition */
  55024. CameraPosition = 7,
  55025. /** Fog Color */
  55026. FogColor = 8,
  55027. /** Delta time */
  55028. DeltaTime = 9
  55029. }
  55030. }
  55031. declare module "babylonjs/Materials/Node/Enums/index" {
  55032. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55033. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55034. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  55035. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  55036. }
  55037. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  55038. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55039. /**
  55040. * Root class for all node material optimizers
  55041. */
  55042. export class NodeMaterialOptimizer {
  55043. /**
  55044. * Function used to optimize a NodeMaterial graph
  55045. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  55046. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  55047. */
  55048. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  55049. }
  55050. }
  55051. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  55052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55055. import { Scene } from "babylonjs/scene";
  55056. /**
  55057. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  55058. */
  55059. export class TransformBlock extends NodeMaterialBlock {
  55060. /**
  55061. * Defines the value to use to complement W value to transform it to a Vector4
  55062. */
  55063. complementW: number;
  55064. /**
  55065. * Defines the value to use to complement z value to transform it to a Vector4
  55066. */
  55067. complementZ: number;
  55068. /**
  55069. * Creates a new TransformBlock
  55070. * @param name defines the block name
  55071. */
  55072. constructor(name: string);
  55073. /**
  55074. * Gets the current class name
  55075. * @returns the class name
  55076. */
  55077. getClassName(): string;
  55078. /**
  55079. * Gets the vector input
  55080. */
  55081. readonly vector: NodeMaterialConnectionPoint;
  55082. /**
  55083. * Gets the output component
  55084. */
  55085. readonly output: NodeMaterialConnectionPoint;
  55086. /**
  55087. * Gets the matrix transform input
  55088. */
  55089. readonly transform: NodeMaterialConnectionPoint;
  55090. protected _buildBlock(state: NodeMaterialBuildState): this;
  55091. serialize(): any;
  55092. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55093. protected _dumpPropertiesCode(): string;
  55094. }
  55095. }
  55096. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  55097. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55098. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55099. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55100. /**
  55101. * Block used to output the vertex position
  55102. */
  55103. export class VertexOutputBlock extends NodeMaterialBlock {
  55104. /**
  55105. * Creates a new VertexOutputBlock
  55106. * @param name defines the block name
  55107. */
  55108. constructor(name: string);
  55109. /**
  55110. * Gets the current class name
  55111. * @returns the class name
  55112. */
  55113. getClassName(): string;
  55114. /**
  55115. * Gets the vector input component
  55116. */
  55117. readonly vector: NodeMaterialConnectionPoint;
  55118. protected _buildBlock(state: NodeMaterialBuildState): this;
  55119. }
  55120. }
  55121. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  55122. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55123. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55124. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55125. /**
  55126. * Block used to output the final color
  55127. */
  55128. export class FragmentOutputBlock extends NodeMaterialBlock {
  55129. /**
  55130. * Create a new FragmentOutputBlock
  55131. * @param name defines the block name
  55132. */
  55133. constructor(name: string);
  55134. /**
  55135. * Gets the current class name
  55136. * @returns the class name
  55137. */
  55138. getClassName(): string;
  55139. /**
  55140. * Gets the rgba input component
  55141. */
  55142. readonly rgba: NodeMaterialConnectionPoint;
  55143. /**
  55144. * Gets the rgb input component
  55145. */
  55146. readonly rgb: NodeMaterialConnectionPoint;
  55147. /**
  55148. * Gets the a input component
  55149. */
  55150. readonly a: NodeMaterialConnectionPoint;
  55151. protected _buildBlock(state: NodeMaterialBuildState): this;
  55152. }
  55153. }
  55154. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  55155. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55156. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55157. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55158. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55159. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55160. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55161. import { Effect } from "babylonjs/Materials/effect";
  55162. import { Mesh } from "babylonjs/Meshes/mesh";
  55163. import { Nullable } from "babylonjs/types";
  55164. import { Scene } from "babylonjs/scene";
  55165. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  55166. /**
  55167. * Block used to read a reflection texture from a sampler
  55168. */
  55169. export class ReflectionTextureBlock extends NodeMaterialBlock {
  55170. private _define3DName;
  55171. private _defineCubicName;
  55172. private _defineExplicitName;
  55173. private _defineProjectionName;
  55174. private _defineLocalCubicName;
  55175. private _defineSphericalName;
  55176. private _definePlanarName;
  55177. private _defineEquirectangularName;
  55178. private _defineMirroredEquirectangularFixedName;
  55179. private _defineEquirectangularFixedName;
  55180. private _defineSkyboxName;
  55181. private _cubeSamplerName;
  55182. private _2DSamplerName;
  55183. private _positionUVWName;
  55184. private _directionWName;
  55185. private _reflectionCoordsName;
  55186. private _reflection2DCoordsName;
  55187. private _reflectionColorName;
  55188. private _reflectionMatrixName;
  55189. /**
  55190. * Gets or sets the texture associated with the node
  55191. */
  55192. texture: Nullable<BaseTexture>;
  55193. /**
  55194. * Create a new TextureBlock
  55195. * @param name defines the block name
  55196. */
  55197. constructor(name: string);
  55198. /**
  55199. * Gets the current class name
  55200. * @returns the class name
  55201. */
  55202. getClassName(): string;
  55203. /**
  55204. * Gets the world position input component
  55205. */
  55206. readonly position: NodeMaterialConnectionPoint;
  55207. /**
  55208. * Gets the world position input component
  55209. */
  55210. readonly worldPosition: NodeMaterialConnectionPoint;
  55211. /**
  55212. * Gets the world normal input component
  55213. */
  55214. readonly worldNormal: NodeMaterialConnectionPoint;
  55215. /**
  55216. * Gets the world input component
  55217. */
  55218. readonly world: NodeMaterialConnectionPoint;
  55219. /**
  55220. * Gets the camera (or eye) position component
  55221. */
  55222. readonly cameraPosition: NodeMaterialConnectionPoint;
  55223. /**
  55224. * Gets the view input component
  55225. */
  55226. readonly view: NodeMaterialConnectionPoint;
  55227. /**
  55228. * Gets the rgb output component
  55229. */
  55230. readonly rgb: NodeMaterialConnectionPoint;
  55231. /**
  55232. * Gets the r output component
  55233. */
  55234. readonly r: NodeMaterialConnectionPoint;
  55235. /**
  55236. * Gets the g output component
  55237. */
  55238. readonly g: NodeMaterialConnectionPoint;
  55239. /**
  55240. * Gets the b output component
  55241. */
  55242. readonly b: NodeMaterialConnectionPoint;
  55243. autoConfigure(material: NodeMaterial): void;
  55244. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55245. isReady(): boolean;
  55246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55247. private _injectVertexCode;
  55248. private _writeOutput;
  55249. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55250. serialize(): any;
  55251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55252. }
  55253. }
  55254. declare module "babylonjs/Materials/Node/nodeMaterial" {
  55255. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55256. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  55257. import { Scene } from "babylonjs/scene";
  55258. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55259. import { Matrix } from "babylonjs/Maths/math.vector";
  55260. import { Mesh } from "babylonjs/Meshes/mesh";
  55261. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55262. import { Observable } from "babylonjs/Misc/observable";
  55263. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55264. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  55265. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  55266. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  55267. import { Nullable } from "babylonjs/types";
  55268. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55269. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55270. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55271. /**
  55272. * Interface used to configure the node material editor
  55273. */
  55274. export interface INodeMaterialEditorOptions {
  55275. /** Define the URl to load node editor script */
  55276. editorURL?: string;
  55277. }
  55278. /** @hidden */
  55279. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  55280. /** BONES */
  55281. NUM_BONE_INFLUENCERS: number;
  55282. BonesPerMesh: number;
  55283. BONETEXTURE: boolean;
  55284. /** MORPH TARGETS */
  55285. MORPHTARGETS: boolean;
  55286. MORPHTARGETS_NORMAL: boolean;
  55287. MORPHTARGETS_TANGENT: boolean;
  55288. MORPHTARGETS_UV: boolean;
  55289. NUM_MORPH_INFLUENCERS: number;
  55290. /** IMAGE PROCESSING */
  55291. IMAGEPROCESSING: boolean;
  55292. VIGNETTE: boolean;
  55293. VIGNETTEBLENDMODEMULTIPLY: boolean;
  55294. VIGNETTEBLENDMODEOPAQUE: boolean;
  55295. TONEMAPPING: boolean;
  55296. TONEMAPPING_ACES: boolean;
  55297. CONTRAST: boolean;
  55298. EXPOSURE: boolean;
  55299. COLORCURVES: boolean;
  55300. COLORGRADING: boolean;
  55301. COLORGRADING3D: boolean;
  55302. SAMPLER3DGREENDEPTH: boolean;
  55303. SAMPLER3DBGRMAP: boolean;
  55304. IMAGEPROCESSINGPOSTPROCESS: boolean;
  55305. /** MISC. */
  55306. BUMPDIRECTUV: number;
  55307. constructor();
  55308. setValue(name: string, value: boolean): void;
  55309. }
  55310. /**
  55311. * Class used to configure NodeMaterial
  55312. */
  55313. export interface INodeMaterialOptions {
  55314. /**
  55315. * Defines if blocks should emit comments
  55316. */
  55317. emitComments: boolean;
  55318. }
  55319. /**
  55320. * Class used to create a node based material built by assembling shader blocks
  55321. */
  55322. export class NodeMaterial extends PushMaterial {
  55323. private static _BuildIdGenerator;
  55324. private _options;
  55325. private _vertexCompilationState;
  55326. private _fragmentCompilationState;
  55327. private _sharedData;
  55328. private _buildId;
  55329. private _buildWasSuccessful;
  55330. private _cachedWorldViewMatrix;
  55331. private _cachedWorldViewProjectionMatrix;
  55332. private _optimizers;
  55333. private _animationFrame;
  55334. /** Define the URl to load node editor script */
  55335. static EditorURL: string;
  55336. private BJSNODEMATERIALEDITOR;
  55337. /** Get the inspector from bundle or global */
  55338. private _getGlobalNodeMaterialEditor;
  55339. /**
  55340. * 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)
  55341. */
  55342. ignoreAlpha: boolean;
  55343. /**
  55344. * Defines the maximum number of lights that can be used in the material
  55345. */
  55346. maxSimultaneousLights: number;
  55347. /**
  55348. * Observable raised when the material is built
  55349. */
  55350. onBuildObservable: Observable<NodeMaterial>;
  55351. /**
  55352. * Gets or sets the root nodes of the material vertex shader
  55353. */
  55354. _vertexOutputNodes: NodeMaterialBlock[];
  55355. /**
  55356. * Gets or sets the root nodes of the material fragment (pixel) shader
  55357. */
  55358. _fragmentOutputNodes: NodeMaterialBlock[];
  55359. /** Gets or sets options to control the node material overall behavior */
  55360. options: INodeMaterialOptions;
  55361. /**
  55362. * Default configuration related to image processing available in the standard Material.
  55363. */
  55364. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  55365. /**
  55366. * Gets the image processing configuration used either in this material.
  55367. */
  55368. /**
  55369. * Sets the Default image processing configuration used either in the this material.
  55370. *
  55371. * If sets to null, the scene one is in use.
  55372. */
  55373. imageProcessingConfiguration: ImageProcessingConfiguration;
  55374. /**
  55375. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  55376. */
  55377. attachedBlocks: NodeMaterialBlock[];
  55378. /**
  55379. * Create a new node based material
  55380. * @param name defines the material name
  55381. * @param scene defines the hosting scene
  55382. * @param options defines creation option
  55383. */
  55384. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  55385. /**
  55386. * Gets the current class name of the material e.g. "NodeMaterial"
  55387. * @returns the class name
  55388. */
  55389. getClassName(): string;
  55390. /**
  55391. * Keep track of the image processing observer to allow dispose and replace.
  55392. */
  55393. private _imageProcessingObserver;
  55394. /**
  55395. * Attaches a new image processing configuration to the Standard Material.
  55396. * @param configuration
  55397. */
  55398. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  55399. /**
  55400. * Get a block by its name
  55401. * @param name defines the name of the block to retrieve
  55402. * @returns the required block or null if not found
  55403. */
  55404. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  55405. /**
  55406. * Get a block by its name
  55407. * @param predicate defines the predicate used to find the good candidate
  55408. * @returns the required block or null if not found
  55409. */
  55410. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  55411. /**
  55412. * Get an input block by its name
  55413. * @param predicate defines the predicate used to find the good candidate
  55414. * @returns the required input block or null if not found
  55415. */
  55416. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  55417. /**
  55418. * Gets the list of input blocks attached to this material
  55419. * @returns an array of InputBlocks
  55420. */
  55421. getInputBlocks(): InputBlock[];
  55422. /**
  55423. * Adds a new optimizer to the list of optimizers
  55424. * @param optimizer defines the optimizers to add
  55425. * @returns the current material
  55426. */
  55427. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55428. /**
  55429. * Remove an optimizer from the list of optimizers
  55430. * @param optimizer defines the optimizers to remove
  55431. * @returns the current material
  55432. */
  55433. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  55434. /**
  55435. * Add a new block to the list of output nodes
  55436. * @param node defines the node to add
  55437. * @returns the current material
  55438. */
  55439. addOutputNode(node: NodeMaterialBlock): this;
  55440. /**
  55441. * Remove a block from the list of root nodes
  55442. * @param node defines the node to remove
  55443. * @returns the current material
  55444. */
  55445. removeOutputNode(node: NodeMaterialBlock): this;
  55446. private _addVertexOutputNode;
  55447. private _removeVertexOutputNode;
  55448. private _addFragmentOutputNode;
  55449. private _removeFragmentOutputNode;
  55450. /**
  55451. * Specifies if the material will require alpha blending
  55452. * @returns a boolean specifying if alpha blending is needed
  55453. */
  55454. needAlphaBlending(): boolean;
  55455. /**
  55456. * Specifies if this material should be rendered in alpha test mode
  55457. * @returns a boolean specifying if an alpha test is needed.
  55458. */
  55459. needAlphaTesting(): boolean;
  55460. private _initializeBlock;
  55461. private _resetDualBlocks;
  55462. /**
  55463. * Build the material and generates the inner effect
  55464. * @param verbose defines if the build should log activity
  55465. */
  55466. build(verbose?: boolean): void;
  55467. /**
  55468. * Runs an otpimization phase to try to improve the shader code
  55469. */
  55470. optimize(): void;
  55471. private _prepareDefinesForAttributes;
  55472. /**
  55473. * Get if the submesh is ready to be used and all its information available.
  55474. * Child classes can use it to update shaders
  55475. * @param mesh defines the mesh to check
  55476. * @param subMesh defines which submesh to check
  55477. * @param useInstances specifies that instances should be used
  55478. * @returns a boolean indicating that the submesh is ready or not
  55479. */
  55480. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  55481. /**
  55482. * Get a string representing the shaders built by the current node graph
  55483. */
  55484. readonly compiledShaders: string;
  55485. /**
  55486. * Binds the world matrix to the material
  55487. * @param world defines the world transformation matrix
  55488. */
  55489. bindOnlyWorldMatrix(world: Matrix): void;
  55490. /**
  55491. * Binds the submesh to this material by preparing the effect and shader to draw
  55492. * @param world defines the world transformation matrix
  55493. * @param mesh defines the mesh containing the submesh
  55494. * @param subMesh defines the submesh to bind the material to
  55495. */
  55496. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  55497. /**
  55498. * Gets the active textures from the material
  55499. * @returns an array of textures
  55500. */
  55501. getActiveTextures(): BaseTexture[];
  55502. /**
  55503. * Gets the list of texture blocks
  55504. * @returns an array of texture blocks
  55505. */
  55506. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  55507. /**
  55508. * Specifies if the material uses a texture
  55509. * @param texture defines the texture to check against the material
  55510. * @returns a boolean specifying if the material uses the texture
  55511. */
  55512. hasTexture(texture: BaseTexture): boolean;
  55513. /**
  55514. * Disposes the material
  55515. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  55516. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  55517. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  55518. */
  55519. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  55520. /** Creates the node editor window. */
  55521. private _createNodeEditor;
  55522. /**
  55523. * Launch the node material editor
  55524. * @param config Define the configuration of the editor
  55525. * @return a promise fulfilled when the node editor is visible
  55526. */
  55527. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  55528. /**
  55529. * Clear the current material
  55530. */
  55531. clear(): void;
  55532. /**
  55533. * Clear the current material and set it to a default state
  55534. */
  55535. setToDefault(): void;
  55536. /**
  55537. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  55538. * @param url defines the url to load from
  55539. * @returns a promise that will fullfil when the material is fully loaded
  55540. */
  55541. loadAsync(url: string): Promise<unknown>;
  55542. private _gatherBlocks;
  55543. /**
  55544. * Generate a string containing the code declaration required to create an equivalent of this material
  55545. * @returns a string
  55546. */
  55547. generateCode(): string;
  55548. /**
  55549. * Serializes this material in a JSON representation
  55550. * @returns the serialized material object
  55551. */
  55552. serialize(): any;
  55553. private _restoreConnections;
  55554. /**
  55555. * Clear the current graph and load a new one from a serialization object
  55556. * @param source defines the JSON representation of the material
  55557. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55558. */
  55559. loadFromSerialization(source: any, rootUrl?: string): void;
  55560. /**
  55561. * Creates a node material from parsed material data
  55562. * @param source defines the JSON representation of the material
  55563. * @param scene defines the hosting scene
  55564. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  55565. * @returns a new node material
  55566. */
  55567. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  55568. /**
  55569. * Creates a new node material set to default basic configuration
  55570. * @param name defines the name of the material
  55571. * @param scene defines the hosting scene
  55572. * @returns a new NodeMaterial
  55573. */
  55574. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  55575. }
  55576. }
  55577. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  55578. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55579. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55580. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55581. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55582. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55583. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55584. import { Effect } from "babylonjs/Materials/effect";
  55585. import { Mesh } from "babylonjs/Meshes/mesh";
  55586. import { Nullable } from "babylonjs/types";
  55587. import { Texture } from "babylonjs/Materials/Textures/texture";
  55588. import { Scene } from "babylonjs/scene";
  55589. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55590. /**
  55591. * Block used to read a texture from a sampler
  55592. */
  55593. export class TextureBlock extends NodeMaterialBlock {
  55594. private _defineName;
  55595. private _linearDefineName;
  55596. private _samplerName;
  55597. private _transformedUVName;
  55598. private _textureTransformName;
  55599. private _textureInfoName;
  55600. private _mainUVName;
  55601. private _mainUVDefineName;
  55602. /**
  55603. * Gets or sets the texture associated with the node
  55604. */
  55605. texture: Nullable<Texture>;
  55606. /**
  55607. * Create a new TextureBlock
  55608. * @param name defines the block name
  55609. */
  55610. constructor(name: string);
  55611. /**
  55612. * Gets the current class name
  55613. * @returns the class name
  55614. */
  55615. getClassName(): string;
  55616. /**
  55617. * Gets the uv input component
  55618. */
  55619. readonly uv: NodeMaterialConnectionPoint;
  55620. /**
  55621. * Gets the rgba output component
  55622. */
  55623. readonly rgba: NodeMaterialConnectionPoint;
  55624. /**
  55625. * Gets the rgb output component
  55626. */
  55627. readonly rgb: NodeMaterialConnectionPoint;
  55628. /**
  55629. * Gets the r output component
  55630. */
  55631. readonly r: NodeMaterialConnectionPoint;
  55632. /**
  55633. * Gets the g output component
  55634. */
  55635. readonly g: NodeMaterialConnectionPoint;
  55636. /**
  55637. * Gets the b output component
  55638. */
  55639. readonly b: NodeMaterialConnectionPoint;
  55640. /**
  55641. * Gets the a output component
  55642. */
  55643. readonly a: NodeMaterialConnectionPoint;
  55644. readonly target: NodeMaterialBlockTargets;
  55645. autoConfigure(material: NodeMaterial): void;
  55646. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  55647. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  55648. isReady(): boolean;
  55649. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55650. private readonly _isMixed;
  55651. private _injectVertexCode;
  55652. private _writeOutput;
  55653. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  55654. protected _dumpPropertiesCode(): string;
  55655. serialize(): any;
  55656. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  55657. }
  55658. }
  55659. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  55660. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55661. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  55662. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  55663. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  55664. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  55665. import { Scene } from "babylonjs/scene";
  55666. /**
  55667. * Class used to store shared data between 2 NodeMaterialBuildState
  55668. */
  55669. export class NodeMaterialBuildStateSharedData {
  55670. /**
  55671. * Gets the list of emitted varyings
  55672. */
  55673. temps: string[];
  55674. /**
  55675. * Gets the list of emitted varyings
  55676. */
  55677. varyings: string[];
  55678. /**
  55679. * Gets the varying declaration string
  55680. */
  55681. varyingDeclaration: string;
  55682. /**
  55683. * Input blocks
  55684. */
  55685. inputBlocks: InputBlock[];
  55686. /**
  55687. * Input blocks
  55688. */
  55689. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  55690. /**
  55691. * Bindable blocks (Blocks that need to set data to the effect)
  55692. */
  55693. bindableBlocks: NodeMaterialBlock[];
  55694. /**
  55695. * List of blocks that can provide a compilation fallback
  55696. */
  55697. blocksWithFallbacks: NodeMaterialBlock[];
  55698. /**
  55699. * List of blocks that can provide a define update
  55700. */
  55701. blocksWithDefines: NodeMaterialBlock[];
  55702. /**
  55703. * List of blocks that can provide a repeatable content
  55704. */
  55705. repeatableContentBlocks: NodeMaterialBlock[];
  55706. /**
  55707. * List of blocks that can provide a dynamic list of uniforms
  55708. */
  55709. dynamicUniformBlocks: NodeMaterialBlock[];
  55710. /**
  55711. * List of blocks that can block the isReady function for the material
  55712. */
  55713. blockingBlocks: NodeMaterialBlock[];
  55714. /**
  55715. * Gets the list of animated inputs
  55716. */
  55717. animatedInputs: InputBlock[];
  55718. /**
  55719. * Build Id used to avoid multiple recompilations
  55720. */
  55721. buildId: number;
  55722. /** List of emitted variables */
  55723. variableNames: {
  55724. [key: string]: number;
  55725. };
  55726. /** List of emitted defines */
  55727. defineNames: {
  55728. [key: string]: number;
  55729. };
  55730. /** Should emit comments? */
  55731. emitComments: boolean;
  55732. /** Emit build activity */
  55733. verbose: boolean;
  55734. /** Gets or sets the hosting scene */
  55735. scene: Scene;
  55736. /**
  55737. * Gets the compilation hints emitted at compilation time
  55738. */
  55739. hints: {
  55740. needWorldViewMatrix: boolean;
  55741. needWorldViewProjectionMatrix: boolean;
  55742. needAlphaBlending: boolean;
  55743. needAlphaTesting: boolean;
  55744. };
  55745. /**
  55746. * List of compilation checks
  55747. */
  55748. checks: {
  55749. emitVertex: boolean;
  55750. emitFragment: boolean;
  55751. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  55752. };
  55753. /** Creates a new shared data */
  55754. constructor();
  55755. /**
  55756. * Emits console errors and exceptions if there is a failing check
  55757. */
  55758. emitErrors(): void;
  55759. }
  55760. }
  55761. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  55762. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55763. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55764. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  55765. /**
  55766. * Class used to store node based material build state
  55767. */
  55768. export class NodeMaterialBuildState {
  55769. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  55770. supportUniformBuffers: boolean;
  55771. /**
  55772. * Gets the list of emitted attributes
  55773. */
  55774. attributes: string[];
  55775. /**
  55776. * Gets the list of emitted uniforms
  55777. */
  55778. uniforms: string[];
  55779. /**
  55780. * Gets the list of emitted constants
  55781. */
  55782. constants: string[];
  55783. /**
  55784. * Gets the list of emitted uniform buffers
  55785. */
  55786. uniformBuffers: string[];
  55787. /**
  55788. * Gets the list of emitted samplers
  55789. */
  55790. samplers: string[];
  55791. /**
  55792. * Gets the list of emitted functions
  55793. */
  55794. functions: {
  55795. [key: string]: string;
  55796. };
  55797. /**
  55798. * Gets the list of emitted extensions
  55799. */
  55800. extensions: {
  55801. [key: string]: string;
  55802. };
  55803. /**
  55804. * Gets the target of the compilation state
  55805. */
  55806. target: NodeMaterialBlockTargets;
  55807. /**
  55808. * Gets the list of emitted counters
  55809. */
  55810. counters: {
  55811. [key: string]: number;
  55812. };
  55813. /**
  55814. * Shared data between multiple NodeMaterialBuildState instances
  55815. */
  55816. sharedData: NodeMaterialBuildStateSharedData;
  55817. /** @hidden */
  55818. _vertexState: NodeMaterialBuildState;
  55819. /** @hidden */
  55820. _attributeDeclaration: string;
  55821. /** @hidden */
  55822. _uniformDeclaration: string;
  55823. /** @hidden */
  55824. _constantDeclaration: string;
  55825. /** @hidden */
  55826. _samplerDeclaration: string;
  55827. /** @hidden */
  55828. _varyingTransfer: string;
  55829. private _repeatableContentAnchorIndex;
  55830. /** @hidden */
  55831. _builtCompilationString: string;
  55832. /**
  55833. * Gets the emitted compilation strings
  55834. */
  55835. compilationString: string;
  55836. /**
  55837. * Finalize the compilation strings
  55838. * @param state defines the current compilation state
  55839. */
  55840. finalize(state: NodeMaterialBuildState): void;
  55841. /** @hidden */
  55842. readonly _repeatableContentAnchor: string;
  55843. /** @hidden */
  55844. _getFreeVariableName(prefix: string): string;
  55845. /** @hidden */
  55846. _getFreeDefineName(prefix: string): string;
  55847. /** @hidden */
  55848. _excludeVariableName(name: string): void;
  55849. /** @hidden */
  55850. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  55851. /** @hidden */
  55852. _emitExtension(name: string, extension: string): void;
  55853. /** @hidden */
  55854. _emitFunction(name: string, code: string, comments: string): void;
  55855. /** @hidden */
  55856. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  55857. replaceStrings?: {
  55858. search: RegExp;
  55859. replace: string;
  55860. }[];
  55861. repeatKey?: string;
  55862. }): string;
  55863. /** @hidden */
  55864. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  55865. repeatKey?: string;
  55866. removeAttributes?: boolean;
  55867. removeUniforms?: boolean;
  55868. removeVaryings?: boolean;
  55869. removeIfDef?: boolean;
  55870. replaceStrings?: {
  55871. search: RegExp;
  55872. replace: string;
  55873. }[];
  55874. }, storeKey?: string): void;
  55875. /** @hidden */
  55876. _registerTempVariable(name: string): boolean;
  55877. /** @hidden */
  55878. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  55879. /** @hidden */
  55880. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  55881. /** @hidden */
  55882. _emitFloat(value: number): string;
  55883. }
  55884. }
  55885. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  55886. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  55887. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  55888. import { Nullable } from "babylonjs/types";
  55889. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  55890. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  55891. import { Effect } from "babylonjs/Materials/effect";
  55892. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55893. import { Mesh } from "babylonjs/Meshes/mesh";
  55894. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  55895. import { Scene } from "babylonjs/scene";
  55896. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  55897. /**
  55898. * Defines a block that can be used inside a node based material
  55899. */
  55900. export class NodeMaterialBlock {
  55901. private _buildId;
  55902. private _buildTarget;
  55903. private _target;
  55904. private _isFinalMerger;
  55905. private _isInput;
  55906. /** @hidden */
  55907. _codeVariableName: string;
  55908. /** @hidden */
  55909. _inputs: NodeMaterialConnectionPoint[];
  55910. /** @hidden */
  55911. _outputs: NodeMaterialConnectionPoint[];
  55912. /** @hidden */
  55913. _preparationId: number;
  55914. /**
  55915. * Gets or sets the name of the block
  55916. */
  55917. name: string;
  55918. /**
  55919. * Gets or sets the unique id of the node
  55920. */
  55921. uniqueId: number;
  55922. /**
  55923. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  55924. */
  55925. readonly isFinalMerger: boolean;
  55926. /**
  55927. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  55928. */
  55929. readonly isInput: boolean;
  55930. /**
  55931. * Gets or sets the build Id
  55932. */
  55933. buildId: number;
  55934. /**
  55935. * Gets or sets the target of the block
  55936. */
  55937. target: NodeMaterialBlockTargets;
  55938. /**
  55939. * Gets the list of input points
  55940. */
  55941. readonly inputs: NodeMaterialConnectionPoint[];
  55942. /** Gets the list of output points */
  55943. readonly outputs: NodeMaterialConnectionPoint[];
  55944. /**
  55945. * Find an input by its name
  55946. * @param name defines the name of the input to look for
  55947. * @returns the input or null if not found
  55948. */
  55949. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55950. /**
  55951. * Find an output by its name
  55952. * @param name defines the name of the outputto look for
  55953. * @returns the output or null if not found
  55954. */
  55955. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  55956. /**
  55957. * Creates a new NodeMaterialBlock
  55958. * @param name defines the block name
  55959. * @param target defines the target of that block (Vertex by default)
  55960. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  55961. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  55962. */
  55963. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  55964. /**
  55965. * Initialize the block and prepare the context for build
  55966. * @param state defines the state that will be used for the build
  55967. */
  55968. initialize(state: NodeMaterialBuildState): void;
  55969. /**
  55970. * Bind data to effect. Will only be called for blocks with isBindable === true
  55971. * @param effect defines the effect to bind data to
  55972. * @param nodeMaterial defines the hosting NodeMaterial
  55973. * @param mesh defines the mesh that will be rendered
  55974. */
  55975. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  55976. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  55977. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  55978. protected _writeFloat(value: number): string;
  55979. /**
  55980. * Gets the current class name e.g. "NodeMaterialBlock"
  55981. * @returns the class name
  55982. */
  55983. getClassName(): string;
  55984. /**
  55985. * Register a new input. Must be called inside a block constructor
  55986. * @param name defines the connection point name
  55987. * @param type defines the connection point type
  55988. * @param isOptional defines a boolean indicating that this input can be omitted
  55989. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55990. * @returns the current block
  55991. */
  55992. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  55993. /**
  55994. * Register a new output. Must be called inside a block constructor
  55995. * @param name defines the connection point name
  55996. * @param type defines the connection point type
  55997. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  55998. * @returns the current block
  55999. */
  56000. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  56001. /**
  56002. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  56003. * @param forOutput defines an optional connection point to check compatibility with
  56004. * @returns the first available input or null
  56005. */
  56006. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  56007. /**
  56008. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  56009. * @param forBlock defines an optional block to check compatibility with
  56010. * @returns the first available input or null
  56011. */
  56012. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  56013. /**
  56014. * Gets the sibling of the given output
  56015. * @param current defines the current output
  56016. * @returns the next output in the list or null
  56017. */
  56018. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  56019. /**
  56020. * Connect current block with another block
  56021. * @param other defines the block to connect with
  56022. * @param options define the various options to help pick the right connections
  56023. * @returns the current block
  56024. */
  56025. connectTo(other: NodeMaterialBlock, options?: {
  56026. input?: string;
  56027. output?: string;
  56028. outputSwizzle?: string;
  56029. }): this | undefined;
  56030. protected _buildBlock(state: NodeMaterialBuildState): void;
  56031. /**
  56032. * Add uniforms, samplers and uniform buffers at compilation time
  56033. * @param state defines the state to update
  56034. * @param nodeMaterial defines the node material requesting the update
  56035. * @param defines defines the material defines to update
  56036. */
  56037. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56038. /**
  56039. * Add potential fallbacks if shader compilation fails
  56040. * @param mesh defines the mesh to be rendered
  56041. * @param fallbacks defines the current prioritized list of fallbacks
  56042. */
  56043. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56044. /**
  56045. * Initialize defines for shader compilation
  56046. * @param mesh defines the mesh to be rendered
  56047. * @param nodeMaterial defines the node material requesting the update
  56048. * @param defines defines the material defines to update
  56049. * @param useInstances specifies that instances should be used
  56050. */
  56051. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56052. /**
  56053. * Update defines for shader compilation
  56054. * @param mesh defines the mesh to be rendered
  56055. * @param nodeMaterial defines the node material requesting the update
  56056. * @param defines defines the material defines to update
  56057. * @param useInstances specifies that instances should be used
  56058. */
  56059. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56060. /**
  56061. * Lets the block try to connect some inputs automatically
  56062. * @param material defines the hosting NodeMaterial
  56063. */
  56064. autoConfigure(material: NodeMaterial): void;
  56065. /**
  56066. * Function called when a block is declared as repeatable content generator
  56067. * @param vertexShaderState defines the current compilation state for the vertex shader
  56068. * @param fragmentShaderState defines the current compilation state for the fragment shader
  56069. * @param mesh defines the mesh to be rendered
  56070. * @param defines defines the material defines to update
  56071. */
  56072. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56073. /**
  56074. * Checks if the block is ready
  56075. * @param mesh defines the mesh to be rendered
  56076. * @param nodeMaterial defines the node material requesting the update
  56077. * @param defines defines the material defines to update
  56078. * @param useInstances specifies that instances should be used
  56079. * @returns true if the block is ready
  56080. */
  56081. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  56082. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  56083. private _processBuild;
  56084. /**
  56085. * Compile the current node and generate the shader code
  56086. * @param state defines the current compilation state (uniforms, samplers, current string)
  56087. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  56088. * @returns true if already built
  56089. */
  56090. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  56091. protected _inputRename(name: string): string;
  56092. protected _outputRename(name: string): string;
  56093. protected _dumpPropertiesCode(): string;
  56094. /** @hidden */
  56095. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  56096. /**
  56097. * Clone the current block to a new identical block
  56098. * @param scene defines the hosting scene
  56099. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  56100. * @returns a copy of the current block
  56101. */
  56102. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  56103. /**
  56104. * Serializes this block in a JSON representation
  56105. * @returns the serialized block object
  56106. */
  56107. serialize(): any;
  56108. /** @hidden */
  56109. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56110. }
  56111. }
  56112. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  56113. /**
  56114. * Enum defining the type of animations supported by InputBlock
  56115. */
  56116. export enum AnimatedInputBlockTypes {
  56117. /** No animation */
  56118. None = 0,
  56119. /** Time based animation. Will only work for floats */
  56120. Time = 1
  56121. }
  56122. }
  56123. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  56124. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56125. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56126. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  56127. import { Nullable } from "babylonjs/types";
  56128. import { Effect } from "babylonjs/Materials/effect";
  56129. import { Matrix } from "babylonjs/Maths/math.vector";
  56130. import { Scene } from "babylonjs/scene";
  56131. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56132. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56133. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56134. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56135. /**
  56136. * Block used to expose an input value
  56137. */
  56138. export class InputBlock extends NodeMaterialBlock {
  56139. private _mode;
  56140. private _associatedVariableName;
  56141. private _storedValue;
  56142. private _valueCallback;
  56143. private _type;
  56144. private _animationType;
  56145. /** Gets or set a value used to limit the range of float values */
  56146. min: number;
  56147. /** Gets or set a value used to limit the range of float values */
  56148. max: number;
  56149. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  56150. matrixMode: number;
  56151. /** @hidden */
  56152. _systemValue: Nullable<NodeMaterialSystemValues>;
  56153. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  56154. visibleInInspector: boolean;
  56155. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  56156. isConstant: boolean;
  56157. /**
  56158. * Gets or sets the connection point type (default is float)
  56159. */
  56160. readonly type: NodeMaterialBlockConnectionPointTypes;
  56161. /**
  56162. * Creates a new InputBlock
  56163. * @param name defines the block name
  56164. * @param target defines the target of that block (Vertex by default)
  56165. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  56166. */
  56167. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  56168. /**
  56169. * Gets the output component
  56170. */
  56171. readonly output: NodeMaterialConnectionPoint;
  56172. /**
  56173. * Set the source of this connection point to a vertex attribute
  56174. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  56175. * @returns the current connection point
  56176. */
  56177. setAsAttribute(attributeName?: string): InputBlock;
  56178. /**
  56179. * Set the source of this connection point to a system value
  56180. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  56181. * @returns the current connection point
  56182. */
  56183. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  56184. /**
  56185. * Gets or sets the value of that point.
  56186. * Please note that this value will be ignored if valueCallback is defined
  56187. */
  56188. value: any;
  56189. /**
  56190. * Gets or sets a callback used to get the value of that point.
  56191. * Please note that setting this value will force the connection point to ignore the value property
  56192. */
  56193. valueCallback: () => any;
  56194. /**
  56195. * Gets or sets the associated variable name in the shader
  56196. */
  56197. associatedVariableName: string;
  56198. /** Gets or sets the type of animation applied to the input */
  56199. animationType: AnimatedInputBlockTypes;
  56200. /**
  56201. * Gets a boolean indicating that this connection point not defined yet
  56202. */
  56203. readonly isUndefined: boolean;
  56204. /**
  56205. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  56206. * In this case the connection point name must be the name of the uniform to use.
  56207. * Can only be set on inputs
  56208. */
  56209. isUniform: boolean;
  56210. /**
  56211. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  56212. * In this case the connection point name must be the name of the attribute to use
  56213. * Can only be set on inputs
  56214. */
  56215. isAttribute: boolean;
  56216. /**
  56217. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  56218. * Can only be set on exit points
  56219. */
  56220. isVarying: boolean;
  56221. /**
  56222. * Gets a boolean indicating that the current connection point is a system value
  56223. */
  56224. readonly isSystemValue: boolean;
  56225. /**
  56226. * Gets or sets the current well known value or null if not defined as a system value
  56227. */
  56228. systemValue: Nullable<NodeMaterialSystemValues>;
  56229. /**
  56230. * Gets the current class name
  56231. * @returns the class name
  56232. */
  56233. getClassName(): string;
  56234. /**
  56235. * Animate the input if animationType !== None
  56236. * @param scene defines the rendering scene
  56237. */
  56238. animate(scene: Scene): void;
  56239. private _emitDefine;
  56240. initialize(state: NodeMaterialBuildState): void;
  56241. /**
  56242. * Set the input block to its default value (based on its type)
  56243. */
  56244. setDefaultValue(): void;
  56245. private _emitConstant;
  56246. private _emit;
  56247. /** @hidden */
  56248. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  56249. /** @hidden */
  56250. _transmit(effect: Effect, scene: Scene): void;
  56251. protected _buildBlock(state: NodeMaterialBuildState): void;
  56252. protected _dumpPropertiesCode(): string;
  56253. serialize(): any;
  56254. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56255. }
  56256. }
  56257. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  56258. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  56259. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  56260. import { Nullable } from "babylonjs/types";
  56261. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56262. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56263. /**
  56264. * Defines a connection point for a block
  56265. */
  56266. export class NodeMaterialConnectionPoint {
  56267. /** @hidden */
  56268. _ownerBlock: NodeMaterialBlock;
  56269. /** @hidden */
  56270. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56271. private _endpoints;
  56272. private _associatedVariableName;
  56273. /** @hidden */
  56274. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56275. /** @hidden */
  56276. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  56277. private _type;
  56278. /** @hidden */
  56279. _enforceAssociatedVariableName: boolean;
  56280. /**
  56281. * Gets or sets the additional types supported by this connection point
  56282. */
  56283. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56284. /**
  56285. * Gets or sets the additional types excluded by this connection point
  56286. */
  56287. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  56288. /**
  56289. * Gets or sets the associated variable name in the shader
  56290. */
  56291. associatedVariableName: string;
  56292. /**
  56293. * Gets or sets the connection point type (default is float)
  56294. */
  56295. type: NodeMaterialBlockConnectionPointTypes;
  56296. /**
  56297. * Gets or sets the connection point name
  56298. */
  56299. name: string;
  56300. /**
  56301. * Gets or sets a boolean indicating that this connection point can be omitted
  56302. */
  56303. isOptional: boolean;
  56304. /**
  56305. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  56306. */
  56307. define: string;
  56308. /** Gets or sets the target of that connection point */
  56309. target: NodeMaterialBlockTargets;
  56310. /**
  56311. * Gets a boolean indicating that the current point is connected
  56312. */
  56313. readonly isConnected: boolean;
  56314. /**
  56315. * Gets a boolean indicating that the current point is connected to an input block
  56316. */
  56317. readonly isConnectedToInputBlock: boolean;
  56318. /**
  56319. * Gets a the connected input block (if any)
  56320. */
  56321. readonly connectInputBlock: Nullable<InputBlock>;
  56322. /** Get the other side of the connection (if any) */
  56323. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  56324. /** Get the block that owns this connection point */
  56325. readonly ownerBlock: NodeMaterialBlock;
  56326. /** Get the block connected on the other side of this connection (if any) */
  56327. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  56328. /** Get the block connected on the endpoints of this connection (if any) */
  56329. readonly connectedBlocks: Array<NodeMaterialBlock>;
  56330. /** Gets the list of connected endpoints */
  56331. readonly endpoints: NodeMaterialConnectionPoint[];
  56332. /** Gets a boolean indicating if that output point is connected to at least one input */
  56333. readonly hasEndpoints: boolean;
  56334. /**
  56335. * Creates a new connection point
  56336. * @param name defines the connection point name
  56337. * @param ownerBlock defines the block hosting this connection point
  56338. */
  56339. constructor(name: string, ownerBlock: NodeMaterialBlock);
  56340. /**
  56341. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  56342. * @returns the class name
  56343. */
  56344. getClassName(): string;
  56345. /**
  56346. * Gets an boolean indicating if the current point can be connected to another point
  56347. * @param connectionPoint defines the other connection point
  56348. * @returns true if the connection is possible
  56349. */
  56350. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  56351. /**
  56352. * Connect this point to another connection point
  56353. * @param connectionPoint defines the other connection point
  56354. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  56355. * @returns the current connection point
  56356. */
  56357. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  56358. /**
  56359. * Disconnect this point from one of his endpoint
  56360. * @param endpoint defines the other connection point
  56361. * @returns the current connection point
  56362. */
  56363. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  56364. /**
  56365. * Serializes this point in a JSON representation
  56366. * @returns the serialized point object
  56367. */
  56368. serialize(): any;
  56369. }
  56370. }
  56371. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  56372. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56373. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56374. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56375. import { Mesh } from "babylonjs/Meshes/mesh";
  56376. import { Effect } from "babylonjs/Materials/effect";
  56377. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56378. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56379. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56380. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56381. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  56382. /**
  56383. * Block used to add support for vertex skinning (bones)
  56384. */
  56385. export class BonesBlock extends NodeMaterialBlock {
  56386. /**
  56387. * Creates a new BonesBlock
  56388. * @param name defines the block name
  56389. */
  56390. constructor(name: string);
  56391. /**
  56392. * Initialize the block and prepare the context for build
  56393. * @param state defines the state that will be used for the build
  56394. */
  56395. initialize(state: NodeMaterialBuildState): void;
  56396. /**
  56397. * Gets the current class name
  56398. * @returns the class name
  56399. */
  56400. getClassName(): string;
  56401. /**
  56402. * Gets the matrix indices input component
  56403. */
  56404. readonly matricesIndices: NodeMaterialConnectionPoint;
  56405. /**
  56406. * Gets the matrix weights input component
  56407. */
  56408. readonly matricesWeights: NodeMaterialConnectionPoint;
  56409. /**
  56410. * Gets the extra matrix indices input component
  56411. */
  56412. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  56413. /**
  56414. * Gets the extra matrix weights input component
  56415. */
  56416. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  56417. /**
  56418. * Gets the world input component
  56419. */
  56420. readonly world: NodeMaterialConnectionPoint;
  56421. /**
  56422. * Gets the output component
  56423. */
  56424. readonly output: NodeMaterialConnectionPoint;
  56425. autoConfigure(material: NodeMaterial): void;
  56426. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  56427. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56428. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56429. protected _buildBlock(state: NodeMaterialBuildState): this;
  56430. }
  56431. }
  56432. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  56433. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56434. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56435. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56436. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56437. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56438. /**
  56439. * Block used to add support for instances
  56440. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  56441. */
  56442. export class InstancesBlock extends NodeMaterialBlock {
  56443. /**
  56444. * Creates a new InstancesBlock
  56445. * @param name defines the block name
  56446. */
  56447. constructor(name: string);
  56448. /**
  56449. * Gets the current class name
  56450. * @returns the class name
  56451. */
  56452. getClassName(): string;
  56453. /**
  56454. * Gets the first world row input component
  56455. */
  56456. readonly world0: NodeMaterialConnectionPoint;
  56457. /**
  56458. * Gets the second world row input component
  56459. */
  56460. readonly world1: NodeMaterialConnectionPoint;
  56461. /**
  56462. * Gets the third world row input component
  56463. */
  56464. readonly world2: NodeMaterialConnectionPoint;
  56465. /**
  56466. * Gets the forth world row input component
  56467. */
  56468. readonly world3: NodeMaterialConnectionPoint;
  56469. /**
  56470. * Gets the world input component
  56471. */
  56472. readonly world: NodeMaterialConnectionPoint;
  56473. /**
  56474. * Gets the output component
  56475. */
  56476. readonly output: NodeMaterialConnectionPoint;
  56477. autoConfigure(material: NodeMaterial): void;
  56478. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  56479. protected _buildBlock(state: NodeMaterialBuildState): this;
  56480. }
  56481. }
  56482. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  56483. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56484. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56485. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56487. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56488. import { Effect } from "babylonjs/Materials/effect";
  56489. import { Mesh } from "babylonjs/Meshes/mesh";
  56490. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56491. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56492. /**
  56493. * Block used to add morph targets support to vertex shader
  56494. */
  56495. export class MorphTargetsBlock extends NodeMaterialBlock {
  56496. private _repeatableContentAnchor;
  56497. private _repeatebleContentGenerated;
  56498. /**
  56499. * Create a new MorphTargetsBlock
  56500. * @param name defines the block name
  56501. */
  56502. constructor(name: string);
  56503. /**
  56504. * Gets the current class name
  56505. * @returns the class name
  56506. */
  56507. getClassName(): string;
  56508. /**
  56509. * Gets the position input component
  56510. */
  56511. readonly position: NodeMaterialConnectionPoint;
  56512. /**
  56513. * Gets the normal input component
  56514. */
  56515. readonly normal: NodeMaterialConnectionPoint;
  56516. /**
  56517. * Gets the tangent input component
  56518. */
  56519. readonly tangent: NodeMaterialConnectionPoint;
  56520. /**
  56521. * Gets the tangent input component
  56522. */
  56523. readonly uv: NodeMaterialConnectionPoint;
  56524. /**
  56525. * Gets the position output component
  56526. */
  56527. readonly positionOutput: NodeMaterialConnectionPoint;
  56528. /**
  56529. * Gets the normal output component
  56530. */
  56531. readonly normalOutput: NodeMaterialConnectionPoint;
  56532. /**
  56533. * Gets the tangent output component
  56534. */
  56535. readonly tangentOutput: NodeMaterialConnectionPoint;
  56536. /**
  56537. * Gets the tangent output component
  56538. */
  56539. readonly uvOutput: NodeMaterialConnectionPoint;
  56540. initialize(state: NodeMaterialBuildState): void;
  56541. autoConfigure(material: NodeMaterial): void;
  56542. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56543. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56544. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  56545. protected _buildBlock(state: NodeMaterialBuildState): this;
  56546. }
  56547. }
  56548. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  56549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56552. import { Nullable } from "babylonjs/types";
  56553. import { Scene } from "babylonjs/scene";
  56554. import { Effect } from "babylonjs/Materials/effect";
  56555. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56556. import { Mesh } from "babylonjs/Meshes/mesh";
  56557. import { Light } from "babylonjs/Lights/light";
  56558. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56559. /**
  56560. * Block used to get data information from a light
  56561. */
  56562. export class LightInformationBlock extends NodeMaterialBlock {
  56563. private _lightDataUniformName;
  56564. private _lightColorUniformName;
  56565. private _lightTypeDefineName;
  56566. /**
  56567. * Gets or sets the light associated with this block
  56568. */
  56569. light: Nullable<Light>;
  56570. /**
  56571. * Creates a new LightInformationBlock
  56572. * @param name defines the block name
  56573. */
  56574. constructor(name: string);
  56575. /**
  56576. * Gets the current class name
  56577. * @returns the class name
  56578. */
  56579. getClassName(): string;
  56580. /**
  56581. * Gets the world position input component
  56582. */
  56583. readonly worldPosition: NodeMaterialConnectionPoint;
  56584. /**
  56585. * Gets the direction output component
  56586. */
  56587. readonly direction: NodeMaterialConnectionPoint;
  56588. /**
  56589. * Gets the direction output component
  56590. */
  56591. readonly color: NodeMaterialConnectionPoint;
  56592. /**
  56593. * Gets the direction output component
  56594. */
  56595. readonly intensity: NodeMaterialConnectionPoint;
  56596. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56597. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56598. protected _buildBlock(state: NodeMaterialBuildState): this;
  56599. serialize(): any;
  56600. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56601. }
  56602. }
  56603. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  56604. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  56605. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  56606. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  56607. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  56608. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  56609. }
  56610. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  56611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56614. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56615. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56616. import { Effect } from "babylonjs/Materials/effect";
  56617. import { Mesh } from "babylonjs/Meshes/mesh";
  56618. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56619. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  56620. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  56621. /**
  56622. * Block used to add image processing support to fragment shader
  56623. */
  56624. export class ImageProcessingBlock extends NodeMaterialBlock {
  56625. /**
  56626. * Create a new ImageProcessingBlock
  56627. * @param name defines the block name
  56628. */
  56629. constructor(name: string);
  56630. /**
  56631. * Gets the current class name
  56632. * @returns the class name
  56633. */
  56634. getClassName(): string;
  56635. /**
  56636. * Gets the color input component
  56637. */
  56638. readonly color: NodeMaterialConnectionPoint;
  56639. /**
  56640. * Gets the output component
  56641. */
  56642. readonly output: NodeMaterialConnectionPoint;
  56643. /**
  56644. * Initialize the block and prepare the context for build
  56645. * @param state defines the state that will be used for the build
  56646. */
  56647. initialize(state: NodeMaterialBuildState): void;
  56648. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  56649. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56650. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56651. protected _buildBlock(state: NodeMaterialBuildState): this;
  56652. }
  56653. }
  56654. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  56655. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56656. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56657. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56658. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56660. import { Effect } from "babylonjs/Materials/effect";
  56661. import { Mesh } from "babylonjs/Meshes/mesh";
  56662. import { Scene } from "babylonjs/scene";
  56663. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  56664. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  56665. /**
  56666. * Block used to pertub normals based on a normal map
  56667. */
  56668. export class PerturbNormalBlock extends NodeMaterialBlock {
  56669. private _tangentSpaceParameterName;
  56670. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  56671. invertX: boolean;
  56672. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  56673. invertY: boolean;
  56674. /**
  56675. * Create a new PerturbNormalBlock
  56676. * @param name defines the block name
  56677. */
  56678. constructor(name: string);
  56679. /**
  56680. * Gets the current class name
  56681. * @returns the class name
  56682. */
  56683. getClassName(): string;
  56684. /**
  56685. * Gets the world position input component
  56686. */
  56687. readonly worldPosition: NodeMaterialConnectionPoint;
  56688. /**
  56689. * Gets the world normal input component
  56690. */
  56691. readonly worldNormal: NodeMaterialConnectionPoint;
  56692. /**
  56693. * Gets the uv input component
  56694. */
  56695. readonly uv: NodeMaterialConnectionPoint;
  56696. /**
  56697. * Gets the normal map color input component
  56698. */
  56699. readonly normalMapColor: NodeMaterialConnectionPoint;
  56700. /**
  56701. * Gets the strength input component
  56702. */
  56703. readonly strength: NodeMaterialConnectionPoint;
  56704. /**
  56705. * Gets the output component
  56706. */
  56707. readonly output: NodeMaterialConnectionPoint;
  56708. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56709. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56710. autoConfigure(material: NodeMaterial): void;
  56711. protected _buildBlock(state: NodeMaterialBuildState): this;
  56712. protected _dumpPropertiesCode(): string;
  56713. serialize(): any;
  56714. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56715. }
  56716. }
  56717. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  56718. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56719. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56720. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56721. /**
  56722. * Block used to discard a pixel if a value is smaller than a cutoff
  56723. */
  56724. export class DiscardBlock extends NodeMaterialBlock {
  56725. /**
  56726. * Create a new DiscardBlock
  56727. * @param name defines the block name
  56728. */
  56729. constructor(name: string);
  56730. /**
  56731. * Gets the current class name
  56732. * @returns the class name
  56733. */
  56734. getClassName(): string;
  56735. /**
  56736. * Gets the color input component
  56737. */
  56738. readonly value: NodeMaterialConnectionPoint;
  56739. /**
  56740. * Gets the cutoff input component
  56741. */
  56742. readonly cutoff: NodeMaterialConnectionPoint;
  56743. protected _buildBlock(state: NodeMaterialBuildState): this;
  56744. }
  56745. }
  56746. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  56747. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  56748. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  56749. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  56750. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  56751. }
  56752. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  56753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56755. import { Mesh } from "babylonjs/Meshes/mesh";
  56756. import { Effect } from "babylonjs/Materials/effect";
  56757. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56758. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56759. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56760. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  56761. /**
  56762. * Block used to add support for scene fog
  56763. */
  56764. export class FogBlock extends NodeMaterialBlock {
  56765. private _fogDistanceName;
  56766. private _fogParameters;
  56767. /**
  56768. * Create a new FogBlock
  56769. * @param name defines the block name
  56770. */
  56771. constructor(name: string);
  56772. /**
  56773. * Gets the current class name
  56774. * @returns the class name
  56775. */
  56776. getClassName(): string;
  56777. /**
  56778. * Gets the world position input component
  56779. */
  56780. readonly worldPosition: NodeMaterialConnectionPoint;
  56781. /**
  56782. * Gets the view input component
  56783. */
  56784. readonly view: NodeMaterialConnectionPoint;
  56785. /**
  56786. * Gets the color input component
  56787. */
  56788. readonly input: NodeMaterialConnectionPoint;
  56789. /**
  56790. * Gets the fog color input component
  56791. */
  56792. readonly fogColor: NodeMaterialConnectionPoint;
  56793. /**
  56794. * Gets the output component
  56795. */
  56796. readonly output: NodeMaterialConnectionPoint;
  56797. autoConfigure(material: NodeMaterial): void;
  56798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56799. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56800. protected _buildBlock(state: NodeMaterialBuildState): this;
  56801. }
  56802. }
  56803. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  56804. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56805. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56806. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56807. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56808. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  56809. import { Effect } from "babylonjs/Materials/effect";
  56810. import { Mesh } from "babylonjs/Meshes/mesh";
  56811. import { Light } from "babylonjs/Lights/light";
  56812. import { Nullable } from "babylonjs/types";
  56813. import { Scene } from "babylonjs/scene";
  56814. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  56815. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  56816. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  56817. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56818. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  56819. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  56820. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  56821. /**
  56822. * Block used to add light in the fragment shader
  56823. */
  56824. export class LightBlock extends NodeMaterialBlock {
  56825. private _lightId;
  56826. /**
  56827. * Gets or sets the light associated with this block
  56828. */
  56829. light: Nullable<Light>;
  56830. /**
  56831. * Create a new LightBlock
  56832. * @param name defines the block name
  56833. */
  56834. constructor(name: string);
  56835. /**
  56836. * Gets the current class name
  56837. * @returns the class name
  56838. */
  56839. getClassName(): string;
  56840. /**
  56841. * Gets the world position input component
  56842. */
  56843. readonly worldPosition: NodeMaterialConnectionPoint;
  56844. /**
  56845. * Gets the world normal input component
  56846. */
  56847. readonly worldNormal: NodeMaterialConnectionPoint;
  56848. /**
  56849. * Gets the camera (or eye) position component
  56850. */
  56851. readonly cameraPosition: NodeMaterialConnectionPoint;
  56852. /**
  56853. * Gets the glossiness component
  56854. */
  56855. readonly glossiness: NodeMaterialConnectionPoint;
  56856. /**
  56857. * Gets the glossinness power component
  56858. */
  56859. readonly glossPower: NodeMaterialConnectionPoint;
  56860. /**
  56861. * Gets the diffuse color component
  56862. */
  56863. readonly diffuseColor: NodeMaterialConnectionPoint;
  56864. /**
  56865. * Gets the specular color component
  56866. */
  56867. readonly specularColor: NodeMaterialConnectionPoint;
  56868. /**
  56869. * Gets the diffuse output component
  56870. */
  56871. readonly diffuseOutput: NodeMaterialConnectionPoint;
  56872. /**
  56873. * Gets the specular output component
  56874. */
  56875. readonly specularOutput: NodeMaterialConnectionPoint;
  56876. autoConfigure(material: NodeMaterial): void;
  56877. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56878. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  56879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  56880. private _injectVertexCode;
  56881. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  56882. serialize(): any;
  56883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  56884. }
  56885. }
  56886. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  56887. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  56888. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  56889. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  56890. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  56891. }
  56892. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  56893. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  56894. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  56895. }
  56896. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  56897. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56898. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56899. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56900. /**
  56901. * Block used to multiply 2 values
  56902. */
  56903. export class MultiplyBlock extends NodeMaterialBlock {
  56904. /**
  56905. * Creates a new MultiplyBlock
  56906. * @param name defines the block name
  56907. */
  56908. constructor(name: string);
  56909. /**
  56910. * Gets the current class name
  56911. * @returns the class name
  56912. */
  56913. getClassName(): string;
  56914. /**
  56915. * Gets the left operand input component
  56916. */
  56917. readonly left: NodeMaterialConnectionPoint;
  56918. /**
  56919. * Gets the right operand input component
  56920. */
  56921. readonly right: NodeMaterialConnectionPoint;
  56922. /**
  56923. * Gets the output component
  56924. */
  56925. readonly output: NodeMaterialConnectionPoint;
  56926. protected _buildBlock(state: NodeMaterialBuildState): this;
  56927. }
  56928. }
  56929. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  56930. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56931. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56932. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56933. /**
  56934. * Block used to add 2 vectors
  56935. */
  56936. export class AddBlock extends NodeMaterialBlock {
  56937. /**
  56938. * Creates a new AddBlock
  56939. * @param name defines the block name
  56940. */
  56941. constructor(name: string);
  56942. /**
  56943. * Gets the current class name
  56944. * @returns the class name
  56945. */
  56946. getClassName(): string;
  56947. /**
  56948. * Gets the left operand input component
  56949. */
  56950. readonly left: NodeMaterialConnectionPoint;
  56951. /**
  56952. * Gets the right operand input component
  56953. */
  56954. readonly right: NodeMaterialConnectionPoint;
  56955. /**
  56956. * Gets the output component
  56957. */
  56958. readonly output: NodeMaterialConnectionPoint;
  56959. protected _buildBlock(state: NodeMaterialBuildState): this;
  56960. }
  56961. }
  56962. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  56963. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56964. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56965. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56966. /**
  56967. * Block used to scale a vector by a float
  56968. */
  56969. export class ScaleBlock extends NodeMaterialBlock {
  56970. /**
  56971. * Creates a new ScaleBlock
  56972. * @param name defines the block name
  56973. */
  56974. constructor(name: string);
  56975. /**
  56976. * Gets the current class name
  56977. * @returns the class name
  56978. */
  56979. getClassName(): string;
  56980. /**
  56981. * Gets the input component
  56982. */
  56983. readonly input: NodeMaterialConnectionPoint;
  56984. /**
  56985. * Gets the factor input component
  56986. */
  56987. readonly factor: NodeMaterialConnectionPoint;
  56988. /**
  56989. * Gets the output component
  56990. */
  56991. readonly output: NodeMaterialConnectionPoint;
  56992. protected _buildBlock(state: NodeMaterialBuildState): this;
  56993. }
  56994. }
  56995. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  56996. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  56997. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  56998. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  56999. import { Scene } from "babylonjs/scene";
  57000. /**
  57001. * Block used to clamp a float
  57002. */
  57003. export class ClampBlock extends NodeMaterialBlock {
  57004. /** Gets or sets the minimum range */
  57005. minimum: number;
  57006. /** Gets or sets the maximum range */
  57007. maximum: number;
  57008. /**
  57009. * Creates a new ClampBlock
  57010. * @param name defines the block name
  57011. */
  57012. constructor(name: string);
  57013. /**
  57014. * Gets the current class name
  57015. * @returns the class name
  57016. */
  57017. getClassName(): string;
  57018. /**
  57019. * Gets the value input component
  57020. */
  57021. readonly value: NodeMaterialConnectionPoint;
  57022. /**
  57023. * Gets the output component
  57024. */
  57025. readonly output: NodeMaterialConnectionPoint;
  57026. protected _buildBlock(state: NodeMaterialBuildState): this;
  57027. protected _dumpPropertiesCode(): string;
  57028. serialize(): any;
  57029. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57030. }
  57031. }
  57032. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  57033. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57034. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57035. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57036. /**
  57037. * Block used to apply a cross product between 2 vectors
  57038. */
  57039. export class CrossBlock extends NodeMaterialBlock {
  57040. /**
  57041. * Creates a new CrossBlock
  57042. * @param name defines the block name
  57043. */
  57044. constructor(name: string);
  57045. /**
  57046. * Gets the current class name
  57047. * @returns the class name
  57048. */
  57049. getClassName(): string;
  57050. /**
  57051. * Gets the left operand input component
  57052. */
  57053. readonly left: NodeMaterialConnectionPoint;
  57054. /**
  57055. * Gets the right operand input component
  57056. */
  57057. readonly right: NodeMaterialConnectionPoint;
  57058. /**
  57059. * Gets the output component
  57060. */
  57061. readonly output: NodeMaterialConnectionPoint;
  57062. protected _buildBlock(state: NodeMaterialBuildState): this;
  57063. }
  57064. }
  57065. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  57066. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57067. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57068. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57069. /**
  57070. * Block used to apply a dot product between 2 vectors
  57071. */
  57072. export class DotBlock extends NodeMaterialBlock {
  57073. /**
  57074. * Creates a new DotBlock
  57075. * @param name defines the block name
  57076. */
  57077. constructor(name: string);
  57078. /**
  57079. * Gets the current class name
  57080. * @returns the class name
  57081. */
  57082. getClassName(): string;
  57083. /**
  57084. * Gets the left operand input component
  57085. */
  57086. readonly left: NodeMaterialConnectionPoint;
  57087. /**
  57088. * Gets the right operand input component
  57089. */
  57090. readonly right: NodeMaterialConnectionPoint;
  57091. /**
  57092. * Gets the output component
  57093. */
  57094. readonly output: NodeMaterialConnectionPoint;
  57095. protected _buildBlock(state: NodeMaterialBuildState): this;
  57096. }
  57097. }
  57098. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  57099. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57100. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57101. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57102. import { Vector2 } from "babylonjs/Maths/math.vector";
  57103. import { Scene } from "babylonjs/scene";
  57104. /**
  57105. * Block used to remap a float from a range to a new one
  57106. */
  57107. export class RemapBlock extends NodeMaterialBlock {
  57108. /**
  57109. * Gets or sets the source range
  57110. */
  57111. sourceRange: Vector2;
  57112. /**
  57113. * Gets or sets the target range
  57114. */
  57115. targetRange: Vector2;
  57116. /**
  57117. * Creates a new RemapBlock
  57118. * @param name defines the block name
  57119. */
  57120. constructor(name: string);
  57121. /**
  57122. * Gets the current class name
  57123. * @returns the class name
  57124. */
  57125. getClassName(): string;
  57126. /**
  57127. * Gets the input component
  57128. */
  57129. readonly input: NodeMaterialConnectionPoint;
  57130. /**
  57131. * Gets the source min input component
  57132. */
  57133. readonly sourceMin: NodeMaterialConnectionPoint;
  57134. /**
  57135. * Gets the source max input component
  57136. */
  57137. readonly sourceMax: NodeMaterialConnectionPoint;
  57138. /**
  57139. * Gets the target min input component
  57140. */
  57141. readonly targetMin: NodeMaterialConnectionPoint;
  57142. /**
  57143. * Gets the target max input component
  57144. */
  57145. readonly targetMax: NodeMaterialConnectionPoint;
  57146. /**
  57147. * Gets the output component
  57148. */
  57149. readonly output: NodeMaterialConnectionPoint;
  57150. protected _buildBlock(state: NodeMaterialBuildState): this;
  57151. protected _dumpPropertiesCode(): string;
  57152. serialize(): any;
  57153. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57154. }
  57155. }
  57156. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  57157. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57158. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57159. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57160. /**
  57161. * Block used to normalize a vector
  57162. */
  57163. export class NormalizeBlock extends NodeMaterialBlock {
  57164. /**
  57165. * Creates a new NormalizeBlock
  57166. * @param name defines the block name
  57167. */
  57168. constructor(name: string);
  57169. /**
  57170. * Gets the current class name
  57171. * @returns the class name
  57172. */
  57173. getClassName(): string;
  57174. /**
  57175. * Gets the input component
  57176. */
  57177. readonly input: NodeMaterialConnectionPoint;
  57178. /**
  57179. * Gets the output component
  57180. */
  57181. readonly output: NodeMaterialConnectionPoint;
  57182. protected _buildBlock(state: NodeMaterialBuildState): this;
  57183. }
  57184. }
  57185. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  57186. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57187. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57188. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57189. import { Scene } from "babylonjs/scene";
  57190. /**
  57191. * Operations supported by the Trigonometry block
  57192. */
  57193. export enum TrigonometryBlockOperations {
  57194. /** Cos */
  57195. Cos = 0,
  57196. /** Sin */
  57197. Sin = 1,
  57198. /** Abs */
  57199. Abs = 2,
  57200. /** Exp */
  57201. Exp = 3,
  57202. /** Exp2 */
  57203. Exp2 = 4,
  57204. /** Round */
  57205. Round = 5,
  57206. /** Floor */
  57207. Floor = 6,
  57208. /** Ceiling */
  57209. Ceiling = 7,
  57210. /** Square root */
  57211. Sqrt = 8,
  57212. /** Log */
  57213. Log = 9,
  57214. /** Tangent */
  57215. Tan = 10,
  57216. /** Arc tangent */
  57217. ArcTan = 11,
  57218. /** Arc cosinus */
  57219. ArcCos = 12,
  57220. /** Arc sinus */
  57221. ArcSin = 13,
  57222. /** Fraction */
  57223. Fract = 14,
  57224. /** Sign */
  57225. Sign = 15,
  57226. /** To radians (from degrees) */
  57227. Radians = 16,
  57228. /** To degrees (from radians) */
  57229. Degrees = 17
  57230. }
  57231. /**
  57232. * Block used to apply trigonometry operation to floats
  57233. */
  57234. export class TrigonometryBlock extends NodeMaterialBlock {
  57235. /**
  57236. * Gets or sets the operation applied by the block
  57237. */
  57238. operation: TrigonometryBlockOperations;
  57239. /**
  57240. * Creates a new TrigonometryBlock
  57241. * @param name defines the block name
  57242. */
  57243. constructor(name: string);
  57244. /**
  57245. * Gets the current class name
  57246. * @returns the class name
  57247. */
  57248. getClassName(): string;
  57249. /**
  57250. * Gets the input component
  57251. */
  57252. readonly input: NodeMaterialConnectionPoint;
  57253. /**
  57254. * Gets the output component
  57255. */
  57256. readonly output: NodeMaterialConnectionPoint;
  57257. protected _buildBlock(state: NodeMaterialBuildState): this;
  57258. serialize(): any;
  57259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  57260. }
  57261. }
  57262. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  57263. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57264. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57265. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57266. /**
  57267. * Block used to create a Color3/4 out of individual inputs (one for each component)
  57268. */
  57269. export class ColorMergerBlock extends NodeMaterialBlock {
  57270. /**
  57271. * Create a new ColorMergerBlock
  57272. * @param name defines the block name
  57273. */
  57274. constructor(name: string);
  57275. /**
  57276. * Gets the current class name
  57277. * @returns the class name
  57278. */
  57279. getClassName(): string;
  57280. /**
  57281. * Gets the r component (input)
  57282. */
  57283. readonly r: NodeMaterialConnectionPoint;
  57284. /**
  57285. * Gets the g component (input)
  57286. */
  57287. readonly g: NodeMaterialConnectionPoint;
  57288. /**
  57289. * Gets the b component (input)
  57290. */
  57291. readonly b: NodeMaterialConnectionPoint;
  57292. /**
  57293. * Gets the a component (input)
  57294. */
  57295. readonly a: NodeMaterialConnectionPoint;
  57296. /**
  57297. * Gets the rgba component (output)
  57298. */
  57299. readonly rgba: NodeMaterialConnectionPoint;
  57300. /**
  57301. * Gets the rgb component (output)
  57302. */
  57303. readonly rgb: NodeMaterialConnectionPoint;
  57304. protected _buildBlock(state: NodeMaterialBuildState): this;
  57305. }
  57306. }
  57307. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  57308. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57309. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57310. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57311. /**
  57312. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  57313. */
  57314. export class VectorMergerBlock extends NodeMaterialBlock {
  57315. /**
  57316. * Create a new VectorMergerBlock
  57317. * @param name defines the block name
  57318. */
  57319. constructor(name: string);
  57320. /**
  57321. * Gets the current class name
  57322. * @returns the class name
  57323. */
  57324. getClassName(): string;
  57325. /**
  57326. * Gets the x component (input)
  57327. */
  57328. readonly x: NodeMaterialConnectionPoint;
  57329. /**
  57330. * Gets the y component (input)
  57331. */
  57332. readonly y: NodeMaterialConnectionPoint;
  57333. /**
  57334. * Gets the z component (input)
  57335. */
  57336. readonly z: NodeMaterialConnectionPoint;
  57337. /**
  57338. * Gets the w component (input)
  57339. */
  57340. readonly w: NodeMaterialConnectionPoint;
  57341. /**
  57342. * Gets the xyzw component (output)
  57343. */
  57344. readonly xyzw: NodeMaterialConnectionPoint;
  57345. /**
  57346. * Gets the xyz component (output)
  57347. */
  57348. readonly xyz: NodeMaterialConnectionPoint;
  57349. /**
  57350. * Gets the xy component (output)
  57351. */
  57352. readonly xy: NodeMaterialConnectionPoint;
  57353. protected _buildBlock(state: NodeMaterialBuildState): this;
  57354. }
  57355. }
  57356. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  57357. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57358. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57359. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57360. /**
  57361. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  57362. */
  57363. export class ColorSplitterBlock extends NodeMaterialBlock {
  57364. /**
  57365. * Create a new ColorSplitterBlock
  57366. * @param name defines the block name
  57367. */
  57368. constructor(name: string);
  57369. /**
  57370. * Gets the current class name
  57371. * @returns the class name
  57372. */
  57373. getClassName(): string;
  57374. /**
  57375. * Gets the rgba component (input)
  57376. */
  57377. readonly rgba: NodeMaterialConnectionPoint;
  57378. /**
  57379. * Gets the rgb component (input)
  57380. */
  57381. readonly rgbIn: NodeMaterialConnectionPoint;
  57382. /**
  57383. * Gets the rgb component (output)
  57384. */
  57385. readonly rgbOut: NodeMaterialConnectionPoint;
  57386. /**
  57387. * Gets the r component (output)
  57388. */
  57389. readonly r: NodeMaterialConnectionPoint;
  57390. /**
  57391. * Gets the g component (output)
  57392. */
  57393. readonly g: NodeMaterialConnectionPoint;
  57394. /**
  57395. * Gets the b component (output)
  57396. */
  57397. readonly b: NodeMaterialConnectionPoint;
  57398. /**
  57399. * Gets the a component (output)
  57400. */
  57401. readonly a: NodeMaterialConnectionPoint;
  57402. protected _inputRename(name: string): string;
  57403. protected _outputRename(name: string): string;
  57404. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  57405. }
  57406. }
  57407. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  57408. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57409. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57410. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57411. /**
  57412. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  57413. */
  57414. export class VectorSplitterBlock extends NodeMaterialBlock {
  57415. /**
  57416. * Create a new VectorSplitterBlock
  57417. * @param name defines the block name
  57418. */
  57419. constructor(name: string);
  57420. /**
  57421. * Gets the current class name
  57422. * @returns the class name
  57423. */
  57424. getClassName(): string;
  57425. /**
  57426. * Gets the xyzw component (input)
  57427. */
  57428. readonly xyzw: NodeMaterialConnectionPoint;
  57429. /**
  57430. * Gets the xyz component (input)
  57431. */
  57432. readonly xyzIn: NodeMaterialConnectionPoint;
  57433. /**
  57434. * Gets the xy component (input)
  57435. */
  57436. readonly xyIn: NodeMaterialConnectionPoint;
  57437. /**
  57438. * Gets the xyz component (output)
  57439. */
  57440. readonly xyzOut: NodeMaterialConnectionPoint;
  57441. /**
  57442. * Gets the xy component (output)
  57443. */
  57444. readonly xyOut: NodeMaterialConnectionPoint;
  57445. /**
  57446. * Gets the x component (output)
  57447. */
  57448. readonly x: NodeMaterialConnectionPoint;
  57449. /**
  57450. * Gets the y component (output)
  57451. */
  57452. readonly y: NodeMaterialConnectionPoint;
  57453. /**
  57454. * Gets the z component (output)
  57455. */
  57456. readonly z: NodeMaterialConnectionPoint;
  57457. /**
  57458. * Gets the w component (output)
  57459. */
  57460. readonly w: NodeMaterialConnectionPoint;
  57461. protected _inputRename(name: string): string;
  57462. protected _outputRename(name: string): string;
  57463. protected _buildBlock(state: NodeMaterialBuildState): this;
  57464. }
  57465. }
  57466. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  57467. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57468. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57469. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57470. /**
  57471. * Block used to lerp between 2 values
  57472. */
  57473. export class LerpBlock extends NodeMaterialBlock {
  57474. /**
  57475. * Creates a new LerpBlock
  57476. * @param name defines the block name
  57477. */
  57478. constructor(name: string);
  57479. /**
  57480. * Gets the current class name
  57481. * @returns the class name
  57482. */
  57483. getClassName(): string;
  57484. /**
  57485. * Gets the left operand input component
  57486. */
  57487. readonly left: NodeMaterialConnectionPoint;
  57488. /**
  57489. * Gets the right operand input component
  57490. */
  57491. readonly right: NodeMaterialConnectionPoint;
  57492. /**
  57493. * Gets the gradient operand input component
  57494. */
  57495. readonly gradient: NodeMaterialConnectionPoint;
  57496. /**
  57497. * Gets the output component
  57498. */
  57499. readonly output: NodeMaterialConnectionPoint;
  57500. protected _buildBlock(state: NodeMaterialBuildState): this;
  57501. }
  57502. }
  57503. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  57504. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57505. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57506. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57507. /**
  57508. * Block used to divide 2 vectors
  57509. */
  57510. export class DivideBlock extends NodeMaterialBlock {
  57511. /**
  57512. * Creates a new DivideBlock
  57513. * @param name defines the block name
  57514. */
  57515. constructor(name: string);
  57516. /**
  57517. * Gets the current class name
  57518. * @returns the class name
  57519. */
  57520. getClassName(): string;
  57521. /**
  57522. * Gets the left operand input component
  57523. */
  57524. readonly left: NodeMaterialConnectionPoint;
  57525. /**
  57526. * Gets the right operand input component
  57527. */
  57528. readonly right: NodeMaterialConnectionPoint;
  57529. /**
  57530. * Gets the output component
  57531. */
  57532. readonly output: NodeMaterialConnectionPoint;
  57533. protected _buildBlock(state: NodeMaterialBuildState): this;
  57534. }
  57535. }
  57536. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  57537. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57538. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57539. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57540. /**
  57541. * Block used to subtract 2 vectors
  57542. */
  57543. export class SubtractBlock extends NodeMaterialBlock {
  57544. /**
  57545. * Creates a new SubtractBlock
  57546. * @param name defines the block name
  57547. */
  57548. constructor(name: string);
  57549. /**
  57550. * Gets the current class name
  57551. * @returns the class name
  57552. */
  57553. getClassName(): string;
  57554. /**
  57555. * Gets the left operand input component
  57556. */
  57557. readonly left: NodeMaterialConnectionPoint;
  57558. /**
  57559. * Gets the right operand input component
  57560. */
  57561. readonly right: NodeMaterialConnectionPoint;
  57562. /**
  57563. * Gets the output component
  57564. */
  57565. readonly output: NodeMaterialConnectionPoint;
  57566. protected _buildBlock(state: NodeMaterialBuildState): this;
  57567. }
  57568. }
  57569. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  57570. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57571. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57572. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57573. /**
  57574. * Block used to step a value
  57575. */
  57576. export class StepBlock extends NodeMaterialBlock {
  57577. /**
  57578. * Creates a new StepBlock
  57579. * @param name defines the block name
  57580. */
  57581. constructor(name: string);
  57582. /**
  57583. * Gets the current class name
  57584. * @returns the class name
  57585. */
  57586. getClassName(): string;
  57587. /**
  57588. * Gets the value operand input component
  57589. */
  57590. readonly value: NodeMaterialConnectionPoint;
  57591. /**
  57592. * Gets the edge operand input component
  57593. */
  57594. readonly edge: NodeMaterialConnectionPoint;
  57595. /**
  57596. * Gets the output component
  57597. */
  57598. readonly output: NodeMaterialConnectionPoint;
  57599. protected _buildBlock(state: NodeMaterialBuildState): this;
  57600. }
  57601. }
  57602. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  57603. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57604. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57605. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57606. /**
  57607. * Block used to get the opposite (1 - x) of a value
  57608. */
  57609. export class OneMinusBlock extends NodeMaterialBlock {
  57610. /**
  57611. * Creates a new OneMinusBlock
  57612. * @param name defines the block name
  57613. */
  57614. constructor(name: string);
  57615. /**
  57616. * Gets the current class name
  57617. * @returns the class name
  57618. */
  57619. getClassName(): string;
  57620. /**
  57621. * Gets the input component
  57622. */
  57623. readonly input: NodeMaterialConnectionPoint;
  57624. /**
  57625. * Gets the output component
  57626. */
  57627. readonly output: NodeMaterialConnectionPoint;
  57628. protected _buildBlock(state: NodeMaterialBuildState): this;
  57629. }
  57630. }
  57631. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  57632. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57633. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57634. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57635. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57636. /**
  57637. * Block used to get the view direction
  57638. */
  57639. export class ViewDirectionBlock extends NodeMaterialBlock {
  57640. /**
  57641. * Creates a new ViewDirectionBlock
  57642. * @param name defines the block name
  57643. */
  57644. constructor(name: string);
  57645. /**
  57646. * Gets the current class name
  57647. * @returns the class name
  57648. */
  57649. getClassName(): string;
  57650. /**
  57651. * Gets the world position component
  57652. */
  57653. readonly worldPosition: NodeMaterialConnectionPoint;
  57654. /**
  57655. * Gets the camera position component
  57656. */
  57657. readonly cameraPosition: NodeMaterialConnectionPoint;
  57658. /**
  57659. * Gets the output component
  57660. */
  57661. readonly output: NodeMaterialConnectionPoint;
  57662. autoConfigure(material: NodeMaterial): void;
  57663. protected _buildBlock(state: NodeMaterialBuildState): this;
  57664. }
  57665. }
  57666. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  57667. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57668. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57669. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57670. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  57671. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  57672. /**
  57673. * Block used to compute fresnel value
  57674. */
  57675. export class FresnelBlock extends NodeMaterialBlock {
  57676. /**
  57677. * Create a new FresnelBlock
  57678. * @param name defines the block name
  57679. */
  57680. constructor(name: string);
  57681. /**
  57682. * Gets the current class name
  57683. * @returns the class name
  57684. */
  57685. getClassName(): string;
  57686. /**
  57687. * Gets the world normal input component
  57688. */
  57689. readonly worldNormal: NodeMaterialConnectionPoint;
  57690. /**
  57691. * Gets the view direction input component
  57692. */
  57693. readonly viewDirection: NodeMaterialConnectionPoint;
  57694. /**
  57695. * Gets the bias input component
  57696. */
  57697. readonly bias: NodeMaterialConnectionPoint;
  57698. /**
  57699. * Gets the camera (or eye) position component
  57700. */
  57701. readonly power: NodeMaterialConnectionPoint;
  57702. /**
  57703. * Gets the fresnel output component
  57704. */
  57705. readonly fresnel: NodeMaterialConnectionPoint;
  57706. autoConfigure(material: NodeMaterial): void;
  57707. protected _buildBlock(state: NodeMaterialBuildState): this;
  57708. }
  57709. }
  57710. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  57711. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57712. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57714. /**
  57715. * Block used to get the max of 2 values
  57716. */
  57717. export class MaxBlock extends NodeMaterialBlock {
  57718. /**
  57719. * Creates a new MaxBlock
  57720. * @param name defines the block name
  57721. */
  57722. constructor(name: string);
  57723. /**
  57724. * Gets the current class name
  57725. * @returns the class name
  57726. */
  57727. getClassName(): string;
  57728. /**
  57729. * Gets the left operand input component
  57730. */
  57731. readonly left: NodeMaterialConnectionPoint;
  57732. /**
  57733. * Gets the right operand input component
  57734. */
  57735. readonly right: NodeMaterialConnectionPoint;
  57736. /**
  57737. * Gets the output component
  57738. */
  57739. readonly output: NodeMaterialConnectionPoint;
  57740. protected _buildBlock(state: NodeMaterialBuildState): this;
  57741. }
  57742. }
  57743. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  57744. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57745. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57746. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57747. /**
  57748. * Block used to get the min of 2 values
  57749. */
  57750. export class MinBlock extends NodeMaterialBlock {
  57751. /**
  57752. * Creates a new MinBlock
  57753. * @param name defines the block name
  57754. */
  57755. constructor(name: string);
  57756. /**
  57757. * Gets the current class name
  57758. * @returns the class name
  57759. */
  57760. getClassName(): string;
  57761. /**
  57762. * Gets the left operand input component
  57763. */
  57764. readonly left: NodeMaterialConnectionPoint;
  57765. /**
  57766. * Gets the right operand input component
  57767. */
  57768. readonly right: NodeMaterialConnectionPoint;
  57769. /**
  57770. * Gets the output component
  57771. */
  57772. readonly output: NodeMaterialConnectionPoint;
  57773. protected _buildBlock(state: NodeMaterialBuildState): this;
  57774. }
  57775. }
  57776. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  57777. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57778. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57779. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57780. /**
  57781. * Block used to get the distance between 2 values
  57782. */
  57783. export class DistanceBlock extends NodeMaterialBlock {
  57784. /**
  57785. * Creates a new DistanceBlock
  57786. * @param name defines the block name
  57787. */
  57788. constructor(name: string);
  57789. /**
  57790. * Gets the current class name
  57791. * @returns the class name
  57792. */
  57793. getClassName(): string;
  57794. /**
  57795. * Gets the left operand input component
  57796. */
  57797. readonly left: NodeMaterialConnectionPoint;
  57798. /**
  57799. * Gets the right operand input component
  57800. */
  57801. readonly right: NodeMaterialConnectionPoint;
  57802. /**
  57803. * Gets the output component
  57804. */
  57805. readonly output: NodeMaterialConnectionPoint;
  57806. protected _buildBlock(state: NodeMaterialBuildState): this;
  57807. }
  57808. }
  57809. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  57810. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57811. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57812. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57813. /**
  57814. * Block used to get the length of a vector
  57815. */
  57816. export class LengthBlock extends NodeMaterialBlock {
  57817. /**
  57818. * Creates a new LengthBlock
  57819. * @param name defines the block name
  57820. */
  57821. constructor(name: string);
  57822. /**
  57823. * Gets the current class name
  57824. * @returns the class name
  57825. */
  57826. getClassName(): string;
  57827. /**
  57828. * Gets the value input component
  57829. */
  57830. readonly value: NodeMaterialConnectionPoint;
  57831. /**
  57832. * Gets the output component
  57833. */
  57834. readonly output: NodeMaterialConnectionPoint;
  57835. protected _buildBlock(state: NodeMaterialBuildState): this;
  57836. }
  57837. }
  57838. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  57839. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57840. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57841. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57842. /**
  57843. * Block used to get negative version of a value (i.e. x * -1)
  57844. */
  57845. export class NegateBlock extends NodeMaterialBlock {
  57846. /**
  57847. * Creates a new NegateBlock
  57848. * @param name defines the block name
  57849. */
  57850. constructor(name: string);
  57851. /**
  57852. * Gets the current class name
  57853. * @returns the class name
  57854. */
  57855. getClassName(): string;
  57856. /**
  57857. * Gets the value input component
  57858. */
  57859. readonly value: NodeMaterialConnectionPoint;
  57860. /**
  57861. * Gets the output component
  57862. */
  57863. readonly output: NodeMaterialConnectionPoint;
  57864. protected _buildBlock(state: NodeMaterialBuildState): this;
  57865. }
  57866. }
  57867. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  57868. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57869. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57870. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57871. /**
  57872. * Block used to get the value of the first parameter raised to the power of the second
  57873. */
  57874. export class PowBlock extends NodeMaterialBlock {
  57875. /**
  57876. * Creates a new PowBlock
  57877. * @param name defines the block name
  57878. */
  57879. constructor(name: string);
  57880. /**
  57881. * Gets the current class name
  57882. * @returns the class name
  57883. */
  57884. getClassName(): string;
  57885. /**
  57886. * Gets the value operand input component
  57887. */
  57888. readonly value: NodeMaterialConnectionPoint;
  57889. /**
  57890. * Gets the power operand input component
  57891. */
  57892. readonly power: NodeMaterialConnectionPoint;
  57893. /**
  57894. * Gets the output component
  57895. */
  57896. readonly output: NodeMaterialConnectionPoint;
  57897. protected _buildBlock(state: NodeMaterialBuildState): this;
  57898. }
  57899. }
  57900. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  57901. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57902. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57903. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57904. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57905. /**
  57906. * Block used to get a random number
  57907. */
  57908. export class RandomNumberBlock extends NodeMaterialBlock {
  57909. /**
  57910. * Creates a new RandomNumberBlock
  57911. * @param name defines the block name
  57912. */
  57913. constructor(name: string);
  57914. /**
  57915. * Gets the current class name
  57916. * @returns the class name
  57917. */
  57918. getClassName(): string;
  57919. /**
  57920. * Gets the seed input component
  57921. */
  57922. readonly seed: NodeMaterialConnectionPoint;
  57923. /**
  57924. * Gets the output component
  57925. */
  57926. readonly output: NodeMaterialConnectionPoint;
  57927. protected _buildBlock(state: NodeMaterialBuildState): this;
  57928. }
  57929. }
  57930. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  57931. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57932. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57933. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57934. /**
  57935. * Block used to compute arc tangent of 2 values
  57936. */
  57937. export class ArcTan2Block extends NodeMaterialBlock {
  57938. /**
  57939. * Creates a new ArcTan2Block
  57940. * @param name defines the block name
  57941. */
  57942. constructor(name: string);
  57943. /**
  57944. * Gets the current class name
  57945. * @returns the class name
  57946. */
  57947. getClassName(): string;
  57948. /**
  57949. * Gets the x operand input component
  57950. */
  57951. readonly x: NodeMaterialConnectionPoint;
  57952. /**
  57953. * Gets the y operand input component
  57954. */
  57955. readonly y: NodeMaterialConnectionPoint;
  57956. /**
  57957. * Gets the output component
  57958. */
  57959. readonly output: NodeMaterialConnectionPoint;
  57960. protected _buildBlock(state: NodeMaterialBuildState): this;
  57961. }
  57962. }
  57963. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  57964. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  57965. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  57966. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  57967. /**
  57968. * Block used to smooth step a value
  57969. */
  57970. export class SmoothStepBlock extends NodeMaterialBlock {
  57971. /**
  57972. * Creates a new SmoothStepBlock
  57973. * @param name defines the block name
  57974. */
  57975. constructor(name: string);
  57976. /**
  57977. * Gets the current class name
  57978. * @returns the class name
  57979. */
  57980. getClassName(): string;
  57981. /**
  57982. * Gets the value operand input component
  57983. */
  57984. readonly value: NodeMaterialConnectionPoint;
  57985. /**
  57986. * Gets the first edge operand input component
  57987. */
  57988. readonly edge0: NodeMaterialConnectionPoint;
  57989. /**
  57990. * Gets the second edge operand input component
  57991. */
  57992. readonly edge1: NodeMaterialConnectionPoint;
  57993. /**
  57994. * Gets the output component
  57995. */
  57996. readonly output: NodeMaterialConnectionPoint;
  57997. protected _buildBlock(state: NodeMaterialBuildState): this;
  57998. }
  57999. }
  58000. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  58001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58004. /**
  58005. * Block used to get the reciprocal (1 / x) of a value
  58006. */
  58007. export class ReciprocalBlock extends NodeMaterialBlock {
  58008. /**
  58009. * Creates a new ReciprocalBlock
  58010. * @param name defines the block name
  58011. */
  58012. constructor(name: string);
  58013. /**
  58014. * Gets the current class name
  58015. * @returns the class name
  58016. */
  58017. getClassName(): string;
  58018. /**
  58019. * Gets the input component
  58020. */
  58021. readonly input: NodeMaterialConnectionPoint;
  58022. /**
  58023. * Gets the output component
  58024. */
  58025. readonly output: NodeMaterialConnectionPoint;
  58026. protected _buildBlock(state: NodeMaterialBuildState): this;
  58027. }
  58028. }
  58029. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  58030. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58031. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58032. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58033. /**
  58034. * Block used to replace a color by another one
  58035. */
  58036. export class ReplaceColorBlock extends NodeMaterialBlock {
  58037. /**
  58038. * Creates a new ReplaceColorBlock
  58039. * @param name defines the block name
  58040. */
  58041. constructor(name: string);
  58042. /**
  58043. * Gets the current class name
  58044. * @returns the class name
  58045. */
  58046. getClassName(): string;
  58047. /**
  58048. * Gets the value input component
  58049. */
  58050. readonly value: NodeMaterialConnectionPoint;
  58051. /**
  58052. * Gets the reference input component
  58053. */
  58054. readonly reference: NodeMaterialConnectionPoint;
  58055. /**
  58056. * Gets the distance input component
  58057. */
  58058. readonly distance: NodeMaterialConnectionPoint;
  58059. /**
  58060. * Gets the replacement input component
  58061. */
  58062. readonly replacement: NodeMaterialConnectionPoint;
  58063. /**
  58064. * Gets the output component
  58065. */
  58066. readonly output: NodeMaterialConnectionPoint;
  58067. protected _buildBlock(state: NodeMaterialBuildState): this;
  58068. }
  58069. }
  58070. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  58071. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58072. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58073. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58074. /**
  58075. * Block used to posterize a value
  58076. * @see https://en.wikipedia.org/wiki/Posterization
  58077. */
  58078. export class PosterizeBlock extends NodeMaterialBlock {
  58079. /**
  58080. * Creates a new PosterizeBlock
  58081. * @param name defines the block name
  58082. */
  58083. constructor(name: string);
  58084. /**
  58085. * Gets the current class name
  58086. * @returns the class name
  58087. */
  58088. getClassName(): string;
  58089. /**
  58090. * Gets the value input component
  58091. */
  58092. readonly value: NodeMaterialConnectionPoint;
  58093. /**
  58094. * Gets the steps input component
  58095. */
  58096. readonly steps: NodeMaterialConnectionPoint;
  58097. /**
  58098. * Gets the output component
  58099. */
  58100. readonly output: NodeMaterialConnectionPoint;
  58101. protected _buildBlock(state: NodeMaterialBuildState): this;
  58102. }
  58103. }
  58104. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  58105. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58106. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58107. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58108. import { Scene } from "babylonjs/scene";
  58109. /**
  58110. * Operations supported by the Wave block
  58111. */
  58112. export enum WaveBlockKind {
  58113. /** SawTooth */
  58114. SawTooth = 0,
  58115. /** Square */
  58116. Square = 1,
  58117. /** Triangle */
  58118. Triangle = 2
  58119. }
  58120. /**
  58121. * Block used to apply wave operation to floats
  58122. */
  58123. export class WaveBlock extends NodeMaterialBlock {
  58124. /**
  58125. * Gets or sets the kibnd of wave to be applied by the block
  58126. */
  58127. kind: WaveBlockKind;
  58128. /**
  58129. * Creates a new WaveBlock
  58130. * @param name defines the block name
  58131. */
  58132. constructor(name: string);
  58133. /**
  58134. * Gets the current class name
  58135. * @returns the class name
  58136. */
  58137. getClassName(): string;
  58138. /**
  58139. * Gets the input component
  58140. */
  58141. readonly input: NodeMaterialConnectionPoint;
  58142. /**
  58143. * Gets the output component
  58144. */
  58145. readonly output: NodeMaterialConnectionPoint;
  58146. protected _buildBlock(state: NodeMaterialBuildState): this;
  58147. serialize(): any;
  58148. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58149. }
  58150. }
  58151. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  58152. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58153. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58154. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58155. import { Color3 } from "babylonjs/Maths/math.color";
  58156. import { Scene } from "babylonjs/scene";
  58157. /**
  58158. * Class used to store a color step for the GradientBlock
  58159. */
  58160. export class GradientBlockColorStep {
  58161. /**
  58162. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58163. */
  58164. step: number;
  58165. /**
  58166. * Gets or sets the color associated with this step
  58167. */
  58168. color: Color3;
  58169. /**
  58170. * Creates a new GradientBlockColorStep
  58171. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  58172. * @param color defines the color associated with this step
  58173. */
  58174. constructor(
  58175. /**
  58176. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  58177. */
  58178. step: number,
  58179. /**
  58180. * Gets or sets the color associated with this step
  58181. */
  58182. color: Color3);
  58183. }
  58184. /**
  58185. * Block used to return a color from a gradient based on an input value between 0 and 1
  58186. */
  58187. export class GradientBlock extends NodeMaterialBlock {
  58188. /**
  58189. * Gets or sets the list of color steps
  58190. */
  58191. colorSteps: GradientBlockColorStep[];
  58192. /**
  58193. * Creates a new GradientBlock
  58194. * @param name defines the block name
  58195. */
  58196. constructor(name: string);
  58197. /**
  58198. * Gets the current class name
  58199. * @returns the class name
  58200. */
  58201. getClassName(): string;
  58202. /**
  58203. * Gets the gradient input component
  58204. */
  58205. readonly gradient: NodeMaterialConnectionPoint;
  58206. /**
  58207. * Gets the output component
  58208. */
  58209. readonly output: NodeMaterialConnectionPoint;
  58210. private _writeColorConstant;
  58211. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  58212. serialize(): any;
  58213. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  58214. protected _dumpPropertiesCode(): string;
  58215. }
  58216. }
  58217. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  58218. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  58219. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  58220. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58221. /**
  58222. * Block used to normalize lerp between 2 values
  58223. */
  58224. export class NLerpBlock extends NodeMaterialBlock {
  58225. /**
  58226. * Creates a new NLerpBlock
  58227. * @param name defines the block name
  58228. */
  58229. constructor(name: string);
  58230. /**
  58231. * Gets the current class name
  58232. * @returns the class name
  58233. */
  58234. getClassName(): string;
  58235. /**
  58236. * Gets the left operand input component
  58237. */
  58238. readonly left: NodeMaterialConnectionPoint;
  58239. /**
  58240. * Gets the right operand input component
  58241. */
  58242. readonly right: NodeMaterialConnectionPoint;
  58243. /**
  58244. * Gets the gradient operand input component
  58245. */
  58246. readonly gradient: NodeMaterialConnectionPoint;
  58247. /**
  58248. * Gets the output component
  58249. */
  58250. readonly output: NodeMaterialConnectionPoint;
  58251. protected _buildBlock(state: NodeMaterialBuildState): this;
  58252. }
  58253. }
  58254. declare module "babylonjs/Materials/Node/Blocks/index" {
  58255. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  58256. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  58257. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  58258. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  58259. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  58260. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  58261. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  58262. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  58263. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  58264. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  58265. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  58266. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  58267. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  58268. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  58269. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  58270. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  58271. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  58272. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  58273. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  58274. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  58275. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  58276. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  58277. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  58278. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  58279. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  58280. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  58281. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  58282. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  58283. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  58284. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  58285. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  58286. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  58287. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  58288. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  58289. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  58290. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  58291. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  58292. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  58293. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  58294. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  58295. }
  58296. declare module "babylonjs/Materials/Node/Optimizers/index" {
  58297. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  58298. }
  58299. declare module "babylonjs/Materials/Node/index" {
  58300. export * from "babylonjs/Materials/Node/Enums/index";
  58301. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  58302. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  58303. export * from "babylonjs/Materials/Node/nodeMaterial";
  58304. export * from "babylonjs/Materials/Node/Blocks/index";
  58305. export * from "babylonjs/Materials/Node/Optimizers/index";
  58306. }
  58307. declare module "babylonjs/Materials/effectRenderer" {
  58308. import { Nullable } from "babylonjs/types";
  58309. import { Texture } from "babylonjs/Materials/Textures/texture";
  58310. import { Engine } from "babylonjs/Engines/engine";
  58311. import { Viewport } from "babylonjs/Maths/math.viewport";
  58312. import { Observable } from "babylonjs/Misc/observable";
  58313. import { Effect } from "babylonjs/Materials/effect";
  58314. import "babylonjs/Shaders/postprocess.vertex";
  58315. /**
  58316. * Effect Render Options
  58317. */
  58318. export interface IEffectRendererOptions {
  58319. /**
  58320. * Defines the vertices positions.
  58321. */
  58322. positions?: number[];
  58323. /**
  58324. * Defines the indices.
  58325. */
  58326. indices?: number[];
  58327. }
  58328. /**
  58329. * Helper class to render one or more effects
  58330. */
  58331. export class EffectRenderer {
  58332. private engine;
  58333. private static _DefaultOptions;
  58334. private _vertexBuffers;
  58335. private _indexBuffer;
  58336. private _ringBufferIndex;
  58337. private _ringScreenBuffer;
  58338. private _fullscreenViewport;
  58339. private _getNextFrameBuffer;
  58340. /**
  58341. * Creates an effect renderer
  58342. * @param engine the engine to use for rendering
  58343. * @param options defines the options of the effect renderer
  58344. */
  58345. constructor(engine: Engine, options?: IEffectRendererOptions);
  58346. /**
  58347. * Sets the current viewport in normalized coordinates 0-1
  58348. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  58349. */
  58350. setViewport(viewport?: Viewport): void;
  58351. /**
  58352. * Binds the embedded attributes buffer to the effect.
  58353. * @param effect Defines the effect to bind the attributes for
  58354. */
  58355. bindBuffers(effect: Effect): void;
  58356. /**
  58357. * Sets the current effect wrapper to use during draw.
  58358. * The effect needs to be ready before calling this api.
  58359. * This also sets the default full screen position attribute.
  58360. * @param effectWrapper Defines the effect to draw with
  58361. */
  58362. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  58363. /**
  58364. * Draws a full screen quad.
  58365. */
  58366. draw(): void;
  58367. /**
  58368. * renders one or more effects to a specified texture
  58369. * @param effectWrappers list of effects to renderer
  58370. * @param outputTexture texture to draw to, if null it will render to the screen
  58371. */
  58372. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  58373. /**
  58374. * Disposes of the effect renderer
  58375. */
  58376. dispose(): void;
  58377. }
  58378. /**
  58379. * Options to create an EffectWrapper
  58380. */
  58381. interface EffectWrapperCreationOptions {
  58382. /**
  58383. * Engine to use to create the effect
  58384. */
  58385. engine: Engine;
  58386. /**
  58387. * Fragment shader for the effect
  58388. */
  58389. fragmentShader: string;
  58390. /**
  58391. * Vertex shader for the effect
  58392. */
  58393. vertexShader?: string;
  58394. /**
  58395. * Attributes to use in the shader
  58396. */
  58397. attributeNames?: Array<string>;
  58398. /**
  58399. * Uniforms to use in the shader
  58400. */
  58401. uniformNames?: Array<string>;
  58402. /**
  58403. * Texture sampler names to use in the shader
  58404. */
  58405. samplerNames?: Array<string>;
  58406. /**
  58407. * The friendly name of the effect displayed in Spector.
  58408. */
  58409. name?: string;
  58410. }
  58411. /**
  58412. * Wraps an effect to be used for rendering
  58413. */
  58414. export class EffectWrapper {
  58415. /**
  58416. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  58417. */
  58418. onApplyObservable: Observable<{}>;
  58419. /**
  58420. * The underlying effect
  58421. */
  58422. effect: Effect;
  58423. /**
  58424. * Creates an effect to be renderer
  58425. * @param creationOptions options to create the effect
  58426. */
  58427. constructor(creationOptions: EffectWrapperCreationOptions);
  58428. /**
  58429. * Disposes of the effect wrapper
  58430. */
  58431. dispose(): void;
  58432. }
  58433. }
  58434. declare module "babylonjs/Materials/index" {
  58435. export * from "babylonjs/Materials/Background/index";
  58436. export * from "babylonjs/Materials/colorCurves";
  58437. export * from "babylonjs/Materials/iEffectFallbacks";
  58438. export * from "babylonjs/Materials/effectFallbacks";
  58439. export * from "babylonjs/Materials/effect";
  58440. export * from "babylonjs/Materials/fresnelParameters";
  58441. export * from "babylonjs/Materials/imageProcessingConfiguration";
  58442. export * from "babylonjs/Materials/material";
  58443. export * from "babylonjs/Materials/materialDefines";
  58444. export * from "babylonjs/Materials/materialHelper";
  58445. export * from "babylonjs/Materials/multiMaterial";
  58446. export * from "babylonjs/Materials/PBR/index";
  58447. export * from "babylonjs/Materials/pushMaterial";
  58448. export * from "babylonjs/Materials/shaderMaterial";
  58449. export * from "babylonjs/Materials/standardMaterial";
  58450. export * from "babylonjs/Materials/Textures/index";
  58451. export * from "babylonjs/Materials/uniformBuffer";
  58452. export * from "babylonjs/Materials/materialFlags";
  58453. export * from "babylonjs/Materials/Node/index";
  58454. export * from "babylonjs/Materials/effectRenderer";
  58455. }
  58456. declare module "babylonjs/Maths/index" {
  58457. export * from "babylonjs/Maths/math.scalar";
  58458. export * from "babylonjs/Maths/math";
  58459. export * from "babylonjs/Maths/sphericalPolynomial";
  58460. }
  58461. declare module "babylonjs/Misc/workerPool" {
  58462. import { IDisposable } from "babylonjs/scene";
  58463. /**
  58464. * Helper class to push actions to a pool of workers.
  58465. */
  58466. export class WorkerPool implements IDisposable {
  58467. private _workerInfos;
  58468. private _pendingActions;
  58469. /**
  58470. * Constructor
  58471. * @param workers Array of workers to use for actions
  58472. */
  58473. constructor(workers: Array<Worker>);
  58474. /**
  58475. * Terminates all workers and clears any pending actions.
  58476. */
  58477. dispose(): void;
  58478. /**
  58479. * Pushes an action to the worker pool. If all the workers are active, the action will be
  58480. * pended until a worker has completed its action.
  58481. * @param action The action to perform. Call onComplete when the action is complete.
  58482. */
  58483. push(action: (worker: Worker, onComplete: () => void) => void): void;
  58484. private _execute;
  58485. }
  58486. }
  58487. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  58488. import { IDisposable } from "babylonjs/scene";
  58489. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58490. /**
  58491. * Configuration for Draco compression
  58492. */
  58493. export interface IDracoCompressionConfiguration {
  58494. /**
  58495. * Configuration for the decoder.
  58496. */
  58497. decoder: {
  58498. /**
  58499. * The url to the WebAssembly module.
  58500. */
  58501. wasmUrl?: string;
  58502. /**
  58503. * The url to the WebAssembly binary.
  58504. */
  58505. wasmBinaryUrl?: string;
  58506. /**
  58507. * The url to the fallback JavaScript module.
  58508. */
  58509. fallbackUrl?: string;
  58510. };
  58511. }
  58512. /**
  58513. * Draco compression (https://google.github.io/draco/)
  58514. *
  58515. * This class wraps the Draco module.
  58516. *
  58517. * **Encoder**
  58518. *
  58519. * The encoder is not currently implemented.
  58520. *
  58521. * **Decoder**
  58522. *
  58523. * 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.
  58524. *
  58525. * To update the configuration, use the following code:
  58526. * ```javascript
  58527. * DracoCompression.Configuration = {
  58528. * decoder: {
  58529. * wasmUrl: "<url to the WebAssembly library>",
  58530. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  58531. * fallbackUrl: "<url to the fallback JavaScript library>",
  58532. * }
  58533. * };
  58534. * ```
  58535. *
  58536. * 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.
  58537. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  58538. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  58539. *
  58540. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  58541. * ```javascript
  58542. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  58543. * ```
  58544. *
  58545. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  58546. */
  58547. export class DracoCompression implements IDisposable {
  58548. private _workerPoolPromise?;
  58549. private _decoderModulePromise?;
  58550. /**
  58551. * The configuration. Defaults to the following urls:
  58552. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  58553. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  58554. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  58555. */
  58556. static Configuration: IDracoCompressionConfiguration;
  58557. /**
  58558. * Returns true if the decoder configuration is available.
  58559. */
  58560. static readonly DecoderAvailable: boolean;
  58561. /**
  58562. * Default number of workers to create when creating the draco compression object.
  58563. */
  58564. static DefaultNumWorkers: number;
  58565. private static GetDefaultNumWorkers;
  58566. private static _Default;
  58567. /**
  58568. * Default instance for the draco compression object.
  58569. */
  58570. static readonly Default: DracoCompression;
  58571. /**
  58572. * Constructor
  58573. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  58574. */
  58575. constructor(numWorkers?: number);
  58576. /**
  58577. * Stop all async operations and release resources.
  58578. */
  58579. dispose(): void;
  58580. /**
  58581. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  58582. * @returns a promise that resolves when ready
  58583. */
  58584. whenReadyAsync(): Promise<void>;
  58585. /**
  58586. * Decode Draco compressed mesh data to vertex data.
  58587. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  58588. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  58589. * @returns A promise that resolves with the decoded vertex data
  58590. */
  58591. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  58592. [kind: string]: number;
  58593. }): Promise<VertexData>;
  58594. }
  58595. }
  58596. declare module "babylonjs/Meshes/Compression/index" {
  58597. export * from "babylonjs/Meshes/Compression/dracoCompression";
  58598. }
  58599. declare module "babylonjs/Meshes/csg" {
  58600. import { Nullable } from "babylonjs/types";
  58601. import { Scene } from "babylonjs/scene";
  58602. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  58603. import { Mesh } from "babylonjs/Meshes/mesh";
  58604. import { Material } from "babylonjs/Materials/material";
  58605. /**
  58606. * Class for building Constructive Solid Geometry
  58607. */
  58608. export class CSG {
  58609. private polygons;
  58610. /**
  58611. * The world matrix
  58612. */
  58613. matrix: Matrix;
  58614. /**
  58615. * Stores the position
  58616. */
  58617. position: Vector3;
  58618. /**
  58619. * Stores the rotation
  58620. */
  58621. rotation: Vector3;
  58622. /**
  58623. * Stores the rotation quaternion
  58624. */
  58625. rotationQuaternion: Nullable<Quaternion>;
  58626. /**
  58627. * Stores the scaling vector
  58628. */
  58629. scaling: Vector3;
  58630. /**
  58631. * Convert the Mesh to CSG
  58632. * @param mesh The Mesh to convert to CSG
  58633. * @returns A new CSG from the Mesh
  58634. */
  58635. static FromMesh(mesh: Mesh): CSG;
  58636. /**
  58637. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  58638. * @param polygons Polygons used to construct a CSG solid
  58639. */
  58640. private static FromPolygons;
  58641. /**
  58642. * Clones, or makes a deep copy, of the CSG
  58643. * @returns A new CSG
  58644. */
  58645. clone(): CSG;
  58646. /**
  58647. * Unions this CSG with another CSG
  58648. * @param csg The CSG to union against this CSG
  58649. * @returns The unioned CSG
  58650. */
  58651. union(csg: CSG): CSG;
  58652. /**
  58653. * Unions this CSG with another CSG in place
  58654. * @param csg The CSG to union against this CSG
  58655. */
  58656. unionInPlace(csg: CSG): void;
  58657. /**
  58658. * Subtracts this CSG with another CSG
  58659. * @param csg The CSG to subtract against this CSG
  58660. * @returns A new CSG
  58661. */
  58662. subtract(csg: CSG): CSG;
  58663. /**
  58664. * Subtracts this CSG with another CSG in place
  58665. * @param csg The CSG to subtact against this CSG
  58666. */
  58667. subtractInPlace(csg: CSG): void;
  58668. /**
  58669. * Intersect this CSG with another CSG
  58670. * @param csg The CSG to intersect against this CSG
  58671. * @returns A new CSG
  58672. */
  58673. intersect(csg: CSG): CSG;
  58674. /**
  58675. * Intersects this CSG with another CSG in place
  58676. * @param csg The CSG to intersect against this CSG
  58677. */
  58678. intersectInPlace(csg: CSG): void;
  58679. /**
  58680. * Return a new CSG solid with solid and empty space switched. This solid is
  58681. * not modified.
  58682. * @returns A new CSG solid with solid and empty space switched
  58683. */
  58684. inverse(): CSG;
  58685. /**
  58686. * Inverses the CSG in place
  58687. */
  58688. inverseInPlace(): void;
  58689. /**
  58690. * This is used to keep meshes transformations so they can be restored
  58691. * when we build back a Babylon Mesh
  58692. * NB : All CSG operations are performed in world coordinates
  58693. * @param csg The CSG to copy the transform attributes from
  58694. * @returns This CSG
  58695. */
  58696. copyTransformAttributes(csg: CSG): CSG;
  58697. /**
  58698. * Build Raw mesh from CSG
  58699. * Coordinates here are in world space
  58700. * @param name The name of the mesh geometry
  58701. * @param scene The Scene
  58702. * @param keepSubMeshes Specifies if the submeshes should be kept
  58703. * @returns A new Mesh
  58704. */
  58705. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58706. /**
  58707. * Build Mesh from CSG taking material and transforms into account
  58708. * @param name The name of the Mesh
  58709. * @param material The material of the Mesh
  58710. * @param scene The Scene
  58711. * @param keepSubMeshes Specifies if submeshes should be kept
  58712. * @returns The new Mesh
  58713. */
  58714. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  58715. }
  58716. }
  58717. declare module "babylonjs/Meshes/trailMesh" {
  58718. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58719. import { Mesh } from "babylonjs/Meshes/mesh";
  58720. import { Scene } from "babylonjs/scene";
  58721. /**
  58722. * Class used to create a trail following a mesh
  58723. */
  58724. export class TrailMesh extends Mesh {
  58725. private _generator;
  58726. private _autoStart;
  58727. private _running;
  58728. private _diameter;
  58729. private _length;
  58730. private _sectionPolygonPointsCount;
  58731. private _sectionVectors;
  58732. private _sectionNormalVectors;
  58733. private _beforeRenderObserver;
  58734. /**
  58735. * @constructor
  58736. * @param name The value used by scene.getMeshByName() to do a lookup.
  58737. * @param generator The mesh to generate a trail.
  58738. * @param scene The scene to add this mesh to.
  58739. * @param diameter Diameter of trailing mesh. Default is 1.
  58740. * @param length Length of trailing mesh. Default is 60.
  58741. * @param autoStart Automatically start trailing mesh. Default true.
  58742. */
  58743. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  58744. /**
  58745. * "TrailMesh"
  58746. * @returns "TrailMesh"
  58747. */
  58748. getClassName(): string;
  58749. private _createMesh;
  58750. /**
  58751. * Start trailing mesh.
  58752. */
  58753. start(): void;
  58754. /**
  58755. * Stop trailing mesh.
  58756. */
  58757. stop(): void;
  58758. /**
  58759. * Update trailing mesh geometry.
  58760. */
  58761. update(): void;
  58762. /**
  58763. * Returns a new TrailMesh object.
  58764. * @param name is a string, the name given to the new mesh
  58765. * @param newGenerator use new generator object for cloned trail mesh
  58766. * @returns a new mesh
  58767. */
  58768. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  58769. /**
  58770. * Serializes this trail mesh
  58771. * @param serializationObject object to write serialization to
  58772. */
  58773. serialize(serializationObject: any): void;
  58774. /**
  58775. * Parses a serialized trail mesh
  58776. * @param parsedMesh the serialized mesh
  58777. * @param scene the scene to create the trail mesh in
  58778. * @returns the created trail mesh
  58779. */
  58780. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  58781. }
  58782. }
  58783. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  58784. import { Nullable } from "babylonjs/types";
  58785. import { Scene } from "babylonjs/scene";
  58786. import { Vector4 } from "babylonjs/Maths/math.vector";
  58787. import { Color4 } from "babylonjs/Maths/math.color";
  58788. import { Mesh } from "babylonjs/Meshes/mesh";
  58789. /**
  58790. * Class containing static functions to help procedurally build meshes
  58791. */
  58792. export class TiledBoxBuilder {
  58793. /**
  58794. * Creates a box mesh
  58795. * 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)
  58796. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58797. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58798. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58799. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58800. * @param name defines the name of the mesh
  58801. * @param options defines the options used to create the mesh
  58802. * @param scene defines the hosting scene
  58803. * @returns the box mesh
  58804. */
  58805. static CreateTiledBox(name: string, options: {
  58806. pattern?: number;
  58807. width?: number;
  58808. height?: number;
  58809. depth?: number;
  58810. tileSize?: number;
  58811. tileWidth?: number;
  58812. tileHeight?: number;
  58813. alignHorizontal?: number;
  58814. alignVertical?: number;
  58815. faceUV?: Vector4[];
  58816. faceColors?: Color4[];
  58817. sideOrientation?: number;
  58818. updatable?: boolean;
  58819. }, scene?: Nullable<Scene>): Mesh;
  58820. }
  58821. }
  58822. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  58823. import { Vector4 } from "babylonjs/Maths/math.vector";
  58824. import { Mesh } from "babylonjs/Meshes/mesh";
  58825. /**
  58826. * Class containing static functions to help procedurally build meshes
  58827. */
  58828. export class TorusKnotBuilder {
  58829. /**
  58830. * Creates a torus knot mesh
  58831. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  58832. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  58833. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  58834. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  58835. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58838. * @param name defines the name of the mesh
  58839. * @param options defines the options used to create the mesh
  58840. * @param scene defines the hosting scene
  58841. * @returns the torus knot mesh
  58842. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  58843. */
  58844. static CreateTorusKnot(name: string, options: {
  58845. radius?: number;
  58846. tube?: number;
  58847. radialSegments?: number;
  58848. tubularSegments?: number;
  58849. p?: number;
  58850. q?: number;
  58851. updatable?: boolean;
  58852. sideOrientation?: number;
  58853. frontUVs?: Vector4;
  58854. backUVs?: Vector4;
  58855. }, scene: any): Mesh;
  58856. }
  58857. }
  58858. declare module "babylonjs/Meshes/polygonMesh" {
  58859. import { Scene } from "babylonjs/scene";
  58860. import { Vector2 } from "babylonjs/Maths/math.vector";
  58861. import { Mesh } from "babylonjs/Meshes/mesh";
  58862. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  58863. import { Path2 } from "babylonjs/Maths/math.path";
  58864. /**
  58865. * Polygon
  58866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  58867. */
  58868. export class Polygon {
  58869. /**
  58870. * Creates a rectangle
  58871. * @param xmin bottom X coord
  58872. * @param ymin bottom Y coord
  58873. * @param xmax top X coord
  58874. * @param ymax top Y coord
  58875. * @returns points that make the resulting rectation
  58876. */
  58877. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  58878. /**
  58879. * Creates a circle
  58880. * @param radius radius of circle
  58881. * @param cx scale in x
  58882. * @param cy scale in y
  58883. * @param numberOfSides number of sides that make up the circle
  58884. * @returns points that make the resulting circle
  58885. */
  58886. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  58887. /**
  58888. * Creates a polygon from input string
  58889. * @param input Input polygon data
  58890. * @returns the parsed points
  58891. */
  58892. static Parse(input: string): Vector2[];
  58893. /**
  58894. * Starts building a polygon from x and y coordinates
  58895. * @param x x coordinate
  58896. * @param y y coordinate
  58897. * @returns the started path2
  58898. */
  58899. static StartingAt(x: number, y: number): Path2;
  58900. }
  58901. /**
  58902. * Builds a polygon
  58903. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  58904. */
  58905. export class PolygonMeshBuilder {
  58906. private _points;
  58907. private _outlinepoints;
  58908. private _holes;
  58909. private _name;
  58910. private _scene;
  58911. private _epoints;
  58912. private _eholes;
  58913. private _addToepoint;
  58914. /**
  58915. * Babylon reference to the earcut plugin.
  58916. */
  58917. bjsEarcut: any;
  58918. /**
  58919. * Creates a PolygonMeshBuilder
  58920. * @param name name of the builder
  58921. * @param contours Path of the polygon
  58922. * @param scene scene to add to when creating the mesh
  58923. * @param earcutInjection can be used to inject your own earcut reference
  58924. */
  58925. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  58926. /**
  58927. * Adds a whole within the polygon
  58928. * @param hole Array of points defining the hole
  58929. * @returns this
  58930. */
  58931. addHole(hole: Vector2[]): PolygonMeshBuilder;
  58932. /**
  58933. * Creates the polygon
  58934. * @param updatable If the mesh should be updatable
  58935. * @param depth The depth of the mesh created
  58936. * @returns the created mesh
  58937. */
  58938. build(updatable?: boolean, depth?: number): Mesh;
  58939. /**
  58940. * Creates the polygon
  58941. * @param depth The depth of the mesh created
  58942. * @returns the created VertexData
  58943. */
  58944. buildVertexData(depth?: number): VertexData;
  58945. /**
  58946. * Adds a side to the polygon
  58947. * @param positions points that make the polygon
  58948. * @param normals normals of the polygon
  58949. * @param uvs uvs of the polygon
  58950. * @param indices indices of the polygon
  58951. * @param bounds bounds of the polygon
  58952. * @param points points of the polygon
  58953. * @param depth depth of the polygon
  58954. * @param flip flip of the polygon
  58955. */
  58956. private addSide;
  58957. }
  58958. }
  58959. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  58960. import { Scene } from "babylonjs/scene";
  58961. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58962. import { Color4 } from "babylonjs/Maths/math.color";
  58963. import { Mesh } from "babylonjs/Meshes/mesh";
  58964. import { Nullable } from "babylonjs/types";
  58965. /**
  58966. * Class containing static functions to help procedurally build meshes
  58967. */
  58968. export class PolygonBuilder {
  58969. /**
  58970. * Creates a polygon mesh
  58971. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  58972. * * 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
  58973. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  58974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58975. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  58976. * * Remember you can only change the shape positions, not their number when updating a polygon
  58977. * @param name defines the name of the mesh
  58978. * @param options defines the options used to create the mesh
  58979. * @param scene defines the hosting scene
  58980. * @param earcutInjection can be used to inject your own earcut reference
  58981. * @returns the polygon mesh
  58982. */
  58983. static CreatePolygon(name: string, options: {
  58984. shape: Vector3[];
  58985. holes?: Vector3[][];
  58986. depth?: number;
  58987. faceUV?: Vector4[];
  58988. faceColors?: Color4[];
  58989. updatable?: boolean;
  58990. sideOrientation?: number;
  58991. frontUVs?: Vector4;
  58992. backUVs?: Vector4;
  58993. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  58994. /**
  58995. * Creates an extruded polygon mesh, with depth in the Y direction.
  58996. * * 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)
  58997. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  58998. * @param name defines the name of the mesh
  58999. * @param options defines the options used to create the mesh
  59000. * @param scene defines the hosting scene
  59001. * @param earcutInjection can be used to inject your own earcut reference
  59002. * @returns the polygon mesh
  59003. */
  59004. static ExtrudePolygon(name: string, options: {
  59005. shape: Vector3[];
  59006. holes?: Vector3[][];
  59007. depth?: number;
  59008. faceUV?: Vector4[];
  59009. faceColors?: Color4[];
  59010. updatable?: boolean;
  59011. sideOrientation?: number;
  59012. frontUVs?: Vector4;
  59013. backUVs?: Vector4;
  59014. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59015. }
  59016. }
  59017. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  59018. import { Scene } from "babylonjs/scene";
  59019. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59020. import { Mesh } from "babylonjs/Meshes/mesh";
  59021. import { Nullable } from "babylonjs/types";
  59022. /**
  59023. * Class containing static functions to help procedurally build meshes
  59024. */
  59025. export class LatheBuilder {
  59026. /**
  59027. * Creates lathe mesh.
  59028. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59029. * * 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
  59030. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59031. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59032. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59033. * * 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
  59034. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59035. * * 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
  59036. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59037. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59038. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59039. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59040. * @param name defines the name of the mesh
  59041. * @param options defines the options used to create the mesh
  59042. * @param scene defines the hosting scene
  59043. * @returns the lathe mesh
  59044. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59045. */
  59046. static CreateLathe(name: string, options: {
  59047. shape: Vector3[];
  59048. radius?: number;
  59049. tessellation?: number;
  59050. clip?: number;
  59051. arc?: number;
  59052. closed?: boolean;
  59053. updatable?: boolean;
  59054. sideOrientation?: number;
  59055. frontUVs?: Vector4;
  59056. backUVs?: Vector4;
  59057. cap?: number;
  59058. invertUV?: boolean;
  59059. }, scene?: Nullable<Scene>): Mesh;
  59060. }
  59061. }
  59062. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  59063. import { Nullable } from "babylonjs/types";
  59064. import { Scene } from "babylonjs/scene";
  59065. import { Vector4 } from "babylonjs/Maths/math.vector";
  59066. import { Mesh } from "babylonjs/Meshes/mesh";
  59067. /**
  59068. * Class containing static functions to help procedurally build meshes
  59069. */
  59070. export class TiledPlaneBuilder {
  59071. /**
  59072. * Creates a tiled plane mesh
  59073. * * The parameter `pattern` will, depending on value, do nothing or
  59074. * * * flip (reflect about central vertical) alternate tiles across and up
  59075. * * * flip every tile on alternate rows
  59076. * * * rotate (180 degs) alternate tiles across and up
  59077. * * * rotate every tile on alternate rows
  59078. * * * flip and rotate alternate tiles across and up
  59079. * * * flip and rotate every tile on alternate rows
  59080. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  59081. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  59082. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59083. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59084. * * 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)
  59085. * * 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)
  59086. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59087. * @param name defines the name of the mesh
  59088. * @param options defines the options used to create the mesh
  59089. * @param scene defines the hosting scene
  59090. * @returns the box mesh
  59091. */
  59092. static CreateTiledPlane(name: string, options: {
  59093. pattern?: number;
  59094. tileSize?: number;
  59095. tileWidth?: number;
  59096. tileHeight?: number;
  59097. size?: number;
  59098. width?: number;
  59099. height?: number;
  59100. alignHorizontal?: number;
  59101. alignVertical?: number;
  59102. sideOrientation?: number;
  59103. frontUVs?: Vector4;
  59104. backUVs?: Vector4;
  59105. updatable?: boolean;
  59106. }, scene?: Nullable<Scene>): Mesh;
  59107. }
  59108. }
  59109. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  59110. import { Nullable } from "babylonjs/types";
  59111. import { Scene } from "babylonjs/scene";
  59112. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  59113. import { Mesh } from "babylonjs/Meshes/mesh";
  59114. /**
  59115. * Class containing static functions to help procedurally build meshes
  59116. */
  59117. export class TubeBuilder {
  59118. /**
  59119. * Creates a tube mesh.
  59120. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59121. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59122. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59123. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59124. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59125. * * 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)
  59126. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59127. * * 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
  59128. * * 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
  59129. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59130. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59131. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59133. * @param name defines the name of the mesh
  59134. * @param options defines the options used to create the mesh
  59135. * @param scene defines the hosting scene
  59136. * @returns the tube mesh
  59137. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59138. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59139. */
  59140. static CreateTube(name: string, options: {
  59141. path: Vector3[];
  59142. radius?: number;
  59143. tessellation?: number;
  59144. radiusFunction?: {
  59145. (i: number, distance: number): number;
  59146. };
  59147. cap?: number;
  59148. arc?: number;
  59149. updatable?: boolean;
  59150. sideOrientation?: number;
  59151. frontUVs?: Vector4;
  59152. backUVs?: Vector4;
  59153. instance?: Mesh;
  59154. invertUV?: boolean;
  59155. }, scene?: Nullable<Scene>): Mesh;
  59156. }
  59157. }
  59158. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  59159. import { Scene } from "babylonjs/scene";
  59160. import { Vector4 } from "babylonjs/Maths/math.vector";
  59161. import { Mesh } from "babylonjs/Meshes/mesh";
  59162. import { Nullable } from "babylonjs/types";
  59163. /**
  59164. * Class containing static functions to help procedurally build meshes
  59165. */
  59166. export class IcoSphereBuilder {
  59167. /**
  59168. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59169. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59170. * * 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`)
  59171. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59172. * * 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
  59173. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59174. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59175. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59176. * @param name defines the name of the mesh
  59177. * @param options defines the options used to create the mesh
  59178. * @param scene defines the hosting scene
  59179. * @returns the icosahedron mesh
  59180. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59181. */
  59182. static CreateIcoSphere(name: string, options: {
  59183. radius?: number;
  59184. radiusX?: number;
  59185. radiusY?: number;
  59186. radiusZ?: number;
  59187. flat?: boolean;
  59188. subdivisions?: number;
  59189. sideOrientation?: number;
  59190. frontUVs?: Vector4;
  59191. backUVs?: Vector4;
  59192. updatable?: boolean;
  59193. }, scene?: Nullable<Scene>): Mesh;
  59194. }
  59195. }
  59196. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  59197. import { Vector3 } from "babylonjs/Maths/math.vector";
  59198. import { Mesh } from "babylonjs/Meshes/mesh";
  59199. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59200. /**
  59201. * Class containing static functions to help procedurally build meshes
  59202. */
  59203. export class DecalBuilder {
  59204. /**
  59205. * Creates a decal mesh.
  59206. * 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
  59207. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59208. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59209. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59210. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59211. * @param name defines the name of the mesh
  59212. * @param sourceMesh defines the mesh where the decal must be applied
  59213. * @param options defines the options used to create the mesh
  59214. * @param scene defines the hosting scene
  59215. * @returns the decal mesh
  59216. * @see https://doc.babylonjs.com/how_to/decals
  59217. */
  59218. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59219. position?: Vector3;
  59220. normal?: Vector3;
  59221. size?: Vector3;
  59222. angle?: number;
  59223. }): Mesh;
  59224. }
  59225. }
  59226. declare module "babylonjs/Meshes/meshBuilder" {
  59227. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  59228. import { Nullable } from "babylonjs/types";
  59229. import { Scene } from "babylonjs/scene";
  59230. import { Mesh } from "babylonjs/Meshes/mesh";
  59231. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  59232. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  59233. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59234. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  59235. import { Plane } from "babylonjs/Maths/math.plane";
  59236. /**
  59237. * Class containing static functions to help procedurally build meshes
  59238. */
  59239. export class MeshBuilder {
  59240. /**
  59241. * Creates a box mesh
  59242. * * The parameter `size` sets the size (float) of each box side (default 1)
  59243. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  59244. * * 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)
  59245. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59246. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59247. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59248. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59249. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  59250. * @param name defines the name of the mesh
  59251. * @param options defines the options used to create the mesh
  59252. * @param scene defines the hosting scene
  59253. * @returns the box mesh
  59254. */
  59255. static CreateBox(name: string, options: {
  59256. size?: number;
  59257. width?: number;
  59258. height?: number;
  59259. depth?: number;
  59260. faceUV?: Vector4[];
  59261. faceColors?: Color4[];
  59262. sideOrientation?: number;
  59263. frontUVs?: Vector4;
  59264. backUVs?: Vector4;
  59265. updatable?: boolean;
  59266. }, scene?: Nullable<Scene>): Mesh;
  59267. /**
  59268. * Creates a tiled box mesh
  59269. * * faceTiles sets the pattern, tile size and number of tiles for a face
  59270. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59271. * @param name defines the name of the mesh
  59272. * @param options defines the options used to create the mesh
  59273. * @param scene defines the hosting scene
  59274. * @returns the tiled box mesh
  59275. */
  59276. static CreateTiledBox(name: string, options: {
  59277. pattern?: number;
  59278. size?: number;
  59279. width?: number;
  59280. height?: number;
  59281. depth: number;
  59282. tileSize?: number;
  59283. tileWidth?: number;
  59284. tileHeight?: number;
  59285. faceUV?: Vector4[];
  59286. faceColors?: Color4[];
  59287. alignHorizontal?: number;
  59288. alignVertical?: number;
  59289. sideOrientation?: number;
  59290. updatable?: boolean;
  59291. }, scene?: Nullable<Scene>): Mesh;
  59292. /**
  59293. * Creates a sphere mesh
  59294. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  59295. * * 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`)
  59296. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  59297. * * 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
  59298. * * 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)
  59299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59302. * @param name defines the name of the mesh
  59303. * @param options defines the options used to create the mesh
  59304. * @param scene defines the hosting scene
  59305. * @returns the sphere mesh
  59306. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  59307. */
  59308. static CreateSphere(name: string, options: {
  59309. segments?: number;
  59310. diameter?: number;
  59311. diameterX?: number;
  59312. diameterY?: number;
  59313. diameterZ?: number;
  59314. arc?: number;
  59315. slice?: number;
  59316. sideOrientation?: number;
  59317. frontUVs?: Vector4;
  59318. backUVs?: Vector4;
  59319. updatable?: boolean;
  59320. }, scene?: Nullable<Scene>): Mesh;
  59321. /**
  59322. * Creates a plane polygonal mesh. By default, this is a disc
  59323. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  59324. * * 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
  59325. * * 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
  59326. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59327. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59328. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59329. * @param name defines the name of the mesh
  59330. * @param options defines the options used to create the mesh
  59331. * @param scene defines the hosting scene
  59332. * @returns the plane polygonal mesh
  59333. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  59334. */
  59335. static CreateDisc(name: string, options: {
  59336. radius?: number;
  59337. tessellation?: number;
  59338. arc?: number;
  59339. updatable?: boolean;
  59340. sideOrientation?: number;
  59341. frontUVs?: Vector4;
  59342. backUVs?: Vector4;
  59343. }, scene?: Nullable<Scene>): Mesh;
  59344. /**
  59345. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  59346. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  59347. * * 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`)
  59348. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  59349. * * 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
  59350. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59351. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59352. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59353. * @param name defines the name of the mesh
  59354. * @param options defines the options used to create the mesh
  59355. * @param scene defines the hosting scene
  59356. * @returns the icosahedron mesh
  59357. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  59358. */
  59359. static CreateIcoSphere(name: string, options: {
  59360. radius?: number;
  59361. radiusX?: number;
  59362. radiusY?: number;
  59363. radiusZ?: number;
  59364. flat?: boolean;
  59365. subdivisions?: number;
  59366. sideOrientation?: number;
  59367. frontUVs?: Vector4;
  59368. backUVs?: Vector4;
  59369. updatable?: boolean;
  59370. }, scene?: Nullable<Scene>): Mesh;
  59371. /**
  59372. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59373. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  59374. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  59375. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  59376. * * 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
  59377. * * 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
  59378. * * 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
  59379. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59380. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59381. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59382. * * 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
  59383. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  59384. * * 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
  59385. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  59386. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59387. * @param name defines the name of the mesh
  59388. * @param options defines the options used to create the mesh
  59389. * @param scene defines the hosting scene
  59390. * @returns the ribbon mesh
  59391. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  59392. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59393. */
  59394. static CreateRibbon(name: string, options: {
  59395. pathArray: Vector3[][];
  59396. closeArray?: boolean;
  59397. closePath?: boolean;
  59398. offset?: number;
  59399. updatable?: boolean;
  59400. sideOrientation?: number;
  59401. frontUVs?: Vector4;
  59402. backUVs?: Vector4;
  59403. instance?: Mesh;
  59404. invertUV?: boolean;
  59405. uvs?: Vector2[];
  59406. colors?: Color4[];
  59407. }, scene?: Nullable<Scene>): Mesh;
  59408. /**
  59409. * Creates a cylinder or a cone mesh
  59410. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  59411. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  59412. * * 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.
  59413. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  59414. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  59415. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  59416. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  59417. * * 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).
  59418. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  59419. * * 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).
  59420. * * 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
  59421. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  59422. * * 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
  59423. * * 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.
  59424. * * If `enclose` is false, a ring surface is one element.
  59425. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  59426. * * 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
  59427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59430. * @param name defines the name of the mesh
  59431. * @param options defines the options used to create the mesh
  59432. * @param scene defines the hosting scene
  59433. * @returns the cylinder mesh
  59434. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  59435. */
  59436. static CreateCylinder(name: string, options: {
  59437. height?: number;
  59438. diameterTop?: number;
  59439. diameterBottom?: number;
  59440. diameter?: number;
  59441. tessellation?: number;
  59442. subdivisions?: number;
  59443. arc?: number;
  59444. faceColors?: Color4[];
  59445. faceUV?: Vector4[];
  59446. updatable?: boolean;
  59447. hasRings?: boolean;
  59448. enclose?: boolean;
  59449. cap?: number;
  59450. sideOrientation?: number;
  59451. frontUVs?: Vector4;
  59452. backUVs?: Vector4;
  59453. }, scene?: Nullable<Scene>): Mesh;
  59454. /**
  59455. * Creates a torus mesh
  59456. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  59457. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  59458. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  59459. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59460. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59461. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59462. * @param name defines the name of the mesh
  59463. * @param options defines the options used to create the mesh
  59464. * @param scene defines the hosting scene
  59465. * @returns the torus mesh
  59466. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  59467. */
  59468. static CreateTorus(name: string, options: {
  59469. diameter?: number;
  59470. thickness?: number;
  59471. tessellation?: number;
  59472. updatable?: boolean;
  59473. sideOrientation?: number;
  59474. frontUVs?: Vector4;
  59475. backUVs?: Vector4;
  59476. }, scene?: Nullable<Scene>): Mesh;
  59477. /**
  59478. * Creates a torus knot mesh
  59479. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  59480. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  59481. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  59482. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  59483. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59484. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59485. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59486. * @param name defines the name of the mesh
  59487. * @param options defines the options used to create the mesh
  59488. * @param scene defines the hosting scene
  59489. * @returns the torus knot mesh
  59490. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  59491. */
  59492. static CreateTorusKnot(name: string, options: {
  59493. radius?: number;
  59494. tube?: number;
  59495. radialSegments?: number;
  59496. tubularSegments?: number;
  59497. p?: number;
  59498. q?: number;
  59499. updatable?: boolean;
  59500. sideOrientation?: number;
  59501. frontUVs?: Vector4;
  59502. backUVs?: Vector4;
  59503. }, scene?: Nullable<Scene>): Mesh;
  59504. /**
  59505. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  59506. * * 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
  59507. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  59508. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  59509. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  59510. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  59511. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  59512. * * 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
  59513. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  59514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  59516. * @param name defines the name of the new line system
  59517. * @param options defines the options used to create the line system
  59518. * @param scene defines the hosting scene
  59519. * @returns a new line system mesh
  59520. */
  59521. static CreateLineSystem(name: string, options: {
  59522. lines: Vector3[][];
  59523. updatable?: boolean;
  59524. instance?: Nullable<LinesMesh>;
  59525. colors?: Nullable<Color4[][]>;
  59526. useVertexAlpha?: boolean;
  59527. }, scene: Nullable<Scene>): LinesMesh;
  59528. /**
  59529. * Creates a line mesh
  59530. * 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
  59531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59532. * * The parameter `points` is an array successive Vector3
  59533. * * 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
  59534. * * The optional parameter `colors` is an array of successive Color4, one per line point
  59535. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  59536. * * When updating an instance, remember that only point positions can change, not the number of points
  59537. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59538. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  59539. * @param name defines the name of the new line system
  59540. * @param options defines the options used to create the line system
  59541. * @param scene defines the hosting scene
  59542. * @returns a new line mesh
  59543. */
  59544. static CreateLines(name: string, options: {
  59545. points: Vector3[];
  59546. updatable?: boolean;
  59547. instance?: Nullable<LinesMesh>;
  59548. colors?: Color4[];
  59549. useVertexAlpha?: boolean;
  59550. }, scene?: Nullable<Scene>): LinesMesh;
  59551. /**
  59552. * Creates a dashed line mesh
  59553. * * 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
  59554. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  59555. * * The parameter `points` is an array successive Vector3
  59556. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  59557. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  59558. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  59559. * * 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
  59560. * * When updating an instance, remember that only point positions can change, not the number of points
  59561. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59562. * @param name defines the name of the mesh
  59563. * @param options defines the options used to create the mesh
  59564. * @param scene defines the hosting scene
  59565. * @returns the dashed line mesh
  59566. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  59567. */
  59568. static CreateDashedLines(name: string, options: {
  59569. points: Vector3[];
  59570. dashSize?: number;
  59571. gapSize?: number;
  59572. dashNb?: number;
  59573. updatable?: boolean;
  59574. instance?: LinesMesh;
  59575. }, scene?: Nullable<Scene>): LinesMesh;
  59576. /**
  59577. * 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.
  59578. * * 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.
  59579. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59580. * * 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.
  59581. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  59582. * * 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
  59583. * * 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
  59584. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  59585. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59586. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59587. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  59588. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59589. * @param name defines the name of the mesh
  59590. * @param options defines the options used to create the mesh
  59591. * @param scene defines the hosting scene
  59592. * @returns the extruded shape mesh
  59593. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59594. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59595. */
  59596. static ExtrudeShape(name: string, options: {
  59597. shape: Vector3[];
  59598. path: Vector3[];
  59599. scale?: number;
  59600. rotation?: number;
  59601. cap?: number;
  59602. updatable?: boolean;
  59603. sideOrientation?: number;
  59604. frontUVs?: Vector4;
  59605. backUVs?: Vector4;
  59606. instance?: Mesh;
  59607. invertUV?: boolean;
  59608. }, scene?: Nullable<Scene>): Mesh;
  59609. /**
  59610. * Creates an custom extruded shape mesh.
  59611. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  59612. * * 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.
  59613. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  59614. * * 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
  59615. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  59616. * * 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
  59617. * * It must returns a float value that will be the scale value applied to the shape on each path point
  59618. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  59619. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  59620. * * 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
  59621. * * 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
  59622. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  59623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59625. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59626. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59627. * @param name defines the name of the mesh
  59628. * @param options defines the options used to create the mesh
  59629. * @param scene defines the hosting scene
  59630. * @returns the custom extruded shape mesh
  59631. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  59632. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59633. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  59634. */
  59635. static ExtrudeShapeCustom(name: string, options: {
  59636. shape: Vector3[];
  59637. path: Vector3[];
  59638. scaleFunction?: any;
  59639. rotationFunction?: any;
  59640. ribbonCloseArray?: boolean;
  59641. ribbonClosePath?: boolean;
  59642. cap?: number;
  59643. updatable?: boolean;
  59644. sideOrientation?: number;
  59645. frontUVs?: Vector4;
  59646. backUVs?: Vector4;
  59647. instance?: Mesh;
  59648. invertUV?: boolean;
  59649. }, scene?: Nullable<Scene>): Mesh;
  59650. /**
  59651. * Creates lathe mesh.
  59652. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  59653. * * 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
  59654. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  59655. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  59656. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  59657. * * 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
  59658. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  59659. * * 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
  59660. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59661. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59662. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59664. * @param name defines the name of the mesh
  59665. * @param options defines the options used to create the mesh
  59666. * @param scene defines the hosting scene
  59667. * @returns the lathe mesh
  59668. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  59669. */
  59670. static CreateLathe(name: string, options: {
  59671. shape: Vector3[];
  59672. radius?: number;
  59673. tessellation?: number;
  59674. clip?: number;
  59675. arc?: number;
  59676. closed?: boolean;
  59677. updatable?: boolean;
  59678. sideOrientation?: number;
  59679. frontUVs?: Vector4;
  59680. backUVs?: Vector4;
  59681. cap?: number;
  59682. invertUV?: boolean;
  59683. }, scene?: Nullable<Scene>): Mesh;
  59684. /**
  59685. * Creates a tiled plane mesh
  59686. * * You can set a limited pattern arrangement with the tiles
  59687. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59688. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59690. * @param name defines the name of the mesh
  59691. * @param options defines the options used to create the mesh
  59692. * @param scene defines the hosting scene
  59693. * @returns the plane mesh
  59694. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59695. */
  59696. static CreateTiledPlane(name: string, options: {
  59697. pattern?: number;
  59698. tileSize?: number;
  59699. tileWidth?: number;
  59700. tileHeight?: number;
  59701. size?: number;
  59702. width?: number;
  59703. height?: number;
  59704. alignHorizontal?: number;
  59705. alignVertical?: number;
  59706. sideOrientation?: number;
  59707. frontUVs?: Vector4;
  59708. backUVs?: Vector4;
  59709. updatable?: boolean;
  59710. }, scene?: Nullable<Scene>): Mesh;
  59711. /**
  59712. * Creates a plane mesh
  59713. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  59714. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  59715. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  59716. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59717. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59718. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59719. * @param name defines the name of the mesh
  59720. * @param options defines the options used to create the mesh
  59721. * @param scene defines the hosting scene
  59722. * @returns the plane mesh
  59723. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  59724. */
  59725. static CreatePlane(name: string, options: {
  59726. size?: number;
  59727. width?: number;
  59728. height?: number;
  59729. sideOrientation?: number;
  59730. frontUVs?: Vector4;
  59731. backUVs?: Vector4;
  59732. updatable?: boolean;
  59733. sourcePlane?: Plane;
  59734. }, scene?: Nullable<Scene>): Mesh;
  59735. /**
  59736. * Creates a ground mesh
  59737. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  59738. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  59739. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59740. * @param name defines the name of the mesh
  59741. * @param options defines the options used to create the mesh
  59742. * @param scene defines the hosting scene
  59743. * @returns the ground mesh
  59744. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  59745. */
  59746. static CreateGround(name: string, options: {
  59747. width?: number;
  59748. height?: number;
  59749. subdivisions?: number;
  59750. subdivisionsX?: number;
  59751. subdivisionsY?: number;
  59752. updatable?: boolean;
  59753. }, scene?: Nullable<Scene>): Mesh;
  59754. /**
  59755. * Creates a tiled ground mesh
  59756. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  59757. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  59758. * * 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
  59759. * * 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
  59760. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59761. * @param name defines the name of the mesh
  59762. * @param options defines the options used to create the mesh
  59763. * @param scene defines the hosting scene
  59764. * @returns the tiled ground mesh
  59765. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  59766. */
  59767. static CreateTiledGround(name: string, options: {
  59768. xmin: number;
  59769. zmin: number;
  59770. xmax: number;
  59771. zmax: number;
  59772. subdivisions?: {
  59773. w: number;
  59774. h: number;
  59775. };
  59776. precision?: {
  59777. w: number;
  59778. h: number;
  59779. };
  59780. updatable?: boolean;
  59781. }, scene?: Nullable<Scene>): Mesh;
  59782. /**
  59783. * Creates a ground mesh from a height map
  59784. * * The parameter `url` sets the URL of the height map image resource.
  59785. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  59786. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  59787. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  59788. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  59789. * * 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.
  59790. * * 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).
  59791. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  59792. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  59793. * @param name defines the name of the mesh
  59794. * @param url defines the url to the height map
  59795. * @param options defines the options used to create the mesh
  59796. * @param scene defines the hosting scene
  59797. * @returns the ground mesh
  59798. * @see https://doc.babylonjs.com/babylon101/height_map
  59799. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  59800. */
  59801. static CreateGroundFromHeightMap(name: string, url: string, options: {
  59802. width?: number;
  59803. height?: number;
  59804. subdivisions?: number;
  59805. minHeight?: number;
  59806. maxHeight?: number;
  59807. colorFilter?: Color3;
  59808. alphaFilter?: number;
  59809. updatable?: boolean;
  59810. onReady?: (mesh: GroundMesh) => void;
  59811. }, scene?: Nullable<Scene>): GroundMesh;
  59812. /**
  59813. * Creates a polygon mesh
  59814. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  59815. * * 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
  59816. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  59817. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59818. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  59819. * * Remember you can only change the shape positions, not their number when updating a polygon
  59820. * @param name defines the name of the mesh
  59821. * @param options defines the options used to create the mesh
  59822. * @param scene defines the hosting scene
  59823. * @param earcutInjection can be used to inject your own earcut reference
  59824. * @returns the polygon mesh
  59825. */
  59826. static CreatePolygon(name: string, options: {
  59827. shape: Vector3[];
  59828. holes?: Vector3[][];
  59829. depth?: number;
  59830. faceUV?: Vector4[];
  59831. faceColors?: Color4[];
  59832. updatable?: boolean;
  59833. sideOrientation?: number;
  59834. frontUVs?: Vector4;
  59835. backUVs?: Vector4;
  59836. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59837. /**
  59838. * Creates an extruded polygon mesh, with depth in the Y direction.
  59839. * * 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)
  59840. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  59841. * @param name defines the name of the mesh
  59842. * @param options defines the options used to create the mesh
  59843. * @param scene defines the hosting scene
  59844. * @param earcutInjection can be used to inject your own earcut reference
  59845. * @returns the polygon mesh
  59846. */
  59847. static ExtrudePolygon(name: string, options: {
  59848. shape: Vector3[];
  59849. holes?: Vector3[][];
  59850. depth?: number;
  59851. faceUV?: Vector4[];
  59852. faceColors?: Color4[];
  59853. updatable?: boolean;
  59854. sideOrientation?: number;
  59855. frontUVs?: Vector4;
  59856. backUVs?: Vector4;
  59857. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  59858. /**
  59859. * Creates a tube mesh.
  59860. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  59861. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  59862. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  59863. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  59864. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  59865. * * 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)
  59866. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  59867. * * 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
  59868. * * 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
  59869. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59870. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59871. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  59872. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59873. * @param name defines the name of the mesh
  59874. * @param options defines the options used to create the mesh
  59875. * @param scene defines the hosting scene
  59876. * @returns the tube mesh
  59877. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  59878. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  59879. */
  59880. static CreateTube(name: string, options: {
  59881. path: Vector3[];
  59882. radius?: number;
  59883. tessellation?: number;
  59884. radiusFunction?: {
  59885. (i: number, distance: number): number;
  59886. };
  59887. cap?: number;
  59888. arc?: number;
  59889. updatable?: boolean;
  59890. sideOrientation?: number;
  59891. frontUVs?: Vector4;
  59892. backUVs?: Vector4;
  59893. instance?: Mesh;
  59894. invertUV?: boolean;
  59895. }, scene?: Nullable<Scene>): Mesh;
  59896. /**
  59897. * Creates a polyhedron mesh
  59898. * * 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
  59899. * * The parameter `size` (positive float, default 1) sets the polygon size
  59900. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  59901. * * 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`
  59902. * * 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
  59903. * * 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)`)
  59904. * * 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
  59905. * * 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
  59906. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  59907. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  59908. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  59909. * @param name defines the name of the mesh
  59910. * @param options defines the options used to create the mesh
  59911. * @param scene defines the hosting scene
  59912. * @returns the polyhedron mesh
  59913. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  59914. */
  59915. static CreatePolyhedron(name: string, options: {
  59916. type?: number;
  59917. size?: number;
  59918. sizeX?: number;
  59919. sizeY?: number;
  59920. sizeZ?: number;
  59921. custom?: any;
  59922. faceUV?: Vector4[];
  59923. faceColors?: Color4[];
  59924. flat?: boolean;
  59925. updatable?: boolean;
  59926. sideOrientation?: number;
  59927. frontUVs?: Vector4;
  59928. backUVs?: Vector4;
  59929. }, scene?: Nullable<Scene>): Mesh;
  59930. /**
  59931. * Creates a decal mesh.
  59932. * 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
  59933. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  59934. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  59935. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  59936. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  59937. * @param name defines the name of the mesh
  59938. * @param sourceMesh defines the mesh where the decal must be applied
  59939. * @param options defines the options used to create the mesh
  59940. * @param scene defines the hosting scene
  59941. * @returns the decal mesh
  59942. * @see https://doc.babylonjs.com/how_to/decals
  59943. */
  59944. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  59945. position?: Vector3;
  59946. normal?: Vector3;
  59947. size?: Vector3;
  59948. angle?: number;
  59949. }): Mesh;
  59950. }
  59951. }
  59952. declare module "babylonjs/Meshes/meshSimplification" {
  59953. import { Mesh } from "babylonjs/Meshes/mesh";
  59954. /**
  59955. * A simplifier interface for future simplification implementations
  59956. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59957. */
  59958. export interface ISimplifier {
  59959. /**
  59960. * Simplification of a given mesh according to the given settings.
  59961. * Since this requires computation, it is assumed that the function runs async.
  59962. * @param settings The settings of the simplification, including quality and distance
  59963. * @param successCallback A callback that will be called after the mesh was simplified.
  59964. * @param errorCallback in case of an error, this callback will be called. optional.
  59965. */
  59966. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  59967. }
  59968. /**
  59969. * Expected simplification settings.
  59970. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  59971. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59972. */
  59973. export interface ISimplificationSettings {
  59974. /**
  59975. * Gets or sets the expected quality
  59976. */
  59977. quality: number;
  59978. /**
  59979. * Gets or sets the distance when this optimized version should be used
  59980. */
  59981. distance: number;
  59982. /**
  59983. * Gets an already optimized mesh
  59984. */
  59985. optimizeMesh?: boolean;
  59986. }
  59987. /**
  59988. * Class used to specify simplification options
  59989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  59990. */
  59991. export class SimplificationSettings implements ISimplificationSettings {
  59992. /** expected quality */
  59993. quality: number;
  59994. /** distance when this optimized version should be used */
  59995. distance: number;
  59996. /** already optimized mesh */
  59997. optimizeMesh?: boolean | undefined;
  59998. /**
  59999. * Creates a SimplificationSettings
  60000. * @param quality expected quality
  60001. * @param distance distance when this optimized version should be used
  60002. * @param optimizeMesh already optimized mesh
  60003. */
  60004. constructor(
  60005. /** expected quality */
  60006. quality: number,
  60007. /** distance when this optimized version should be used */
  60008. distance: number,
  60009. /** already optimized mesh */
  60010. optimizeMesh?: boolean | undefined);
  60011. }
  60012. /**
  60013. * Interface used to define a simplification task
  60014. */
  60015. export interface ISimplificationTask {
  60016. /**
  60017. * Array of settings
  60018. */
  60019. settings: Array<ISimplificationSettings>;
  60020. /**
  60021. * Simplification type
  60022. */
  60023. simplificationType: SimplificationType;
  60024. /**
  60025. * Mesh to simplify
  60026. */
  60027. mesh: Mesh;
  60028. /**
  60029. * Callback called on success
  60030. */
  60031. successCallback?: () => void;
  60032. /**
  60033. * Defines if parallel processing can be used
  60034. */
  60035. parallelProcessing: boolean;
  60036. }
  60037. /**
  60038. * Queue used to order the simplification tasks
  60039. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60040. */
  60041. export class SimplificationQueue {
  60042. private _simplificationArray;
  60043. /**
  60044. * Gets a boolean indicating that the process is still running
  60045. */
  60046. running: boolean;
  60047. /**
  60048. * Creates a new queue
  60049. */
  60050. constructor();
  60051. /**
  60052. * Adds a new simplification task
  60053. * @param task defines a task to add
  60054. */
  60055. addTask(task: ISimplificationTask): void;
  60056. /**
  60057. * Execute next task
  60058. */
  60059. executeNext(): void;
  60060. /**
  60061. * Execute a simplification task
  60062. * @param task defines the task to run
  60063. */
  60064. runSimplification(task: ISimplificationTask): void;
  60065. private getSimplifier;
  60066. }
  60067. /**
  60068. * The implemented types of simplification
  60069. * At the moment only Quadratic Error Decimation is implemented
  60070. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60071. */
  60072. export enum SimplificationType {
  60073. /** Quadratic error decimation */
  60074. QUADRATIC = 0
  60075. }
  60076. }
  60077. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  60078. import { Scene } from "babylonjs/scene";
  60079. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  60080. import { ISceneComponent } from "babylonjs/sceneComponent";
  60081. module "babylonjs/scene" {
  60082. interface Scene {
  60083. /** @hidden (Backing field) */
  60084. _simplificationQueue: SimplificationQueue;
  60085. /**
  60086. * Gets or sets the simplification queue attached to the scene
  60087. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  60088. */
  60089. simplificationQueue: SimplificationQueue;
  60090. }
  60091. }
  60092. module "babylonjs/Meshes/mesh" {
  60093. interface Mesh {
  60094. /**
  60095. * Simplify the mesh according to the given array of settings.
  60096. * Function will return immediately and will simplify async
  60097. * @param settings a collection of simplification settings
  60098. * @param parallelProcessing should all levels calculate parallel or one after the other
  60099. * @param simplificationType the type of simplification to run
  60100. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  60101. * @returns the current mesh
  60102. */
  60103. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  60104. }
  60105. }
  60106. /**
  60107. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  60108. * created in a scene
  60109. */
  60110. export class SimplicationQueueSceneComponent implements ISceneComponent {
  60111. /**
  60112. * The component name helpfull to identify the component in the list of scene components.
  60113. */
  60114. readonly name: string;
  60115. /**
  60116. * The scene the component belongs to.
  60117. */
  60118. scene: Scene;
  60119. /**
  60120. * Creates a new instance of the component for the given scene
  60121. * @param scene Defines the scene to register the component in
  60122. */
  60123. constructor(scene: Scene);
  60124. /**
  60125. * Registers the component in a given scene
  60126. */
  60127. register(): void;
  60128. /**
  60129. * Rebuilds the elements related to this component in case of
  60130. * context lost for instance.
  60131. */
  60132. rebuild(): void;
  60133. /**
  60134. * Disposes the component and the associated ressources
  60135. */
  60136. dispose(): void;
  60137. private _beforeCameraUpdate;
  60138. }
  60139. }
  60140. declare module "babylonjs/Meshes/Builders/index" {
  60141. export * from "babylonjs/Meshes/Builders/boxBuilder";
  60142. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  60143. export * from "babylonjs/Meshes/Builders/discBuilder";
  60144. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  60145. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  60146. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  60147. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  60148. export * from "babylonjs/Meshes/Builders/torusBuilder";
  60149. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  60150. export * from "babylonjs/Meshes/Builders/linesBuilder";
  60151. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  60152. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  60153. export * from "babylonjs/Meshes/Builders/latheBuilder";
  60154. export * from "babylonjs/Meshes/Builders/planeBuilder";
  60155. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  60156. export * from "babylonjs/Meshes/Builders/groundBuilder";
  60157. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  60158. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  60159. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  60160. export * from "babylonjs/Meshes/Builders/decalBuilder";
  60161. }
  60162. declare module "babylonjs/Meshes/index" {
  60163. export * from "babylonjs/Meshes/abstractMesh";
  60164. export * from "babylonjs/Meshes/buffer";
  60165. export * from "babylonjs/Meshes/Compression/index";
  60166. export * from "babylonjs/Meshes/csg";
  60167. export * from "babylonjs/Meshes/geometry";
  60168. export * from "babylonjs/Meshes/groundMesh";
  60169. export * from "babylonjs/Meshes/trailMesh";
  60170. export * from "babylonjs/Meshes/instancedMesh";
  60171. export * from "babylonjs/Meshes/linesMesh";
  60172. export * from "babylonjs/Meshes/mesh";
  60173. export * from "babylonjs/Meshes/mesh.vertexData";
  60174. export * from "babylonjs/Meshes/meshBuilder";
  60175. export * from "babylonjs/Meshes/meshSimplification";
  60176. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  60177. export * from "babylonjs/Meshes/polygonMesh";
  60178. export * from "babylonjs/Meshes/subMesh";
  60179. export * from "babylonjs/Meshes/meshLODLevel";
  60180. export * from "babylonjs/Meshes/transformNode";
  60181. export * from "babylonjs/Meshes/Builders/index";
  60182. export * from "babylonjs/Meshes/dataBuffer";
  60183. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  60184. }
  60185. declare module "babylonjs/Morph/index" {
  60186. export * from "babylonjs/Morph/morphTarget";
  60187. export * from "babylonjs/Morph/morphTargetManager";
  60188. }
  60189. declare module "babylonjs/Navigation/INavigationEngine" {
  60190. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60191. import { Vector3 } from "babylonjs/Maths/math";
  60192. import { Mesh } from "babylonjs/Meshes/mesh";
  60193. import { Scene } from "babylonjs/scene";
  60194. /**
  60195. * Navigation plugin interface to add navigation constrained by a navigation mesh
  60196. */
  60197. export interface INavigationEnginePlugin {
  60198. /**
  60199. * plugin name
  60200. */
  60201. name: string;
  60202. /**
  60203. * Creates a navigation mesh
  60204. * @param meshes array of all the geometry used to compute the navigatio mesh
  60205. * @param parameters bunch of parameters used to filter geometry
  60206. */
  60207. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60208. /**
  60209. * Create a navigation mesh debug mesh
  60210. * @param scene is where the mesh will be added
  60211. * @returns debug display mesh
  60212. */
  60213. createDebugNavMesh(scene: Scene): Mesh;
  60214. /**
  60215. * Get a navigation mesh constrained position, closest to the parameter position
  60216. * @param position world position
  60217. * @returns the closest point to position constrained by the navigation mesh
  60218. */
  60219. getClosestPoint(position: Vector3): Vector3;
  60220. /**
  60221. * Get a navigation mesh constrained position, within a particular radius
  60222. * @param position world position
  60223. * @param maxRadius the maximum distance to the constrained world position
  60224. * @returns the closest point to position constrained by the navigation mesh
  60225. */
  60226. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60227. /**
  60228. * Compute the final position from a segment made of destination-position
  60229. * @param position world position
  60230. * @param destination world position
  60231. * @returns the resulting point along the navmesh
  60232. */
  60233. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60234. /**
  60235. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60236. * @param start world position
  60237. * @param end world position
  60238. * @returns array containing world position composing the path
  60239. */
  60240. computePath(start: Vector3, end: Vector3): Vector3[];
  60241. /**
  60242. * If this plugin is supported
  60243. * @returns true if plugin is supported
  60244. */
  60245. isSupported(): boolean;
  60246. /**
  60247. * Create a new Crowd so you can add agents
  60248. * @param maxAgents the maximum agent count in the crowd
  60249. * @param maxAgentRadius the maximum radius an agent can have
  60250. * @param scene to attach the crowd to
  60251. * @returns the crowd you can add agents to
  60252. */
  60253. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60254. /**
  60255. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60256. * The queries will try to find a solution within those bounds
  60257. * default is (1,1,1)
  60258. * @param extent x,y,z value that define the extent around the queries point of reference
  60259. */
  60260. setDefaultQueryExtent(extent: Vector3): void;
  60261. /**
  60262. * Get the Bounding box extent specified by setDefaultQueryExtent
  60263. * @returns the box extent values
  60264. */
  60265. getDefaultQueryExtent(): Vector3;
  60266. /**
  60267. * Release all resources
  60268. */
  60269. dispose(): void;
  60270. }
  60271. /**
  60272. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  60273. */
  60274. export interface ICrowd {
  60275. /**
  60276. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60277. * You can attach anything to that node. The node position is updated in the scene update tick.
  60278. * @param pos world position that will be constrained by the navigation mesh
  60279. * @param parameters agent parameters
  60280. * @param transform hooked to the agent that will be update by the scene
  60281. * @returns agent index
  60282. */
  60283. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60284. /**
  60285. * Returns the agent position in world space
  60286. * @param index agent index returned by addAgent
  60287. * @returns world space position
  60288. */
  60289. getAgentPosition(index: number): Vector3;
  60290. /**
  60291. * Gets the agent velocity in world space
  60292. * @param index agent index returned by addAgent
  60293. * @returns world space velocity
  60294. */
  60295. getAgentVelocity(index: number): Vector3;
  60296. /**
  60297. * remove a particular agent previously created
  60298. * @param index agent index returned by addAgent
  60299. */
  60300. removeAgent(index: number): void;
  60301. /**
  60302. * get the list of all agents attached to this crowd
  60303. * @returns list of agent indices
  60304. */
  60305. getAgents(): number[];
  60306. /**
  60307. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60308. * @param deltaTime in seconds
  60309. */
  60310. update(deltaTime: number): void;
  60311. /**
  60312. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60313. * @param index agent index returned by addAgent
  60314. * @param destination targeted world position
  60315. */
  60316. agentGoto(index: number, destination: Vector3): void;
  60317. /**
  60318. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60319. * The queries will try to find a solution within those bounds
  60320. * default is (1,1,1)
  60321. * @param extent x,y,z value that define the extent around the queries point of reference
  60322. */
  60323. setDefaultQueryExtent(extent: Vector3): void;
  60324. /**
  60325. * Get the Bounding box extent specified by setDefaultQueryExtent
  60326. * @returns the box extent values
  60327. */
  60328. getDefaultQueryExtent(): Vector3;
  60329. /**
  60330. * Release all resources
  60331. */
  60332. dispose(): void;
  60333. }
  60334. /**
  60335. * Configures an agent
  60336. */
  60337. export interface IAgentParameters {
  60338. /**
  60339. * Agent radius. [Limit: >= 0]
  60340. */
  60341. radius: number;
  60342. /**
  60343. * Agent height. [Limit: > 0]
  60344. */
  60345. height: number;
  60346. /**
  60347. * Maximum allowed acceleration. [Limit: >= 0]
  60348. */
  60349. maxAcceleration: number;
  60350. /**
  60351. * Maximum allowed speed. [Limit: >= 0]
  60352. */
  60353. maxSpeed: number;
  60354. /**
  60355. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  60356. */
  60357. collisionQueryRange: number;
  60358. /**
  60359. * The path visibility optimization range. [Limit: > 0]
  60360. */
  60361. pathOptimizationRange: number;
  60362. /**
  60363. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  60364. */
  60365. separationWeight: number;
  60366. }
  60367. /**
  60368. * Configures the navigation mesh creation
  60369. */
  60370. export interface INavMeshParameters {
  60371. /**
  60372. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  60373. */
  60374. cs: number;
  60375. /**
  60376. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  60377. */
  60378. ch: number;
  60379. /**
  60380. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  60381. */
  60382. walkableSlopeAngle: number;
  60383. /**
  60384. * Minimum floor to 'ceiling' height that will still allow the floor area to
  60385. * be considered walkable. [Limit: >= 3] [Units: vx]
  60386. */
  60387. walkableHeight: number;
  60388. /**
  60389. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  60390. */
  60391. walkableClimb: number;
  60392. /**
  60393. * The distance to erode/shrink the walkable area of the heightfield away from
  60394. * obstructions. [Limit: >=0] [Units: vx]
  60395. */
  60396. walkableRadius: number;
  60397. /**
  60398. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  60399. */
  60400. maxEdgeLen: number;
  60401. /**
  60402. * The maximum distance a simplfied contour's border edges should deviate
  60403. * the original raw contour. [Limit: >=0] [Units: vx]
  60404. */
  60405. maxSimplificationError: number;
  60406. /**
  60407. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  60408. */
  60409. minRegionArea: number;
  60410. /**
  60411. * Any regions with a span count smaller than this value will, if possible,
  60412. * be merged with larger regions. [Limit: >=0] [Units: vx]
  60413. */
  60414. mergeRegionArea: number;
  60415. /**
  60416. * The maximum number of vertices allowed for polygons generated during the
  60417. * contour to polygon conversion process. [Limit: >= 3]
  60418. */
  60419. maxVertsPerPoly: number;
  60420. /**
  60421. * Sets the sampling distance to use when generating the detail mesh.
  60422. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  60423. */
  60424. detailSampleDist: number;
  60425. /**
  60426. * The maximum distance the detail mesh surface should deviate from heightfield
  60427. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  60428. */
  60429. detailSampleMaxError: number;
  60430. }
  60431. }
  60432. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  60433. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  60434. import { Mesh } from "babylonjs/Meshes/mesh";
  60435. import { Scene } from "babylonjs/scene";
  60436. import { Vector3 } from "babylonjs/Maths/math";
  60437. import { TransformNode } from "babylonjs/Meshes/transformNode";
  60438. /**
  60439. * RecastJS navigation plugin
  60440. */
  60441. export class RecastJSPlugin implements INavigationEnginePlugin {
  60442. /**
  60443. * Reference to the Recast library
  60444. */
  60445. bjsRECAST: any;
  60446. /**
  60447. * plugin name
  60448. */
  60449. name: string;
  60450. /**
  60451. * the first navmesh created. We might extend this to support multiple navmeshes
  60452. */
  60453. navMesh: any;
  60454. /**
  60455. * Initializes the recastJS plugin
  60456. * @param recastInjection can be used to inject your own recast reference
  60457. */
  60458. constructor(recastInjection?: any);
  60459. /**
  60460. * Creates a navigation mesh
  60461. * @param meshes array of all the geometry used to compute the navigatio mesh
  60462. * @param parameters bunch of parameters used to filter geometry
  60463. */
  60464. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  60465. /**
  60466. * Create a navigation mesh debug mesh
  60467. * @param scene is where the mesh will be added
  60468. * @returns debug display mesh
  60469. */
  60470. createDebugNavMesh(scene: Scene): Mesh;
  60471. /**
  60472. * Get a navigation mesh constrained position, closest to the parameter position
  60473. * @param position world position
  60474. * @returns the closest point to position constrained by the navigation mesh
  60475. */
  60476. getClosestPoint(position: Vector3): Vector3;
  60477. /**
  60478. * Get a navigation mesh constrained position, within a particular radius
  60479. * @param position world position
  60480. * @param maxRadius the maximum distance to the constrained world position
  60481. * @returns the closest point to position constrained by the navigation mesh
  60482. */
  60483. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  60484. /**
  60485. * Compute the final position from a segment made of destination-position
  60486. * @param position world position
  60487. * @param destination world position
  60488. * @returns the resulting point along the navmesh
  60489. */
  60490. moveAlong(position: Vector3, destination: Vector3): Vector3;
  60491. /**
  60492. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  60493. * @param start world position
  60494. * @param end world position
  60495. * @returns array containing world position composing the path
  60496. */
  60497. computePath(start: Vector3, end: Vector3): Vector3[];
  60498. /**
  60499. * Create a new Crowd so you can add agents
  60500. * @param maxAgents the maximum agent count in the crowd
  60501. * @param maxAgentRadius the maximum radius an agent can have
  60502. * @param scene to attach the crowd to
  60503. * @returns the crowd you can add agents to
  60504. */
  60505. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  60506. /**
  60507. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60508. * The queries will try to find a solution within those bounds
  60509. * default is (1,1,1)
  60510. * @param extent x,y,z value that define the extent around the queries point of reference
  60511. */
  60512. setDefaultQueryExtent(extent: Vector3): void;
  60513. /**
  60514. * Get the Bounding box extent specified by setDefaultQueryExtent
  60515. * @returns the box extent values
  60516. */
  60517. getDefaultQueryExtent(): Vector3;
  60518. /**
  60519. * Disposes
  60520. */
  60521. dispose(): void;
  60522. /**
  60523. * If this plugin is supported
  60524. * @returns true if plugin is supported
  60525. */
  60526. isSupported(): boolean;
  60527. }
  60528. /**
  60529. * Recast detour crowd implementation
  60530. */
  60531. export class RecastJSCrowd implements ICrowd {
  60532. /**
  60533. * Recast/detour plugin
  60534. */
  60535. bjsRECASTPlugin: RecastJSPlugin;
  60536. /**
  60537. * Link to the detour crowd
  60538. */
  60539. recastCrowd: any;
  60540. /**
  60541. * One transform per agent
  60542. */
  60543. transforms: TransformNode[];
  60544. /**
  60545. * All agents created
  60546. */
  60547. agents: number[];
  60548. /**
  60549. * Link to the scene is kept to unregister the crowd from the scene
  60550. */
  60551. private _scene;
  60552. /**
  60553. * Observer for crowd updates
  60554. */
  60555. private _onBeforeAnimationsObserver;
  60556. /**
  60557. * Constructor
  60558. * @param plugin recastJS plugin
  60559. * @param maxAgents the maximum agent count in the crowd
  60560. * @param maxAgentRadius the maximum radius an agent can have
  60561. * @param scene to attach the crowd to
  60562. * @returns the crowd you can add agents to
  60563. */
  60564. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  60565. /**
  60566. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  60567. * You can attach anything to that node. The node position is updated in the scene update tick.
  60568. * @param pos world position that will be constrained by the navigation mesh
  60569. * @param parameters agent parameters
  60570. * @param transform hooked to the agent that will be update by the scene
  60571. * @returns agent index
  60572. */
  60573. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  60574. /**
  60575. * Returns the agent position in world space
  60576. * @param index agent index returned by addAgent
  60577. * @returns world space position
  60578. */
  60579. getAgentPosition(index: number): Vector3;
  60580. /**
  60581. * Returns the agent velocity in world space
  60582. * @param index agent index returned by addAgent
  60583. * @returns world space velocity
  60584. */
  60585. getAgentVelocity(index: number): Vector3;
  60586. /**
  60587. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  60588. * @param index agent index returned by addAgent
  60589. * @param destination targeted world position
  60590. */
  60591. agentGoto(index: number, destination: Vector3): void;
  60592. /**
  60593. * remove a particular agent previously created
  60594. * @param index agent index returned by addAgent
  60595. */
  60596. removeAgent(index: number): void;
  60597. /**
  60598. * get the list of all agents attached to this crowd
  60599. * @returns list of agent indices
  60600. */
  60601. getAgents(): number[];
  60602. /**
  60603. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  60604. * @param deltaTime in seconds
  60605. */
  60606. update(deltaTime: number): void;
  60607. /**
  60608. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  60609. * The queries will try to find a solution within those bounds
  60610. * default is (1,1,1)
  60611. * @param extent x,y,z value that define the extent around the queries point of reference
  60612. */
  60613. setDefaultQueryExtent(extent: Vector3): void;
  60614. /**
  60615. * Get the Bounding box extent specified by setDefaultQueryExtent
  60616. * @returns the box extent values
  60617. */
  60618. getDefaultQueryExtent(): Vector3;
  60619. /**
  60620. * Release all resources
  60621. */
  60622. dispose(): void;
  60623. }
  60624. }
  60625. declare module "babylonjs/Navigation/Plugins/index" {
  60626. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  60627. }
  60628. declare module "babylonjs/Navigation/index" {
  60629. export * from "babylonjs/Navigation/INavigationEngine";
  60630. export * from "babylonjs/Navigation/Plugins/index";
  60631. }
  60632. declare module "babylonjs/Offline/database" {
  60633. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  60634. /**
  60635. * Class used to enable access to IndexedDB
  60636. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  60637. */
  60638. export class Database implements IOfflineProvider {
  60639. private _callbackManifestChecked;
  60640. private _currentSceneUrl;
  60641. private _db;
  60642. private _enableSceneOffline;
  60643. private _enableTexturesOffline;
  60644. private _manifestVersionFound;
  60645. private _mustUpdateRessources;
  60646. private _hasReachedQuota;
  60647. private _isSupported;
  60648. private _idbFactory;
  60649. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  60650. private static IsUASupportingBlobStorage;
  60651. /**
  60652. * Gets a boolean indicating if Database storate is enabled (off by default)
  60653. */
  60654. static IDBStorageEnabled: boolean;
  60655. /**
  60656. * Gets a boolean indicating if scene must be saved in the database
  60657. */
  60658. readonly enableSceneOffline: boolean;
  60659. /**
  60660. * Gets a boolean indicating if textures must be saved in the database
  60661. */
  60662. readonly enableTexturesOffline: boolean;
  60663. /**
  60664. * Creates a new Database
  60665. * @param urlToScene defines the url to load the scene
  60666. * @param callbackManifestChecked defines the callback to use when manifest is checked
  60667. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  60668. */
  60669. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  60670. private static _ParseURL;
  60671. private static _ReturnFullUrlLocation;
  60672. private _checkManifestFile;
  60673. /**
  60674. * Open the database and make it available
  60675. * @param successCallback defines the callback to call on success
  60676. * @param errorCallback defines the callback to call on error
  60677. */
  60678. open(successCallback: () => void, errorCallback: () => void): void;
  60679. /**
  60680. * Loads an image from the database
  60681. * @param url defines the url to load from
  60682. * @param image defines the target DOM image
  60683. */
  60684. loadImage(url: string, image: HTMLImageElement): void;
  60685. private _loadImageFromDBAsync;
  60686. private _saveImageIntoDBAsync;
  60687. private _checkVersionFromDB;
  60688. private _loadVersionFromDBAsync;
  60689. private _saveVersionIntoDBAsync;
  60690. /**
  60691. * Loads a file from database
  60692. * @param url defines the URL to load from
  60693. * @param sceneLoaded defines a callback to call on success
  60694. * @param progressCallBack defines a callback to call when progress changed
  60695. * @param errorCallback defines a callback to call on error
  60696. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  60697. */
  60698. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  60699. private _loadFileAsync;
  60700. private _saveFileAsync;
  60701. /**
  60702. * Validates if xhr data is correct
  60703. * @param xhr defines the request to validate
  60704. * @param dataType defines the expected data type
  60705. * @returns true if data is correct
  60706. */
  60707. private static _ValidateXHRData;
  60708. }
  60709. }
  60710. declare module "babylonjs/Offline/index" {
  60711. export * from "babylonjs/Offline/database";
  60712. export * from "babylonjs/Offline/IOfflineProvider";
  60713. }
  60714. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  60715. /** @hidden */
  60716. export var gpuUpdateParticlesPixelShader: {
  60717. name: string;
  60718. shader: string;
  60719. };
  60720. }
  60721. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  60722. /** @hidden */
  60723. export var gpuUpdateParticlesVertexShader: {
  60724. name: string;
  60725. shader: string;
  60726. };
  60727. }
  60728. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  60729. /** @hidden */
  60730. export var clipPlaneFragmentDeclaration2: {
  60731. name: string;
  60732. shader: string;
  60733. };
  60734. }
  60735. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  60736. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  60737. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  60738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60739. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  60740. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  60741. /** @hidden */
  60742. export var gpuRenderParticlesPixelShader: {
  60743. name: string;
  60744. shader: string;
  60745. };
  60746. }
  60747. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  60748. /** @hidden */
  60749. export var clipPlaneVertexDeclaration2: {
  60750. name: string;
  60751. shader: string;
  60752. };
  60753. }
  60754. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  60755. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  60756. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  60757. /** @hidden */
  60758. export var gpuRenderParticlesVertexShader: {
  60759. name: string;
  60760. shader: string;
  60761. };
  60762. }
  60763. declare module "babylonjs/Particles/gpuParticleSystem" {
  60764. import { Nullable } from "babylonjs/types";
  60765. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  60766. import { Observable } from "babylonjs/Misc/observable";
  60767. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  60768. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  60769. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  60770. import { Scene, IDisposable } from "babylonjs/scene";
  60771. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  60772. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  60773. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  60774. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  60775. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  60776. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  60777. /**
  60778. * This represents a GPU particle system in Babylon
  60779. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  60780. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  60781. */
  60782. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  60783. /**
  60784. * The layer mask we are rendering the particles through.
  60785. */
  60786. layerMask: number;
  60787. private _capacity;
  60788. private _activeCount;
  60789. private _currentActiveCount;
  60790. private _accumulatedCount;
  60791. private _renderEffect;
  60792. private _updateEffect;
  60793. private _buffer0;
  60794. private _buffer1;
  60795. private _spriteBuffer;
  60796. private _updateVAO;
  60797. private _renderVAO;
  60798. private _targetIndex;
  60799. private _sourceBuffer;
  60800. private _targetBuffer;
  60801. private _engine;
  60802. private _currentRenderId;
  60803. private _started;
  60804. private _stopped;
  60805. private _timeDelta;
  60806. private _randomTexture;
  60807. private _randomTexture2;
  60808. private _attributesStrideSize;
  60809. private _updateEffectOptions;
  60810. private _randomTextureSize;
  60811. private _actualFrame;
  60812. private readonly _rawTextureWidth;
  60813. /**
  60814. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  60815. */
  60816. static readonly IsSupported: boolean;
  60817. /**
  60818. * An event triggered when the system is disposed.
  60819. */
  60820. onDisposeObservable: Observable<GPUParticleSystem>;
  60821. /**
  60822. * Gets the maximum number of particles active at the same time.
  60823. * @returns The max number of active particles.
  60824. */
  60825. getCapacity(): number;
  60826. /**
  60827. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  60828. * to override the particles.
  60829. */
  60830. forceDepthWrite: boolean;
  60831. /**
  60832. * Gets or set the number of active particles
  60833. */
  60834. activeParticleCount: number;
  60835. private _preWarmDone;
  60836. /**
  60837. * Is this system ready to be used/rendered
  60838. * @return true if the system is ready
  60839. */
  60840. isReady(): boolean;
  60841. /**
  60842. * Gets if the system has been started. (Note: this will still be true after stop is called)
  60843. * @returns True if it has been started, otherwise false.
  60844. */
  60845. isStarted(): boolean;
  60846. /**
  60847. * Starts the particle system and begins to emit
  60848. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  60849. */
  60850. start(delay?: number): void;
  60851. /**
  60852. * Stops the particle system.
  60853. */
  60854. stop(): void;
  60855. /**
  60856. * Remove all active particles
  60857. */
  60858. reset(): void;
  60859. /**
  60860. * Returns the string "GPUParticleSystem"
  60861. * @returns a string containing the class name
  60862. */
  60863. getClassName(): string;
  60864. private _colorGradientsTexture;
  60865. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  60866. /**
  60867. * Adds a new color gradient
  60868. * @param gradient defines the gradient to use (between 0 and 1)
  60869. * @param color1 defines the color to affect to the specified gradient
  60870. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  60871. * @returns the current particle system
  60872. */
  60873. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  60874. /**
  60875. * Remove a specific color gradient
  60876. * @param gradient defines the gradient to remove
  60877. * @returns the current particle system
  60878. */
  60879. removeColorGradient(gradient: number): GPUParticleSystem;
  60880. private _angularSpeedGradientsTexture;
  60881. private _sizeGradientsTexture;
  60882. private _velocityGradientsTexture;
  60883. private _limitVelocityGradientsTexture;
  60884. private _dragGradientsTexture;
  60885. private _addFactorGradient;
  60886. /**
  60887. * Adds a new size gradient
  60888. * @param gradient defines the gradient to use (between 0 and 1)
  60889. * @param factor defines the size factor to affect to the specified gradient
  60890. * @returns the current particle system
  60891. */
  60892. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  60893. /**
  60894. * Remove a specific size gradient
  60895. * @param gradient defines the gradient to remove
  60896. * @returns the current particle system
  60897. */
  60898. removeSizeGradient(gradient: number): GPUParticleSystem;
  60899. /**
  60900. * Adds a new angular speed gradient
  60901. * @param gradient defines the gradient to use (between 0 and 1)
  60902. * @param factor defines the angular speed to affect to the specified gradient
  60903. * @returns the current particle system
  60904. */
  60905. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  60906. /**
  60907. * Remove a specific angular speed gradient
  60908. * @param gradient defines the gradient to remove
  60909. * @returns the current particle system
  60910. */
  60911. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  60912. /**
  60913. * Adds a new velocity gradient
  60914. * @param gradient defines the gradient to use (between 0 and 1)
  60915. * @param factor defines the velocity to affect to the specified gradient
  60916. * @returns the current particle system
  60917. */
  60918. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60919. /**
  60920. * Remove a specific velocity gradient
  60921. * @param gradient defines the gradient to remove
  60922. * @returns the current particle system
  60923. */
  60924. removeVelocityGradient(gradient: number): GPUParticleSystem;
  60925. /**
  60926. * Adds a new limit velocity gradient
  60927. * @param gradient defines the gradient to use (between 0 and 1)
  60928. * @param factor defines the limit velocity value to affect to the specified gradient
  60929. * @returns the current particle system
  60930. */
  60931. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  60932. /**
  60933. * Remove a specific limit velocity gradient
  60934. * @param gradient defines the gradient to remove
  60935. * @returns the current particle system
  60936. */
  60937. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  60938. /**
  60939. * Adds a new drag gradient
  60940. * @param gradient defines the gradient to use (between 0 and 1)
  60941. * @param factor defines the drag value to affect to the specified gradient
  60942. * @returns the current particle system
  60943. */
  60944. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  60945. /**
  60946. * Remove a specific drag gradient
  60947. * @param gradient defines the gradient to remove
  60948. * @returns the current particle system
  60949. */
  60950. removeDragGradient(gradient: number): GPUParticleSystem;
  60951. /**
  60952. * Not supported by GPUParticleSystem
  60953. * @param gradient defines the gradient to use (between 0 and 1)
  60954. * @param factor defines the emit rate value to affect to the specified gradient
  60955. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60956. * @returns the current particle system
  60957. */
  60958. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60959. /**
  60960. * Not supported by GPUParticleSystem
  60961. * @param gradient defines the gradient to remove
  60962. * @returns the current particle system
  60963. */
  60964. removeEmitRateGradient(gradient: number): IParticleSystem;
  60965. /**
  60966. * Not supported by GPUParticleSystem
  60967. * @param gradient defines the gradient to use (between 0 and 1)
  60968. * @param factor defines the start size value to affect to the specified gradient
  60969. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  60970. * @returns the current particle system
  60971. */
  60972. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  60973. /**
  60974. * Not supported by GPUParticleSystem
  60975. * @param gradient defines the gradient to remove
  60976. * @returns the current particle system
  60977. */
  60978. removeStartSizeGradient(gradient: number): IParticleSystem;
  60979. /**
  60980. * Not supported by GPUParticleSystem
  60981. * @param gradient defines the gradient to use (between 0 and 1)
  60982. * @param min defines the color remap minimal range
  60983. * @param max defines the color remap maximal range
  60984. * @returns the current particle system
  60985. */
  60986. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  60987. /**
  60988. * Not supported by GPUParticleSystem
  60989. * @param gradient defines the gradient to remove
  60990. * @returns the current particle system
  60991. */
  60992. removeColorRemapGradient(): IParticleSystem;
  60993. /**
  60994. * Not supported by GPUParticleSystem
  60995. * @param gradient defines the gradient to use (between 0 and 1)
  60996. * @param min defines the alpha remap minimal range
  60997. * @param max defines the alpha remap maximal range
  60998. * @returns the current particle system
  60999. */
  61000. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  61001. /**
  61002. * Not supported by GPUParticleSystem
  61003. * @param gradient defines the gradient to remove
  61004. * @returns the current particle system
  61005. */
  61006. removeAlphaRemapGradient(): IParticleSystem;
  61007. /**
  61008. * Not supported by GPUParticleSystem
  61009. * @param gradient defines the gradient to use (between 0 and 1)
  61010. * @param color defines the color to affect to the specified gradient
  61011. * @returns the current particle system
  61012. */
  61013. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  61014. /**
  61015. * Not supported by GPUParticleSystem
  61016. * @param gradient defines the gradient to remove
  61017. * @returns the current particle system
  61018. */
  61019. removeRampGradient(): IParticleSystem;
  61020. /**
  61021. * Not supported by GPUParticleSystem
  61022. * @returns the list of ramp gradients
  61023. */
  61024. getRampGradients(): Nullable<Array<Color3Gradient>>;
  61025. /**
  61026. * Not supported by GPUParticleSystem
  61027. * Gets or sets a boolean indicating that ramp gradients must be used
  61028. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  61029. */
  61030. useRampGradients: boolean;
  61031. /**
  61032. * Not supported by GPUParticleSystem
  61033. * @param gradient defines the gradient to use (between 0 and 1)
  61034. * @param factor defines the life time factor to affect to the specified gradient
  61035. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  61036. * @returns the current particle system
  61037. */
  61038. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  61039. /**
  61040. * Not supported by GPUParticleSystem
  61041. * @param gradient defines the gradient to remove
  61042. * @returns the current particle system
  61043. */
  61044. removeLifeTimeGradient(gradient: number): IParticleSystem;
  61045. /**
  61046. * Instantiates a GPU particle system.
  61047. * 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.
  61048. * @param name The name of the particle system
  61049. * @param options The options used to create the system
  61050. * @param scene The scene the particle system belongs to
  61051. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  61052. */
  61053. constructor(name: string, options: Partial<{
  61054. capacity: number;
  61055. randomTextureSize: number;
  61056. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  61057. protected _reset(): void;
  61058. private _createUpdateVAO;
  61059. private _createRenderVAO;
  61060. private _initialize;
  61061. /** @hidden */
  61062. _recreateUpdateEffect(): void;
  61063. /** @hidden */
  61064. _recreateRenderEffect(): void;
  61065. /**
  61066. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  61067. * @param preWarm defines if we are in the pre-warmimg phase
  61068. */
  61069. animate(preWarm?: boolean): void;
  61070. private _createFactorGradientTexture;
  61071. private _createSizeGradientTexture;
  61072. private _createAngularSpeedGradientTexture;
  61073. private _createVelocityGradientTexture;
  61074. private _createLimitVelocityGradientTexture;
  61075. private _createDragGradientTexture;
  61076. private _createColorGradientTexture;
  61077. /**
  61078. * Renders the particle system in its current state
  61079. * @param preWarm defines if the system should only update the particles but not render them
  61080. * @returns the current number of particles
  61081. */
  61082. render(preWarm?: boolean): number;
  61083. /**
  61084. * Rebuilds the particle system
  61085. */
  61086. rebuild(): void;
  61087. private _releaseBuffers;
  61088. private _releaseVAOs;
  61089. /**
  61090. * Disposes the particle system and free the associated resources
  61091. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  61092. */
  61093. dispose(disposeTexture?: boolean): void;
  61094. /**
  61095. * Clones the particle system.
  61096. * @param name The name of the cloned object
  61097. * @param newEmitter The new emitter to use
  61098. * @returns the cloned particle system
  61099. */
  61100. clone(name: string, newEmitter: any): GPUParticleSystem;
  61101. /**
  61102. * Serializes the particle system to a JSON object.
  61103. * @returns the JSON object
  61104. */
  61105. serialize(): any;
  61106. /**
  61107. * Parses a JSON object to create a GPU particle system.
  61108. * @param parsedParticleSystem The JSON object to parse
  61109. * @param scene The scene to create the particle system in
  61110. * @param rootUrl The root url to use to load external dependencies like texture
  61111. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  61112. * @returns the parsed GPU particle system
  61113. */
  61114. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  61115. }
  61116. }
  61117. declare module "babylonjs/Particles/particleSystemSet" {
  61118. import { Nullable } from "babylonjs/types";
  61119. import { Color3 } from "babylonjs/Maths/math.color";
  61120. import { TransformNode } from "babylonjs/Meshes/transformNode";
  61121. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61122. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61123. import { Scene, IDisposable } from "babylonjs/scene";
  61124. /**
  61125. * Represents a set of particle systems working together to create a specific effect
  61126. */
  61127. export class ParticleSystemSet implements IDisposable {
  61128. private _emitterCreationOptions;
  61129. private _emitterNode;
  61130. /**
  61131. * Gets the particle system list
  61132. */
  61133. systems: IParticleSystem[];
  61134. /**
  61135. * Gets the emitter node used with this set
  61136. */
  61137. readonly emitterNode: Nullable<TransformNode>;
  61138. /**
  61139. * Creates a new emitter mesh as a sphere
  61140. * @param options defines the options used to create the sphere
  61141. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  61142. * @param scene defines the hosting scene
  61143. */
  61144. setEmitterAsSphere(options: {
  61145. diameter: number;
  61146. segments: number;
  61147. color: Color3;
  61148. }, renderingGroupId: number, scene: Scene): void;
  61149. /**
  61150. * Starts all particle systems of the set
  61151. * @param emitter defines an optional mesh to use as emitter for the particle systems
  61152. */
  61153. start(emitter?: AbstractMesh): void;
  61154. /**
  61155. * Release all associated resources
  61156. */
  61157. dispose(): void;
  61158. /**
  61159. * Serialize the set into a JSON compatible object
  61160. * @returns a JSON compatible representation of the set
  61161. */
  61162. serialize(): any;
  61163. /**
  61164. * Parse a new ParticleSystemSet from a serialized source
  61165. * @param data defines a JSON compatible representation of the set
  61166. * @param scene defines the hosting scene
  61167. * @param gpu defines if we want GPU particles or CPU particles
  61168. * @returns a new ParticleSystemSet
  61169. */
  61170. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  61171. }
  61172. }
  61173. declare module "babylonjs/Particles/particleHelper" {
  61174. import { Nullable } from "babylonjs/types";
  61175. import { Scene } from "babylonjs/scene";
  61176. import { Vector3 } from "babylonjs/Maths/math.vector";
  61177. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61178. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61179. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  61180. /**
  61181. * This class is made for on one-liner static method to help creating particle system set.
  61182. */
  61183. export class ParticleHelper {
  61184. /**
  61185. * Gets or sets base Assets URL
  61186. */
  61187. static BaseAssetsUrl: string;
  61188. /**
  61189. * Create a default particle system that you can tweak
  61190. * @param emitter defines the emitter to use
  61191. * @param capacity defines the system capacity (default is 500 particles)
  61192. * @param scene defines the hosting scene
  61193. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  61194. * @returns the new Particle system
  61195. */
  61196. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  61197. /**
  61198. * This is the main static method (one-liner) of this helper to create different particle systems
  61199. * @param type This string represents the type to the particle system to create
  61200. * @param scene The scene where the particle system should live
  61201. * @param gpu If the system will use gpu
  61202. * @returns the ParticleSystemSet created
  61203. */
  61204. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  61205. /**
  61206. * Static function used to export a particle system to a ParticleSystemSet variable.
  61207. * Please note that the emitter shape is not exported
  61208. * @param systems defines the particle systems to export
  61209. * @returns the created particle system set
  61210. */
  61211. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  61212. }
  61213. }
  61214. declare module "babylonjs/Particles/particleSystemComponent" {
  61215. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  61216. import { Effect } from "babylonjs/Materials/effect";
  61217. import "babylonjs/Shaders/particles.vertex";
  61218. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61219. module "babylonjs/Engines/engine" {
  61220. interface Engine {
  61221. /**
  61222. * Create an effect to use with particle systems.
  61223. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  61224. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  61225. * @param uniformsNames defines a list of attribute names
  61226. * @param samplers defines an array of string used to represent textures
  61227. * @param defines defines the string containing the defines to use to compile the shaders
  61228. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  61229. * @param onCompiled defines a function to call when the effect creation is successful
  61230. * @param onError defines a function to call when the effect creation has failed
  61231. * @returns the new Effect
  61232. */
  61233. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  61234. }
  61235. }
  61236. module "babylonjs/Meshes/mesh" {
  61237. interface Mesh {
  61238. /**
  61239. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  61240. * @returns an array of IParticleSystem
  61241. */
  61242. getEmittedParticleSystems(): IParticleSystem[];
  61243. /**
  61244. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  61245. * @returns an array of IParticleSystem
  61246. */
  61247. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  61248. }
  61249. }
  61250. /**
  61251. * @hidden
  61252. */
  61253. export var _IDoNeedToBeInTheBuild: number;
  61254. }
  61255. declare module "babylonjs/Particles/index" {
  61256. export * from "babylonjs/Particles/baseParticleSystem";
  61257. export * from "babylonjs/Particles/EmitterTypes/index";
  61258. export * from "babylonjs/Particles/gpuParticleSystem";
  61259. export * from "babylonjs/Particles/IParticleSystem";
  61260. export * from "babylonjs/Particles/particle";
  61261. export * from "babylonjs/Particles/particleHelper";
  61262. export * from "babylonjs/Particles/particleSystem";
  61263. export * from "babylonjs/Particles/particleSystemComponent";
  61264. export * from "babylonjs/Particles/particleSystemSet";
  61265. export * from "babylonjs/Particles/solidParticle";
  61266. export * from "babylonjs/Particles/solidParticleSystem";
  61267. export * from "babylonjs/Particles/subEmitter";
  61268. }
  61269. declare module "babylonjs/Physics/physicsEngineComponent" {
  61270. import { Nullable } from "babylonjs/types";
  61271. import { Observable, Observer } from "babylonjs/Misc/observable";
  61272. import { Vector3 } from "babylonjs/Maths/math.vector";
  61273. import { Mesh } from "babylonjs/Meshes/mesh";
  61274. import { ISceneComponent } from "babylonjs/sceneComponent";
  61275. import { Scene } from "babylonjs/scene";
  61276. import { Node } from "babylonjs/node";
  61277. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  61278. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61279. module "babylonjs/scene" {
  61280. interface Scene {
  61281. /** @hidden (Backing field) */
  61282. _physicsEngine: Nullable<IPhysicsEngine>;
  61283. /**
  61284. * Gets the current physics engine
  61285. * @returns a IPhysicsEngine or null if none attached
  61286. */
  61287. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  61288. /**
  61289. * Enables physics to the current scene
  61290. * @param gravity defines the scene's gravity for the physics engine
  61291. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  61292. * @return a boolean indicating if the physics engine was initialized
  61293. */
  61294. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  61295. /**
  61296. * Disables and disposes the physics engine associated with the scene
  61297. */
  61298. disablePhysicsEngine(): void;
  61299. /**
  61300. * Gets a boolean indicating if there is an active physics engine
  61301. * @returns a boolean indicating if there is an active physics engine
  61302. */
  61303. isPhysicsEnabled(): boolean;
  61304. /**
  61305. * Deletes a physics compound impostor
  61306. * @param compound defines the compound to delete
  61307. */
  61308. deleteCompoundImpostor(compound: any): void;
  61309. /**
  61310. * An event triggered when physic simulation is about to be run
  61311. */
  61312. onBeforePhysicsObservable: Observable<Scene>;
  61313. /**
  61314. * An event triggered when physic simulation has been done
  61315. */
  61316. onAfterPhysicsObservable: Observable<Scene>;
  61317. }
  61318. }
  61319. module "babylonjs/Meshes/abstractMesh" {
  61320. interface AbstractMesh {
  61321. /** @hidden */
  61322. _physicsImpostor: Nullable<PhysicsImpostor>;
  61323. /**
  61324. * Gets or sets impostor used for physic simulation
  61325. * @see http://doc.babylonjs.com/features/physics_engine
  61326. */
  61327. physicsImpostor: Nullable<PhysicsImpostor>;
  61328. /**
  61329. * Gets the current physics impostor
  61330. * @see http://doc.babylonjs.com/features/physics_engine
  61331. * @returns a physics impostor or null
  61332. */
  61333. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  61334. /** Apply a physic impulse to the mesh
  61335. * @param force defines the force to apply
  61336. * @param contactPoint defines where to apply the force
  61337. * @returns the current mesh
  61338. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  61339. */
  61340. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  61341. /**
  61342. * Creates a physic joint between two meshes
  61343. * @param otherMesh defines the other mesh to use
  61344. * @param pivot1 defines the pivot to use on this mesh
  61345. * @param pivot2 defines the pivot to use on the other mesh
  61346. * @param options defines additional options (can be plugin dependent)
  61347. * @returns the current mesh
  61348. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  61349. */
  61350. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  61351. /** @hidden */
  61352. _disposePhysicsObserver: Nullable<Observer<Node>>;
  61353. }
  61354. }
  61355. /**
  61356. * Defines the physics engine scene component responsible to manage a physics engine
  61357. */
  61358. export class PhysicsEngineSceneComponent implements ISceneComponent {
  61359. /**
  61360. * The component name helpful to identify the component in the list of scene components.
  61361. */
  61362. readonly name: string;
  61363. /**
  61364. * The scene the component belongs to.
  61365. */
  61366. scene: Scene;
  61367. /**
  61368. * Creates a new instance of the component for the given scene
  61369. * @param scene Defines the scene to register the component in
  61370. */
  61371. constructor(scene: Scene);
  61372. /**
  61373. * Registers the component in a given scene
  61374. */
  61375. register(): void;
  61376. /**
  61377. * Rebuilds the elements related to this component in case of
  61378. * context lost for instance.
  61379. */
  61380. rebuild(): void;
  61381. /**
  61382. * Disposes the component and the associated ressources
  61383. */
  61384. dispose(): void;
  61385. }
  61386. }
  61387. declare module "babylonjs/Physics/physicsHelper" {
  61388. import { Nullable } from "babylonjs/types";
  61389. import { Vector3 } from "babylonjs/Maths/math.vector";
  61390. import { Mesh } from "babylonjs/Meshes/mesh";
  61391. import { Scene } from "babylonjs/scene";
  61392. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  61393. /**
  61394. * A helper for physics simulations
  61395. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61396. */
  61397. export class PhysicsHelper {
  61398. private _scene;
  61399. private _physicsEngine;
  61400. /**
  61401. * Initializes the Physics helper
  61402. * @param scene Babylon.js scene
  61403. */
  61404. constructor(scene: Scene);
  61405. /**
  61406. * Applies a radial explosion impulse
  61407. * @param origin the origin of the explosion
  61408. * @param radiusOrEventOptions the radius or the options of radial explosion
  61409. * @param strength the explosion strength
  61410. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61411. * @returns A physics radial explosion event, or null
  61412. */
  61413. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61414. /**
  61415. * Applies a radial explosion force
  61416. * @param origin the origin of the explosion
  61417. * @param radiusOrEventOptions the radius or the options of radial explosion
  61418. * @param strength the explosion strength
  61419. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61420. * @returns A physics radial explosion event, or null
  61421. */
  61422. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  61423. /**
  61424. * Creates a gravitational field
  61425. * @param origin the origin of the explosion
  61426. * @param radiusOrEventOptions the radius or the options of radial explosion
  61427. * @param strength the explosion strength
  61428. * @param falloff possible options: Constant & Linear. Defaults to Constant
  61429. * @returns A physics gravitational field event, or null
  61430. */
  61431. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  61432. /**
  61433. * Creates a physics updraft event
  61434. * @param origin the origin of the updraft
  61435. * @param radiusOrEventOptions the radius or the options of the updraft
  61436. * @param strength the strength of the updraft
  61437. * @param height the height of the updraft
  61438. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  61439. * @returns A physics updraft event, or null
  61440. */
  61441. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  61442. /**
  61443. * Creates a physics vortex event
  61444. * @param origin the of the vortex
  61445. * @param radiusOrEventOptions the radius or the options of the vortex
  61446. * @param strength the strength of the vortex
  61447. * @param height the height of the vortex
  61448. * @returns a Physics vortex event, or null
  61449. * A physics vortex event or null
  61450. */
  61451. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  61452. }
  61453. /**
  61454. * Represents a physics radial explosion event
  61455. */
  61456. class PhysicsRadialExplosionEvent {
  61457. private _scene;
  61458. private _options;
  61459. private _sphere;
  61460. private _dataFetched;
  61461. /**
  61462. * Initializes a radial explosioin event
  61463. * @param _scene BabylonJS scene
  61464. * @param _options The options for the vortex event
  61465. */
  61466. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  61467. /**
  61468. * Returns the data related to the radial explosion event (sphere).
  61469. * @returns The radial explosion event data
  61470. */
  61471. getData(): PhysicsRadialExplosionEventData;
  61472. /**
  61473. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  61474. * @param impostor A physics imposter
  61475. * @param origin the origin of the explosion
  61476. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  61477. */
  61478. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  61479. /**
  61480. * Triggers affecterd impostors callbacks
  61481. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  61482. */
  61483. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  61484. /**
  61485. * Disposes the sphere.
  61486. * @param force Specifies if the sphere should be disposed by force
  61487. */
  61488. dispose(force?: boolean): void;
  61489. /*** Helpers ***/
  61490. private _prepareSphere;
  61491. private _intersectsWithSphere;
  61492. }
  61493. /**
  61494. * Represents a gravitational field event
  61495. */
  61496. class PhysicsGravitationalFieldEvent {
  61497. private _physicsHelper;
  61498. private _scene;
  61499. private _origin;
  61500. private _options;
  61501. private _tickCallback;
  61502. private _sphere;
  61503. private _dataFetched;
  61504. /**
  61505. * Initializes the physics gravitational field event
  61506. * @param _physicsHelper A physics helper
  61507. * @param _scene BabylonJS scene
  61508. * @param _origin The origin position of the gravitational field event
  61509. * @param _options The options for the vortex event
  61510. */
  61511. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  61512. /**
  61513. * Returns the data related to the gravitational field event (sphere).
  61514. * @returns A gravitational field event
  61515. */
  61516. getData(): PhysicsGravitationalFieldEventData;
  61517. /**
  61518. * Enables the gravitational field.
  61519. */
  61520. enable(): void;
  61521. /**
  61522. * Disables the gravitational field.
  61523. */
  61524. disable(): void;
  61525. /**
  61526. * Disposes the sphere.
  61527. * @param force The force to dispose from the gravitational field event
  61528. */
  61529. dispose(force?: boolean): void;
  61530. private _tick;
  61531. }
  61532. /**
  61533. * Represents a physics updraft event
  61534. */
  61535. class PhysicsUpdraftEvent {
  61536. private _scene;
  61537. private _origin;
  61538. private _options;
  61539. private _physicsEngine;
  61540. private _originTop;
  61541. private _originDirection;
  61542. private _tickCallback;
  61543. private _cylinder;
  61544. private _cylinderPosition;
  61545. private _dataFetched;
  61546. /**
  61547. * Initializes the physics updraft event
  61548. * @param _scene BabylonJS scene
  61549. * @param _origin The origin position of the updraft
  61550. * @param _options The options for the updraft event
  61551. */
  61552. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  61553. /**
  61554. * Returns the data related to the updraft event (cylinder).
  61555. * @returns A physics updraft event
  61556. */
  61557. getData(): PhysicsUpdraftEventData;
  61558. /**
  61559. * Enables the updraft.
  61560. */
  61561. enable(): void;
  61562. /**
  61563. * Disables the updraft.
  61564. */
  61565. disable(): void;
  61566. /**
  61567. * Disposes the cylinder.
  61568. * @param force Specifies if the updraft should be disposed by force
  61569. */
  61570. dispose(force?: boolean): void;
  61571. private getImpostorHitData;
  61572. private _tick;
  61573. /*** Helpers ***/
  61574. private _prepareCylinder;
  61575. private _intersectsWithCylinder;
  61576. }
  61577. /**
  61578. * Represents a physics vortex event
  61579. */
  61580. class PhysicsVortexEvent {
  61581. private _scene;
  61582. private _origin;
  61583. private _options;
  61584. private _physicsEngine;
  61585. private _originTop;
  61586. private _tickCallback;
  61587. private _cylinder;
  61588. private _cylinderPosition;
  61589. private _dataFetched;
  61590. /**
  61591. * Initializes the physics vortex event
  61592. * @param _scene The BabylonJS scene
  61593. * @param _origin The origin position of the vortex
  61594. * @param _options The options for the vortex event
  61595. */
  61596. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  61597. /**
  61598. * Returns the data related to the vortex event (cylinder).
  61599. * @returns The physics vortex event data
  61600. */
  61601. getData(): PhysicsVortexEventData;
  61602. /**
  61603. * Enables the vortex.
  61604. */
  61605. enable(): void;
  61606. /**
  61607. * Disables the cortex.
  61608. */
  61609. disable(): void;
  61610. /**
  61611. * Disposes the sphere.
  61612. * @param force
  61613. */
  61614. dispose(force?: boolean): void;
  61615. private getImpostorHitData;
  61616. private _tick;
  61617. /*** Helpers ***/
  61618. private _prepareCylinder;
  61619. private _intersectsWithCylinder;
  61620. }
  61621. /**
  61622. * Options fot the radial explosion event
  61623. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61624. */
  61625. export class PhysicsRadialExplosionEventOptions {
  61626. /**
  61627. * The radius of the sphere for the radial explosion.
  61628. */
  61629. radius: number;
  61630. /**
  61631. * The strenth of the explosion.
  61632. */
  61633. strength: number;
  61634. /**
  61635. * The strenght of the force in correspondence to the distance of the affected object
  61636. */
  61637. falloff: PhysicsRadialImpulseFalloff;
  61638. /**
  61639. * Sphere options for the radial explosion.
  61640. */
  61641. sphere: {
  61642. segments: number;
  61643. diameter: number;
  61644. };
  61645. /**
  61646. * Sphere options for the radial explosion.
  61647. */
  61648. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  61649. }
  61650. /**
  61651. * Options fot the updraft event
  61652. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61653. */
  61654. export class PhysicsUpdraftEventOptions {
  61655. /**
  61656. * The radius of the cylinder for the vortex
  61657. */
  61658. radius: number;
  61659. /**
  61660. * The strenth of the updraft.
  61661. */
  61662. strength: number;
  61663. /**
  61664. * The height of the cylinder for the updraft.
  61665. */
  61666. height: number;
  61667. /**
  61668. * The mode for the the updraft.
  61669. */
  61670. updraftMode: PhysicsUpdraftMode;
  61671. }
  61672. /**
  61673. * Options fot the vortex event
  61674. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61675. */
  61676. export class PhysicsVortexEventOptions {
  61677. /**
  61678. * The radius of the cylinder for the vortex
  61679. */
  61680. radius: number;
  61681. /**
  61682. * The strenth of the vortex.
  61683. */
  61684. strength: number;
  61685. /**
  61686. * The height of the cylinder for the vortex.
  61687. */
  61688. height: number;
  61689. /**
  61690. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  61691. */
  61692. centripetalForceThreshold: number;
  61693. /**
  61694. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  61695. */
  61696. centripetalForceMultiplier: number;
  61697. /**
  61698. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  61699. */
  61700. centrifugalForceMultiplier: number;
  61701. /**
  61702. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  61703. */
  61704. updraftForceMultiplier: number;
  61705. }
  61706. /**
  61707. * The strenght of the force in correspondence to the distance of the affected object
  61708. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61709. */
  61710. export enum PhysicsRadialImpulseFalloff {
  61711. /** Defines that impulse is constant in strength across it's whole radius */
  61712. Constant = 0,
  61713. /** Defines that impulse gets weaker if it's further from the origin */
  61714. Linear = 1
  61715. }
  61716. /**
  61717. * The strength of the force in correspondence to the distance of the affected object
  61718. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61719. */
  61720. export enum PhysicsUpdraftMode {
  61721. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  61722. Center = 0,
  61723. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  61724. Perpendicular = 1
  61725. }
  61726. /**
  61727. * Interface for a physics hit data
  61728. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61729. */
  61730. export interface PhysicsHitData {
  61731. /**
  61732. * The force applied at the contact point
  61733. */
  61734. force: Vector3;
  61735. /**
  61736. * The contact point
  61737. */
  61738. contactPoint: Vector3;
  61739. /**
  61740. * The distance from the origin to the contact point
  61741. */
  61742. distanceFromOrigin: number;
  61743. }
  61744. /**
  61745. * Interface for radial explosion event data
  61746. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61747. */
  61748. export interface PhysicsRadialExplosionEventData {
  61749. /**
  61750. * A sphere used for the radial explosion event
  61751. */
  61752. sphere: Mesh;
  61753. }
  61754. /**
  61755. * Interface for gravitational field event data
  61756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61757. */
  61758. export interface PhysicsGravitationalFieldEventData {
  61759. /**
  61760. * A sphere mesh used for the gravitational field event
  61761. */
  61762. sphere: Mesh;
  61763. }
  61764. /**
  61765. * Interface for updraft event data
  61766. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61767. */
  61768. export interface PhysicsUpdraftEventData {
  61769. /**
  61770. * A cylinder used for the updraft event
  61771. */
  61772. cylinder: Mesh;
  61773. }
  61774. /**
  61775. * Interface for vortex event data
  61776. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61777. */
  61778. export interface PhysicsVortexEventData {
  61779. /**
  61780. * A cylinder used for the vortex event
  61781. */
  61782. cylinder: Mesh;
  61783. }
  61784. /**
  61785. * Interface for an affected physics impostor
  61786. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  61787. */
  61788. export interface PhysicsAffectedImpostorWithData {
  61789. /**
  61790. * The impostor affected by the effect
  61791. */
  61792. impostor: PhysicsImpostor;
  61793. /**
  61794. * The data about the hit/horce from the explosion
  61795. */
  61796. hitData: PhysicsHitData;
  61797. }
  61798. }
  61799. declare module "babylonjs/Physics/Plugins/index" {
  61800. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  61801. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  61802. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  61803. }
  61804. declare module "babylonjs/Physics/index" {
  61805. export * from "babylonjs/Physics/IPhysicsEngine";
  61806. export * from "babylonjs/Physics/physicsEngine";
  61807. export * from "babylonjs/Physics/physicsEngineComponent";
  61808. export * from "babylonjs/Physics/physicsHelper";
  61809. export * from "babylonjs/Physics/physicsImpostor";
  61810. export * from "babylonjs/Physics/physicsJoint";
  61811. export * from "babylonjs/Physics/Plugins/index";
  61812. }
  61813. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  61814. /** @hidden */
  61815. export var blackAndWhitePixelShader: {
  61816. name: string;
  61817. shader: string;
  61818. };
  61819. }
  61820. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  61821. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61822. import { Camera } from "babylonjs/Cameras/camera";
  61823. import { Engine } from "babylonjs/Engines/engine";
  61824. import "babylonjs/Shaders/blackAndWhite.fragment";
  61825. /**
  61826. * Post process used to render in black and white
  61827. */
  61828. export class BlackAndWhitePostProcess extends PostProcess {
  61829. /**
  61830. * Linear about to convert he result to black and white (default: 1)
  61831. */
  61832. degree: number;
  61833. /**
  61834. * Creates a black and white post process
  61835. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  61836. * @param name The name of the effect.
  61837. * @param options The required width/height ratio to downsize to before computing the render pass.
  61838. * @param camera The camera to apply the render pass to.
  61839. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  61840. * @param engine The engine which the post process will be applied. (default: current engine)
  61841. * @param reusable If the post process can be reused on the same frame. (default: false)
  61842. */
  61843. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  61844. }
  61845. }
  61846. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  61847. import { Nullable } from "babylonjs/types";
  61848. import { Camera } from "babylonjs/Cameras/camera";
  61849. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61850. import { Engine } from "babylonjs/Engines/engine";
  61851. /**
  61852. * This represents a set of one or more post processes in Babylon.
  61853. * A post process can be used to apply a shader to a texture after it is rendered.
  61854. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  61855. */
  61856. export class PostProcessRenderEffect {
  61857. private _postProcesses;
  61858. private _getPostProcesses;
  61859. private _singleInstance;
  61860. private _cameras;
  61861. private _indicesForCamera;
  61862. /**
  61863. * Name of the effect
  61864. * @hidden
  61865. */
  61866. _name: string;
  61867. /**
  61868. * Instantiates a post process render effect.
  61869. * A post process can be used to apply a shader to a texture after it is rendered.
  61870. * @param engine The engine the effect is tied to
  61871. * @param name The name of the effect
  61872. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  61873. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  61874. */
  61875. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  61876. /**
  61877. * Checks if all the post processes in the effect are supported.
  61878. */
  61879. readonly isSupported: boolean;
  61880. /**
  61881. * Updates the current state of the effect
  61882. * @hidden
  61883. */
  61884. _update(): void;
  61885. /**
  61886. * Attaches the effect on cameras
  61887. * @param cameras The camera to attach to.
  61888. * @hidden
  61889. */
  61890. _attachCameras(cameras: Camera): void;
  61891. /**
  61892. * Attaches the effect on cameras
  61893. * @param cameras The camera to attach to.
  61894. * @hidden
  61895. */
  61896. _attachCameras(cameras: Camera[]): void;
  61897. /**
  61898. * Detaches the effect on cameras
  61899. * @param cameras The camera to detatch from.
  61900. * @hidden
  61901. */
  61902. _detachCameras(cameras: Camera): void;
  61903. /**
  61904. * Detatches the effect on cameras
  61905. * @param cameras The camera to detatch from.
  61906. * @hidden
  61907. */
  61908. _detachCameras(cameras: Camera[]): void;
  61909. /**
  61910. * Enables the effect on given cameras
  61911. * @param cameras The camera to enable.
  61912. * @hidden
  61913. */
  61914. _enable(cameras: Camera): void;
  61915. /**
  61916. * Enables the effect on given cameras
  61917. * @param cameras The camera to enable.
  61918. * @hidden
  61919. */
  61920. _enable(cameras: Nullable<Camera[]>): void;
  61921. /**
  61922. * Disables the effect on the given cameras
  61923. * @param cameras The camera to disable.
  61924. * @hidden
  61925. */
  61926. _disable(cameras: Camera): void;
  61927. /**
  61928. * Disables the effect on the given cameras
  61929. * @param cameras The camera to disable.
  61930. * @hidden
  61931. */
  61932. _disable(cameras: Nullable<Camera[]>): void;
  61933. /**
  61934. * Gets a list of the post processes contained in the effect.
  61935. * @param camera The camera to get the post processes on.
  61936. * @returns The list of the post processes in the effect.
  61937. */
  61938. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  61939. }
  61940. }
  61941. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  61942. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61943. /** @hidden */
  61944. export var extractHighlightsPixelShader: {
  61945. name: string;
  61946. shader: string;
  61947. };
  61948. }
  61949. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  61950. import { Nullable } from "babylonjs/types";
  61951. import { Camera } from "babylonjs/Cameras/camera";
  61952. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61953. import { Engine } from "babylonjs/Engines/engine";
  61954. import "babylonjs/Shaders/extractHighlights.fragment";
  61955. /**
  61956. * 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.
  61957. */
  61958. export class ExtractHighlightsPostProcess extends PostProcess {
  61959. /**
  61960. * The luminance threshold, pixels below this value will be set to black.
  61961. */
  61962. threshold: number;
  61963. /** @hidden */
  61964. _exposure: number;
  61965. /**
  61966. * Post process which has the input texture to be used when performing highlight extraction
  61967. * @hidden
  61968. */
  61969. _inputPostProcess: Nullable<PostProcess>;
  61970. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  61971. }
  61972. }
  61973. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  61974. /** @hidden */
  61975. export var bloomMergePixelShader: {
  61976. name: string;
  61977. shader: string;
  61978. };
  61979. }
  61980. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  61981. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  61982. import { Nullable } from "babylonjs/types";
  61983. import { Engine } from "babylonjs/Engines/engine";
  61984. import { Camera } from "babylonjs/Cameras/camera";
  61985. import "babylonjs/Shaders/bloomMerge.fragment";
  61986. /**
  61987. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  61988. */
  61989. export class BloomMergePostProcess extends PostProcess {
  61990. /** Weight of the bloom to be added to the original input. */
  61991. weight: number;
  61992. /**
  61993. * Creates a new instance of @see BloomMergePostProcess
  61994. * @param name The name of the effect.
  61995. * @param originalFromInput Post process which's input will be used for the merge.
  61996. * @param blurred Blurred highlights post process which's output will be used.
  61997. * @param weight Weight of the bloom to be added to the original input.
  61998. * @param options The required width/height ratio to downsize to before computing the render pass.
  61999. * @param camera The camera to apply the render pass to.
  62000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62001. * @param engine The engine which the post process will be applied. (default: current engine)
  62002. * @param reusable If the post process can be reused on the same frame. (default: false)
  62003. * @param textureType Type of textures used when performing the post process. (default: 0)
  62004. * @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)
  62005. */
  62006. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  62007. /** Weight of the bloom to be added to the original input. */
  62008. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62009. }
  62010. }
  62011. declare module "babylonjs/PostProcesses/bloomEffect" {
  62012. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62013. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62014. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  62015. import { Camera } from "babylonjs/Cameras/camera";
  62016. import { Scene } from "babylonjs/scene";
  62017. /**
  62018. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  62019. */
  62020. export class BloomEffect extends PostProcessRenderEffect {
  62021. private bloomScale;
  62022. /**
  62023. * @hidden Internal
  62024. */
  62025. _effects: Array<PostProcess>;
  62026. /**
  62027. * @hidden Internal
  62028. */
  62029. _downscale: ExtractHighlightsPostProcess;
  62030. private _blurX;
  62031. private _blurY;
  62032. private _merge;
  62033. /**
  62034. * The luminance threshold to find bright areas of the image to bloom.
  62035. */
  62036. threshold: number;
  62037. /**
  62038. * The strength of the bloom.
  62039. */
  62040. weight: number;
  62041. /**
  62042. * Specifies the size of the bloom blur kernel, relative to the final output size
  62043. */
  62044. kernel: number;
  62045. /**
  62046. * Creates a new instance of @see BloomEffect
  62047. * @param scene The scene the effect belongs to.
  62048. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  62049. * @param bloomKernel The size of the kernel to be used when applying the blur.
  62050. * @param bloomWeight The the strength of bloom.
  62051. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62052. * @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)
  62053. */
  62054. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  62055. /**
  62056. * Disposes each of the internal effects for a given camera.
  62057. * @param camera The camera to dispose the effect on.
  62058. */
  62059. disposeEffects(camera: Camera): void;
  62060. /**
  62061. * @hidden Internal
  62062. */
  62063. _updateEffects(): void;
  62064. /**
  62065. * Internal
  62066. * @returns if all the contained post processes are ready.
  62067. * @hidden
  62068. */
  62069. _isReady(): boolean;
  62070. }
  62071. }
  62072. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  62073. /** @hidden */
  62074. export var chromaticAberrationPixelShader: {
  62075. name: string;
  62076. shader: string;
  62077. };
  62078. }
  62079. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  62080. import { Vector2 } from "babylonjs/Maths/math.vector";
  62081. import { Nullable } from "babylonjs/types";
  62082. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62083. import { Camera } from "babylonjs/Cameras/camera";
  62084. import { Engine } from "babylonjs/Engines/engine";
  62085. import "babylonjs/Shaders/chromaticAberration.fragment";
  62086. /**
  62087. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  62088. */
  62089. export class ChromaticAberrationPostProcess extends PostProcess {
  62090. /**
  62091. * The amount of seperation of rgb channels (default: 30)
  62092. */
  62093. aberrationAmount: number;
  62094. /**
  62095. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  62096. */
  62097. radialIntensity: number;
  62098. /**
  62099. * 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))
  62100. */
  62101. direction: Vector2;
  62102. /**
  62103. * 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))
  62104. */
  62105. centerPosition: Vector2;
  62106. /**
  62107. * Creates a new instance ChromaticAberrationPostProcess
  62108. * @param name The name of the effect.
  62109. * @param screenWidth The width of the screen to apply the effect on.
  62110. * @param screenHeight The height of the screen to apply the effect on.
  62111. * @param options The required width/height ratio to downsize to before computing the render pass.
  62112. * @param camera The camera to apply the render pass to.
  62113. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62114. * @param engine The engine which the post process will be applied. (default: current engine)
  62115. * @param reusable If the post process can be reused on the same frame. (default: false)
  62116. * @param textureType Type of textures used when performing the post process. (default: 0)
  62117. * @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)
  62118. */
  62119. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62120. }
  62121. }
  62122. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  62123. /** @hidden */
  62124. export var circleOfConfusionPixelShader: {
  62125. name: string;
  62126. shader: string;
  62127. };
  62128. }
  62129. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  62130. import { Nullable } from "babylonjs/types";
  62131. import { Engine } from "babylonjs/Engines/engine";
  62132. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62133. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62134. import { Camera } from "babylonjs/Cameras/camera";
  62135. import "babylonjs/Shaders/circleOfConfusion.fragment";
  62136. /**
  62137. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  62138. */
  62139. export class CircleOfConfusionPostProcess extends PostProcess {
  62140. /**
  62141. * 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.
  62142. */
  62143. lensSize: number;
  62144. /**
  62145. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62146. */
  62147. fStop: number;
  62148. /**
  62149. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62150. */
  62151. focusDistance: number;
  62152. /**
  62153. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  62154. */
  62155. focalLength: number;
  62156. private _depthTexture;
  62157. /**
  62158. * Creates a new instance CircleOfConfusionPostProcess
  62159. * @param name The name of the effect.
  62160. * @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.
  62161. * @param options The required width/height ratio to downsize to before computing the render pass.
  62162. * @param camera The camera to apply the render pass to.
  62163. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62164. * @param engine The engine which the post process will be applied. (default: current engine)
  62165. * @param reusable If the post process can be reused on the same frame. (default: false)
  62166. * @param textureType Type of textures used when performing the post process. (default: 0)
  62167. * @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)
  62168. */
  62169. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62170. /**
  62171. * 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.
  62172. */
  62173. depthTexture: RenderTargetTexture;
  62174. }
  62175. }
  62176. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  62177. /** @hidden */
  62178. export var colorCorrectionPixelShader: {
  62179. name: string;
  62180. shader: string;
  62181. };
  62182. }
  62183. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  62184. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62185. import { Engine } from "babylonjs/Engines/engine";
  62186. import { Camera } from "babylonjs/Cameras/camera";
  62187. import "babylonjs/Shaders/colorCorrection.fragment";
  62188. /**
  62189. *
  62190. * This post-process allows the modification of rendered colors by using
  62191. * a 'look-up table' (LUT). This effect is also called Color Grading.
  62192. *
  62193. * The object needs to be provided an url to a texture containing the color
  62194. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  62195. * Use an image editing software to tweak the LUT to match your needs.
  62196. *
  62197. * For an example of a color LUT, see here:
  62198. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  62199. * For explanations on color grading, see here:
  62200. * @see http://udn.epicgames.com/Three/ColorGrading.html
  62201. *
  62202. */
  62203. export class ColorCorrectionPostProcess extends PostProcess {
  62204. private _colorTableTexture;
  62205. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62206. }
  62207. }
  62208. declare module "babylonjs/Shaders/convolution.fragment" {
  62209. /** @hidden */
  62210. export var convolutionPixelShader: {
  62211. name: string;
  62212. shader: string;
  62213. };
  62214. }
  62215. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  62216. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62217. import { Nullable } from "babylonjs/types";
  62218. import { Camera } from "babylonjs/Cameras/camera";
  62219. import { Engine } from "babylonjs/Engines/engine";
  62220. import "babylonjs/Shaders/convolution.fragment";
  62221. /**
  62222. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  62223. * input texture to perform effects such as edge detection or sharpening
  62224. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  62225. */
  62226. export class ConvolutionPostProcess extends PostProcess {
  62227. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62228. kernel: number[];
  62229. /**
  62230. * Creates a new instance ConvolutionPostProcess
  62231. * @param name The name of the effect.
  62232. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  62233. * @param options The required width/height ratio to downsize to before computing the render pass.
  62234. * @param camera The camera to apply the render pass to.
  62235. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62236. * @param engine The engine which the post process will be applied. (default: current engine)
  62237. * @param reusable If the post process can be reused on the same frame. (default: false)
  62238. * @param textureType Type of textures used when performing the post process. (default: 0)
  62239. */
  62240. constructor(name: string,
  62241. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  62242. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62243. /**
  62244. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62245. */
  62246. static EdgeDetect0Kernel: number[];
  62247. /**
  62248. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62249. */
  62250. static EdgeDetect1Kernel: number[];
  62251. /**
  62252. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62253. */
  62254. static EdgeDetect2Kernel: number[];
  62255. /**
  62256. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62257. */
  62258. static SharpenKernel: number[];
  62259. /**
  62260. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62261. */
  62262. static EmbossKernel: number[];
  62263. /**
  62264. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  62265. */
  62266. static GaussianKernel: number[];
  62267. }
  62268. }
  62269. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  62270. import { Nullable } from "babylonjs/types";
  62271. import { Vector2 } from "babylonjs/Maths/math.vector";
  62272. import { Camera } from "babylonjs/Cameras/camera";
  62273. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62274. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  62275. import { Engine } from "babylonjs/Engines/engine";
  62276. import { Scene } from "babylonjs/scene";
  62277. /**
  62278. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  62279. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  62280. * based on samples that have a large difference in distance than the center pixel.
  62281. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  62282. */
  62283. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  62284. direction: Vector2;
  62285. /**
  62286. * Creates a new instance CircleOfConfusionPostProcess
  62287. * @param name The name of the effect.
  62288. * @param scene The scene the effect belongs to.
  62289. * @param direction The direction the blur should be applied.
  62290. * @param kernel The size of the kernel used to blur.
  62291. * @param options The required width/height ratio to downsize to before computing the render pass.
  62292. * @param camera The camera to apply the render pass to.
  62293. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  62294. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  62295. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62296. * @param engine The engine which the post process will be applied. (default: current engine)
  62297. * @param reusable If the post process can be reused on the same frame. (default: false)
  62298. * @param textureType Type of textures used when performing the post process. (default: 0)
  62299. * @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)
  62300. */
  62301. 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);
  62302. }
  62303. }
  62304. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  62305. /** @hidden */
  62306. export var depthOfFieldMergePixelShader: {
  62307. name: string;
  62308. shader: string;
  62309. };
  62310. }
  62311. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  62312. import { Nullable } from "babylonjs/types";
  62313. import { Camera } from "babylonjs/Cameras/camera";
  62314. import { Effect } from "babylonjs/Materials/effect";
  62315. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62316. import { Engine } from "babylonjs/Engines/engine";
  62317. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  62318. /**
  62319. * Options to be set when merging outputs from the default pipeline.
  62320. */
  62321. export class DepthOfFieldMergePostProcessOptions {
  62322. /**
  62323. * The original image to merge on top of
  62324. */
  62325. originalFromInput: PostProcess;
  62326. /**
  62327. * Parameters to perform the merge of the depth of field effect
  62328. */
  62329. depthOfField?: {
  62330. circleOfConfusion: PostProcess;
  62331. blurSteps: Array<PostProcess>;
  62332. };
  62333. /**
  62334. * Parameters to perform the merge of bloom effect
  62335. */
  62336. bloom?: {
  62337. blurred: PostProcess;
  62338. weight: number;
  62339. };
  62340. }
  62341. /**
  62342. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  62343. */
  62344. export class DepthOfFieldMergePostProcess extends PostProcess {
  62345. private blurSteps;
  62346. /**
  62347. * Creates a new instance of DepthOfFieldMergePostProcess
  62348. * @param name The name of the effect.
  62349. * @param originalFromInput Post process which's input will be used for the merge.
  62350. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  62351. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  62352. * @param options The required width/height ratio to downsize to before computing the render pass.
  62353. * @param camera The camera to apply the render pass to.
  62354. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62355. * @param engine The engine which the post process will be applied. (default: current engine)
  62356. * @param reusable If the post process can be reused on the same frame. (default: false)
  62357. * @param textureType Type of textures used when performing the post process. (default: 0)
  62358. * @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)
  62359. */
  62360. 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);
  62361. /**
  62362. * Updates the effect with the current post process compile time values and recompiles the shader.
  62363. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  62364. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  62365. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  62366. * @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
  62367. * @param onCompiled Called when the shader has been compiled.
  62368. * @param onError Called if there is an error when compiling a shader.
  62369. */
  62370. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  62371. }
  62372. }
  62373. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  62374. import { Nullable } from "babylonjs/types";
  62375. import { Camera } from "babylonjs/Cameras/camera";
  62376. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62377. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62378. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  62379. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  62380. import { Scene } from "babylonjs/scene";
  62381. /**
  62382. * Specifies the level of max blur that should be applied when using the depth of field effect
  62383. */
  62384. export enum DepthOfFieldEffectBlurLevel {
  62385. /**
  62386. * Subtle blur
  62387. */
  62388. Low = 0,
  62389. /**
  62390. * Medium blur
  62391. */
  62392. Medium = 1,
  62393. /**
  62394. * Large blur
  62395. */
  62396. High = 2
  62397. }
  62398. /**
  62399. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  62400. */
  62401. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  62402. private _circleOfConfusion;
  62403. /**
  62404. * @hidden Internal, blurs from high to low
  62405. */
  62406. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  62407. private _depthOfFieldBlurY;
  62408. private _dofMerge;
  62409. /**
  62410. * @hidden Internal post processes in depth of field effect
  62411. */
  62412. _effects: Array<PostProcess>;
  62413. /**
  62414. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  62415. */
  62416. focalLength: number;
  62417. /**
  62418. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  62419. */
  62420. fStop: number;
  62421. /**
  62422. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  62423. */
  62424. focusDistance: number;
  62425. /**
  62426. * 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.
  62427. */
  62428. lensSize: number;
  62429. /**
  62430. * Creates a new instance DepthOfFieldEffect
  62431. * @param scene The scene the effect belongs to.
  62432. * @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.
  62433. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  62434. * @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)
  62435. */
  62436. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  62437. /**
  62438. * Get the current class name of the current effet
  62439. * @returns "DepthOfFieldEffect"
  62440. */
  62441. getClassName(): string;
  62442. /**
  62443. * 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.
  62444. */
  62445. depthTexture: RenderTargetTexture;
  62446. /**
  62447. * Disposes each of the internal effects for a given camera.
  62448. * @param camera The camera to dispose the effect on.
  62449. */
  62450. disposeEffects(camera: Camera): void;
  62451. /**
  62452. * @hidden Internal
  62453. */
  62454. _updateEffects(): void;
  62455. /**
  62456. * Internal
  62457. * @returns if all the contained post processes are ready.
  62458. * @hidden
  62459. */
  62460. _isReady(): boolean;
  62461. }
  62462. }
  62463. declare module "babylonjs/Shaders/displayPass.fragment" {
  62464. /** @hidden */
  62465. export var displayPassPixelShader: {
  62466. name: string;
  62467. shader: string;
  62468. };
  62469. }
  62470. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  62471. import { Nullable } from "babylonjs/types";
  62472. import { Camera } from "babylonjs/Cameras/camera";
  62473. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62474. import { Engine } from "babylonjs/Engines/engine";
  62475. import "babylonjs/Shaders/displayPass.fragment";
  62476. /**
  62477. * DisplayPassPostProcess which produces an output the same as it's input
  62478. */
  62479. export class DisplayPassPostProcess extends PostProcess {
  62480. /**
  62481. * Creates the DisplayPassPostProcess
  62482. * @param name The name of the effect.
  62483. * @param options The required width/height ratio to downsize to before computing the render pass.
  62484. * @param camera The camera to apply the render pass to.
  62485. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62486. * @param engine The engine which the post process will be applied. (default: current engine)
  62487. * @param reusable If the post process can be reused on the same frame. (default: false)
  62488. */
  62489. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62490. }
  62491. }
  62492. declare module "babylonjs/Shaders/filter.fragment" {
  62493. /** @hidden */
  62494. export var filterPixelShader: {
  62495. name: string;
  62496. shader: string;
  62497. };
  62498. }
  62499. declare module "babylonjs/PostProcesses/filterPostProcess" {
  62500. import { Nullable } from "babylonjs/types";
  62501. import { Matrix } from "babylonjs/Maths/math.vector";
  62502. import { Camera } from "babylonjs/Cameras/camera";
  62503. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62504. import { Engine } from "babylonjs/Engines/engine";
  62505. import "babylonjs/Shaders/filter.fragment";
  62506. /**
  62507. * Applies a kernel filter to the image
  62508. */
  62509. export class FilterPostProcess extends PostProcess {
  62510. /** The matrix to be applied to the image */
  62511. kernelMatrix: Matrix;
  62512. /**
  62513. *
  62514. * @param name The name of the effect.
  62515. * @param kernelMatrix The matrix to be applied to the image
  62516. * @param options The required width/height ratio to downsize to before computing the render pass.
  62517. * @param camera The camera to apply the render pass to.
  62518. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62519. * @param engine The engine which the post process will be applied. (default: current engine)
  62520. * @param reusable If the post process can be reused on the same frame. (default: false)
  62521. */
  62522. constructor(name: string,
  62523. /** The matrix to be applied to the image */
  62524. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62525. }
  62526. }
  62527. declare module "babylonjs/Shaders/fxaa.fragment" {
  62528. /** @hidden */
  62529. export var fxaaPixelShader: {
  62530. name: string;
  62531. shader: string;
  62532. };
  62533. }
  62534. declare module "babylonjs/Shaders/fxaa.vertex" {
  62535. /** @hidden */
  62536. export var fxaaVertexShader: {
  62537. name: string;
  62538. shader: string;
  62539. };
  62540. }
  62541. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  62542. import { Nullable } from "babylonjs/types";
  62543. import { Camera } from "babylonjs/Cameras/camera";
  62544. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62545. import { Engine } from "babylonjs/Engines/engine";
  62546. import "babylonjs/Shaders/fxaa.fragment";
  62547. import "babylonjs/Shaders/fxaa.vertex";
  62548. /**
  62549. * Fxaa post process
  62550. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  62551. */
  62552. export class FxaaPostProcess extends PostProcess {
  62553. /** @hidden */
  62554. texelWidth: number;
  62555. /** @hidden */
  62556. texelHeight: number;
  62557. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62558. private _getDefines;
  62559. }
  62560. }
  62561. declare module "babylonjs/Shaders/grain.fragment" {
  62562. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62563. /** @hidden */
  62564. export var grainPixelShader: {
  62565. name: string;
  62566. shader: string;
  62567. };
  62568. }
  62569. declare module "babylonjs/PostProcesses/grainPostProcess" {
  62570. import { Nullable } from "babylonjs/types";
  62571. import { Camera } from "babylonjs/Cameras/camera";
  62572. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62573. import { Engine } from "babylonjs/Engines/engine";
  62574. import "babylonjs/Shaders/grain.fragment";
  62575. /**
  62576. * The GrainPostProcess adds noise to the image at mid luminance levels
  62577. */
  62578. export class GrainPostProcess extends PostProcess {
  62579. /**
  62580. * The intensity of the grain added (default: 30)
  62581. */
  62582. intensity: number;
  62583. /**
  62584. * If the grain should be randomized on every frame
  62585. */
  62586. animated: boolean;
  62587. /**
  62588. * Creates a new instance of @see GrainPostProcess
  62589. * @param name The name of the effect.
  62590. * @param options The required width/height ratio to downsize to before computing the render pass.
  62591. * @param camera The camera to apply the render pass to.
  62592. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62593. * @param engine The engine which the post process will be applied. (default: current engine)
  62594. * @param reusable If the post process can be reused on the same frame. (default: false)
  62595. * @param textureType Type of textures used when performing the post process. (default: 0)
  62596. * @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)
  62597. */
  62598. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62599. }
  62600. }
  62601. declare module "babylonjs/Shaders/highlights.fragment" {
  62602. /** @hidden */
  62603. export var highlightsPixelShader: {
  62604. name: string;
  62605. shader: string;
  62606. };
  62607. }
  62608. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  62609. import { Nullable } from "babylonjs/types";
  62610. import { Camera } from "babylonjs/Cameras/camera";
  62611. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62612. import { Engine } from "babylonjs/Engines/engine";
  62613. import "babylonjs/Shaders/highlights.fragment";
  62614. /**
  62615. * Extracts highlights from the image
  62616. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62617. */
  62618. export class HighlightsPostProcess extends PostProcess {
  62619. /**
  62620. * Extracts highlights from the image
  62621. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  62622. * @param name The name of the effect.
  62623. * @param options The required width/height ratio to downsize to before computing the render pass.
  62624. * @param camera The camera to apply the render pass to.
  62625. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62626. * @param engine The engine which the post process will be applied. (default: current engine)
  62627. * @param reusable If the post process can be reused on the same frame. (default: false)
  62628. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  62629. */
  62630. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  62631. }
  62632. }
  62633. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  62634. /** @hidden */
  62635. export var mrtFragmentDeclaration: {
  62636. name: string;
  62637. shader: string;
  62638. };
  62639. }
  62640. declare module "babylonjs/Shaders/geometry.fragment" {
  62641. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  62642. /** @hidden */
  62643. export var geometryPixelShader: {
  62644. name: string;
  62645. shader: string;
  62646. };
  62647. }
  62648. declare module "babylonjs/Shaders/geometry.vertex" {
  62649. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62650. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62651. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62652. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62653. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62654. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62655. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62656. /** @hidden */
  62657. export var geometryVertexShader: {
  62658. name: string;
  62659. shader: string;
  62660. };
  62661. }
  62662. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  62663. import { Matrix } from "babylonjs/Maths/math.vector";
  62664. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62665. import { Mesh } from "babylonjs/Meshes/mesh";
  62666. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  62667. import { Effect } from "babylonjs/Materials/effect";
  62668. import { Scene } from "babylonjs/scene";
  62669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62670. import "babylonjs/Shaders/geometry.fragment";
  62671. import "babylonjs/Shaders/geometry.vertex";
  62672. /** @hidden */
  62673. interface ISavedTransformationMatrix {
  62674. world: Matrix;
  62675. viewProjection: Matrix;
  62676. }
  62677. /**
  62678. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  62679. */
  62680. export class GeometryBufferRenderer {
  62681. /**
  62682. * Constant used to retrieve the position texture index in the G-Buffer textures array
  62683. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  62684. */
  62685. static readonly POSITION_TEXTURE_TYPE: number;
  62686. /**
  62687. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  62688. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  62689. */
  62690. static readonly VELOCITY_TEXTURE_TYPE: number;
  62691. /**
  62692. * Dictionary used to store the previous transformation matrices of each rendered mesh
  62693. * in order to compute objects velocities when enableVelocity is set to "true"
  62694. * @hidden
  62695. */
  62696. _previousTransformationMatrices: {
  62697. [index: number]: ISavedTransformationMatrix;
  62698. };
  62699. /**
  62700. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  62701. * in order to compute objects velocities when enableVelocity is set to "true"
  62702. * @hidden
  62703. */
  62704. _previousBonesTransformationMatrices: {
  62705. [index: number]: Float32Array;
  62706. };
  62707. /**
  62708. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  62709. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  62710. */
  62711. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  62712. private _scene;
  62713. private _multiRenderTarget;
  62714. private _ratio;
  62715. private _enablePosition;
  62716. private _enableVelocity;
  62717. private _positionIndex;
  62718. private _velocityIndex;
  62719. protected _effect: Effect;
  62720. protected _cachedDefines: string;
  62721. /**
  62722. * Set the render list (meshes to be rendered) used in the G buffer.
  62723. */
  62724. renderList: Mesh[];
  62725. /**
  62726. * Gets wether or not G buffer are supported by the running hardware.
  62727. * This requires draw buffer supports
  62728. */
  62729. readonly isSupported: boolean;
  62730. /**
  62731. * Returns the index of the given texture type in the G-Buffer textures array
  62732. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  62733. * @returns the index of the given texture type in the G-Buffer textures array
  62734. */
  62735. getTextureIndex(textureType: number): number;
  62736. /**
  62737. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  62738. */
  62739. /**
  62740. * Sets whether or not objects positions are enabled for the G buffer.
  62741. */
  62742. enablePosition: boolean;
  62743. /**
  62744. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  62745. */
  62746. /**
  62747. * Sets wether or not objects velocities are enabled for the G buffer.
  62748. */
  62749. enableVelocity: boolean;
  62750. /**
  62751. * Gets the scene associated with the buffer.
  62752. */
  62753. readonly scene: Scene;
  62754. /**
  62755. * Gets the ratio used by the buffer during its creation.
  62756. * How big is the buffer related to the main canvas.
  62757. */
  62758. readonly ratio: number;
  62759. /** @hidden */
  62760. static _SceneComponentInitialization: (scene: Scene) => void;
  62761. /**
  62762. * Creates a new G Buffer for the scene
  62763. * @param scene The scene the buffer belongs to
  62764. * @param ratio How big is the buffer related to the main canvas.
  62765. */
  62766. constructor(scene: Scene, ratio?: number);
  62767. /**
  62768. * Checks wether everything is ready to render a submesh to the G buffer.
  62769. * @param subMesh the submesh to check readiness for
  62770. * @param useInstances is the mesh drawn using instance or not
  62771. * @returns true if ready otherwise false
  62772. */
  62773. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62774. /**
  62775. * Gets the current underlying G Buffer.
  62776. * @returns the buffer
  62777. */
  62778. getGBuffer(): MultiRenderTarget;
  62779. /**
  62780. * Gets the number of samples used to render the buffer (anti aliasing).
  62781. */
  62782. /**
  62783. * Sets the number of samples used to render the buffer (anti aliasing).
  62784. */
  62785. samples: number;
  62786. /**
  62787. * Disposes the renderer and frees up associated resources.
  62788. */
  62789. dispose(): void;
  62790. protected _createRenderTargets(): void;
  62791. private _copyBonesTransformationMatrices;
  62792. }
  62793. }
  62794. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  62795. import { Nullable } from "babylonjs/types";
  62796. import { Scene } from "babylonjs/scene";
  62797. import { ISceneComponent } from "babylonjs/sceneComponent";
  62798. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  62799. module "babylonjs/scene" {
  62800. interface Scene {
  62801. /** @hidden (Backing field) */
  62802. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62803. /**
  62804. * Gets or Sets the current geometry buffer associated to the scene.
  62805. */
  62806. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  62807. /**
  62808. * Enables a GeometryBufferRender and associates it with the scene
  62809. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  62810. * @returns the GeometryBufferRenderer
  62811. */
  62812. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  62813. /**
  62814. * Disables the GeometryBufferRender associated with the scene
  62815. */
  62816. disableGeometryBufferRenderer(): void;
  62817. }
  62818. }
  62819. /**
  62820. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  62821. * in several rendering techniques.
  62822. */
  62823. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  62824. /**
  62825. * The component name helpful to identify the component in the list of scene components.
  62826. */
  62827. readonly name: string;
  62828. /**
  62829. * The scene the component belongs to.
  62830. */
  62831. scene: Scene;
  62832. /**
  62833. * Creates a new instance of the component for the given scene
  62834. * @param scene Defines the scene to register the component in
  62835. */
  62836. constructor(scene: Scene);
  62837. /**
  62838. * Registers the component in a given scene
  62839. */
  62840. register(): void;
  62841. /**
  62842. * Rebuilds the elements related to this component in case of
  62843. * context lost for instance.
  62844. */
  62845. rebuild(): void;
  62846. /**
  62847. * Disposes the component and the associated ressources
  62848. */
  62849. dispose(): void;
  62850. private _gatherRenderTargets;
  62851. }
  62852. }
  62853. declare module "babylonjs/Shaders/motionBlur.fragment" {
  62854. /** @hidden */
  62855. export var motionBlurPixelShader: {
  62856. name: string;
  62857. shader: string;
  62858. };
  62859. }
  62860. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  62861. import { Nullable } from "babylonjs/types";
  62862. import { Camera } from "babylonjs/Cameras/camera";
  62863. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62864. import { Scene } from "babylonjs/scene";
  62865. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62866. import "babylonjs/Animations/animatable";
  62867. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  62868. import "babylonjs/Shaders/motionBlur.fragment";
  62869. import { Engine } from "babylonjs/Engines/engine";
  62870. /**
  62871. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  62872. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  62873. * As an example, all you have to do is to create the post-process:
  62874. * var mb = new BABYLON.MotionBlurPostProcess(
  62875. * 'mb', // The name of the effect.
  62876. * scene, // The scene containing the objects to blur according to their velocity.
  62877. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  62878. * camera // The camera to apply the render pass to.
  62879. * );
  62880. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  62881. */
  62882. export class MotionBlurPostProcess extends PostProcess {
  62883. /**
  62884. * Defines how much the image is blurred by the movement. Default value is equal to 1
  62885. */
  62886. motionStrength: number;
  62887. /**
  62888. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  62889. */
  62890. /**
  62891. * Sets the number of iterations to be used for motion blur quality
  62892. */
  62893. motionBlurSamples: number;
  62894. private _motionBlurSamples;
  62895. private _geometryBufferRenderer;
  62896. /**
  62897. * Creates a new instance MotionBlurPostProcess
  62898. * @param name The name of the effect.
  62899. * @param scene The scene containing the objects to blur according to their velocity.
  62900. * @param options The required width/height ratio to downsize to before computing the render pass.
  62901. * @param camera The camera to apply the render pass to.
  62902. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62903. * @param engine The engine which the post process will be applied. (default: current engine)
  62904. * @param reusable If the post process can be reused on the same frame. (default: false)
  62905. * @param textureType Type of textures used when performing the post process. (default: 0)
  62906. * @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)
  62907. */
  62908. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  62909. /**
  62910. * Excludes the given skinned mesh from computing bones velocities.
  62911. * 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.
  62912. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  62913. */
  62914. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62915. /**
  62916. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  62917. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  62918. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  62919. */
  62920. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  62921. /**
  62922. * Disposes the post process.
  62923. * @param camera The camera to dispose the post process on.
  62924. */
  62925. dispose(camera?: Camera): void;
  62926. }
  62927. }
  62928. declare module "babylonjs/Shaders/refraction.fragment" {
  62929. /** @hidden */
  62930. export var refractionPixelShader: {
  62931. name: string;
  62932. shader: string;
  62933. };
  62934. }
  62935. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  62936. import { Color3 } from "babylonjs/Maths/math.color";
  62937. import { Camera } from "babylonjs/Cameras/camera";
  62938. import { Texture } from "babylonjs/Materials/Textures/texture";
  62939. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62940. import { Engine } from "babylonjs/Engines/engine";
  62941. import "babylonjs/Shaders/refraction.fragment";
  62942. /**
  62943. * Post process which applies a refractin texture
  62944. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62945. */
  62946. export class RefractionPostProcess extends PostProcess {
  62947. /** the base color of the refraction (used to taint the rendering) */
  62948. color: Color3;
  62949. /** simulated refraction depth */
  62950. depth: number;
  62951. /** the coefficient of the base color (0 to remove base color tainting) */
  62952. colorLevel: number;
  62953. private _refTexture;
  62954. private _ownRefractionTexture;
  62955. /**
  62956. * Gets or sets the refraction texture
  62957. * Please note that you are responsible for disposing the texture if you set it manually
  62958. */
  62959. refractionTexture: Texture;
  62960. /**
  62961. * Initializes the RefractionPostProcess
  62962. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  62963. * @param name The name of the effect.
  62964. * @param refractionTextureUrl Url of the refraction texture to use
  62965. * @param color the base color of the refraction (used to taint the rendering)
  62966. * @param depth simulated refraction depth
  62967. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  62968. * @param camera The camera to apply the render pass to.
  62969. * @param options The required width/height ratio to downsize to before computing the render pass.
  62970. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  62971. * @param engine The engine which the post process will be applied. (default: current engine)
  62972. * @param reusable If the post process can be reused on the same frame. (default: false)
  62973. */
  62974. constructor(name: string, refractionTextureUrl: string,
  62975. /** the base color of the refraction (used to taint the rendering) */
  62976. color: Color3,
  62977. /** simulated refraction depth */
  62978. depth: number,
  62979. /** the coefficient of the base color (0 to remove base color tainting) */
  62980. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  62981. /**
  62982. * Disposes of the post process
  62983. * @param camera Camera to dispose post process on
  62984. */
  62985. dispose(camera: Camera): void;
  62986. }
  62987. }
  62988. declare module "babylonjs/Shaders/sharpen.fragment" {
  62989. /** @hidden */
  62990. export var sharpenPixelShader: {
  62991. name: string;
  62992. shader: string;
  62993. };
  62994. }
  62995. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  62996. import { Nullable } from "babylonjs/types";
  62997. import { Camera } from "babylonjs/Cameras/camera";
  62998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  62999. import "babylonjs/Shaders/sharpen.fragment";
  63000. import { Engine } from "babylonjs/Engines/engine";
  63001. /**
  63002. * The SharpenPostProcess applies a sharpen kernel to every pixel
  63003. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  63004. */
  63005. export class SharpenPostProcess extends PostProcess {
  63006. /**
  63007. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  63008. */
  63009. colorAmount: number;
  63010. /**
  63011. * How much sharpness should be applied (default: 0.3)
  63012. */
  63013. edgeAmount: number;
  63014. /**
  63015. * Creates a new instance ConvolutionPostProcess
  63016. * @param name The name of the effect.
  63017. * @param options The required width/height ratio to downsize to before computing the render pass.
  63018. * @param camera The camera to apply the render pass to.
  63019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  63020. * @param engine The engine which the post process will be applied. (default: current engine)
  63021. * @param reusable If the post process can be reused on the same frame. (default: false)
  63022. * @param textureType Type of textures used when performing the post process. (default: 0)
  63023. * @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)
  63024. */
  63025. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  63026. }
  63027. }
  63028. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  63029. import { Nullable } from "babylonjs/types";
  63030. import { Camera } from "babylonjs/Cameras/camera";
  63031. import { Engine } from "babylonjs/Engines/engine";
  63032. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  63033. import { IInspectable } from "babylonjs/Misc/iInspectable";
  63034. /**
  63035. * PostProcessRenderPipeline
  63036. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63037. */
  63038. export class PostProcessRenderPipeline {
  63039. private engine;
  63040. private _renderEffects;
  63041. private _renderEffectsForIsolatedPass;
  63042. /**
  63043. * List of inspectable custom properties (used by the Inspector)
  63044. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  63045. */
  63046. inspectableCustomProperties: IInspectable[];
  63047. /**
  63048. * @hidden
  63049. */
  63050. protected _cameras: Camera[];
  63051. /** @hidden */
  63052. _name: string;
  63053. /**
  63054. * Gets pipeline name
  63055. */
  63056. readonly name: string;
  63057. /**
  63058. * Initializes a PostProcessRenderPipeline
  63059. * @param engine engine to add the pipeline to
  63060. * @param name name of the pipeline
  63061. */
  63062. constructor(engine: Engine, name: string);
  63063. /**
  63064. * Gets the class name
  63065. * @returns "PostProcessRenderPipeline"
  63066. */
  63067. getClassName(): string;
  63068. /**
  63069. * If all the render effects in the pipeline are supported
  63070. */
  63071. readonly isSupported: boolean;
  63072. /**
  63073. * Adds an effect to the pipeline
  63074. * @param renderEffect the effect to add
  63075. */
  63076. addEffect(renderEffect: PostProcessRenderEffect): void;
  63077. /** @hidden */
  63078. _rebuild(): void;
  63079. /** @hidden */
  63080. _enableEffect(renderEffectName: string, cameras: Camera): void;
  63081. /** @hidden */
  63082. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  63083. /** @hidden */
  63084. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63085. /** @hidden */
  63086. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  63087. /** @hidden */
  63088. _attachCameras(cameras: Camera, unique: boolean): void;
  63089. /** @hidden */
  63090. _attachCameras(cameras: Camera[], unique: boolean): void;
  63091. /** @hidden */
  63092. _detachCameras(cameras: Camera): void;
  63093. /** @hidden */
  63094. _detachCameras(cameras: Nullable<Camera[]>): void;
  63095. /** @hidden */
  63096. _update(): void;
  63097. /** @hidden */
  63098. _reset(): void;
  63099. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  63100. /**
  63101. * Disposes of the pipeline
  63102. */
  63103. dispose(): void;
  63104. }
  63105. }
  63106. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  63107. import { Camera } from "babylonjs/Cameras/camera";
  63108. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63109. /**
  63110. * PostProcessRenderPipelineManager class
  63111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63112. */
  63113. export class PostProcessRenderPipelineManager {
  63114. private _renderPipelines;
  63115. /**
  63116. * Initializes a PostProcessRenderPipelineManager
  63117. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63118. */
  63119. constructor();
  63120. /**
  63121. * Gets the list of supported render pipelines
  63122. */
  63123. readonly supportedPipelines: PostProcessRenderPipeline[];
  63124. /**
  63125. * Adds a pipeline to the manager
  63126. * @param renderPipeline The pipeline to add
  63127. */
  63128. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  63129. /**
  63130. * Attaches a camera to the pipeline
  63131. * @param renderPipelineName The name of the pipeline to attach to
  63132. * @param cameras the camera to attach
  63133. * @param unique if the camera can be attached multiple times to the pipeline
  63134. */
  63135. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  63136. /**
  63137. * Detaches a camera from the pipeline
  63138. * @param renderPipelineName The name of the pipeline to detach from
  63139. * @param cameras the camera to detach
  63140. */
  63141. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  63142. /**
  63143. * Enables an effect by name on a pipeline
  63144. * @param renderPipelineName the name of the pipeline to enable the effect in
  63145. * @param renderEffectName the name of the effect to enable
  63146. * @param cameras the cameras that the effect should be enabled on
  63147. */
  63148. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63149. /**
  63150. * Disables an effect by name on a pipeline
  63151. * @param renderPipelineName the name of the pipeline to disable the effect in
  63152. * @param renderEffectName the name of the effect to disable
  63153. * @param cameras the cameras that the effect should be disabled on
  63154. */
  63155. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  63156. /**
  63157. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  63158. */
  63159. update(): void;
  63160. /** @hidden */
  63161. _rebuild(): void;
  63162. /**
  63163. * Disposes of the manager and pipelines
  63164. */
  63165. dispose(): void;
  63166. }
  63167. }
  63168. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  63169. import { ISceneComponent } from "babylonjs/sceneComponent";
  63170. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  63171. import { Scene } from "babylonjs/scene";
  63172. module "babylonjs/scene" {
  63173. interface Scene {
  63174. /** @hidden (Backing field) */
  63175. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63176. /**
  63177. * Gets the postprocess render pipeline manager
  63178. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  63179. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63180. */
  63181. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  63182. }
  63183. }
  63184. /**
  63185. * Defines the Render Pipeline scene component responsible to rendering pipelines
  63186. */
  63187. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  63188. /**
  63189. * The component name helpfull to identify the component in the list of scene components.
  63190. */
  63191. readonly name: string;
  63192. /**
  63193. * The scene the component belongs to.
  63194. */
  63195. scene: Scene;
  63196. /**
  63197. * Creates a new instance of the component for the given scene
  63198. * @param scene Defines the scene to register the component in
  63199. */
  63200. constructor(scene: Scene);
  63201. /**
  63202. * Registers the component in a given scene
  63203. */
  63204. register(): void;
  63205. /**
  63206. * Rebuilds the elements related to this component in case of
  63207. * context lost for instance.
  63208. */
  63209. rebuild(): void;
  63210. /**
  63211. * Disposes the component and the associated ressources
  63212. */
  63213. dispose(): void;
  63214. private _gatherRenderTargets;
  63215. }
  63216. }
  63217. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  63218. import { Nullable } from "babylonjs/types";
  63219. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63220. import { Camera } from "babylonjs/Cameras/camera";
  63221. import { IDisposable } from "babylonjs/scene";
  63222. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  63223. import { Scene } from "babylonjs/scene";
  63224. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  63225. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  63226. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  63227. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  63228. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63229. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63230. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  63231. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63232. import { Animation } from "babylonjs/Animations/animation";
  63233. /**
  63234. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  63235. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  63236. */
  63237. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63238. private _scene;
  63239. private _camerasToBeAttached;
  63240. /**
  63241. * ID of the sharpen post process,
  63242. */
  63243. private readonly SharpenPostProcessId;
  63244. /**
  63245. * @ignore
  63246. * ID of the image processing post process;
  63247. */
  63248. readonly ImageProcessingPostProcessId: string;
  63249. /**
  63250. * @ignore
  63251. * ID of the Fast Approximate Anti-Aliasing post process;
  63252. */
  63253. readonly FxaaPostProcessId: string;
  63254. /**
  63255. * ID of the chromatic aberration post process,
  63256. */
  63257. private readonly ChromaticAberrationPostProcessId;
  63258. /**
  63259. * ID of the grain post process
  63260. */
  63261. private readonly GrainPostProcessId;
  63262. /**
  63263. * Sharpen post process which will apply a sharpen convolution to enhance edges
  63264. */
  63265. sharpen: SharpenPostProcess;
  63266. private _sharpenEffect;
  63267. private bloom;
  63268. /**
  63269. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  63270. */
  63271. depthOfField: DepthOfFieldEffect;
  63272. /**
  63273. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  63274. */
  63275. fxaa: FxaaPostProcess;
  63276. /**
  63277. * Image post processing pass used to perform operations such as tone mapping or color grading.
  63278. */
  63279. imageProcessing: ImageProcessingPostProcess;
  63280. /**
  63281. * Chromatic aberration post process which will shift rgb colors in the image
  63282. */
  63283. chromaticAberration: ChromaticAberrationPostProcess;
  63284. private _chromaticAberrationEffect;
  63285. /**
  63286. * Grain post process which add noise to the image
  63287. */
  63288. grain: GrainPostProcess;
  63289. private _grainEffect;
  63290. /**
  63291. * Glow post process which adds a glow to emissive areas of the image
  63292. */
  63293. private _glowLayer;
  63294. /**
  63295. * Animations which can be used to tweak settings over a period of time
  63296. */
  63297. animations: Animation[];
  63298. private _imageProcessingConfigurationObserver;
  63299. private _sharpenEnabled;
  63300. private _bloomEnabled;
  63301. private _depthOfFieldEnabled;
  63302. private _depthOfFieldBlurLevel;
  63303. private _fxaaEnabled;
  63304. private _imageProcessingEnabled;
  63305. private _defaultPipelineTextureType;
  63306. private _bloomScale;
  63307. private _chromaticAberrationEnabled;
  63308. private _grainEnabled;
  63309. private _buildAllowed;
  63310. /**
  63311. * Gets active scene
  63312. */
  63313. readonly scene: Scene;
  63314. /**
  63315. * Enable or disable the sharpen process from the pipeline
  63316. */
  63317. sharpenEnabled: boolean;
  63318. private _resizeObserver;
  63319. private _hardwareScaleLevel;
  63320. private _bloomKernel;
  63321. /**
  63322. * Specifies the size of the bloom blur kernel, relative to the final output size
  63323. */
  63324. bloomKernel: number;
  63325. /**
  63326. * Specifies the weight of the bloom in the final rendering
  63327. */
  63328. private _bloomWeight;
  63329. /**
  63330. * Specifies the luma threshold for the area that will be blurred by the bloom
  63331. */
  63332. private _bloomThreshold;
  63333. private _hdr;
  63334. /**
  63335. * The strength of the bloom.
  63336. */
  63337. bloomWeight: number;
  63338. /**
  63339. * The strength of the bloom.
  63340. */
  63341. bloomThreshold: number;
  63342. /**
  63343. * The scale of the bloom, lower value will provide better performance.
  63344. */
  63345. bloomScale: number;
  63346. /**
  63347. * Enable or disable the bloom from the pipeline
  63348. */
  63349. bloomEnabled: boolean;
  63350. private _rebuildBloom;
  63351. /**
  63352. * If the depth of field is enabled.
  63353. */
  63354. depthOfFieldEnabled: boolean;
  63355. /**
  63356. * Blur level of the depth of field effect. (Higher blur will effect performance)
  63357. */
  63358. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  63359. /**
  63360. * If the anti aliasing is enabled.
  63361. */
  63362. fxaaEnabled: boolean;
  63363. private _samples;
  63364. /**
  63365. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  63366. */
  63367. samples: number;
  63368. /**
  63369. * If image processing is enabled.
  63370. */
  63371. imageProcessingEnabled: boolean;
  63372. /**
  63373. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  63374. */
  63375. glowLayerEnabled: boolean;
  63376. /**
  63377. * Gets the glow layer (or null if not defined)
  63378. */
  63379. readonly glowLayer: Nullable<GlowLayer>;
  63380. /**
  63381. * Enable or disable the chromaticAberration process from the pipeline
  63382. */
  63383. chromaticAberrationEnabled: boolean;
  63384. /**
  63385. * Enable or disable the grain process from the pipeline
  63386. */
  63387. grainEnabled: boolean;
  63388. /**
  63389. * @constructor
  63390. * @param name - The rendering pipeline name (default: "")
  63391. * @param hdr - If high dynamic range textures should be used (default: true)
  63392. * @param scene - The scene linked to this pipeline (default: the last created scene)
  63393. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  63394. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  63395. */
  63396. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  63397. /**
  63398. * Get the class name
  63399. * @returns "DefaultRenderingPipeline"
  63400. */
  63401. getClassName(): string;
  63402. /**
  63403. * Force the compilation of the entire pipeline.
  63404. */
  63405. prepare(): void;
  63406. private _hasCleared;
  63407. private _prevPostProcess;
  63408. private _prevPrevPostProcess;
  63409. private _setAutoClearAndTextureSharing;
  63410. private _depthOfFieldSceneObserver;
  63411. private _buildPipeline;
  63412. private _disposePostProcesses;
  63413. /**
  63414. * Adds a camera to the pipeline
  63415. * @param camera the camera to be added
  63416. */
  63417. addCamera(camera: Camera): void;
  63418. /**
  63419. * Removes a camera from the pipeline
  63420. * @param camera the camera to remove
  63421. */
  63422. removeCamera(camera: Camera): void;
  63423. /**
  63424. * Dispose of the pipeline and stop all post processes
  63425. */
  63426. dispose(): void;
  63427. /**
  63428. * Serialize the rendering pipeline (Used when exporting)
  63429. * @returns the serialized object
  63430. */
  63431. serialize(): any;
  63432. /**
  63433. * Parse the serialized pipeline
  63434. * @param source Source pipeline.
  63435. * @param scene The scene to load the pipeline to.
  63436. * @param rootUrl The URL of the serialized pipeline.
  63437. * @returns An instantiated pipeline from the serialized object.
  63438. */
  63439. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  63440. }
  63441. }
  63442. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  63443. /** @hidden */
  63444. export var lensHighlightsPixelShader: {
  63445. name: string;
  63446. shader: string;
  63447. };
  63448. }
  63449. declare module "babylonjs/Shaders/depthOfField.fragment" {
  63450. /** @hidden */
  63451. export var depthOfFieldPixelShader: {
  63452. name: string;
  63453. shader: string;
  63454. };
  63455. }
  63456. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  63457. import { Camera } from "babylonjs/Cameras/camera";
  63458. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63459. import { Scene } from "babylonjs/scene";
  63460. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63461. import "babylonjs/Shaders/chromaticAberration.fragment";
  63462. import "babylonjs/Shaders/lensHighlights.fragment";
  63463. import "babylonjs/Shaders/depthOfField.fragment";
  63464. /**
  63465. * BABYLON.JS Chromatic Aberration GLSL Shader
  63466. * Author: Olivier Guyot
  63467. * Separates very slightly R, G and B colors on the edges of the screen
  63468. * Inspired by Francois Tarlier & Martins Upitis
  63469. */
  63470. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  63471. /**
  63472. * @ignore
  63473. * The chromatic aberration PostProcess id in the pipeline
  63474. */
  63475. LensChromaticAberrationEffect: string;
  63476. /**
  63477. * @ignore
  63478. * The highlights enhancing PostProcess id in the pipeline
  63479. */
  63480. HighlightsEnhancingEffect: string;
  63481. /**
  63482. * @ignore
  63483. * The depth-of-field PostProcess id in the pipeline
  63484. */
  63485. LensDepthOfFieldEffect: string;
  63486. private _scene;
  63487. private _depthTexture;
  63488. private _grainTexture;
  63489. private _chromaticAberrationPostProcess;
  63490. private _highlightsPostProcess;
  63491. private _depthOfFieldPostProcess;
  63492. private _edgeBlur;
  63493. private _grainAmount;
  63494. private _chromaticAberration;
  63495. private _distortion;
  63496. private _highlightsGain;
  63497. private _highlightsThreshold;
  63498. private _dofDistance;
  63499. private _dofAperture;
  63500. private _dofDarken;
  63501. private _dofPentagon;
  63502. private _blurNoise;
  63503. /**
  63504. * @constructor
  63505. *
  63506. * Effect parameters are as follow:
  63507. * {
  63508. * chromatic_aberration: number; // from 0 to x (1 for realism)
  63509. * edge_blur: number; // from 0 to x (1 for realism)
  63510. * distortion: number; // from 0 to x (1 for realism)
  63511. * grain_amount: number; // from 0 to 1
  63512. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  63513. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  63514. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  63515. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  63516. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  63517. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  63518. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  63519. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  63520. * }
  63521. * Note: if an effect parameter is unset, effect is disabled
  63522. *
  63523. * @param name The rendering pipeline name
  63524. * @param parameters - An object containing all parameters (see above)
  63525. * @param scene The scene linked to this pipeline
  63526. * @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)
  63527. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63528. */
  63529. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  63530. /**
  63531. * Get the class name
  63532. * @returns "LensRenderingPipeline"
  63533. */
  63534. getClassName(): string;
  63535. /**
  63536. * Gets associated scene
  63537. */
  63538. readonly scene: Scene;
  63539. /**
  63540. * Gets or sets the edge blur
  63541. */
  63542. edgeBlur: number;
  63543. /**
  63544. * Gets or sets the grain amount
  63545. */
  63546. grainAmount: number;
  63547. /**
  63548. * Gets or sets the chromatic aberration amount
  63549. */
  63550. chromaticAberration: number;
  63551. /**
  63552. * Gets or sets the depth of field aperture
  63553. */
  63554. dofAperture: number;
  63555. /**
  63556. * Gets or sets the edge distortion
  63557. */
  63558. edgeDistortion: number;
  63559. /**
  63560. * Gets or sets the depth of field distortion
  63561. */
  63562. dofDistortion: number;
  63563. /**
  63564. * Gets or sets the darken out of focus amount
  63565. */
  63566. darkenOutOfFocus: number;
  63567. /**
  63568. * Gets or sets a boolean indicating if blur noise is enabled
  63569. */
  63570. blurNoise: boolean;
  63571. /**
  63572. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  63573. */
  63574. pentagonBokeh: boolean;
  63575. /**
  63576. * Gets or sets the highlight grain amount
  63577. */
  63578. highlightsGain: number;
  63579. /**
  63580. * Gets or sets the highlight threshold
  63581. */
  63582. highlightsThreshold: number;
  63583. /**
  63584. * Sets the amount of blur at the edges
  63585. * @param amount blur amount
  63586. */
  63587. setEdgeBlur(amount: number): void;
  63588. /**
  63589. * Sets edge blur to 0
  63590. */
  63591. disableEdgeBlur(): void;
  63592. /**
  63593. * Sets the amout of grain
  63594. * @param amount Amount of grain
  63595. */
  63596. setGrainAmount(amount: number): void;
  63597. /**
  63598. * Set grain amount to 0
  63599. */
  63600. disableGrain(): void;
  63601. /**
  63602. * Sets the chromatic aberration amount
  63603. * @param amount amount of chromatic aberration
  63604. */
  63605. setChromaticAberration(amount: number): void;
  63606. /**
  63607. * Sets chromatic aberration amount to 0
  63608. */
  63609. disableChromaticAberration(): void;
  63610. /**
  63611. * Sets the EdgeDistortion amount
  63612. * @param amount amount of EdgeDistortion
  63613. */
  63614. setEdgeDistortion(amount: number): void;
  63615. /**
  63616. * Sets edge distortion to 0
  63617. */
  63618. disableEdgeDistortion(): void;
  63619. /**
  63620. * Sets the FocusDistance amount
  63621. * @param amount amount of FocusDistance
  63622. */
  63623. setFocusDistance(amount: number): void;
  63624. /**
  63625. * Disables depth of field
  63626. */
  63627. disableDepthOfField(): void;
  63628. /**
  63629. * Sets the Aperture amount
  63630. * @param amount amount of Aperture
  63631. */
  63632. setAperture(amount: number): void;
  63633. /**
  63634. * Sets the DarkenOutOfFocus amount
  63635. * @param amount amount of DarkenOutOfFocus
  63636. */
  63637. setDarkenOutOfFocus(amount: number): void;
  63638. private _pentagonBokehIsEnabled;
  63639. /**
  63640. * Creates a pentagon bokeh effect
  63641. */
  63642. enablePentagonBokeh(): void;
  63643. /**
  63644. * Disables the pentagon bokeh effect
  63645. */
  63646. disablePentagonBokeh(): void;
  63647. /**
  63648. * Enables noise blur
  63649. */
  63650. enableNoiseBlur(): void;
  63651. /**
  63652. * Disables noise blur
  63653. */
  63654. disableNoiseBlur(): void;
  63655. /**
  63656. * Sets the HighlightsGain amount
  63657. * @param amount amount of HighlightsGain
  63658. */
  63659. setHighlightsGain(amount: number): void;
  63660. /**
  63661. * Sets the HighlightsThreshold amount
  63662. * @param amount amount of HighlightsThreshold
  63663. */
  63664. setHighlightsThreshold(amount: number): void;
  63665. /**
  63666. * Disables highlights
  63667. */
  63668. disableHighlights(): void;
  63669. /**
  63670. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  63671. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  63672. */
  63673. dispose(disableDepthRender?: boolean): void;
  63674. private _createChromaticAberrationPostProcess;
  63675. private _createHighlightsPostProcess;
  63676. private _createDepthOfFieldPostProcess;
  63677. private _createGrainTexture;
  63678. }
  63679. }
  63680. declare module "babylonjs/Shaders/ssao2.fragment" {
  63681. /** @hidden */
  63682. export var ssao2PixelShader: {
  63683. name: string;
  63684. shader: string;
  63685. };
  63686. }
  63687. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  63688. /** @hidden */
  63689. export var ssaoCombinePixelShader: {
  63690. name: string;
  63691. shader: string;
  63692. };
  63693. }
  63694. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  63695. import { Camera } from "babylonjs/Cameras/camera";
  63696. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63697. import { Scene } from "babylonjs/scene";
  63698. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63699. import "babylonjs/Shaders/ssao2.fragment";
  63700. import "babylonjs/Shaders/ssaoCombine.fragment";
  63701. /**
  63702. * Render pipeline to produce ssao effect
  63703. */
  63704. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  63705. /**
  63706. * @ignore
  63707. * The PassPostProcess id in the pipeline that contains the original scene color
  63708. */
  63709. SSAOOriginalSceneColorEffect: string;
  63710. /**
  63711. * @ignore
  63712. * The SSAO PostProcess id in the pipeline
  63713. */
  63714. SSAORenderEffect: string;
  63715. /**
  63716. * @ignore
  63717. * The horizontal blur PostProcess id in the pipeline
  63718. */
  63719. SSAOBlurHRenderEffect: string;
  63720. /**
  63721. * @ignore
  63722. * The vertical blur PostProcess id in the pipeline
  63723. */
  63724. SSAOBlurVRenderEffect: string;
  63725. /**
  63726. * @ignore
  63727. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63728. */
  63729. SSAOCombineRenderEffect: string;
  63730. /**
  63731. * The output strength of the SSAO post-process. Default value is 1.0.
  63732. */
  63733. totalStrength: number;
  63734. /**
  63735. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  63736. */
  63737. maxZ: number;
  63738. /**
  63739. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  63740. */
  63741. minZAspect: number;
  63742. private _samples;
  63743. /**
  63744. * Number of samples used for the SSAO calculations. Default value is 8
  63745. */
  63746. samples: number;
  63747. private _textureSamples;
  63748. /**
  63749. * Number of samples to use for antialiasing
  63750. */
  63751. textureSamples: number;
  63752. /**
  63753. * Ratio object used for SSAO ratio and blur ratio
  63754. */
  63755. private _ratio;
  63756. /**
  63757. * Dynamically generated sphere sampler.
  63758. */
  63759. private _sampleSphere;
  63760. /**
  63761. * Blur filter offsets
  63762. */
  63763. private _samplerOffsets;
  63764. private _expensiveBlur;
  63765. /**
  63766. * If bilateral blur should be used
  63767. */
  63768. expensiveBlur: boolean;
  63769. /**
  63770. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  63771. */
  63772. radius: number;
  63773. /**
  63774. * The base color of the SSAO post-process
  63775. * The final result is "base + ssao" between [0, 1]
  63776. */
  63777. base: number;
  63778. /**
  63779. * Support test.
  63780. */
  63781. static readonly IsSupported: boolean;
  63782. private _scene;
  63783. private _depthTexture;
  63784. private _normalTexture;
  63785. private _randomTexture;
  63786. private _originalColorPostProcess;
  63787. private _ssaoPostProcess;
  63788. private _blurHPostProcess;
  63789. private _blurVPostProcess;
  63790. private _ssaoCombinePostProcess;
  63791. private _firstUpdate;
  63792. /**
  63793. * Gets active scene
  63794. */
  63795. readonly scene: Scene;
  63796. /**
  63797. * @constructor
  63798. * @param name The rendering pipeline name
  63799. * @param scene The scene linked to this pipeline
  63800. * @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 }
  63801. * @param cameras The array of cameras that the rendering pipeline will be attached to
  63802. */
  63803. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63804. /**
  63805. * Get the class name
  63806. * @returns "SSAO2RenderingPipeline"
  63807. */
  63808. getClassName(): string;
  63809. /**
  63810. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63811. */
  63812. dispose(disableGeometryBufferRenderer?: boolean): void;
  63813. private _createBlurPostProcess;
  63814. /** @hidden */
  63815. _rebuild(): void;
  63816. private _bits;
  63817. private _radicalInverse_VdC;
  63818. private _hammersley;
  63819. private _hemisphereSample_uniform;
  63820. private _generateHemisphere;
  63821. private _createSSAOPostProcess;
  63822. private _createSSAOCombinePostProcess;
  63823. private _createRandomTexture;
  63824. /**
  63825. * Serialize the rendering pipeline (Used when exporting)
  63826. * @returns the serialized object
  63827. */
  63828. serialize(): any;
  63829. /**
  63830. * Parse the serialized pipeline
  63831. * @param source Source pipeline.
  63832. * @param scene The scene to load the pipeline to.
  63833. * @param rootUrl The URL of the serialized pipeline.
  63834. * @returns An instantiated pipeline from the serialized object.
  63835. */
  63836. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  63837. }
  63838. }
  63839. declare module "babylonjs/Shaders/ssao.fragment" {
  63840. /** @hidden */
  63841. export var ssaoPixelShader: {
  63842. name: string;
  63843. shader: string;
  63844. };
  63845. }
  63846. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  63847. import { Camera } from "babylonjs/Cameras/camera";
  63848. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63849. import { Scene } from "babylonjs/scene";
  63850. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63851. import "babylonjs/Shaders/ssao.fragment";
  63852. import "babylonjs/Shaders/ssaoCombine.fragment";
  63853. /**
  63854. * Render pipeline to produce ssao effect
  63855. */
  63856. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  63857. /**
  63858. * @ignore
  63859. * The PassPostProcess id in the pipeline that contains the original scene color
  63860. */
  63861. SSAOOriginalSceneColorEffect: string;
  63862. /**
  63863. * @ignore
  63864. * The SSAO PostProcess id in the pipeline
  63865. */
  63866. SSAORenderEffect: string;
  63867. /**
  63868. * @ignore
  63869. * The horizontal blur PostProcess id in the pipeline
  63870. */
  63871. SSAOBlurHRenderEffect: string;
  63872. /**
  63873. * @ignore
  63874. * The vertical blur PostProcess id in the pipeline
  63875. */
  63876. SSAOBlurVRenderEffect: string;
  63877. /**
  63878. * @ignore
  63879. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  63880. */
  63881. SSAOCombineRenderEffect: string;
  63882. /**
  63883. * The output strength of the SSAO post-process. Default value is 1.0.
  63884. */
  63885. totalStrength: number;
  63886. /**
  63887. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  63888. */
  63889. radius: number;
  63890. /**
  63891. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  63892. * Must not be equal to fallOff and superior to fallOff.
  63893. * Default value is 0.0075
  63894. */
  63895. area: number;
  63896. /**
  63897. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  63898. * Must not be equal to area and inferior to area.
  63899. * Default value is 0.000001
  63900. */
  63901. fallOff: number;
  63902. /**
  63903. * The base color of the SSAO post-process
  63904. * The final result is "base + ssao" between [0, 1]
  63905. */
  63906. base: number;
  63907. private _scene;
  63908. private _depthTexture;
  63909. private _randomTexture;
  63910. private _originalColorPostProcess;
  63911. private _ssaoPostProcess;
  63912. private _blurHPostProcess;
  63913. private _blurVPostProcess;
  63914. private _ssaoCombinePostProcess;
  63915. private _firstUpdate;
  63916. /**
  63917. * Gets active scene
  63918. */
  63919. readonly scene: Scene;
  63920. /**
  63921. * @constructor
  63922. * @param name - The rendering pipeline name
  63923. * @param scene - The scene linked to this pipeline
  63924. * @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 }
  63925. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  63926. */
  63927. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  63928. /**
  63929. * Get the class name
  63930. * @returns "SSAORenderingPipeline"
  63931. */
  63932. getClassName(): string;
  63933. /**
  63934. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  63935. */
  63936. dispose(disableDepthRender?: boolean): void;
  63937. private _createBlurPostProcess;
  63938. /** @hidden */
  63939. _rebuild(): void;
  63940. private _createSSAOPostProcess;
  63941. private _createSSAOCombinePostProcess;
  63942. private _createRandomTexture;
  63943. }
  63944. }
  63945. declare module "babylonjs/Shaders/standard.fragment" {
  63946. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  63947. /** @hidden */
  63948. export var standardPixelShader: {
  63949. name: string;
  63950. shader: string;
  63951. };
  63952. }
  63953. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  63954. import { Nullable } from "babylonjs/types";
  63955. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  63956. import { Camera } from "babylonjs/Cameras/camera";
  63957. import { Texture } from "babylonjs/Materials/Textures/texture";
  63958. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  63959. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  63960. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  63961. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  63962. import { IDisposable } from "babylonjs/scene";
  63963. import { SpotLight } from "babylonjs/Lights/spotLight";
  63964. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  63965. import { Scene } from "babylonjs/scene";
  63966. import { Animation } from "babylonjs/Animations/animation";
  63967. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  63968. import "babylonjs/Shaders/standard.fragment";
  63969. /**
  63970. * Standard rendering pipeline
  63971. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  63972. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  63973. */
  63974. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  63975. /**
  63976. * Public members
  63977. */
  63978. /**
  63979. * Post-process which contains the original scene color before the pipeline applies all the effects
  63980. */
  63981. originalPostProcess: Nullable<PostProcess>;
  63982. /**
  63983. * Post-process used to down scale an image x4
  63984. */
  63985. downSampleX4PostProcess: Nullable<PostProcess>;
  63986. /**
  63987. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  63988. */
  63989. brightPassPostProcess: Nullable<PostProcess>;
  63990. /**
  63991. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  63992. */
  63993. blurHPostProcesses: PostProcess[];
  63994. /**
  63995. * Post-process array storing all the vertical blur post-processes used by the pipeline
  63996. */
  63997. blurVPostProcesses: PostProcess[];
  63998. /**
  63999. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  64000. */
  64001. textureAdderPostProcess: Nullable<PostProcess>;
  64002. /**
  64003. * Post-process used to create volumetric lighting effect
  64004. */
  64005. volumetricLightPostProcess: Nullable<PostProcess>;
  64006. /**
  64007. * Post-process used to smooth the previous volumetric light post-process on the X axis
  64008. */
  64009. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  64010. /**
  64011. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  64012. */
  64013. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  64014. /**
  64015. * Post-process used to merge the volumetric light effect and the real scene color
  64016. */
  64017. volumetricLightMergePostProces: Nullable<PostProcess>;
  64018. /**
  64019. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  64020. */
  64021. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  64022. /**
  64023. * Base post-process used to calculate the average luminance of the final image for HDR
  64024. */
  64025. luminancePostProcess: Nullable<PostProcess>;
  64026. /**
  64027. * Post-processes used to create down sample post-processes in order to get
  64028. * the average luminance of the final image for HDR
  64029. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  64030. */
  64031. luminanceDownSamplePostProcesses: PostProcess[];
  64032. /**
  64033. * Post-process used to create a HDR effect (light adaptation)
  64034. */
  64035. hdrPostProcess: Nullable<PostProcess>;
  64036. /**
  64037. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  64038. */
  64039. textureAdderFinalPostProcess: Nullable<PostProcess>;
  64040. /**
  64041. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  64042. */
  64043. lensFlareFinalPostProcess: Nullable<PostProcess>;
  64044. /**
  64045. * Post-process used to merge the final HDR post-process and the real scene color
  64046. */
  64047. hdrFinalPostProcess: Nullable<PostProcess>;
  64048. /**
  64049. * Post-process used to create a lens flare effect
  64050. */
  64051. lensFlarePostProcess: Nullable<PostProcess>;
  64052. /**
  64053. * Post-process that merges the result of the lens flare post-process and the real scene color
  64054. */
  64055. lensFlareComposePostProcess: Nullable<PostProcess>;
  64056. /**
  64057. * Post-process used to create a motion blur effect
  64058. */
  64059. motionBlurPostProcess: Nullable<PostProcess>;
  64060. /**
  64061. * Post-process used to create a depth of field effect
  64062. */
  64063. depthOfFieldPostProcess: Nullable<PostProcess>;
  64064. /**
  64065. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  64066. */
  64067. fxaaPostProcess: Nullable<FxaaPostProcess>;
  64068. /**
  64069. * Represents the brightness threshold in order to configure the illuminated surfaces
  64070. */
  64071. brightThreshold: number;
  64072. /**
  64073. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  64074. */
  64075. blurWidth: number;
  64076. /**
  64077. * Sets if the blur for highlighted surfaces must be only horizontal
  64078. */
  64079. horizontalBlur: boolean;
  64080. /**
  64081. * Gets the overall exposure used by the pipeline
  64082. */
  64083. /**
  64084. * Sets the overall exposure used by the pipeline
  64085. */
  64086. exposure: number;
  64087. /**
  64088. * Texture used typically to simulate "dirty" on camera lens
  64089. */
  64090. lensTexture: Nullable<Texture>;
  64091. /**
  64092. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  64093. */
  64094. volumetricLightCoefficient: number;
  64095. /**
  64096. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  64097. */
  64098. volumetricLightPower: number;
  64099. /**
  64100. * Used the set the blur intensity to smooth the volumetric lights
  64101. */
  64102. volumetricLightBlurScale: number;
  64103. /**
  64104. * Light (spot or directional) used to generate the volumetric lights rays
  64105. * The source light must have a shadow generate so the pipeline can get its
  64106. * depth map
  64107. */
  64108. sourceLight: Nullable<SpotLight | DirectionalLight>;
  64109. /**
  64110. * For eye adaptation, represents the minimum luminance the eye can see
  64111. */
  64112. hdrMinimumLuminance: number;
  64113. /**
  64114. * For eye adaptation, represents the decrease luminance speed
  64115. */
  64116. hdrDecreaseRate: number;
  64117. /**
  64118. * For eye adaptation, represents the increase luminance speed
  64119. */
  64120. hdrIncreaseRate: number;
  64121. /**
  64122. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64123. */
  64124. /**
  64125. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  64126. */
  64127. hdrAutoExposure: boolean;
  64128. /**
  64129. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  64130. */
  64131. lensColorTexture: Nullable<Texture>;
  64132. /**
  64133. * The overall strengh for the lens flare effect
  64134. */
  64135. lensFlareStrength: number;
  64136. /**
  64137. * Dispersion coefficient for lens flare ghosts
  64138. */
  64139. lensFlareGhostDispersal: number;
  64140. /**
  64141. * Main lens flare halo width
  64142. */
  64143. lensFlareHaloWidth: number;
  64144. /**
  64145. * Based on the lens distortion effect, defines how much the lens flare result
  64146. * is distorted
  64147. */
  64148. lensFlareDistortionStrength: number;
  64149. /**
  64150. * Configures the blur intensity used for for lens flare (halo)
  64151. */
  64152. lensFlareBlurWidth: number;
  64153. /**
  64154. * Lens star texture must be used to simulate rays on the flares and is available
  64155. * in the documentation
  64156. */
  64157. lensStarTexture: Nullable<Texture>;
  64158. /**
  64159. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  64160. * flare effect by taking account of the dirt texture
  64161. */
  64162. lensFlareDirtTexture: Nullable<Texture>;
  64163. /**
  64164. * Represents the focal length for the depth of field effect
  64165. */
  64166. depthOfFieldDistance: number;
  64167. /**
  64168. * Represents the blur intensity for the blurred part of the depth of field effect
  64169. */
  64170. depthOfFieldBlurWidth: number;
  64171. /**
  64172. * Gets how much the image is blurred by the movement while using the motion blur post-process
  64173. */
  64174. /**
  64175. * Sets how much the image is blurred by the movement while using the motion blur post-process
  64176. */
  64177. motionStrength: number;
  64178. /**
  64179. * Gets wether or not the motion blur post-process is object based or screen based.
  64180. */
  64181. /**
  64182. * Sets wether or not the motion blur post-process should be object based or screen based
  64183. */
  64184. objectBasedMotionBlur: boolean;
  64185. /**
  64186. * List of animations for the pipeline (IAnimatable implementation)
  64187. */
  64188. animations: Animation[];
  64189. /**
  64190. * Private members
  64191. */
  64192. private _scene;
  64193. private _currentDepthOfFieldSource;
  64194. private _basePostProcess;
  64195. private _fixedExposure;
  64196. private _currentExposure;
  64197. private _hdrAutoExposure;
  64198. private _hdrCurrentLuminance;
  64199. private _motionStrength;
  64200. private _isObjectBasedMotionBlur;
  64201. private _floatTextureType;
  64202. private _camerasToBeAttached;
  64203. private _ratio;
  64204. private _bloomEnabled;
  64205. private _depthOfFieldEnabled;
  64206. private _vlsEnabled;
  64207. private _lensFlareEnabled;
  64208. private _hdrEnabled;
  64209. private _motionBlurEnabled;
  64210. private _fxaaEnabled;
  64211. private _motionBlurSamples;
  64212. private _volumetricLightStepsCount;
  64213. private _samples;
  64214. /**
  64215. * @ignore
  64216. * Specifies if the bloom pipeline is enabled
  64217. */
  64218. BloomEnabled: boolean;
  64219. /**
  64220. * @ignore
  64221. * Specifies if the depth of field pipeline is enabed
  64222. */
  64223. DepthOfFieldEnabled: boolean;
  64224. /**
  64225. * @ignore
  64226. * Specifies if the lens flare pipeline is enabed
  64227. */
  64228. LensFlareEnabled: boolean;
  64229. /**
  64230. * @ignore
  64231. * Specifies if the HDR pipeline is enabled
  64232. */
  64233. HDREnabled: boolean;
  64234. /**
  64235. * @ignore
  64236. * Specifies if the volumetric lights scattering effect is enabled
  64237. */
  64238. VLSEnabled: boolean;
  64239. /**
  64240. * @ignore
  64241. * Specifies if the motion blur effect is enabled
  64242. */
  64243. MotionBlurEnabled: boolean;
  64244. /**
  64245. * Specifies if anti-aliasing is enabled
  64246. */
  64247. fxaaEnabled: boolean;
  64248. /**
  64249. * Specifies the number of steps used to calculate the volumetric lights
  64250. * Typically in interval [50, 200]
  64251. */
  64252. volumetricLightStepsCount: number;
  64253. /**
  64254. * Specifies the number of samples used for the motion blur effect
  64255. * Typically in interval [16, 64]
  64256. */
  64257. motionBlurSamples: number;
  64258. /**
  64259. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  64260. */
  64261. samples: number;
  64262. /**
  64263. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  64264. * @constructor
  64265. * @param name The rendering pipeline name
  64266. * @param scene The scene linked to this pipeline
  64267. * @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)
  64268. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  64269. * @param cameras The array of cameras that the rendering pipeline will be attached to
  64270. */
  64271. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  64272. private _buildPipeline;
  64273. private _createDownSampleX4PostProcess;
  64274. private _createBrightPassPostProcess;
  64275. private _createBlurPostProcesses;
  64276. private _createTextureAdderPostProcess;
  64277. private _createVolumetricLightPostProcess;
  64278. private _createLuminancePostProcesses;
  64279. private _createHdrPostProcess;
  64280. private _createLensFlarePostProcess;
  64281. private _createDepthOfFieldPostProcess;
  64282. private _createMotionBlurPostProcess;
  64283. private _getDepthTexture;
  64284. private _disposePostProcesses;
  64285. /**
  64286. * Dispose of the pipeline and stop all post processes
  64287. */
  64288. dispose(): void;
  64289. /**
  64290. * Serialize the rendering pipeline (Used when exporting)
  64291. * @returns the serialized object
  64292. */
  64293. serialize(): any;
  64294. /**
  64295. * Parse the serialized pipeline
  64296. * @param source Source pipeline.
  64297. * @param scene The scene to load the pipeline to.
  64298. * @param rootUrl The URL of the serialized pipeline.
  64299. * @returns An instantiated pipeline from the serialized object.
  64300. */
  64301. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  64302. /**
  64303. * Luminance steps
  64304. */
  64305. static LuminanceSteps: number;
  64306. }
  64307. }
  64308. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  64309. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  64310. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  64311. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  64312. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  64313. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  64314. }
  64315. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  64316. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  64317. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  64318. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  64319. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  64320. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  64321. }
  64322. declare module "babylonjs/Shaders/tonemap.fragment" {
  64323. /** @hidden */
  64324. export var tonemapPixelShader: {
  64325. name: string;
  64326. shader: string;
  64327. };
  64328. }
  64329. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  64330. import { Camera } from "babylonjs/Cameras/camera";
  64331. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64332. import "babylonjs/Shaders/tonemap.fragment";
  64333. import { Engine } from "babylonjs/Engines/engine";
  64334. /** Defines operator used for tonemapping */
  64335. export enum TonemappingOperator {
  64336. /** Hable */
  64337. Hable = 0,
  64338. /** Reinhard */
  64339. Reinhard = 1,
  64340. /** HejiDawson */
  64341. HejiDawson = 2,
  64342. /** Photographic */
  64343. Photographic = 3
  64344. }
  64345. /**
  64346. * Defines a post process to apply tone mapping
  64347. */
  64348. export class TonemapPostProcess extends PostProcess {
  64349. private _operator;
  64350. /** Defines the required exposure adjustement */
  64351. exposureAdjustment: number;
  64352. /**
  64353. * Creates a new TonemapPostProcess
  64354. * @param name defines the name of the postprocess
  64355. * @param _operator defines the operator to use
  64356. * @param exposureAdjustment defines the required exposure adjustement
  64357. * @param camera defines the camera to use (can be null)
  64358. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  64359. * @param engine defines the hosting engine (can be ignore if camera is set)
  64360. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  64361. */
  64362. constructor(name: string, _operator: TonemappingOperator,
  64363. /** Defines the required exposure adjustement */
  64364. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  64365. }
  64366. }
  64367. declare module "babylonjs/Shaders/depth.vertex" {
  64368. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64370. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64371. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64372. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64373. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64374. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64375. /** @hidden */
  64376. export var depthVertexShader: {
  64377. name: string;
  64378. shader: string;
  64379. };
  64380. }
  64381. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  64382. /** @hidden */
  64383. export var volumetricLightScatteringPixelShader: {
  64384. name: string;
  64385. shader: string;
  64386. };
  64387. }
  64388. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  64389. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64392. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64396. /** @hidden */
  64397. export var volumetricLightScatteringPassVertexShader: {
  64398. name: string;
  64399. shader: string;
  64400. };
  64401. }
  64402. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  64403. /** @hidden */
  64404. export var volumetricLightScatteringPassPixelShader: {
  64405. name: string;
  64406. shader: string;
  64407. };
  64408. }
  64409. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  64410. import { Vector3 } from "babylonjs/Maths/math.vector";
  64411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64412. import { Mesh } from "babylonjs/Meshes/mesh";
  64413. import { Camera } from "babylonjs/Cameras/camera";
  64414. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64415. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  64416. import { Scene } from "babylonjs/scene";
  64417. import "babylonjs/Meshes/Builders/planeBuilder";
  64418. import "babylonjs/Shaders/depth.vertex";
  64419. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  64420. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  64421. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  64422. import { Engine } from "babylonjs/Engines/engine";
  64423. /**
  64424. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  64425. */
  64426. export class VolumetricLightScatteringPostProcess extends PostProcess {
  64427. private _volumetricLightScatteringPass;
  64428. private _volumetricLightScatteringRTT;
  64429. private _viewPort;
  64430. private _screenCoordinates;
  64431. private _cachedDefines;
  64432. /**
  64433. * If not undefined, the mesh position is computed from the attached node position
  64434. */
  64435. attachedNode: {
  64436. position: Vector3;
  64437. };
  64438. /**
  64439. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  64440. */
  64441. customMeshPosition: Vector3;
  64442. /**
  64443. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  64444. */
  64445. useCustomMeshPosition: boolean;
  64446. /**
  64447. * If the post-process should inverse the light scattering direction
  64448. */
  64449. invert: boolean;
  64450. /**
  64451. * The internal mesh used by the post-process
  64452. */
  64453. mesh: Mesh;
  64454. /**
  64455. * @hidden
  64456. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  64457. */
  64458. useDiffuseColor: boolean;
  64459. /**
  64460. * Array containing the excluded meshes not rendered in the internal pass
  64461. */
  64462. excludedMeshes: AbstractMesh[];
  64463. /**
  64464. * Controls the overall intensity of the post-process
  64465. */
  64466. exposure: number;
  64467. /**
  64468. * Dissipates each sample's contribution in range [0, 1]
  64469. */
  64470. decay: number;
  64471. /**
  64472. * Controls the overall intensity of each sample
  64473. */
  64474. weight: number;
  64475. /**
  64476. * Controls the density of each sample
  64477. */
  64478. density: number;
  64479. /**
  64480. * @constructor
  64481. * @param name The post-process name
  64482. * @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)
  64483. * @param camera The camera that the post-process will be attached to
  64484. * @param mesh The mesh used to create the light scattering
  64485. * @param samples The post-process quality, default 100
  64486. * @param samplingModeThe post-process filtering mode
  64487. * @param engine The babylon engine
  64488. * @param reusable If the post-process is reusable
  64489. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  64490. */
  64491. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  64492. /**
  64493. * Returns the string "VolumetricLightScatteringPostProcess"
  64494. * @returns "VolumetricLightScatteringPostProcess"
  64495. */
  64496. getClassName(): string;
  64497. private _isReady;
  64498. /**
  64499. * Sets the new light position for light scattering effect
  64500. * @param position The new custom light position
  64501. */
  64502. setCustomMeshPosition(position: Vector3): void;
  64503. /**
  64504. * Returns the light position for light scattering effect
  64505. * @return Vector3 The custom light position
  64506. */
  64507. getCustomMeshPosition(): Vector3;
  64508. /**
  64509. * Disposes the internal assets and detaches the post-process from the camera
  64510. */
  64511. dispose(camera: Camera): void;
  64512. /**
  64513. * Returns the render target texture used by the post-process
  64514. * @return the render target texture used by the post-process
  64515. */
  64516. getPass(): RenderTargetTexture;
  64517. private _meshExcluded;
  64518. private _createPass;
  64519. private _updateMeshScreenCoordinates;
  64520. /**
  64521. * Creates a default mesh for the Volumeric Light Scattering post-process
  64522. * @param name The mesh name
  64523. * @param scene The scene where to create the mesh
  64524. * @return the default mesh
  64525. */
  64526. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  64527. }
  64528. }
  64529. declare module "babylonjs/PostProcesses/index" {
  64530. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  64531. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  64532. export * from "babylonjs/PostProcesses/bloomEffect";
  64533. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  64534. export * from "babylonjs/PostProcesses/blurPostProcess";
  64535. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  64536. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  64537. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  64538. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  64539. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  64540. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  64541. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  64542. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  64543. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  64544. export * from "babylonjs/PostProcesses/filterPostProcess";
  64545. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  64546. export * from "babylonjs/PostProcesses/grainPostProcess";
  64547. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  64548. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  64549. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  64550. export * from "babylonjs/PostProcesses/passPostProcess";
  64551. export * from "babylonjs/PostProcesses/postProcess";
  64552. export * from "babylonjs/PostProcesses/postProcessManager";
  64553. export * from "babylonjs/PostProcesses/refractionPostProcess";
  64554. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  64555. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  64556. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  64557. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  64558. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  64559. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  64560. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  64561. }
  64562. declare module "babylonjs/Probes/index" {
  64563. export * from "babylonjs/Probes/reflectionProbe";
  64564. }
  64565. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  64566. import { Scene } from "babylonjs/scene";
  64567. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64568. import { SmartArray } from "babylonjs/Misc/smartArray";
  64569. import { ISceneComponent } from "babylonjs/sceneComponent";
  64570. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  64571. import "babylonjs/Meshes/Builders/boxBuilder";
  64572. import "babylonjs/Shaders/color.fragment";
  64573. import "babylonjs/Shaders/color.vertex";
  64574. import { Color3 } from "babylonjs/Maths/math.color";
  64575. module "babylonjs/scene" {
  64576. interface Scene {
  64577. /** @hidden (Backing field) */
  64578. _boundingBoxRenderer: BoundingBoxRenderer;
  64579. /** @hidden (Backing field) */
  64580. _forceShowBoundingBoxes: boolean;
  64581. /**
  64582. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  64583. */
  64584. forceShowBoundingBoxes: boolean;
  64585. /**
  64586. * Gets the bounding box renderer associated with the scene
  64587. * @returns a BoundingBoxRenderer
  64588. */
  64589. getBoundingBoxRenderer(): BoundingBoxRenderer;
  64590. }
  64591. }
  64592. module "babylonjs/Meshes/abstractMesh" {
  64593. interface AbstractMesh {
  64594. /** @hidden (Backing field) */
  64595. _showBoundingBox: boolean;
  64596. /**
  64597. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  64598. */
  64599. showBoundingBox: boolean;
  64600. }
  64601. }
  64602. /**
  64603. * Component responsible of rendering the bounding box of the meshes in a scene.
  64604. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  64605. */
  64606. export class BoundingBoxRenderer implements ISceneComponent {
  64607. /**
  64608. * The component name helpfull to identify the component in the list of scene components.
  64609. */
  64610. readonly name: string;
  64611. /**
  64612. * The scene the component belongs to.
  64613. */
  64614. scene: Scene;
  64615. /**
  64616. * Color of the bounding box lines placed in front of an object
  64617. */
  64618. frontColor: Color3;
  64619. /**
  64620. * Color of the bounding box lines placed behind an object
  64621. */
  64622. backColor: Color3;
  64623. /**
  64624. * Defines if the renderer should show the back lines or not
  64625. */
  64626. showBackLines: boolean;
  64627. /**
  64628. * @hidden
  64629. */
  64630. renderList: SmartArray<BoundingBox>;
  64631. private _colorShader;
  64632. private _vertexBuffers;
  64633. private _indexBuffer;
  64634. private _fillIndexBuffer;
  64635. private _fillIndexData;
  64636. /**
  64637. * Instantiates a new bounding box renderer in a scene.
  64638. * @param scene the scene the renderer renders in
  64639. */
  64640. constructor(scene: Scene);
  64641. /**
  64642. * Registers the component in a given scene
  64643. */
  64644. register(): void;
  64645. private _evaluateSubMesh;
  64646. private _activeMesh;
  64647. private _prepareRessources;
  64648. private _createIndexBuffer;
  64649. /**
  64650. * Rebuilds the elements related to this component in case of
  64651. * context lost for instance.
  64652. */
  64653. rebuild(): void;
  64654. /**
  64655. * @hidden
  64656. */
  64657. reset(): void;
  64658. /**
  64659. * Render the bounding boxes of a specific rendering group
  64660. * @param renderingGroupId defines the rendering group to render
  64661. */
  64662. render(renderingGroupId: number): void;
  64663. /**
  64664. * In case of occlusion queries, we can render the occlusion bounding box through this method
  64665. * @param mesh Define the mesh to render the occlusion bounding box for
  64666. */
  64667. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  64668. /**
  64669. * Dispose and release the resources attached to this renderer.
  64670. */
  64671. dispose(): void;
  64672. }
  64673. }
  64674. declare module "babylonjs/Shaders/depth.fragment" {
  64675. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  64676. /** @hidden */
  64677. export var depthPixelShader: {
  64678. name: string;
  64679. shader: string;
  64680. };
  64681. }
  64682. declare module "babylonjs/Rendering/depthRenderer" {
  64683. import { Nullable } from "babylonjs/types";
  64684. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64685. import { Scene } from "babylonjs/scene";
  64686. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64687. import { Camera } from "babylonjs/Cameras/camera";
  64688. import "babylonjs/Shaders/depth.fragment";
  64689. import "babylonjs/Shaders/depth.vertex";
  64690. /**
  64691. * This represents a depth renderer in Babylon.
  64692. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  64693. */
  64694. export class DepthRenderer {
  64695. private _scene;
  64696. private _depthMap;
  64697. private _effect;
  64698. private readonly _storeNonLinearDepth;
  64699. private readonly _clearColor;
  64700. /** Get if the depth renderer is using packed depth or not */
  64701. readonly isPacked: boolean;
  64702. private _cachedDefines;
  64703. private _camera;
  64704. /**
  64705. * Specifiess that the depth renderer will only be used within
  64706. * the camera it is created for.
  64707. * This can help forcing its rendering during the camera processing.
  64708. */
  64709. useOnlyInActiveCamera: boolean;
  64710. /** @hidden */
  64711. static _SceneComponentInitialization: (scene: Scene) => void;
  64712. /**
  64713. * Instantiates a depth renderer
  64714. * @param scene The scene the renderer belongs to
  64715. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  64716. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  64717. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64718. */
  64719. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  64720. /**
  64721. * Creates the depth rendering effect and checks if the effect is ready.
  64722. * @param subMesh The submesh to be used to render the depth map of
  64723. * @param useInstances If multiple world instances should be used
  64724. * @returns if the depth renderer is ready to render the depth map
  64725. */
  64726. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64727. /**
  64728. * Gets the texture which the depth map will be written to.
  64729. * @returns The depth map texture
  64730. */
  64731. getDepthMap(): RenderTargetTexture;
  64732. /**
  64733. * Disposes of the depth renderer.
  64734. */
  64735. dispose(): void;
  64736. }
  64737. }
  64738. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  64739. import { Nullable } from "babylonjs/types";
  64740. import { Scene } from "babylonjs/scene";
  64741. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  64742. import { Camera } from "babylonjs/Cameras/camera";
  64743. import { ISceneComponent } from "babylonjs/sceneComponent";
  64744. module "babylonjs/scene" {
  64745. interface Scene {
  64746. /** @hidden (Backing field) */
  64747. _depthRenderer: {
  64748. [id: string]: DepthRenderer;
  64749. };
  64750. /**
  64751. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  64752. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  64753. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  64754. * @returns the created depth renderer
  64755. */
  64756. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  64757. /**
  64758. * Disables a depth renderer for a given camera
  64759. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  64760. */
  64761. disableDepthRenderer(camera?: Nullable<Camera>): void;
  64762. }
  64763. }
  64764. /**
  64765. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  64766. * in several rendering techniques.
  64767. */
  64768. export class DepthRendererSceneComponent implements ISceneComponent {
  64769. /**
  64770. * The component name helpfull to identify the component in the list of scene components.
  64771. */
  64772. readonly name: string;
  64773. /**
  64774. * The scene the component belongs to.
  64775. */
  64776. scene: Scene;
  64777. /**
  64778. * Creates a new instance of the component for the given scene
  64779. * @param scene Defines the scene to register the component in
  64780. */
  64781. constructor(scene: Scene);
  64782. /**
  64783. * Registers the component in a given scene
  64784. */
  64785. register(): void;
  64786. /**
  64787. * Rebuilds the elements related to this component in case of
  64788. * context lost for instance.
  64789. */
  64790. rebuild(): void;
  64791. /**
  64792. * Disposes the component and the associated ressources
  64793. */
  64794. dispose(): void;
  64795. private _gatherRenderTargets;
  64796. private _gatherActiveCameraRenderTargets;
  64797. }
  64798. }
  64799. declare module "babylonjs/Shaders/outline.fragment" {
  64800. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64801. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  64802. /** @hidden */
  64803. export var outlinePixelShader: {
  64804. name: string;
  64805. shader: string;
  64806. };
  64807. }
  64808. declare module "babylonjs/Shaders/outline.vertex" {
  64809. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  64810. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  64811. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  64812. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  64813. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  64814. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  64815. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  64816. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  64817. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  64818. /** @hidden */
  64819. export var outlineVertexShader: {
  64820. name: string;
  64821. shader: string;
  64822. };
  64823. }
  64824. declare module "babylonjs/Rendering/outlineRenderer" {
  64825. import { SubMesh } from "babylonjs/Meshes/subMesh";
  64826. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  64827. import { Scene } from "babylonjs/scene";
  64828. import { ISceneComponent } from "babylonjs/sceneComponent";
  64829. import "babylonjs/Shaders/outline.fragment";
  64830. import "babylonjs/Shaders/outline.vertex";
  64831. module "babylonjs/scene" {
  64832. interface Scene {
  64833. /** @hidden */
  64834. _outlineRenderer: OutlineRenderer;
  64835. /**
  64836. * Gets the outline renderer associated with the scene
  64837. * @returns a OutlineRenderer
  64838. */
  64839. getOutlineRenderer(): OutlineRenderer;
  64840. }
  64841. }
  64842. module "babylonjs/Meshes/abstractMesh" {
  64843. interface AbstractMesh {
  64844. /** @hidden (Backing field) */
  64845. _renderOutline: boolean;
  64846. /**
  64847. * Gets or sets a boolean indicating if the outline must be rendered as well
  64848. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  64849. */
  64850. renderOutline: boolean;
  64851. /** @hidden (Backing field) */
  64852. _renderOverlay: boolean;
  64853. /**
  64854. * Gets or sets a boolean indicating if the overlay must be rendered as well
  64855. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  64856. */
  64857. renderOverlay: boolean;
  64858. }
  64859. }
  64860. /**
  64861. * This class is responsible to draw bothe outline/overlay of meshes.
  64862. * It should not be used directly but through the available method on mesh.
  64863. */
  64864. export class OutlineRenderer implements ISceneComponent {
  64865. /**
  64866. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  64867. */
  64868. private static _StencilReference;
  64869. /**
  64870. * The name of the component. Each component must have a unique name.
  64871. */
  64872. name: string;
  64873. /**
  64874. * The scene the component belongs to.
  64875. */
  64876. scene: Scene;
  64877. /**
  64878. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  64879. */
  64880. zOffset: number;
  64881. private _engine;
  64882. private _effect;
  64883. private _cachedDefines;
  64884. private _savedDepthWrite;
  64885. /**
  64886. * Instantiates a new outline renderer. (There could be only one per scene).
  64887. * @param scene Defines the scene it belongs to
  64888. */
  64889. constructor(scene: Scene);
  64890. /**
  64891. * Register the component to one instance of a scene.
  64892. */
  64893. register(): void;
  64894. /**
  64895. * Rebuilds the elements related to this component in case of
  64896. * context lost for instance.
  64897. */
  64898. rebuild(): void;
  64899. /**
  64900. * Disposes the component and the associated ressources.
  64901. */
  64902. dispose(): void;
  64903. /**
  64904. * Renders the outline in the canvas.
  64905. * @param subMesh Defines the sumesh to render
  64906. * @param batch Defines the batch of meshes in case of instances
  64907. * @param useOverlay Defines if the rendering is for the overlay or the outline
  64908. */
  64909. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  64910. /**
  64911. * Returns whether or not the outline renderer is ready for a given submesh.
  64912. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  64913. * @param subMesh Defines the submesh to check readyness for
  64914. * @param useInstances Defines wheter wee are trying to render instances or not
  64915. * @returns true if ready otherwise false
  64916. */
  64917. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  64918. private _beforeRenderingMesh;
  64919. private _afterRenderingMesh;
  64920. }
  64921. }
  64922. declare module "babylonjs/Rendering/index" {
  64923. export * from "babylonjs/Rendering/boundingBoxRenderer";
  64924. export * from "babylonjs/Rendering/depthRenderer";
  64925. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  64926. export * from "babylonjs/Rendering/edgesRenderer";
  64927. export * from "babylonjs/Rendering/geometryBufferRenderer";
  64928. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  64929. export * from "babylonjs/Rendering/outlineRenderer";
  64930. export * from "babylonjs/Rendering/renderingGroup";
  64931. export * from "babylonjs/Rendering/renderingManager";
  64932. export * from "babylonjs/Rendering/utilityLayerRenderer";
  64933. }
  64934. declare module "babylonjs/Sprites/spritePackedManager" {
  64935. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  64936. import { Scene } from "babylonjs/scene";
  64937. /**
  64938. * Class used to manage multiple sprites of different sizes on the same spritesheet
  64939. * @see http://doc.babylonjs.com/babylon101/sprites
  64940. */
  64941. export class SpritePackedManager extends SpriteManager {
  64942. /** defines the packed manager's name */
  64943. name: string;
  64944. /**
  64945. * Creates a new sprite manager from a packed sprite sheet
  64946. * @param name defines the manager's name
  64947. * @param imgUrl defines the sprite sheet url
  64948. * @param capacity defines the maximum allowed number of sprites
  64949. * @param scene defines the hosting scene
  64950. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  64951. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  64952. * @param samplingMode defines the smapling mode to use with spritesheet
  64953. * @param fromPacked set to true; do not alter
  64954. */
  64955. constructor(
  64956. /** defines the packed manager's name */
  64957. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  64958. }
  64959. }
  64960. declare module "babylonjs/Sprites/index" {
  64961. export * from "babylonjs/Sprites/sprite";
  64962. export * from "babylonjs/Sprites/spriteManager";
  64963. export * from "babylonjs/Sprites/spritePackedManager";
  64964. export * from "babylonjs/Sprites/spriteSceneComponent";
  64965. }
  64966. declare module "babylonjs/States/index" {
  64967. export * from "babylonjs/States/alphaCullingState";
  64968. export * from "babylonjs/States/depthCullingState";
  64969. export * from "babylonjs/States/stencilState";
  64970. }
  64971. declare module "babylonjs/Misc/assetsManager" {
  64972. import { Scene } from "babylonjs/scene";
  64973. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64974. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  64975. import { Skeleton } from "babylonjs/Bones/skeleton";
  64976. import { Observable } from "babylonjs/Misc/observable";
  64977. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64978. import { Texture } from "babylonjs/Materials/Textures/texture";
  64979. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  64980. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  64981. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  64982. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  64983. /**
  64984. * Defines the list of states available for a task inside a AssetsManager
  64985. */
  64986. export enum AssetTaskState {
  64987. /**
  64988. * Initialization
  64989. */
  64990. INIT = 0,
  64991. /**
  64992. * Running
  64993. */
  64994. RUNNING = 1,
  64995. /**
  64996. * Done
  64997. */
  64998. DONE = 2,
  64999. /**
  65000. * Error
  65001. */
  65002. ERROR = 3
  65003. }
  65004. /**
  65005. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  65006. */
  65007. export abstract class AbstractAssetTask {
  65008. /**
  65009. * Task name
  65010. */ name: string;
  65011. /**
  65012. * Callback called when the task is successful
  65013. */
  65014. onSuccess: (task: any) => void;
  65015. /**
  65016. * Callback called when the task is not successful
  65017. */
  65018. onError: (task: any, message?: string, exception?: any) => void;
  65019. /**
  65020. * Creates a new AssetsManager
  65021. * @param name defines the name of the task
  65022. */
  65023. constructor(
  65024. /**
  65025. * Task name
  65026. */ name: string);
  65027. private _isCompleted;
  65028. private _taskState;
  65029. private _errorObject;
  65030. /**
  65031. * Get if the task is completed
  65032. */
  65033. readonly isCompleted: boolean;
  65034. /**
  65035. * Gets the current state of the task
  65036. */
  65037. readonly taskState: AssetTaskState;
  65038. /**
  65039. * Gets the current error object (if task is in error)
  65040. */
  65041. readonly errorObject: {
  65042. message?: string;
  65043. exception?: any;
  65044. };
  65045. /**
  65046. * Internal only
  65047. * @hidden
  65048. */
  65049. _setErrorObject(message?: string, exception?: any): void;
  65050. /**
  65051. * Execute the current task
  65052. * @param scene defines the scene where you want your assets to be loaded
  65053. * @param onSuccess is a callback called when the task is successfully executed
  65054. * @param onError is a callback called if an error occurs
  65055. */
  65056. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65057. /**
  65058. * Execute the current task
  65059. * @param scene defines the scene where you want your assets to be loaded
  65060. * @param onSuccess is a callback called when the task is successfully executed
  65061. * @param onError is a callback called if an error occurs
  65062. */
  65063. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65064. /**
  65065. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  65066. * This can be used with failed tasks that have the reason for failure fixed.
  65067. */
  65068. reset(): void;
  65069. private onErrorCallback;
  65070. private onDoneCallback;
  65071. }
  65072. /**
  65073. * Define the interface used by progress events raised during assets loading
  65074. */
  65075. export interface IAssetsProgressEvent {
  65076. /**
  65077. * Defines the number of remaining tasks to process
  65078. */
  65079. remainingCount: number;
  65080. /**
  65081. * Defines the total number of tasks
  65082. */
  65083. totalCount: number;
  65084. /**
  65085. * Defines the task that was just processed
  65086. */
  65087. task: AbstractAssetTask;
  65088. }
  65089. /**
  65090. * Class used to share progress information about assets loading
  65091. */
  65092. export class AssetsProgressEvent implements IAssetsProgressEvent {
  65093. /**
  65094. * Defines the number of remaining tasks to process
  65095. */
  65096. remainingCount: number;
  65097. /**
  65098. * Defines the total number of tasks
  65099. */
  65100. totalCount: number;
  65101. /**
  65102. * Defines the task that was just processed
  65103. */
  65104. task: AbstractAssetTask;
  65105. /**
  65106. * Creates a AssetsProgressEvent
  65107. * @param remainingCount defines the number of remaining tasks to process
  65108. * @param totalCount defines the total number of tasks
  65109. * @param task defines the task that was just processed
  65110. */
  65111. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  65112. }
  65113. /**
  65114. * Define a task used by AssetsManager to load meshes
  65115. */
  65116. export class MeshAssetTask extends AbstractAssetTask {
  65117. /**
  65118. * Defines the name of the task
  65119. */
  65120. name: string;
  65121. /**
  65122. * Defines the list of mesh's names you want to load
  65123. */
  65124. meshesNames: any;
  65125. /**
  65126. * Defines the root url to use as a base to load your meshes and associated resources
  65127. */
  65128. rootUrl: string;
  65129. /**
  65130. * Defines the filename of the scene to load from
  65131. */
  65132. sceneFilename: string;
  65133. /**
  65134. * Gets the list of loaded meshes
  65135. */
  65136. loadedMeshes: Array<AbstractMesh>;
  65137. /**
  65138. * Gets the list of loaded particle systems
  65139. */
  65140. loadedParticleSystems: Array<IParticleSystem>;
  65141. /**
  65142. * Gets the list of loaded skeletons
  65143. */
  65144. loadedSkeletons: Array<Skeleton>;
  65145. /**
  65146. * Gets the list of loaded animation groups
  65147. */
  65148. loadedAnimationGroups: Array<AnimationGroup>;
  65149. /**
  65150. * Callback called when the task is successful
  65151. */
  65152. onSuccess: (task: MeshAssetTask) => void;
  65153. /**
  65154. * Callback called when the task is successful
  65155. */
  65156. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  65157. /**
  65158. * Creates a new MeshAssetTask
  65159. * @param name defines the name of the task
  65160. * @param meshesNames defines the list of mesh's names you want to load
  65161. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  65162. * @param sceneFilename defines the filename of the scene to load from
  65163. */
  65164. constructor(
  65165. /**
  65166. * Defines the name of the task
  65167. */
  65168. name: string,
  65169. /**
  65170. * Defines the list of mesh's names you want to load
  65171. */
  65172. meshesNames: any,
  65173. /**
  65174. * Defines the root url to use as a base to load your meshes and associated resources
  65175. */
  65176. rootUrl: string,
  65177. /**
  65178. * Defines the filename of the scene to load from
  65179. */
  65180. sceneFilename: string);
  65181. /**
  65182. * Execute the current task
  65183. * @param scene defines the scene where you want your assets to be loaded
  65184. * @param onSuccess is a callback called when the task is successfully executed
  65185. * @param onError is a callback called if an error occurs
  65186. */
  65187. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65188. }
  65189. /**
  65190. * Define a task used by AssetsManager to load text content
  65191. */
  65192. export class TextFileAssetTask extends AbstractAssetTask {
  65193. /**
  65194. * Defines the name of the task
  65195. */
  65196. name: string;
  65197. /**
  65198. * Defines the location of the file to load
  65199. */
  65200. url: string;
  65201. /**
  65202. * Gets the loaded text string
  65203. */
  65204. text: string;
  65205. /**
  65206. * Callback called when the task is successful
  65207. */
  65208. onSuccess: (task: TextFileAssetTask) => void;
  65209. /**
  65210. * Callback called when the task is successful
  65211. */
  65212. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  65213. /**
  65214. * Creates a new TextFileAssetTask object
  65215. * @param name defines the name of the task
  65216. * @param url defines the location of the file to load
  65217. */
  65218. constructor(
  65219. /**
  65220. * Defines the name of the task
  65221. */
  65222. name: string,
  65223. /**
  65224. * Defines the location of the file to load
  65225. */
  65226. url: string);
  65227. /**
  65228. * Execute the current task
  65229. * @param scene defines the scene where you want your assets to be loaded
  65230. * @param onSuccess is a callback called when the task is successfully executed
  65231. * @param onError is a callback called if an error occurs
  65232. */
  65233. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65234. }
  65235. /**
  65236. * Define a task used by AssetsManager to load binary data
  65237. */
  65238. export class BinaryFileAssetTask extends AbstractAssetTask {
  65239. /**
  65240. * Defines the name of the task
  65241. */
  65242. name: string;
  65243. /**
  65244. * Defines the location of the file to load
  65245. */
  65246. url: string;
  65247. /**
  65248. * Gets the lodaded data (as an array buffer)
  65249. */
  65250. data: ArrayBuffer;
  65251. /**
  65252. * Callback called when the task is successful
  65253. */
  65254. onSuccess: (task: BinaryFileAssetTask) => void;
  65255. /**
  65256. * Callback called when the task is successful
  65257. */
  65258. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  65259. /**
  65260. * Creates a new BinaryFileAssetTask object
  65261. * @param name defines the name of the new task
  65262. * @param url defines the location of the file to load
  65263. */
  65264. constructor(
  65265. /**
  65266. * Defines the name of the task
  65267. */
  65268. name: string,
  65269. /**
  65270. * Defines the location of the file to load
  65271. */
  65272. url: string);
  65273. /**
  65274. * Execute the current task
  65275. * @param scene defines the scene where you want your assets to be loaded
  65276. * @param onSuccess is a callback called when the task is successfully executed
  65277. * @param onError is a callback called if an error occurs
  65278. */
  65279. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65280. }
  65281. /**
  65282. * Define a task used by AssetsManager to load images
  65283. */
  65284. export class ImageAssetTask extends AbstractAssetTask {
  65285. /**
  65286. * Defines the name of the task
  65287. */
  65288. name: string;
  65289. /**
  65290. * Defines the location of the image to load
  65291. */
  65292. url: string;
  65293. /**
  65294. * Gets the loaded images
  65295. */
  65296. image: HTMLImageElement;
  65297. /**
  65298. * Callback called when the task is successful
  65299. */
  65300. onSuccess: (task: ImageAssetTask) => void;
  65301. /**
  65302. * Callback called when the task is successful
  65303. */
  65304. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  65305. /**
  65306. * Creates a new ImageAssetTask
  65307. * @param name defines the name of the task
  65308. * @param url defines the location of the image to load
  65309. */
  65310. constructor(
  65311. /**
  65312. * Defines the name of the task
  65313. */
  65314. name: string,
  65315. /**
  65316. * Defines the location of the image to load
  65317. */
  65318. url: string);
  65319. /**
  65320. * Execute the current task
  65321. * @param scene defines the scene where you want your assets to be loaded
  65322. * @param onSuccess is a callback called when the task is successfully executed
  65323. * @param onError is a callback called if an error occurs
  65324. */
  65325. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65326. }
  65327. /**
  65328. * Defines the interface used by texture loading tasks
  65329. */
  65330. export interface ITextureAssetTask<TEX extends BaseTexture> {
  65331. /**
  65332. * Gets the loaded texture
  65333. */
  65334. texture: TEX;
  65335. }
  65336. /**
  65337. * Define a task used by AssetsManager to load 2D textures
  65338. */
  65339. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  65340. /**
  65341. * Defines the name of the task
  65342. */
  65343. name: string;
  65344. /**
  65345. * Defines the location of the file to load
  65346. */
  65347. url: string;
  65348. /**
  65349. * Defines if mipmap should not be generated (default is false)
  65350. */
  65351. noMipmap?: boolean | undefined;
  65352. /**
  65353. * Defines if texture must be inverted on Y axis (default is false)
  65354. */
  65355. invertY?: boolean | undefined;
  65356. /**
  65357. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65358. */
  65359. samplingMode: number;
  65360. /**
  65361. * Gets the loaded texture
  65362. */
  65363. texture: Texture;
  65364. /**
  65365. * Callback called when the task is successful
  65366. */
  65367. onSuccess: (task: TextureAssetTask) => void;
  65368. /**
  65369. * Callback called when the task is successful
  65370. */
  65371. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  65372. /**
  65373. * Creates a new TextureAssetTask object
  65374. * @param name defines the name of the task
  65375. * @param url defines the location of the file to load
  65376. * @param noMipmap defines if mipmap should not be generated (default is false)
  65377. * @param invertY defines if texture must be inverted on Y axis (default is false)
  65378. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65379. */
  65380. constructor(
  65381. /**
  65382. * Defines the name of the task
  65383. */
  65384. name: string,
  65385. /**
  65386. * Defines the location of the file to load
  65387. */
  65388. url: string,
  65389. /**
  65390. * Defines if mipmap should not be generated (default is false)
  65391. */
  65392. noMipmap?: boolean | undefined,
  65393. /**
  65394. * Defines if texture must be inverted on Y axis (default is false)
  65395. */
  65396. invertY?: boolean | undefined,
  65397. /**
  65398. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  65399. */
  65400. samplingMode?: number);
  65401. /**
  65402. * Execute the current task
  65403. * @param scene defines the scene where you want your assets to be loaded
  65404. * @param onSuccess is a callback called when the task is successfully executed
  65405. * @param onError is a callback called if an error occurs
  65406. */
  65407. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65408. }
  65409. /**
  65410. * Define a task used by AssetsManager to load cube textures
  65411. */
  65412. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  65413. /**
  65414. * Defines the name of the task
  65415. */
  65416. name: string;
  65417. /**
  65418. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65419. */
  65420. url: string;
  65421. /**
  65422. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65423. */
  65424. extensions?: string[] | undefined;
  65425. /**
  65426. * Defines if mipmaps should not be generated (default is false)
  65427. */
  65428. noMipmap?: boolean | undefined;
  65429. /**
  65430. * Defines the explicit list of files (undefined by default)
  65431. */
  65432. files?: string[] | undefined;
  65433. /**
  65434. * Gets the loaded texture
  65435. */
  65436. texture: CubeTexture;
  65437. /**
  65438. * Callback called when the task is successful
  65439. */
  65440. onSuccess: (task: CubeTextureAssetTask) => void;
  65441. /**
  65442. * Callback called when the task is successful
  65443. */
  65444. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  65445. /**
  65446. * Creates a new CubeTextureAssetTask
  65447. * @param name defines the name of the task
  65448. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65449. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65450. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65451. * @param files defines the explicit list of files (undefined by default)
  65452. */
  65453. constructor(
  65454. /**
  65455. * Defines the name of the task
  65456. */
  65457. name: string,
  65458. /**
  65459. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  65460. */
  65461. url: string,
  65462. /**
  65463. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  65464. */
  65465. extensions?: string[] | undefined,
  65466. /**
  65467. * Defines if mipmaps should not be generated (default is false)
  65468. */
  65469. noMipmap?: boolean | undefined,
  65470. /**
  65471. * Defines the explicit list of files (undefined by default)
  65472. */
  65473. files?: string[] | undefined);
  65474. /**
  65475. * Execute the current task
  65476. * @param scene defines the scene where you want your assets to be loaded
  65477. * @param onSuccess is a callback called when the task is successfully executed
  65478. * @param onError is a callback called if an error occurs
  65479. */
  65480. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65481. }
  65482. /**
  65483. * Define a task used by AssetsManager to load HDR cube textures
  65484. */
  65485. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  65486. /**
  65487. * Defines the name of the task
  65488. */
  65489. name: string;
  65490. /**
  65491. * Defines the location of the file to load
  65492. */
  65493. url: string;
  65494. /**
  65495. * Defines the desired size (the more it increases the longer the generation will be)
  65496. */
  65497. size: number;
  65498. /**
  65499. * Defines if mipmaps should not be generated (default is false)
  65500. */
  65501. noMipmap: boolean;
  65502. /**
  65503. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65504. */
  65505. generateHarmonics: boolean;
  65506. /**
  65507. * 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)
  65508. */
  65509. gammaSpace: boolean;
  65510. /**
  65511. * Internal Use Only
  65512. */
  65513. reserved: boolean;
  65514. /**
  65515. * Gets the loaded texture
  65516. */
  65517. texture: HDRCubeTexture;
  65518. /**
  65519. * Callback called when the task is successful
  65520. */
  65521. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  65522. /**
  65523. * Callback called when the task is successful
  65524. */
  65525. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  65526. /**
  65527. * Creates a new HDRCubeTextureAssetTask object
  65528. * @param name defines the name of the task
  65529. * @param url defines the location of the file to load
  65530. * @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.
  65531. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65532. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65533. * @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)
  65534. * @param reserved Internal use only
  65535. */
  65536. constructor(
  65537. /**
  65538. * Defines the name of the task
  65539. */
  65540. name: string,
  65541. /**
  65542. * Defines the location of the file to load
  65543. */
  65544. url: string,
  65545. /**
  65546. * Defines the desired size (the more it increases the longer the generation will be)
  65547. */
  65548. size: number,
  65549. /**
  65550. * Defines if mipmaps should not be generated (default is false)
  65551. */
  65552. noMipmap?: boolean,
  65553. /**
  65554. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  65555. */
  65556. generateHarmonics?: boolean,
  65557. /**
  65558. * 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)
  65559. */
  65560. gammaSpace?: boolean,
  65561. /**
  65562. * Internal Use Only
  65563. */
  65564. reserved?: boolean);
  65565. /**
  65566. * Execute the current task
  65567. * @param scene defines the scene where you want your assets to be loaded
  65568. * @param onSuccess is a callback called when the task is successfully executed
  65569. * @param onError is a callback called if an error occurs
  65570. */
  65571. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65572. }
  65573. /**
  65574. * Define a task used by AssetsManager to load Equirectangular cube textures
  65575. */
  65576. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  65577. /**
  65578. * Defines the name of the task
  65579. */
  65580. name: string;
  65581. /**
  65582. * Defines the location of the file to load
  65583. */
  65584. url: string;
  65585. /**
  65586. * Defines the desired size (the more it increases the longer the generation will be)
  65587. */
  65588. size: number;
  65589. /**
  65590. * Defines if mipmaps should not be generated (default is false)
  65591. */
  65592. noMipmap: boolean;
  65593. /**
  65594. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65595. * but the standard material would require them in Gamma space) (default is true)
  65596. */
  65597. gammaSpace: boolean;
  65598. /**
  65599. * Gets the loaded texture
  65600. */
  65601. texture: EquiRectangularCubeTexture;
  65602. /**
  65603. * Callback called when the task is successful
  65604. */
  65605. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  65606. /**
  65607. * Callback called when the task is successful
  65608. */
  65609. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  65610. /**
  65611. * Creates a new EquiRectangularCubeTextureAssetTask object
  65612. * @param name defines the name of the task
  65613. * @param url defines the location of the file to load
  65614. * @param size defines the desired size (the more it increases the longer the generation will be)
  65615. * If the size is omitted this implies you are using a preprocessed cubemap.
  65616. * @param noMipmap defines if mipmaps should not be generated (default is false)
  65617. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  65618. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  65619. * (default is true)
  65620. */
  65621. constructor(
  65622. /**
  65623. * Defines the name of the task
  65624. */
  65625. name: string,
  65626. /**
  65627. * Defines the location of the file to load
  65628. */
  65629. url: string,
  65630. /**
  65631. * Defines the desired size (the more it increases the longer the generation will be)
  65632. */
  65633. size: number,
  65634. /**
  65635. * Defines if mipmaps should not be generated (default is false)
  65636. */
  65637. noMipmap?: boolean,
  65638. /**
  65639. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  65640. * but the standard material would require them in Gamma space) (default is true)
  65641. */
  65642. gammaSpace?: boolean);
  65643. /**
  65644. * Execute the current task
  65645. * @param scene defines the scene where you want your assets to be loaded
  65646. * @param onSuccess is a callback called when the task is successfully executed
  65647. * @param onError is a callback called if an error occurs
  65648. */
  65649. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  65650. }
  65651. /**
  65652. * This class can be used to easily import assets into a scene
  65653. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  65654. */
  65655. export class AssetsManager {
  65656. private _scene;
  65657. private _isLoading;
  65658. protected _tasks: AbstractAssetTask[];
  65659. protected _waitingTasksCount: number;
  65660. protected _totalTasksCount: number;
  65661. /**
  65662. * Callback called when all tasks are processed
  65663. */
  65664. onFinish: (tasks: AbstractAssetTask[]) => void;
  65665. /**
  65666. * Callback called when a task is successful
  65667. */
  65668. onTaskSuccess: (task: AbstractAssetTask) => void;
  65669. /**
  65670. * Callback called when a task had an error
  65671. */
  65672. onTaskError: (task: AbstractAssetTask) => void;
  65673. /**
  65674. * Callback called when a task is done (whatever the result is)
  65675. */
  65676. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  65677. /**
  65678. * Observable called when all tasks are processed
  65679. */
  65680. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  65681. /**
  65682. * Observable called when a task had an error
  65683. */
  65684. onTaskErrorObservable: Observable<AbstractAssetTask>;
  65685. /**
  65686. * Observable called when all tasks were executed
  65687. */
  65688. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  65689. /**
  65690. * Observable called when a task is done (whatever the result is)
  65691. */
  65692. onProgressObservable: Observable<IAssetsProgressEvent>;
  65693. /**
  65694. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  65695. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  65696. */
  65697. useDefaultLoadingScreen: boolean;
  65698. /**
  65699. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  65700. * when all assets have been downloaded.
  65701. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  65702. */
  65703. autoHideLoadingUI: boolean;
  65704. /**
  65705. * Creates a new AssetsManager
  65706. * @param scene defines the scene to work on
  65707. */
  65708. constructor(scene: Scene);
  65709. /**
  65710. * Add a MeshAssetTask to the list of active tasks
  65711. * @param taskName defines the name of the new task
  65712. * @param meshesNames defines the name of meshes to load
  65713. * @param rootUrl defines the root url to use to locate files
  65714. * @param sceneFilename defines the filename of the scene file
  65715. * @returns a new MeshAssetTask object
  65716. */
  65717. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  65718. /**
  65719. * Add a TextFileAssetTask to the list of active tasks
  65720. * @param taskName defines the name of the new task
  65721. * @param url defines the url of the file to load
  65722. * @returns a new TextFileAssetTask object
  65723. */
  65724. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  65725. /**
  65726. * Add a BinaryFileAssetTask to the list of active tasks
  65727. * @param taskName defines the name of the new task
  65728. * @param url defines the url of the file to load
  65729. * @returns a new BinaryFileAssetTask object
  65730. */
  65731. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  65732. /**
  65733. * Add a ImageAssetTask to the list of active tasks
  65734. * @param taskName defines the name of the new task
  65735. * @param url defines the url of the file to load
  65736. * @returns a new ImageAssetTask object
  65737. */
  65738. addImageTask(taskName: string, url: string): ImageAssetTask;
  65739. /**
  65740. * Add a TextureAssetTask to the list of active tasks
  65741. * @param taskName defines the name of the new task
  65742. * @param url defines the url of the file to load
  65743. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65744. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  65745. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65746. * @returns a new TextureAssetTask object
  65747. */
  65748. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  65749. /**
  65750. * Add a CubeTextureAssetTask to the list of active tasks
  65751. * @param taskName defines the name of the new task
  65752. * @param url defines the url of the file to load
  65753. * @param extensions defines the extension to use to load the cube map (can be null)
  65754. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65755. * @param files defines the list of files to load (can be null)
  65756. * @returns a new CubeTextureAssetTask object
  65757. */
  65758. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  65759. /**
  65760. *
  65761. * Add a HDRCubeTextureAssetTask to the list of active tasks
  65762. * @param taskName defines the name of the new task
  65763. * @param url defines the url of the file to load
  65764. * @param size defines the size you want for the cubemap (can be null)
  65765. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65766. * @param generateHarmonics defines if you want to automatically generate (true by default)
  65767. * @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)
  65768. * @param reserved Internal use only
  65769. * @returns a new HDRCubeTextureAssetTask object
  65770. */
  65771. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  65772. /**
  65773. *
  65774. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  65775. * @param taskName defines the name of the new task
  65776. * @param url defines the url of the file to load
  65777. * @param size defines the size you want for the cubemap (can be null)
  65778. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  65779. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  65780. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  65781. * @returns a new EquiRectangularCubeTextureAssetTask object
  65782. */
  65783. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  65784. /**
  65785. * Remove a task from the assets manager.
  65786. * @param task the task to remove
  65787. */
  65788. removeTask(task: AbstractAssetTask): void;
  65789. private _decreaseWaitingTasksCount;
  65790. private _runTask;
  65791. /**
  65792. * Reset the AssetsManager and remove all tasks
  65793. * @return the current instance of the AssetsManager
  65794. */
  65795. reset(): AssetsManager;
  65796. /**
  65797. * Start the loading process
  65798. * @return the current instance of the AssetsManager
  65799. */
  65800. load(): AssetsManager;
  65801. /**
  65802. * Start the loading process as an async operation
  65803. * @return a promise returning the list of failed tasks
  65804. */
  65805. loadAsync(): Promise<void>;
  65806. }
  65807. }
  65808. declare module "babylonjs/Misc/deferred" {
  65809. /**
  65810. * Wrapper class for promise with external resolve and reject.
  65811. */
  65812. export class Deferred<T> {
  65813. /**
  65814. * The promise associated with this deferred object.
  65815. */
  65816. readonly promise: Promise<T>;
  65817. private _resolve;
  65818. private _reject;
  65819. /**
  65820. * The resolve method of the promise associated with this deferred object.
  65821. */
  65822. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  65823. /**
  65824. * The reject method of the promise associated with this deferred object.
  65825. */
  65826. readonly reject: (reason?: any) => void;
  65827. /**
  65828. * Constructor for this deferred object.
  65829. */
  65830. constructor();
  65831. }
  65832. }
  65833. declare module "babylonjs/Misc/meshExploder" {
  65834. import { Mesh } from "babylonjs/Meshes/mesh";
  65835. /**
  65836. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  65837. */
  65838. export class MeshExploder {
  65839. private _centerMesh;
  65840. private _meshes;
  65841. private _meshesOrigins;
  65842. private _toCenterVectors;
  65843. private _scaledDirection;
  65844. private _newPosition;
  65845. private _centerPosition;
  65846. /**
  65847. * Explodes meshes from a center mesh.
  65848. * @param meshes The meshes to explode.
  65849. * @param centerMesh The mesh to be center of explosion.
  65850. */
  65851. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  65852. private _setCenterMesh;
  65853. /**
  65854. * Get class name
  65855. * @returns "MeshExploder"
  65856. */
  65857. getClassName(): string;
  65858. /**
  65859. * "Exploded meshes"
  65860. * @returns Array of meshes with the centerMesh at index 0.
  65861. */
  65862. getMeshes(): Array<Mesh>;
  65863. /**
  65864. * Explodes meshes giving a specific direction
  65865. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  65866. */
  65867. explode(direction?: number): void;
  65868. }
  65869. }
  65870. declare module "babylonjs/Misc/filesInput" {
  65871. import { Engine } from "babylonjs/Engines/engine";
  65872. import { Scene } from "babylonjs/scene";
  65873. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  65874. /**
  65875. * Class used to help managing file picking and drag'n'drop
  65876. */
  65877. export class FilesInput {
  65878. /**
  65879. * List of files ready to be loaded
  65880. */
  65881. static readonly FilesToLoad: {
  65882. [key: string]: File;
  65883. };
  65884. /**
  65885. * Callback called when a file is processed
  65886. */
  65887. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  65888. private _engine;
  65889. private _currentScene;
  65890. private _sceneLoadedCallback;
  65891. private _progressCallback;
  65892. private _additionalRenderLoopLogicCallback;
  65893. private _textureLoadingCallback;
  65894. private _startingProcessingFilesCallback;
  65895. private _onReloadCallback;
  65896. private _errorCallback;
  65897. private _elementToMonitor;
  65898. private _sceneFileToLoad;
  65899. private _filesToLoad;
  65900. /**
  65901. * Creates a new FilesInput
  65902. * @param engine defines the rendering engine
  65903. * @param scene defines the hosting scene
  65904. * @param sceneLoadedCallback callback called when scene is loaded
  65905. * @param progressCallback callback called to track progress
  65906. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  65907. * @param textureLoadingCallback callback called when a texture is loading
  65908. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  65909. * @param onReloadCallback callback called when a reload is requested
  65910. * @param errorCallback callback call if an error occurs
  65911. */
  65912. 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);
  65913. private _dragEnterHandler;
  65914. private _dragOverHandler;
  65915. private _dropHandler;
  65916. /**
  65917. * Calls this function to listen to drag'n'drop events on a specific DOM element
  65918. * @param elementToMonitor defines the DOM element to track
  65919. */
  65920. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  65921. /**
  65922. * Release all associated resources
  65923. */
  65924. dispose(): void;
  65925. private renderFunction;
  65926. private drag;
  65927. private drop;
  65928. private _traverseFolder;
  65929. private _processFiles;
  65930. /**
  65931. * Load files from a drop event
  65932. * @param event defines the drop event to use as source
  65933. */
  65934. loadFiles(event: any): void;
  65935. private _processReload;
  65936. /**
  65937. * Reload the current scene from the loaded files
  65938. */
  65939. reload(): void;
  65940. }
  65941. }
  65942. declare module "babylonjs/Misc/HighDynamicRange/index" {
  65943. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  65944. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  65945. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  65946. }
  65947. declare module "babylonjs/Misc/sceneOptimizer" {
  65948. import { Scene, IDisposable } from "babylonjs/scene";
  65949. import { Observable } from "babylonjs/Misc/observable";
  65950. /**
  65951. * Defines the root class used to create scene optimization to use with SceneOptimizer
  65952. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65953. */
  65954. export class SceneOptimization {
  65955. /**
  65956. * Defines the priority of this optimization (0 by default which means first in the list)
  65957. */
  65958. priority: number;
  65959. /**
  65960. * Gets a string describing the action executed by the current optimization
  65961. * @returns description string
  65962. */
  65963. getDescription(): string;
  65964. /**
  65965. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  65966. * @param scene defines the current scene where to apply this optimization
  65967. * @param optimizer defines the current optimizer
  65968. * @returns true if everything that can be done was applied
  65969. */
  65970. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  65971. /**
  65972. * Creates the SceneOptimization object
  65973. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  65974. * @param desc defines the description associated with the optimization
  65975. */
  65976. constructor(
  65977. /**
  65978. * Defines the priority of this optimization (0 by default which means first in the list)
  65979. */
  65980. priority?: number);
  65981. }
  65982. /**
  65983. * Defines an optimization used to reduce the size of render target textures
  65984. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  65985. */
  65986. export class TextureOptimization extends SceneOptimization {
  65987. /**
  65988. * Defines the priority of this optimization (0 by default which means first in the list)
  65989. */
  65990. priority: number;
  65991. /**
  65992. * 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
  65993. */
  65994. maximumSize: number;
  65995. /**
  65996. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  65997. */
  65998. step: number;
  65999. /**
  66000. * Gets a string describing the action executed by the current optimization
  66001. * @returns description string
  66002. */
  66003. getDescription(): string;
  66004. /**
  66005. * Creates the TextureOptimization object
  66006. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66007. * @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
  66008. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66009. */
  66010. constructor(
  66011. /**
  66012. * Defines the priority of this optimization (0 by default which means first in the list)
  66013. */
  66014. priority?: number,
  66015. /**
  66016. * 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
  66017. */
  66018. maximumSize?: number,
  66019. /**
  66020. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  66021. */
  66022. step?: number);
  66023. /**
  66024. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66025. * @param scene defines the current scene where to apply this optimization
  66026. * @param optimizer defines the current optimizer
  66027. * @returns true if everything that can be done was applied
  66028. */
  66029. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66030. }
  66031. /**
  66032. * Defines an optimization used to increase or decrease the rendering resolution
  66033. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66034. */
  66035. export class HardwareScalingOptimization extends SceneOptimization {
  66036. /**
  66037. * Defines the priority of this optimization (0 by default which means first in the list)
  66038. */
  66039. priority: number;
  66040. /**
  66041. * Defines the maximum scale to use (2 by default)
  66042. */
  66043. maximumScale: number;
  66044. /**
  66045. * Defines the step to use between two passes (0.5 by default)
  66046. */
  66047. step: number;
  66048. private _currentScale;
  66049. private _directionOffset;
  66050. /**
  66051. * Gets a string describing the action executed by the current optimization
  66052. * @return description string
  66053. */
  66054. getDescription(): string;
  66055. /**
  66056. * Creates the HardwareScalingOptimization object
  66057. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66058. * @param maximumScale defines the maximum scale to use (2 by default)
  66059. * @param step defines the step to use between two passes (0.5 by default)
  66060. */
  66061. constructor(
  66062. /**
  66063. * Defines the priority of this optimization (0 by default which means first in the list)
  66064. */
  66065. priority?: number,
  66066. /**
  66067. * Defines the maximum scale to use (2 by default)
  66068. */
  66069. maximumScale?: number,
  66070. /**
  66071. * Defines the step to use between two passes (0.5 by default)
  66072. */
  66073. step?: number);
  66074. /**
  66075. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66076. * @param scene defines the current scene where to apply this optimization
  66077. * @param optimizer defines the current optimizer
  66078. * @returns true if everything that can be done was applied
  66079. */
  66080. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66081. }
  66082. /**
  66083. * Defines an optimization used to remove shadows
  66084. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66085. */
  66086. export class ShadowsOptimization extends SceneOptimization {
  66087. /**
  66088. * Gets a string describing the action executed by the current optimization
  66089. * @return description string
  66090. */
  66091. getDescription(): string;
  66092. /**
  66093. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66094. * @param scene defines the current scene where to apply this optimization
  66095. * @param optimizer defines the current optimizer
  66096. * @returns true if everything that can be done was applied
  66097. */
  66098. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66099. }
  66100. /**
  66101. * Defines an optimization used to turn post-processes off
  66102. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66103. */
  66104. export class PostProcessesOptimization extends SceneOptimization {
  66105. /**
  66106. * Gets a string describing the action executed by the current optimization
  66107. * @return description string
  66108. */
  66109. getDescription(): string;
  66110. /**
  66111. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66112. * @param scene defines the current scene where to apply this optimization
  66113. * @param optimizer defines the current optimizer
  66114. * @returns true if everything that can be done was applied
  66115. */
  66116. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66117. }
  66118. /**
  66119. * Defines an optimization used to turn lens flares off
  66120. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66121. */
  66122. export class LensFlaresOptimization extends SceneOptimization {
  66123. /**
  66124. * Gets a string describing the action executed by the current optimization
  66125. * @return description string
  66126. */
  66127. getDescription(): string;
  66128. /**
  66129. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66130. * @param scene defines the current scene where to apply this optimization
  66131. * @param optimizer defines the current optimizer
  66132. * @returns true if everything that can be done was applied
  66133. */
  66134. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66135. }
  66136. /**
  66137. * Defines an optimization based on user defined callback.
  66138. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66139. */
  66140. export class CustomOptimization extends SceneOptimization {
  66141. /**
  66142. * Callback called to apply the custom optimization.
  66143. */
  66144. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  66145. /**
  66146. * Callback called to get custom description
  66147. */
  66148. onGetDescription: () => string;
  66149. /**
  66150. * Gets a string describing the action executed by the current optimization
  66151. * @returns description string
  66152. */
  66153. getDescription(): string;
  66154. /**
  66155. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66156. * @param scene defines the current scene where to apply this optimization
  66157. * @param optimizer defines the current optimizer
  66158. * @returns true if everything that can be done was applied
  66159. */
  66160. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66161. }
  66162. /**
  66163. * Defines an optimization used to turn particles off
  66164. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66165. */
  66166. export class ParticlesOptimization extends SceneOptimization {
  66167. /**
  66168. * Gets a string describing the action executed by the current optimization
  66169. * @return description string
  66170. */
  66171. getDescription(): string;
  66172. /**
  66173. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66174. * @param scene defines the current scene where to apply this optimization
  66175. * @param optimizer defines the current optimizer
  66176. * @returns true if everything that can be done was applied
  66177. */
  66178. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66179. }
  66180. /**
  66181. * Defines an optimization used to turn render targets off
  66182. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66183. */
  66184. export class RenderTargetsOptimization extends SceneOptimization {
  66185. /**
  66186. * Gets a string describing the action executed by the current optimization
  66187. * @return description string
  66188. */
  66189. getDescription(): string;
  66190. /**
  66191. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66192. * @param scene defines the current scene where to apply this optimization
  66193. * @param optimizer defines the current optimizer
  66194. * @returns true if everything that can be done was applied
  66195. */
  66196. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  66197. }
  66198. /**
  66199. * Defines an optimization used to merge meshes with compatible materials
  66200. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66201. */
  66202. export class MergeMeshesOptimization extends SceneOptimization {
  66203. private static _UpdateSelectionTree;
  66204. /**
  66205. * Gets or sets a boolean which defines if optimization octree has to be updated
  66206. */
  66207. /**
  66208. * Gets or sets a boolean which defines if optimization octree has to be updated
  66209. */
  66210. static UpdateSelectionTree: boolean;
  66211. /**
  66212. * Gets a string describing the action executed by the current optimization
  66213. * @return description string
  66214. */
  66215. getDescription(): string;
  66216. private _canBeMerged;
  66217. /**
  66218. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  66219. * @param scene defines the current scene where to apply this optimization
  66220. * @param optimizer defines the current optimizer
  66221. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  66222. * @returns true if everything that can be done was applied
  66223. */
  66224. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  66225. }
  66226. /**
  66227. * Defines a list of options used by SceneOptimizer
  66228. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66229. */
  66230. export class SceneOptimizerOptions {
  66231. /**
  66232. * Defines the target frame rate to reach (60 by default)
  66233. */
  66234. targetFrameRate: number;
  66235. /**
  66236. * Defines the interval between two checkes (2000ms by default)
  66237. */
  66238. trackerDuration: number;
  66239. /**
  66240. * Gets the list of optimizations to apply
  66241. */
  66242. optimizations: SceneOptimization[];
  66243. /**
  66244. * Creates a new list of options used by SceneOptimizer
  66245. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  66246. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  66247. */
  66248. constructor(
  66249. /**
  66250. * Defines the target frame rate to reach (60 by default)
  66251. */
  66252. targetFrameRate?: number,
  66253. /**
  66254. * Defines the interval between two checkes (2000ms by default)
  66255. */
  66256. trackerDuration?: number);
  66257. /**
  66258. * Add a new optimization
  66259. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  66260. * @returns the current SceneOptimizerOptions
  66261. */
  66262. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  66263. /**
  66264. * Add a new custom optimization
  66265. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  66266. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  66267. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  66268. * @returns the current SceneOptimizerOptions
  66269. */
  66270. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  66271. /**
  66272. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  66273. * @param targetFrameRate defines the target frame rate (60 by default)
  66274. * @returns a SceneOptimizerOptions object
  66275. */
  66276. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66277. /**
  66278. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  66279. * @param targetFrameRate defines the target frame rate (60 by default)
  66280. * @returns a SceneOptimizerOptions object
  66281. */
  66282. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66283. /**
  66284. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  66285. * @param targetFrameRate defines the target frame rate (60 by default)
  66286. * @returns a SceneOptimizerOptions object
  66287. */
  66288. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  66289. }
  66290. /**
  66291. * Class used to run optimizations in order to reach a target frame rate
  66292. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  66293. */
  66294. export class SceneOptimizer implements IDisposable {
  66295. private _isRunning;
  66296. private _options;
  66297. private _scene;
  66298. private _currentPriorityLevel;
  66299. private _targetFrameRate;
  66300. private _trackerDuration;
  66301. private _currentFrameRate;
  66302. private _sceneDisposeObserver;
  66303. private _improvementMode;
  66304. /**
  66305. * Defines an observable called when the optimizer reaches the target frame rate
  66306. */
  66307. onSuccessObservable: Observable<SceneOptimizer>;
  66308. /**
  66309. * Defines an observable called when the optimizer enables an optimization
  66310. */
  66311. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  66312. /**
  66313. * Defines an observable called when the optimizer is not able to reach the target frame rate
  66314. */
  66315. onFailureObservable: Observable<SceneOptimizer>;
  66316. /**
  66317. * Gets a boolean indicating if the optimizer is in improvement mode
  66318. */
  66319. readonly isInImprovementMode: boolean;
  66320. /**
  66321. * Gets the current priority level (0 at start)
  66322. */
  66323. readonly currentPriorityLevel: number;
  66324. /**
  66325. * Gets the current frame rate checked by the SceneOptimizer
  66326. */
  66327. readonly currentFrameRate: number;
  66328. /**
  66329. * Gets or sets the current target frame rate (60 by default)
  66330. */
  66331. /**
  66332. * Gets or sets the current target frame rate (60 by default)
  66333. */
  66334. targetFrameRate: number;
  66335. /**
  66336. * Gets or sets the current interval between two checks (every 2000ms by default)
  66337. */
  66338. /**
  66339. * Gets or sets the current interval between two checks (every 2000ms by default)
  66340. */
  66341. trackerDuration: number;
  66342. /**
  66343. * Gets the list of active optimizations
  66344. */
  66345. readonly optimizations: SceneOptimization[];
  66346. /**
  66347. * Creates a new SceneOptimizer
  66348. * @param scene defines the scene to work on
  66349. * @param options defines the options to use with the SceneOptimizer
  66350. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  66351. * @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)
  66352. */
  66353. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  66354. /**
  66355. * Stops the current optimizer
  66356. */
  66357. stop(): void;
  66358. /**
  66359. * Reset the optimizer to initial step (current priority level = 0)
  66360. */
  66361. reset(): void;
  66362. /**
  66363. * Start the optimizer. By default it will try to reach a specific framerate
  66364. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  66365. */
  66366. start(): void;
  66367. private _checkCurrentState;
  66368. /**
  66369. * Release all resources
  66370. */
  66371. dispose(): void;
  66372. /**
  66373. * Helper function to create a SceneOptimizer with one single line of code
  66374. * @param scene defines the scene to work on
  66375. * @param options defines the options to use with the SceneOptimizer
  66376. * @param onSuccess defines a callback to call on success
  66377. * @param onFailure defines a callback to call on failure
  66378. * @returns the new SceneOptimizer object
  66379. */
  66380. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  66381. }
  66382. }
  66383. declare module "babylonjs/Misc/sceneSerializer" {
  66384. import { Scene } from "babylonjs/scene";
  66385. /**
  66386. * Class used to serialize a scene into a string
  66387. */
  66388. export class SceneSerializer {
  66389. /**
  66390. * Clear cache used by a previous serialization
  66391. */
  66392. static ClearCache(): void;
  66393. /**
  66394. * Serialize a scene into a JSON compatible object
  66395. * @param scene defines the scene to serialize
  66396. * @returns a JSON compatible object
  66397. */
  66398. static Serialize(scene: Scene): any;
  66399. /**
  66400. * Serialize a mesh into a JSON compatible object
  66401. * @param toSerialize defines the mesh to serialize
  66402. * @param withParents defines if parents must be serialized as well
  66403. * @param withChildren defines if children must be serialized as well
  66404. * @returns a JSON compatible object
  66405. */
  66406. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  66407. }
  66408. }
  66409. declare module "babylonjs/Misc/textureTools" {
  66410. import { Texture } from "babylonjs/Materials/Textures/texture";
  66411. /**
  66412. * Class used to host texture specific utilities
  66413. */
  66414. export class TextureTools {
  66415. /**
  66416. * Uses the GPU to create a copy texture rescaled at a given size
  66417. * @param texture Texture to copy from
  66418. * @param width defines the desired width
  66419. * @param height defines the desired height
  66420. * @param useBilinearMode defines if bilinear mode has to be used
  66421. * @return the generated texture
  66422. */
  66423. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  66424. }
  66425. }
  66426. declare module "babylonjs/Misc/videoRecorder" {
  66427. import { Nullable } from "babylonjs/types";
  66428. import { Engine } from "babylonjs/Engines/engine";
  66429. /**
  66430. * This represents the different options available for the video capture.
  66431. */
  66432. export interface VideoRecorderOptions {
  66433. /** Defines the mime type of the video. */
  66434. mimeType: string;
  66435. /** Defines the FPS the video should be recorded at. */
  66436. fps: number;
  66437. /** Defines the chunk size for the recording data. */
  66438. recordChunckSize: number;
  66439. /** The audio tracks to attach to the recording. */
  66440. audioTracks?: MediaStreamTrack[];
  66441. }
  66442. /**
  66443. * This can help with recording videos from BabylonJS.
  66444. * This is based on the available WebRTC functionalities of the browser.
  66445. *
  66446. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  66447. */
  66448. export class VideoRecorder {
  66449. private static readonly _defaultOptions;
  66450. /**
  66451. * Returns whether or not the VideoRecorder is available in your browser.
  66452. * @param engine Defines the Babylon Engine.
  66453. * @returns true if supported otherwise false.
  66454. */
  66455. static IsSupported(engine: Engine): boolean;
  66456. private readonly _options;
  66457. private _canvas;
  66458. private _mediaRecorder;
  66459. private _recordedChunks;
  66460. private _fileName;
  66461. private _resolve;
  66462. private _reject;
  66463. /**
  66464. * True when a recording is already in progress.
  66465. */
  66466. readonly isRecording: boolean;
  66467. /**
  66468. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  66469. * @param engine Defines the BabylonJS Engine you wish to record.
  66470. * @param options Defines options that can be used to customize the capture.
  66471. */
  66472. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  66473. /**
  66474. * Stops the current recording before the default capture timeout passed in the startRecording function.
  66475. */
  66476. stopRecording(): void;
  66477. /**
  66478. * Starts recording the canvas for a max duration specified in parameters.
  66479. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  66480. * If null no automatic download will start and you can rely on the promise to get the data back.
  66481. * @param maxDuration Defines the maximum recording time in seconds.
  66482. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  66483. * @return A promise callback at the end of the recording with the video data in Blob.
  66484. */
  66485. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  66486. /**
  66487. * Releases internal resources used during the recording.
  66488. */
  66489. dispose(): void;
  66490. private _handleDataAvailable;
  66491. private _handleError;
  66492. private _handleStop;
  66493. }
  66494. }
  66495. declare module "babylonjs/Misc/screenshotTools" {
  66496. import { Camera } from "babylonjs/Cameras/camera";
  66497. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  66498. import { Engine } from "babylonjs/Engines/engine";
  66499. /**
  66500. * Class containing a set of static utilities functions for screenshots
  66501. */
  66502. export class ScreenshotTools {
  66503. /**
  66504. * Captures a screenshot of the current rendering
  66505. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66506. * @param engine defines the rendering engine
  66507. * @param camera defines the source camera
  66508. * @param size This parameter can be set to a single number or to an object with the
  66509. * following (optional) properties: precision, width, height. If a single number is passed,
  66510. * it will be used for both width and height. If an object is passed, the screenshot size
  66511. * will be derived from the parameters. The precision property is a multiplier allowing
  66512. * rendering at a higher or lower resolution
  66513. * @param successCallback defines the callback receives a single parameter which contains the
  66514. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66515. * src parameter of an <img> to display it
  66516. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66517. * Check your browser for supported MIME types
  66518. */
  66519. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  66520. /**
  66521. * Captures a screenshot of the current rendering
  66522. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66523. * @param engine defines the rendering engine
  66524. * @param camera defines the source camera
  66525. * @param size This parameter can be set to a single number or to an object with the
  66526. * following (optional) properties: precision, width, height. If a single number is passed,
  66527. * it will be used for both width and height. If an object is passed, the screenshot size
  66528. * will be derived from the parameters. The precision property is a multiplier allowing
  66529. * rendering at a higher or lower resolution
  66530. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  66531. * Check your browser for supported MIME types
  66532. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66533. * to the src parameter of an <img> to display it
  66534. */
  66535. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  66536. /**
  66537. * Generates an image screenshot from the specified camera.
  66538. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66539. * @param engine The engine to use for rendering
  66540. * @param camera The camera to use for rendering
  66541. * @param size This parameter can be set to a single number or to an object with the
  66542. * following (optional) properties: precision, width, height. If a single number is passed,
  66543. * it will be used for both width and height. If an object is passed, the screenshot size
  66544. * will be derived from the parameters. The precision property is a multiplier allowing
  66545. * rendering at a higher or lower resolution
  66546. * @param successCallback The callback receives a single parameter which contains the
  66547. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  66548. * src parameter of an <img> to display it
  66549. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66550. * Check your browser for supported MIME types
  66551. * @param samples Texture samples (default: 1)
  66552. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66553. * @param fileName A name for for the downloaded file.
  66554. */
  66555. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  66556. /**
  66557. * Generates an image screenshot from the specified camera.
  66558. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  66559. * @param engine The engine to use for rendering
  66560. * @param camera The camera to use for rendering
  66561. * @param size This parameter can be set to a single number or to an object with the
  66562. * following (optional) properties: precision, width, height. If a single number is passed,
  66563. * it will be used for both width and height. If an object is passed, the screenshot size
  66564. * will be derived from the parameters. The precision property is a multiplier allowing
  66565. * rendering at a higher or lower resolution
  66566. * @param mimeType The MIME type of the screenshot image (default: image/png).
  66567. * Check your browser for supported MIME types
  66568. * @param samples Texture samples (default: 1)
  66569. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  66570. * @param fileName A name for for the downloaded file.
  66571. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  66572. * to the src parameter of an <img> to display it
  66573. */
  66574. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  66575. /**
  66576. * Gets height and width for screenshot size
  66577. * @private
  66578. */
  66579. private static _getScreenshotSize;
  66580. }
  66581. }
  66582. declare module "babylonjs/Misc/index" {
  66583. export * from "babylonjs/Misc/andOrNotEvaluator";
  66584. export * from "babylonjs/Misc/assetsManager";
  66585. export * from "babylonjs/Misc/dds";
  66586. export * from "babylonjs/Misc/decorators";
  66587. export * from "babylonjs/Misc/deferred";
  66588. export * from "babylonjs/Misc/environmentTextureTools";
  66589. export * from "babylonjs/Misc/meshExploder";
  66590. export * from "babylonjs/Misc/filesInput";
  66591. export * from "babylonjs/Misc/HighDynamicRange/index";
  66592. export * from "babylonjs/Misc/khronosTextureContainer";
  66593. export * from "babylonjs/Misc/observable";
  66594. export * from "babylonjs/Misc/performanceMonitor";
  66595. export * from "babylonjs/Misc/promise";
  66596. export * from "babylonjs/Misc/sceneOptimizer";
  66597. export * from "babylonjs/Misc/sceneSerializer";
  66598. export * from "babylonjs/Misc/smartArray";
  66599. export * from "babylonjs/Misc/stringDictionary";
  66600. export * from "babylonjs/Misc/tags";
  66601. export * from "babylonjs/Misc/textureTools";
  66602. export * from "babylonjs/Misc/tga";
  66603. export * from "babylonjs/Misc/tools";
  66604. export * from "babylonjs/Misc/videoRecorder";
  66605. export * from "babylonjs/Misc/virtualJoystick";
  66606. export * from "babylonjs/Misc/workerPool";
  66607. export * from "babylonjs/Misc/logger";
  66608. export * from "babylonjs/Misc/typeStore";
  66609. export * from "babylonjs/Misc/filesInputStore";
  66610. export * from "babylonjs/Misc/deepCopier";
  66611. export * from "babylonjs/Misc/pivotTools";
  66612. export * from "babylonjs/Misc/precisionDate";
  66613. export * from "babylonjs/Misc/screenshotTools";
  66614. export * from "babylonjs/Misc/typeStore";
  66615. export * from "babylonjs/Misc/webRequest";
  66616. export * from "babylonjs/Misc/iInspectable";
  66617. export * from "babylonjs/Misc/brdfTextureTools";
  66618. export * from "babylonjs/Misc/rgbdTextureTools";
  66619. export * from "babylonjs/Misc/gradients";
  66620. export * from "babylonjs/Misc/perfCounter";
  66621. export * from "babylonjs/Misc/fileRequest";
  66622. export * from "babylonjs/Misc/customAnimationFrameRequester";
  66623. export * from "babylonjs/Misc/retryStrategy";
  66624. export * from "babylonjs/Misc/loadFileError";
  66625. export * from "babylonjs/Misc/interfaces/screenshotSize";
  66626. }
  66627. declare module "babylonjs/index" {
  66628. export * from "babylonjs/abstractScene";
  66629. export * from "babylonjs/Actions/index";
  66630. export * from "babylonjs/Animations/index";
  66631. export * from "babylonjs/assetContainer";
  66632. export * from "babylonjs/Audio/index";
  66633. export * from "babylonjs/Behaviors/index";
  66634. export * from "babylonjs/Bones/index";
  66635. export * from "babylonjs/Cameras/index";
  66636. export * from "babylonjs/Collisions/index";
  66637. export * from "babylonjs/Culling/index";
  66638. export * from "babylonjs/Debug/index";
  66639. export * from "babylonjs/Engines/index";
  66640. export * from "babylonjs/Events/index";
  66641. export * from "babylonjs/Gamepads/index";
  66642. export * from "babylonjs/Gizmos/index";
  66643. export * from "babylonjs/Helpers/index";
  66644. export * from "babylonjs/Instrumentation/index";
  66645. export * from "babylonjs/Layers/index";
  66646. export * from "babylonjs/LensFlares/index";
  66647. export * from "babylonjs/Lights/index";
  66648. export * from "babylonjs/Loading/index";
  66649. export * from "babylonjs/Materials/index";
  66650. export * from "babylonjs/Maths/index";
  66651. export * from "babylonjs/Meshes/index";
  66652. export * from "babylonjs/Morph/index";
  66653. export * from "babylonjs/Navigation/index";
  66654. export * from "babylonjs/node";
  66655. export * from "babylonjs/Offline/index";
  66656. export * from "babylonjs/Particles/index";
  66657. export * from "babylonjs/Physics/index";
  66658. export * from "babylonjs/PostProcesses/index";
  66659. export * from "babylonjs/Probes/index";
  66660. export * from "babylonjs/Rendering/index";
  66661. export * from "babylonjs/scene";
  66662. export * from "babylonjs/sceneComponent";
  66663. export * from "babylonjs/Sprites/index";
  66664. export * from "babylonjs/States/index";
  66665. export * from "babylonjs/Misc/index";
  66666. export * from "babylonjs/types";
  66667. }
  66668. declare module "babylonjs/Animations/pathCursor" {
  66669. import { Vector3 } from "babylonjs/Maths/math.vector";
  66670. import { Path2 } from "babylonjs/Maths/math.path";
  66671. /**
  66672. * A cursor which tracks a point on a path
  66673. */
  66674. export class PathCursor {
  66675. private path;
  66676. /**
  66677. * Stores path cursor callbacks for when an onchange event is triggered
  66678. */
  66679. private _onchange;
  66680. /**
  66681. * The value of the path cursor
  66682. */
  66683. value: number;
  66684. /**
  66685. * The animation array of the path cursor
  66686. */
  66687. animations: Animation[];
  66688. /**
  66689. * Initializes the path cursor
  66690. * @param path The path to track
  66691. */
  66692. constructor(path: Path2);
  66693. /**
  66694. * Gets the cursor point on the path
  66695. * @returns A point on the path cursor at the cursor location
  66696. */
  66697. getPoint(): Vector3;
  66698. /**
  66699. * Moves the cursor ahead by the step amount
  66700. * @param step The amount to move the cursor forward
  66701. * @returns This path cursor
  66702. */
  66703. moveAhead(step?: number): PathCursor;
  66704. /**
  66705. * Moves the cursor behind by the step amount
  66706. * @param step The amount to move the cursor back
  66707. * @returns This path cursor
  66708. */
  66709. moveBack(step?: number): PathCursor;
  66710. /**
  66711. * Moves the cursor by the step amount
  66712. * If the step amount is greater than one, an exception is thrown
  66713. * @param step The amount to move the cursor
  66714. * @returns This path cursor
  66715. */
  66716. move(step: number): PathCursor;
  66717. /**
  66718. * Ensures that the value is limited between zero and one
  66719. * @returns This path cursor
  66720. */
  66721. private ensureLimits;
  66722. /**
  66723. * Runs onchange callbacks on change (used by the animation engine)
  66724. * @returns This path cursor
  66725. */
  66726. private raiseOnChange;
  66727. /**
  66728. * Executes a function on change
  66729. * @param f A path cursor onchange callback
  66730. * @returns This path cursor
  66731. */
  66732. onchange(f: (cursor: PathCursor) => void): PathCursor;
  66733. }
  66734. }
  66735. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  66736. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  66737. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  66738. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  66739. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  66740. }
  66741. declare module "babylonjs/Engines/Processors/Expressions/index" {
  66742. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  66743. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  66744. }
  66745. declare module "babylonjs/Engines/Processors/index" {
  66746. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  66747. export * from "babylonjs/Engines/Processors/Expressions/index";
  66748. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  66749. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  66750. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  66751. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  66752. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  66753. export * from "babylonjs/Engines/Processors/shaderProcessor";
  66754. }
  66755. declare module "babylonjs/Legacy/legacy" {
  66756. import * as Babylon from "babylonjs/index";
  66757. export * from "babylonjs/index";
  66758. }
  66759. declare module "babylonjs/Shaders/blur.fragment" {
  66760. /** @hidden */
  66761. export var blurPixelShader: {
  66762. name: string;
  66763. shader: string;
  66764. };
  66765. }
  66766. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  66767. /** @hidden */
  66768. export var pointCloudVertexDeclaration: {
  66769. name: string;
  66770. shader: string;
  66771. };
  66772. }
  66773. declare module "babylonjs" {
  66774. export * from "babylonjs/Legacy/legacy";
  66775. }
  66776. declare module BABYLON {
  66777. /** Alias type for value that can be null */
  66778. export type Nullable<T> = T | null;
  66779. /**
  66780. * Alias type for number that are floats
  66781. * @ignorenaming
  66782. */
  66783. export type float = number;
  66784. /**
  66785. * Alias type for number that are doubles.
  66786. * @ignorenaming
  66787. */
  66788. export type double = number;
  66789. /**
  66790. * Alias type for number that are integer
  66791. * @ignorenaming
  66792. */
  66793. export type int = number;
  66794. /** Alias type for number array or Float32Array */
  66795. export type FloatArray = number[] | Float32Array;
  66796. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  66797. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  66798. /**
  66799. * Alias for types that can be used by a Buffer or VertexBuffer.
  66800. */
  66801. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  66802. /**
  66803. * Alias type for primitive types
  66804. * @ignorenaming
  66805. */
  66806. type Primitive = undefined | null | boolean | string | number | Function;
  66807. /**
  66808. * Type modifier to make all the properties of an object Readonly
  66809. */
  66810. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  66811. /**
  66812. * Type modifier to make all the properties of an object Readonly recursively
  66813. */
  66814. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  66815. /**
  66816. * Type modifier to make object properties readonly.
  66817. */
  66818. export type DeepImmutableObject<T> = {
  66819. readonly [K in keyof T]: DeepImmutable<T[K]>;
  66820. };
  66821. /** @hidden */
  66822. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  66823. }
  66824. }
  66825. declare module BABYLON {
  66826. /**
  66827. * A class serves as a medium between the observable and its observers
  66828. */
  66829. export class EventState {
  66830. /**
  66831. * Create a new EventState
  66832. * @param mask defines the mask associated with this state
  66833. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66834. * @param target defines the original target of the state
  66835. * @param currentTarget defines the current target of the state
  66836. */
  66837. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  66838. /**
  66839. * Initialize the current event state
  66840. * @param mask defines the mask associated with this state
  66841. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  66842. * @param target defines the original target of the state
  66843. * @param currentTarget defines the current target of the state
  66844. * @returns the current event state
  66845. */
  66846. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  66847. /**
  66848. * An Observer can set this property to true to prevent subsequent observers of being notified
  66849. */
  66850. skipNextObservers: boolean;
  66851. /**
  66852. * Get the mask value that were used to trigger the event corresponding to this EventState object
  66853. */
  66854. mask: number;
  66855. /**
  66856. * The object that originally notified the event
  66857. */
  66858. target?: any;
  66859. /**
  66860. * The current object in the bubbling phase
  66861. */
  66862. currentTarget?: any;
  66863. /**
  66864. * This will be populated with the return value of the last function that was executed.
  66865. * If it is the first function in the callback chain it will be the event data.
  66866. */
  66867. lastReturnValue?: any;
  66868. }
  66869. /**
  66870. * Represent an Observer registered to a given Observable object.
  66871. */
  66872. export class Observer<T> {
  66873. /**
  66874. * Defines the callback to call when the observer is notified
  66875. */
  66876. callback: (eventData: T, eventState: EventState) => void;
  66877. /**
  66878. * Defines the mask of the observer (used to filter notifications)
  66879. */
  66880. mask: number;
  66881. /**
  66882. * Defines the current scope used to restore the JS context
  66883. */
  66884. scope: any;
  66885. /** @hidden */
  66886. _willBeUnregistered: boolean;
  66887. /**
  66888. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  66889. */
  66890. unregisterOnNextCall: boolean;
  66891. /**
  66892. * Creates a new observer
  66893. * @param callback defines the callback to call when the observer is notified
  66894. * @param mask defines the mask of the observer (used to filter notifications)
  66895. * @param scope defines the current scope used to restore the JS context
  66896. */
  66897. constructor(
  66898. /**
  66899. * Defines the callback to call when the observer is notified
  66900. */
  66901. callback: (eventData: T, eventState: EventState) => void,
  66902. /**
  66903. * Defines the mask of the observer (used to filter notifications)
  66904. */
  66905. mask: number,
  66906. /**
  66907. * Defines the current scope used to restore the JS context
  66908. */
  66909. scope?: any);
  66910. }
  66911. /**
  66912. * Represent a list of observers registered to multiple Observables object.
  66913. */
  66914. export class MultiObserver<T> {
  66915. private _observers;
  66916. private _observables;
  66917. /**
  66918. * Release associated resources
  66919. */
  66920. dispose(): void;
  66921. /**
  66922. * Raise a callback when one of the observable will notify
  66923. * @param observables defines a list of observables to watch
  66924. * @param callback defines the callback to call on notification
  66925. * @param mask defines the mask used to filter notifications
  66926. * @param scope defines the current scope used to restore the JS context
  66927. * @returns the new MultiObserver
  66928. */
  66929. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  66930. }
  66931. /**
  66932. * The Observable class is a simple implementation of the Observable pattern.
  66933. *
  66934. * 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.
  66935. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  66936. * 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).
  66937. * 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.
  66938. */
  66939. export class Observable<T> {
  66940. private _observers;
  66941. private _eventState;
  66942. private _onObserverAdded;
  66943. /**
  66944. * Gets the list of observers
  66945. */
  66946. readonly observers: Array<Observer<T>>;
  66947. /**
  66948. * Creates a new observable
  66949. * @param onObserverAdded defines a callback to call when a new observer is added
  66950. */
  66951. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  66952. /**
  66953. * Create a new Observer with the specified callback
  66954. * @param callback the callback that will be executed for that Observer
  66955. * @param mask the mask used to filter observers
  66956. * @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.
  66957. * @param scope optional scope for the callback to be called from
  66958. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  66959. * @returns the new observer created for the callback
  66960. */
  66961. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  66962. /**
  66963. * Create a new Observer with the specified callback and unregisters after the next notification
  66964. * @param callback the callback that will be executed for that Observer
  66965. * @returns the new observer created for the callback
  66966. */
  66967. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  66968. /**
  66969. * Remove an Observer from the Observable object
  66970. * @param observer the instance of the Observer to remove
  66971. * @returns false if it doesn't belong to this Observable
  66972. */
  66973. remove(observer: Nullable<Observer<T>>): boolean;
  66974. /**
  66975. * Remove a callback from the Observable object
  66976. * @param callback the callback to remove
  66977. * @param scope optional scope. If used only the callbacks with this scope will be removed
  66978. * @returns false if it doesn't belong to this Observable
  66979. */
  66980. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  66981. private _deferUnregister;
  66982. private _remove;
  66983. /**
  66984. * Moves the observable to the top of the observer list making it get called first when notified
  66985. * @param observer the observer to move
  66986. */
  66987. makeObserverTopPriority(observer: Observer<T>): void;
  66988. /**
  66989. * Moves the observable to the bottom of the observer list making it get called last when notified
  66990. * @param observer the observer to move
  66991. */
  66992. makeObserverBottomPriority(observer: Observer<T>): void;
  66993. /**
  66994. * Notify all Observers by calling their respective callback with the given data
  66995. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  66996. * @param eventData defines the data to send to all observers
  66997. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  66998. * @param target defines the original target of the state
  66999. * @param currentTarget defines the current target of the state
  67000. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  67001. */
  67002. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  67003. /**
  67004. * Calling this will execute each callback, expecting it to be a promise or return a value.
  67005. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  67006. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  67007. * and it is crucial that all callbacks will be executed.
  67008. * The order of the callbacks is kept, callbacks are not executed parallel.
  67009. *
  67010. * @param eventData The data to be sent to each callback
  67011. * @param mask is used to filter observers defaults to -1
  67012. * @param target defines the callback target (see EventState)
  67013. * @param currentTarget defines he current object in the bubbling phase
  67014. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  67015. */
  67016. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  67017. /**
  67018. * Notify a specific observer
  67019. * @param observer defines the observer to notify
  67020. * @param eventData defines the data to be sent to each callback
  67021. * @param mask is used to filter observers defaults to -1
  67022. */
  67023. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  67024. /**
  67025. * Gets a boolean indicating if the observable has at least one observer
  67026. * @returns true is the Observable has at least one Observer registered
  67027. */
  67028. hasObservers(): boolean;
  67029. /**
  67030. * Clear the list of observers
  67031. */
  67032. clear(): void;
  67033. /**
  67034. * Clone the current observable
  67035. * @returns a new observable
  67036. */
  67037. clone(): Observable<T>;
  67038. /**
  67039. * Does this observable handles observer registered with a given mask
  67040. * @param mask defines the mask to be tested
  67041. * @return whether or not one observer registered with the given mask is handeled
  67042. **/
  67043. hasSpecificMask(mask?: number): boolean;
  67044. }
  67045. }
  67046. declare module BABYLON {
  67047. /**
  67048. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  67049. * Babylon.js
  67050. */
  67051. export class DomManagement {
  67052. /**
  67053. * Checks if the window object exists
  67054. * @returns true if the window object exists
  67055. */
  67056. static IsWindowObjectExist(): boolean;
  67057. /**
  67058. * Checks if the navigator object exists
  67059. * @returns true if the navigator object exists
  67060. */
  67061. static IsNavigatorAvailable(): boolean;
  67062. /**
  67063. * Extracts text content from a DOM element hierarchy
  67064. * @param element defines the root element
  67065. * @returns a string
  67066. */
  67067. static GetDOMTextContent(element: HTMLElement): string;
  67068. }
  67069. }
  67070. declare module BABYLON {
  67071. /**
  67072. * Logger used througouht the application to allow configuration of
  67073. * the log level required for the messages.
  67074. */
  67075. export class Logger {
  67076. /**
  67077. * No log
  67078. */
  67079. static readonly NoneLogLevel: number;
  67080. /**
  67081. * Only message logs
  67082. */
  67083. static readonly MessageLogLevel: number;
  67084. /**
  67085. * Only warning logs
  67086. */
  67087. static readonly WarningLogLevel: number;
  67088. /**
  67089. * Only error logs
  67090. */
  67091. static readonly ErrorLogLevel: number;
  67092. /**
  67093. * All logs
  67094. */
  67095. static readonly AllLogLevel: number;
  67096. private static _LogCache;
  67097. /**
  67098. * Gets a value indicating the number of loading errors
  67099. * @ignorenaming
  67100. */
  67101. static errorsCount: number;
  67102. /**
  67103. * Callback called when a new log is added
  67104. */
  67105. static OnNewCacheEntry: (entry: string) => void;
  67106. private static _AddLogEntry;
  67107. private static _FormatMessage;
  67108. private static _LogDisabled;
  67109. private static _LogEnabled;
  67110. private static _WarnDisabled;
  67111. private static _WarnEnabled;
  67112. private static _ErrorDisabled;
  67113. private static _ErrorEnabled;
  67114. /**
  67115. * Log a message to the console
  67116. */
  67117. static Log: (message: string) => void;
  67118. /**
  67119. * Write a warning message to the console
  67120. */
  67121. static Warn: (message: string) => void;
  67122. /**
  67123. * Write an error message to the console
  67124. */
  67125. static Error: (message: string) => void;
  67126. /**
  67127. * Gets current log cache (list of logs)
  67128. */
  67129. static readonly LogCache: string;
  67130. /**
  67131. * Clears the log cache
  67132. */
  67133. static ClearLogCache(): void;
  67134. /**
  67135. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  67136. */
  67137. static LogLevels: number;
  67138. }
  67139. }
  67140. declare module BABYLON {
  67141. /** @hidden */
  67142. export class _TypeStore {
  67143. /** @hidden */
  67144. static RegisteredTypes: {
  67145. [key: string]: Object;
  67146. };
  67147. /** @hidden */
  67148. static GetClass(fqdn: string): any;
  67149. }
  67150. }
  67151. declare module BABYLON {
  67152. /**
  67153. * Class containing a set of static utilities functions for deep copy.
  67154. */
  67155. export class DeepCopier {
  67156. /**
  67157. * Tries to copy an object by duplicating every property
  67158. * @param source defines the source object
  67159. * @param destination defines the target object
  67160. * @param doNotCopyList defines a list of properties to avoid
  67161. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  67162. */
  67163. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  67164. }
  67165. }
  67166. declare module BABYLON {
  67167. /**
  67168. * Class containing a set of static utilities functions for precision date
  67169. */
  67170. export class PrecisionDate {
  67171. /**
  67172. * Gets either window.performance.now() if supported or Date.now() else
  67173. */
  67174. static readonly Now: number;
  67175. }
  67176. }
  67177. declare module BABYLON {
  67178. /** @hidden */
  67179. export class _DevTools {
  67180. static WarnImport(name: string): string;
  67181. }
  67182. }
  67183. declare module BABYLON {
  67184. /**
  67185. * Interface used to define the mechanism to get data from the network
  67186. */
  67187. export interface IWebRequest {
  67188. /**
  67189. * Returns client's response url
  67190. */
  67191. responseURL: string;
  67192. /**
  67193. * Returns client's status
  67194. */
  67195. status: number;
  67196. /**
  67197. * Returns client's status as a text
  67198. */
  67199. statusText: string;
  67200. }
  67201. }
  67202. declare module BABYLON {
  67203. /**
  67204. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  67205. */
  67206. export class WebRequest implements IWebRequest {
  67207. private _xhr;
  67208. /**
  67209. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  67210. * i.e. when loading files, where the server/service expects an Authorization header
  67211. */
  67212. static CustomRequestHeaders: {
  67213. [key: string]: string;
  67214. };
  67215. /**
  67216. * Add callback functions in this array to update all the requests before they get sent to the network
  67217. */
  67218. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  67219. private _injectCustomRequestHeaders;
  67220. /**
  67221. * Gets or sets a function to be called when loading progress changes
  67222. */
  67223. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  67224. /**
  67225. * Returns client's state
  67226. */
  67227. readonly readyState: number;
  67228. /**
  67229. * Returns client's status
  67230. */
  67231. readonly status: number;
  67232. /**
  67233. * Returns client's status as a text
  67234. */
  67235. readonly statusText: string;
  67236. /**
  67237. * Returns client's response
  67238. */
  67239. readonly response: any;
  67240. /**
  67241. * Returns client's response url
  67242. */
  67243. readonly responseURL: string;
  67244. /**
  67245. * Returns client's response as text
  67246. */
  67247. readonly responseText: string;
  67248. /**
  67249. * Gets or sets the expected response type
  67250. */
  67251. responseType: XMLHttpRequestResponseType;
  67252. /** @hidden */
  67253. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  67254. /** @hidden */
  67255. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  67256. /**
  67257. * Cancels any network activity
  67258. */
  67259. abort(): void;
  67260. /**
  67261. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  67262. * @param body defines an optional request body
  67263. */
  67264. send(body?: Document | BodyInit | null): void;
  67265. /**
  67266. * Sets the request method, request URL
  67267. * @param method defines the method to use (GET, POST, etc..)
  67268. * @param url defines the url to connect with
  67269. */
  67270. open(method: string, url: string): void;
  67271. }
  67272. }
  67273. declare module BABYLON {
  67274. /**
  67275. * File request interface
  67276. */
  67277. export interface IFileRequest {
  67278. /**
  67279. * Raised when the request is complete (success or error).
  67280. */
  67281. onCompleteObservable: Observable<IFileRequest>;
  67282. /**
  67283. * Aborts the request for a file.
  67284. */
  67285. abort: () => void;
  67286. }
  67287. }
  67288. declare module BABYLON {
  67289. /**
  67290. * Scalar computation library
  67291. */
  67292. export class Scalar {
  67293. /**
  67294. * Two pi constants convenient for computation.
  67295. */
  67296. static TwoPi: number;
  67297. /**
  67298. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67299. * @param a number
  67300. * @param b number
  67301. * @param epsilon (default = 1.401298E-45)
  67302. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67303. */
  67304. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  67305. /**
  67306. * Returns a string : the upper case translation of the number i to hexadecimal.
  67307. * @param i number
  67308. * @returns the upper case translation of the number i to hexadecimal.
  67309. */
  67310. static ToHex(i: number): string;
  67311. /**
  67312. * Returns -1 if value is negative and +1 is value is positive.
  67313. * @param value the value
  67314. * @returns the value itself if it's equal to zero.
  67315. */
  67316. static Sign(value: number): number;
  67317. /**
  67318. * Returns the value itself if it's between min and max.
  67319. * Returns min if the value is lower than min.
  67320. * Returns max if the value is greater than max.
  67321. * @param value the value to clmap
  67322. * @param min the min value to clamp to (default: 0)
  67323. * @param max the max value to clamp to (default: 1)
  67324. * @returns the clamped value
  67325. */
  67326. static Clamp(value: number, min?: number, max?: number): number;
  67327. /**
  67328. * the log2 of value.
  67329. * @param value the value to compute log2 of
  67330. * @returns the log2 of value.
  67331. */
  67332. static Log2(value: number): number;
  67333. /**
  67334. * Loops the value, so that it is never larger than length and never smaller than 0.
  67335. *
  67336. * This is similar to the modulo operator but it works with floating point numbers.
  67337. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67338. * With t = 5 and length = 2.5, the result would be 0.0.
  67339. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  67340. * @param value the value
  67341. * @param length the length
  67342. * @returns the looped value
  67343. */
  67344. static Repeat(value: number, length: number): number;
  67345. /**
  67346. * Normalize the value between 0.0 and 1.0 using min and max values
  67347. * @param value value to normalize
  67348. * @param min max to normalize between
  67349. * @param max min to normalize between
  67350. * @returns the normalized value
  67351. */
  67352. static Normalize(value: number, min: number, max: number): number;
  67353. /**
  67354. * Denormalize the value from 0.0 and 1.0 using min and max values
  67355. * @param normalized value to denormalize
  67356. * @param min max to denormalize between
  67357. * @param max min to denormalize between
  67358. * @returns the denormalized value
  67359. */
  67360. static Denormalize(normalized: number, min: number, max: number): number;
  67361. /**
  67362. * Calculates the shortest difference between two given angles given in degrees.
  67363. * @param current current angle in degrees
  67364. * @param target target angle in degrees
  67365. * @returns the delta
  67366. */
  67367. static DeltaAngle(current: number, target: number): number;
  67368. /**
  67369. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  67370. * @param tx value
  67371. * @param length length
  67372. * @returns The returned value will move back and forth between 0 and length
  67373. */
  67374. static PingPong(tx: number, length: number): number;
  67375. /**
  67376. * Interpolates between min and max with smoothing at the limits.
  67377. *
  67378. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  67379. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  67380. * @param from from
  67381. * @param to to
  67382. * @param tx value
  67383. * @returns the smooth stepped value
  67384. */
  67385. static SmoothStep(from: number, to: number, tx: number): number;
  67386. /**
  67387. * Moves a value current towards target.
  67388. *
  67389. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  67390. * Negative values of maxDelta pushes the value away from target.
  67391. * @param current current value
  67392. * @param target target value
  67393. * @param maxDelta max distance to move
  67394. * @returns resulting value
  67395. */
  67396. static MoveTowards(current: number, target: number, maxDelta: number): number;
  67397. /**
  67398. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67399. *
  67400. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  67401. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  67402. * @param current current value
  67403. * @param target target value
  67404. * @param maxDelta max distance to move
  67405. * @returns resulting angle
  67406. */
  67407. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  67408. /**
  67409. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  67410. * @param start start value
  67411. * @param end target value
  67412. * @param amount amount to lerp between
  67413. * @returns the lerped value
  67414. */
  67415. static Lerp(start: number, end: number, amount: number): number;
  67416. /**
  67417. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  67418. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  67419. * @param start start value
  67420. * @param end target value
  67421. * @param amount amount to lerp between
  67422. * @returns the lerped value
  67423. */
  67424. static LerpAngle(start: number, end: number, amount: number): number;
  67425. /**
  67426. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  67427. * @param a start value
  67428. * @param b target value
  67429. * @param value value between a and b
  67430. * @returns the inverseLerp value
  67431. */
  67432. static InverseLerp(a: number, b: number, value: number): number;
  67433. /**
  67434. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  67435. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  67436. * @param value1 spline value
  67437. * @param tangent1 spline value
  67438. * @param value2 spline value
  67439. * @param tangent2 spline value
  67440. * @param amount input value
  67441. * @returns hermite result
  67442. */
  67443. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  67444. /**
  67445. * Returns a random float number between and min and max values
  67446. * @param min min value of random
  67447. * @param max max value of random
  67448. * @returns random value
  67449. */
  67450. static RandomRange(min: number, max: number): number;
  67451. /**
  67452. * This function returns percentage of a number in a given range.
  67453. *
  67454. * RangeToPercent(40,20,60) will return 0.5 (50%)
  67455. * RangeToPercent(34,0,100) will return 0.34 (34%)
  67456. * @param number to convert to percentage
  67457. * @param min min range
  67458. * @param max max range
  67459. * @returns the percentage
  67460. */
  67461. static RangeToPercent(number: number, min: number, max: number): number;
  67462. /**
  67463. * This function returns number that corresponds to the percentage in a given range.
  67464. *
  67465. * PercentToRange(0.34,0,100) will return 34.
  67466. * @param percent to convert to number
  67467. * @param min min range
  67468. * @param max max range
  67469. * @returns the number
  67470. */
  67471. static PercentToRange(percent: number, min: number, max: number): number;
  67472. /**
  67473. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  67474. * @param angle The angle to normalize in radian.
  67475. * @return The converted angle.
  67476. */
  67477. static NormalizeRadians(angle: number): number;
  67478. }
  67479. }
  67480. declare module BABYLON {
  67481. /**
  67482. * Constant used to convert a value to gamma space
  67483. * @ignorenaming
  67484. */
  67485. export const ToGammaSpace: number;
  67486. /**
  67487. * Constant used to convert a value to linear space
  67488. * @ignorenaming
  67489. */
  67490. export const ToLinearSpace = 2.2;
  67491. /**
  67492. * Constant used to define the minimal number value in Babylon.js
  67493. * @ignorenaming
  67494. */
  67495. let Epsilon: number;
  67496. }
  67497. declare module BABYLON {
  67498. /**
  67499. * Class used to represent a viewport on screen
  67500. */
  67501. export class Viewport {
  67502. /** viewport left coordinate */
  67503. x: number;
  67504. /** viewport top coordinate */
  67505. y: number;
  67506. /**viewport width */
  67507. width: number;
  67508. /** viewport height */
  67509. height: number;
  67510. /**
  67511. * Creates a Viewport object located at (x, y) and sized (width, height)
  67512. * @param x defines viewport left coordinate
  67513. * @param y defines viewport top coordinate
  67514. * @param width defines the viewport width
  67515. * @param height defines the viewport height
  67516. */
  67517. constructor(
  67518. /** viewport left coordinate */
  67519. x: number,
  67520. /** viewport top coordinate */
  67521. y: number,
  67522. /**viewport width */
  67523. width: number,
  67524. /** viewport height */
  67525. height: number);
  67526. /**
  67527. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  67528. * @param renderWidth defines the rendering width
  67529. * @param renderHeight defines the rendering height
  67530. * @returns a new Viewport
  67531. */
  67532. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  67533. /**
  67534. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  67535. * @param renderWidth defines the rendering width
  67536. * @param renderHeight defines the rendering height
  67537. * @param ref defines the target viewport
  67538. * @returns the current viewport
  67539. */
  67540. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  67541. /**
  67542. * Returns a new Viewport copied from the current one
  67543. * @returns a new Viewport
  67544. */
  67545. clone(): Viewport;
  67546. }
  67547. }
  67548. declare module BABYLON {
  67549. /**
  67550. * Class containing a set of static utilities functions for arrays.
  67551. */
  67552. export class ArrayTools {
  67553. /**
  67554. * Returns an array of the given size filled with element built from the given constructor and the paramters
  67555. * @param size the number of element to construct and put in the array
  67556. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  67557. * @returns a new array filled with new objects
  67558. */
  67559. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  67560. }
  67561. }
  67562. declare module BABYLON {
  67563. /**
  67564. * @hidden
  67565. */
  67566. export interface IColor4Like {
  67567. r: float;
  67568. g: float;
  67569. b: float;
  67570. a: float;
  67571. }
  67572. /**
  67573. * @hidden
  67574. */
  67575. export interface IColor3Like {
  67576. r: float;
  67577. g: float;
  67578. b: float;
  67579. }
  67580. /**
  67581. * @hidden
  67582. */
  67583. export interface IVector4Like {
  67584. x: float;
  67585. y: float;
  67586. z: float;
  67587. w: float;
  67588. }
  67589. /**
  67590. * @hidden
  67591. */
  67592. export interface IVector3Like {
  67593. x: float;
  67594. y: float;
  67595. z: float;
  67596. }
  67597. /**
  67598. * @hidden
  67599. */
  67600. export interface IVector2Like {
  67601. x: float;
  67602. y: float;
  67603. }
  67604. /**
  67605. * @hidden
  67606. */
  67607. export interface IMatrixLike {
  67608. toArray(): DeepImmutable<Float32Array>;
  67609. updateFlag: int;
  67610. }
  67611. /**
  67612. * @hidden
  67613. */
  67614. export interface IViewportLike {
  67615. x: float;
  67616. y: float;
  67617. width: float;
  67618. height: float;
  67619. }
  67620. /**
  67621. * @hidden
  67622. */
  67623. export interface IPlaneLike {
  67624. normal: IVector3Like;
  67625. d: float;
  67626. normalize(): void;
  67627. }
  67628. }
  67629. declare module BABYLON {
  67630. /**
  67631. * Class representing a vector containing 2 coordinates
  67632. */
  67633. export class Vector2 {
  67634. /** defines the first coordinate */
  67635. x: number;
  67636. /** defines the second coordinate */
  67637. y: number;
  67638. /**
  67639. * Creates a new Vector2 from the given x and y coordinates
  67640. * @param x defines the first coordinate
  67641. * @param y defines the second coordinate
  67642. */
  67643. constructor(
  67644. /** defines the first coordinate */
  67645. x?: number,
  67646. /** defines the second coordinate */
  67647. y?: number);
  67648. /**
  67649. * Gets a string with the Vector2 coordinates
  67650. * @returns a string with the Vector2 coordinates
  67651. */
  67652. toString(): string;
  67653. /**
  67654. * Gets class name
  67655. * @returns the string "Vector2"
  67656. */
  67657. getClassName(): string;
  67658. /**
  67659. * Gets current vector hash code
  67660. * @returns the Vector2 hash code as a number
  67661. */
  67662. getHashCode(): number;
  67663. /**
  67664. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  67665. * @param array defines the source array
  67666. * @param index defines the offset in source array
  67667. * @returns the current Vector2
  67668. */
  67669. toArray(array: FloatArray, index?: number): Vector2;
  67670. /**
  67671. * Copy the current vector to an array
  67672. * @returns a new array with 2 elements: the Vector2 coordinates.
  67673. */
  67674. asArray(): number[];
  67675. /**
  67676. * Sets the Vector2 coordinates with the given Vector2 coordinates
  67677. * @param source defines the source Vector2
  67678. * @returns the current updated Vector2
  67679. */
  67680. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  67681. /**
  67682. * Sets the Vector2 coordinates with the given floats
  67683. * @param x defines the first coordinate
  67684. * @param y defines the second coordinate
  67685. * @returns the current updated Vector2
  67686. */
  67687. copyFromFloats(x: number, y: number): Vector2;
  67688. /**
  67689. * Sets the Vector2 coordinates with the given floats
  67690. * @param x defines the first coordinate
  67691. * @param y defines the second coordinate
  67692. * @returns the current updated Vector2
  67693. */
  67694. set(x: number, y: number): Vector2;
  67695. /**
  67696. * Add another vector with the current one
  67697. * @param otherVector defines the other vector
  67698. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  67699. */
  67700. add(otherVector: DeepImmutable<Vector2>): Vector2;
  67701. /**
  67702. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  67703. * @param otherVector defines the other vector
  67704. * @param result defines the target vector
  67705. * @returns the unmodified current Vector2
  67706. */
  67707. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67708. /**
  67709. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  67710. * @param otherVector defines the other vector
  67711. * @returns the current updated Vector2
  67712. */
  67713. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67714. /**
  67715. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  67716. * @param otherVector defines the other vector
  67717. * @returns a new Vector2
  67718. */
  67719. addVector3(otherVector: Vector3): Vector2;
  67720. /**
  67721. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  67722. * @param otherVector defines the other vector
  67723. * @returns a new Vector2
  67724. */
  67725. subtract(otherVector: Vector2): Vector2;
  67726. /**
  67727. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  67728. * @param otherVector defines the other vector
  67729. * @param result defines the target vector
  67730. * @returns the unmodified current Vector2
  67731. */
  67732. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67733. /**
  67734. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  67735. * @param otherVector defines the other vector
  67736. * @returns the current updated Vector2
  67737. */
  67738. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67739. /**
  67740. * Multiplies in place the current Vector2 coordinates by the given ones
  67741. * @param otherVector defines the other vector
  67742. * @returns the current updated Vector2
  67743. */
  67744. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67745. /**
  67746. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  67747. * @param otherVector defines the other vector
  67748. * @returns a new Vector2
  67749. */
  67750. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  67751. /**
  67752. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  67753. * @param otherVector defines the other vector
  67754. * @param result defines the target vector
  67755. * @returns the unmodified current Vector2
  67756. */
  67757. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67758. /**
  67759. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  67760. * @param x defines the first coordinate
  67761. * @param y defines the second coordinate
  67762. * @returns a new Vector2
  67763. */
  67764. multiplyByFloats(x: number, y: number): Vector2;
  67765. /**
  67766. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  67767. * @param otherVector defines the other vector
  67768. * @returns a new Vector2
  67769. */
  67770. divide(otherVector: Vector2): Vector2;
  67771. /**
  67772. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  67773. * @param otherVector defines the other vector
  67774. * @param result defines the target vector
  67775. * @returns the unmodified current Vector2
  67776. */
  67777. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  67778. /**
  67779. * Divides the current Vector2 coordinates by the given ones
  67780. * @param otherVector defines the other vector
  67781. * @returns the current updated Vector2
  67782. */
  67783. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  67784. /**
  67785. * Gets a new Vector2 with current Vector2 negated coordinates
  67786. * @returns a new Vector2
  67787. */
  67788. negate(): Vector2;
  67789. /**
  67790. * Multiply the Vector2 coordinates by scale
  67791. * @param scale defines the scaling factor
  67792. * @returns the current updated Vector2
  67793. */
  67794. scaleInPlace(scale: number): Vector2;
  67795. /**
  67796. * Returns a new Vector2 scaled by "scale" from the current Vector2
  67797. * @param scale defines the scaling factor
  67798. * @returns a new Vector2
  67799. */
  67800. scale(scale: number): Vector2;
  67801. /**
  67802. * Scale the current Vector2 values by a factor to a given Vector2
  67803. * @param scale defines the scale factor
  67804. * @param result defines the Vector2 object where to store the result
  67805. * @returns the unmodified current Vector2
  67806. */
  67807. scaleToRef(scale: number, result: Vector2): Vector2;
  67808. /**
  67809. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  67810. * @param scale defines the scale factor
  67811. * @param result defines the Vector2 object where to store the result
  67812. * @returns the unmodified current Vector2
  67813. */
  67814. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  67815. /**
  67816. * Gets a boolean if two vectors are equals
  67817. * @param otherVector defines the other vector
  67818. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  67819. */
  67820. equals(otherVector: DeepImmutable<Vector2>): boolean;
  67821. /**
  67822. * Gets a boolean if two vectors are equals (using an epsilon value)
  67823. * @param otherVector defines the other vector
  67824. * @param epsilon defines the minimal distance to consider equality
  67825. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  67826. */
  67827. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  67828. /**
  67829. * Gets a new Vector2 from current Vector2 floored values
  67830. * @returns a new Vector2
  67831. */
  67832. floor(): Vector2;
  67833. /**
  67834. * Gets a new Vector2 from current Vector2 floored values
  67835. * @returns a new Vector2
  67836. */
  67837. fract(): Vector2;
  67838. /**
  67839. * Gets the length of the vector
  67840. * @returns the vector length (float)
  67841. */
  67842. length(): number;
  67843. /**
  67844. * Gets the vector squared length
  67845. * @returns the vector squared length (float)
  67846. */
  67847. lengthSquared(): number;
  67848. /**
  67849. * Normalize the vector
  67850. * @returns the current updated Vector2
  67851. */
  67852. normalize(): Vector2;
  67853. /**
  67854. * Gets a new Vector2 copied from the Vector2
  67855. * @returns a new Vector2
  67856. */
  67857. clone(): Vector2;
  67858. /**
  67859. * Gets a new Vector2(0, 0)
  67860. * @returns a new Vector2
  67861. */
  67862. static Zero(): Vector2;
  67863. /**
  67864. * Gets a new Vector2(1, 1)
  67865. * @returns a new Vector2
  67866. */
  67867. static One(): Vector2;
  67868. /**
  67869. * Gets a new Vector2 set from the given index element of the given array
  67870. * @param array defines the data source
  67871. * @param offset defines the offset in the data source
  67872. * @returns a new Vector2
  67873. */
  67874. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  67875. /**
  67876. * Sets "result" from the given index element of the given array
  67877. * @param array defines the data source
  67878. * @param offset defines the offset in the data source
  67879. * @param result defines the target vector
  67880. */
  67881. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  67882. /**
  67883. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  67884. * @param value1 defines 1st point of control
  67885. * @param value2 defines 2nd point of control
  67886. * @param value3 defines 3rd point of control
  67887. * @param value4 defines 4th point of control
  67888. * @param amount defines the interpolation factor
  67889. * @returns a new Vector2
  67890. */
  67891. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  67892. /**
  67893. * 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".
  67894. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  67895. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  67896. * @param value defines the value to clamp
  67897. * @param min defines the lower limit
  67898. * @param max defines the upper limit
  67899. * @returns a new Vector2
  67900. */
  67901. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  67902. /**
  67903. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  67904. * @param value1 defines the 1st control point
  67905. * @param tangent1 defines the outgoing tangent
  67906. * @param value2 defines the 2nd control point
  67907. * @param tangent2 defines the incoming tangent
  67908. * @param amount defines the interpolation factor
  67909. * @returns a new Vector2
  67910. */
  67911. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  67912. /**
  67913. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  67914. * @param start defines the start vector
  67915. * @param end defines the end vector
  67916. * @param amount defines the interpolation factor
  67917. * @returns a new Vector2
  67918. */
  67919. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  67920. /**
  67921. * Gets the dot product of the vector "left" and the vector "right"
  67922. * @param left defines first vector
  67923. * @param right defines second vector
  67924. * @returns the dot product (float)
  67925. */
  67926. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  67927. /**
  67928. * Returns a new Vector2 equal to the normalized given vector
  67929. * @param vector defines the vector to normalize
  67930. * @returns a new Vector2
  67931. */
  67932. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  67933. /**
  67934. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  67935. * @param left defines 1st vector
  67936. * @param right defines 2nd vector
  67937. * @returns a new Vector2
  67938. */
  67939. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67940. /**
  67941. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  67942. * @param left defines 1st vector
  67943. * @param right defines 2nd vector
  67944. * @returns a new Vector2
  67945. */
  67946. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  67947. /**
  67948. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  67949. * @param vector defines the vector to transform
  67950. * @param transformation defines the matrix to apply
  67951. * @returns a new Vector2
  67952. */
  67953. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  67954. /**
  67955. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  67956. * @param vector defines the vector to transform
  67957. * @param transformation defines the matrix to apply
  67958. * @param result defines the target vector
  67959. */
  67960. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  67961. /**
  67962. * Determines if a given vector is included in a triangle
  67963. * @param p defines the vector to test
  67964. * @param p0 defines 1st triangle point
  67965. * @param p1 defines 2nd triangle point
  67966. * @param p2 defines 3rd triangle point
  67967. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  67968. */
  67969. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  67970. /**
  67971. * Gets the distance between the vectors "value1" and "value2"
  67972. * @param value1 defines first vector
  67973. * @param value2 defines second vector
  67974. * @returns the distance between vectors
  67975. */
  67976. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67977. /**
  67978. * Returns the squared distance between the vectors "value1" and "value2"
  67979. * @param value1 defines first vector
  67980. * @param value2 defines second vector
  67981. * @returns the squared distance between vectors
  67982. */
  67983. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  67984. /**
  67985. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  67986. * @param value1 defines first vector
  67987. * @param value2 defines second vector
  67988. * @returns a new Vector2
  67989. */
  67990. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  67991. /**
  67992. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  67993. * @param p defines the middle point
  67994. * @param segA defines one point of the segment
  67995. * @param segB defines the other point of the segment
  67996. * @returns the shortest distance
  67997. */
  67998. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  67999. }
  68000. /**
  68001. * Classed used to store (x,y,z) vector representation
  68002. * A Vector3 is the main object used in 3D geometry
  68003. * It can represent etiher the coordinates of a point the space, either a direction
  68004. * Reminder: js uses a left handed forward facing system
  68005. */
  68006. export class Vector3 {
  68007. /**
  68008. * Defines the first coordinates (on X axis)
  68009. */
  68010. x: number;
  68011. /**
  68012. * Defines the second coordinates (on Y axis)
  68013. */
  68014. y: number;
  68015. /**
  68016. * Defines the third coordinates (on Z axis)
  68017. */
  68018. z: number;
  68019. private static _UpReadOnly;
  68020. private static _ZeroReadOnly;
  68021. /**
  68022. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  68023. * @param x defines the first coordinates (on X axis)
  68024. * @param y defines the second coordinates (on Y axis)
  68025. * @param z defines the third coordinates (on Z axis)
  68026. */
  68027. constructor(
  68028. /**
  68029. * Defines the first coordinates (on X axis)
  68030. */
  68031. x?: number,
  68032. /**
  68033. * Defines the second coordinates (on Y axis)
  68034. */
  68035. y?: number,
  68036. /**
  68037. * Defines the third coordinates (on Z axis)
  68038. */
  68039. z?: number);
  68040. /**
  68041. * Creates a string representation of the Vector3
  68042. * @returns a string with the Vector3 coordinates.
  68043. */
  68044. toString(): string;
  68045. /**
  68046. * Gets the class name
  68047. * @returns the string "Vector3"
  68048. */
  68049. getClassName(): string;
  68050. /**
  68051. * Creates the Vector3 hash code
  68052. * @returns a number which tends to be unique between Vector3 instances
  68053. */
  68054. getHashCode(): number;
  68055. /**
  68056. * Creates an array containing three elements : the coordinates of the Vector3
  68057. * @returns a new array of numbers
  68058. */
  68059. asArray(): number[];
  68060. /**
  68061. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  68062. * @param array defines the destination array
  68063. * @param index defines the offset in the destination array
  68064. * @returns the current Vector3
  68065. */
  68066. toArray(array: FloatArray, index?: number): Vector3;
  68067. /**
  68068. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  68069. * @returns a new Quaternion object, computed from the Vector3 coordinates
  68070. */
  68071. toQuaternion(): Quaternion;
  68072. /**
  68073. * Adds the given vector to the current Vector3
  68074. * @param otherVector defines the second operand
  68075. * @returns the current updated Vector3
  68076. */
  68077. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68078. /**
  68079. * Adds the given coordinates to the current Vector3
  68080. * @param x defines the x coordinate of the operand
  68081. * @param y defines the y coordinate of the operand
  68082. * @param z defines the z coordinate of the operand
  68083. * @returns the current updated Vector3
  68084. */
  68085. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68086. /**
  68087. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  68088. * @param otherVector defines the second operand
  68089. * @returns the resulting Vector3
  68090. */
  68091. add(otherVector: DeepImmutable<Vector3>): Vector3;
  68092. /**
  68093. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  68094. * @param otherVector defines the second operand
  68095. * @param result defines the Vector3 object where to store the result
  68096. * @returns the current Vector3
  68097. */
  68098. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68099. /**
  68100. * Subtract the given vector from the current Vector3
  68101. * @param otherVector defines the second operand
  68102. * @returns the current updated Vector3
  68103. */
  68104. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68105. /**
  68106. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  68107. * @param otherVector defines the second operand
  68108. * @returns the resulting Vector3
  68109. */
  68110. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  68111. /**
  68112. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  68113. * @param otherVector defines the second operand
  68114. * @param result defines the Vector3 object where to store the result
  68115. * @returns the current Vector3
  68116. */
  68117. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68118. /**
  68119. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  68120. * @param x defines the x coordinate of the operand
  68121. * @param y defines the y coordinate of the operand
  68122. * @param z defines the z coordinate of the operand
  68123. * @returns the resulting Vector3
  68124. */
  68125. subtractFromFloats(x: number, y: number, z: number): Vector3;
  68126. /**
  68127. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  68128. * @param x defines the x coordinate of the operand
  68129. * @param y defines the y coordinate of the operand
  68130. * @param z defines the z coordinate of the operand
  68131. * @param result defines the Vector3 object where to store the result
  68132. * @returns the current Vector3
  68133. */
  68134. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  68135. /**
  68136. * Gets a new Vector3 set with the current Vector3 negated coordinates
  68137. * @returns a new Vector3
  68138. */
  68139. negate(): Vector3;
  68140. /**
  68141. * Multiplies the Vector3 coordinates by the float "scale"
  68142. * @param scale defines the multiplier factor
  68143. * @returns the current updated Vector3
  68144. */
  68145. scaleInPlace(scale: number): Vector3;
  68146. /**
  68147. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  68148. * @param scale defines the multiplier factor
  68149. * @returns a new Vector3
  68150. */
  68151. scale(scale: number): Vector3;
  68152. /**
  68153. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  68154. * @param scale defines the multiplier factor
  68155. * @param result defines the Vector3 object where to store the result
  68156. * @returns the current Vector3
  68157. */
  68158. scaleToRef(scale: number, result: Vector3): Vector3;
  68159. /**
  68160. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  68161. * @param scale defines the scale factor
  68162. * @param result defines the Vector3 object where to store the result
  68163. * @returns the unmodified current Vector3
  68164. */
  68165. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  68166. /**
  68167. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  68168. * @param otherVector defines the second operand
  68169. * @returns true if both vectors are equals
  68170. */
  68171. equals(otherVector: DeepImmutable<Vector3>): boolean;
  68172. /**
  68173. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  68174. * @param otherVector defines the second operand
  68175. * @param epsilon defines the minimal distance to define values as equals
  68176. * @returns true if both vectors are distant less than epsilon
  68177. */
  68178. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  68179. /**
  68180. * Returns true if the current Vector3 coordinates equals the given floats
  68181. * @param x defines the x coordinate of the operand
  68182. * @param y defines the y coordinate of the operand
  68183. * @param z defines the z coordinate of the operand
  68184. * @returns true if both vectors are equals
  68185. */
  68186. equalsToFloats(x: number, y: number, z: number): boolean;
  68187. /**
  68188. * Multiplies the current Vector3 coordinates by the given ones
  68189. * @param otherVector defines the second operand
  68190. * @returns the current updated Vector3
  68191. */
  68192. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  68193. /**
  68194. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  68195. * @param otherVector defines the second operand
  68196. * @returns the new Vector3
  68197. */
  68198. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  68199. /**
  68200. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  68201. * @param otherVector defines the second operand
  68202. * @param result defines the Vector3 object where to store the result
  68203. * @returns the current Vector3
  68204. */
  68205. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68206. /**
  68207. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  68208. * @param x defines the x coordinate of the operand
  68209. * @param y defines the y coordinate of the operand
  68210. * @param z defines the z coordinate of the operand
  68211. * @returns the new Vector3
  68212. */
  68213. multiplyByFloats(x: number, y: number, z: number): Vector3;
  68214. /**
  68215. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  68216. * @param otherVector defines the second operand
  68217. * @returns the new Vector3
  68218. */
  68219. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  68220. /**
  68221. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  68222. * @param otherVector defines the second operand
  68223. * @param result defines the Vector3 object where to store the result
  68224. * @returns the current Vector3
  68225. */
  68226. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  68227. /**
  68228. * Divides the current Vector3 coordinates by the given ones.
  68229. * @param otherVector defines the second operand
  68230. * @returns the current updated Vector3
  68231. */
  68232. divideInPlace(otherVector: Vector3): Vector3;
  68233. /**
  68234. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  68235. * @param other defines the second operand
  68236. * @returns the current updated Vector3
  68237. */
  68238. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68239. /**
  68240. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  68241. * @param other defines the second operand
  68242. * @returns the current updated Vector3
  68243. */
  68244. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  68245. /**
  68246. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  68247. * @param x defines the x coordinate of the operand
  68248. * @param y defines the y coordinate of the operand
  68249. * @param z defines the z coordinate of the operand
  68250. * @returns the current updated Vector3
  68251. */
  68252. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68253. /**
  68254. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  68255. * @param x defines the x coordinate of the operand
  68256. * @param y defines the y coordinate of the operand
  68257. * @param z defines the z coordinate of the operand
  68258. * @returns the current updated Vector3
  68259. */
  68260. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  68261. /**
  68262. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  68263. * Check if is non uniform within a certain amount of decimal places to account for this
  68264. * @param epsilon the amount the values can differ
  68265. * @returns if the the vector is non uniform to a certain number of decimal places
  68266. */
  68267. isNonUniformWithinEpsilon(epsilon: number): boolean;
  68268. /**
  68269. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  68270. */
  68271. readonly isNonUniform: boolean;
  68272. /**
  68273. * Gets a new Vector3 from current Vector3 floored values
  68274. * @returns a new Vector3
  68275. */
  68276. floor(): Vector3;
  68277. /**
  68278. * Gets a new Vector3 from current Vector3 floored values
  68279. * @returns a new Vector3
  68280. */
  68281. fract(): Vector3;
  68282. /**
  68283. * Gets the length of the Vector3
  68284. * @returns the length of the Vector3
  68285. */
  68286. length(): number;
  68287. /**
  68288. * Gets the squared length of the Vector3
  68289. * @returns squared length of the Vector3
  68290. */
  68291. lengthSquared(): number;
  68292. /**
  68293. * Normalize the current Vector3.
  68294. * Please note that this is an in place operation.
  68295. * @returns the current updated Vector3
  68296. */
  68297. normalize(): Vector3;
  68298. /**
  68299. * Reorders the x y z properties of the vector in place
  68300. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  68301. * @returns the current updated vector
  68302. */
  68303. reorderInPlace(order: string): this;
  68304. /**
  68305. * Rotates the vector around 0,0,0 by a quaternion
  68306. * @param quaternion the rotation quaternion
  68307. * @param result vector to store the result
  68308. * @returns the resulting vector
  68309. */
  68310. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  68311. /**
  68312. * Rotates a vector around a given point
  68313. * @param quaternion the rotation quaternion
  68314. * @param point the point to rotate around
  68315. * @param result vector to store the result
  68316. * @returns the resulting vector
  68317. */
  68318. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  68319. /**
  68320. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  68321. * The cross product is then orthogonal to both current and "other"
  68322. * @param other defines the right operand
  68323. * @returns the cross product
  68324. */
  68325. cross(other: Vector3): Vector3;
  68326. /**
  68327. * Normalize the current Vector3 with the given input length.
  68328. * Please note that this is an in place operation.
  68329. * @param len the length of the vector
  68330. * @returns the current updated Vector3
  68331. */
  68332. normalizeFromLength(len: number): Vector3;
  68333. /**
  68334. * Normalize the current Vector3 to a new vector
  68335. * @returns the new Vector3
  68336. */
  68337. normalizeToNew(): Vector3;
  68338. /**
  68339. * Normalize the current Vector3 to the reference
  68340. * @param reference define the Vector3 to update
  68341. * @returns the updated Vector3
  68342. */
  68343. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  68344. /**
  68345. * Creates a new Vector3 copied from the current Vector3
  68346. * @returns the new Vector3
  68347. */
  68348. clone(): Vector3;
  68349. /**
  68350. * Copies the given vector coordinates to the current Vector3 ones
  68351. * @param source defines the source Vector3
  68352. * @returns the current updated Vector3
  68353. */
  68354. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  68355. /**
  68356. * Copies the given floats to the current Vector3 coordinates
  68357. * @param x defines the x coordinate of the operand
  68358. * @param y defines the y coordinate of the operand
  68359. * @param z defines the z coordinate of the operand
  68360. * @returns the current updated Vector3
  68361. */
  68362. copyFromFloats(x: number, y: number, z: number): Vector3;
  68363. /**
  68364. * Copies the given floats to the current Vector3 coordinates
  68365. * @param x defines the x coordinate of the operand
  68366. * @param y defines the y coordinate of the operand
  68367. * @param z defines the z coordinate of the operand
  68368. * @returns the current updated Vector3
  68369. */
  68370. set(x: number, y: number, z: number): Vector3;
  68371. /**
  68372. * Copies the given float to the current Vector3 coordinates
  68373. * @param v defines the x, y and z coordinates of the operand
  68374. * @returns the current updated Vector3
  68375. */
  68376. setAll(v: number): Vector3;
  68377. /**
  68378. * Get the clip factor between two vectors
  68379. * @param vector0 defines the first operand
  68380. * @param vector1 defines the second operand
  68381. * @param axis defines the axis to use
  68382. * @param size defines the size along the axis
  68383. * @returns the clip factor
  68384. */
  68385. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  68386. /**
  68387. * Get angle between two vectors
  68388. * @param vector0 angle between vector0 and vector1
  68389. * @param vector1 angle between vector0 and vector1
  68390. * @param normal direction of the normal
  68391. * @return the angle between vector0 and vector1
  68392. */
  68393. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  68394. /**
  68395. * Returns a new Vector3 set from the index "offset" of the given array
  68396. * @param array defines the source array
  68397. * @param offset defines the offset in the source array
  68398. * @returns the new Vector3
  68399. */
  68400. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  68401. /**
  68402. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  68403. * This function is deprecated. Use FromArray instead
  68404. * @param array defines the source array
  68405. * @param offset defines the offset in the source array
  68406. * @returns the new Vector3
  68407. */
  68408. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  68409. /**
  68410. * Sets the given vector "result" with the element values from the index "offset" of the given array
  68411. * @param array defines the source array
  68412. * @param offset defines the offset in the source array
  68413. * @param result defines the Vector3 where to store the result
  68414. */
  68415. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  68416. /**
  68417. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  68418. * This function is deprecated. Use FromArrayToRef instead.
  68419. * @param array defines the source array
  68420. * @param offset defines the offset in the source array
  68421. * @param result defines the Vector3 where to store the result
  68422. */
  68423. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  68424. /**
  68425. * Sets the given vector "result" with the given floats.
  68426. * @param x defines the x coordinate of the source
  68427. * @param y defines the y coordinate of the source
  68428. * @param z defines the z coordinate of the source
  68429. * @param result defines the Vector3 where to store the result
  68430. */
  68431. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  68432. /**
  68433. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  68434. * @returns a new empty Vector3
  68435. */
  68436. static Zero(): Vector3;
  68437. /**
  68438. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  68439. * @returns a new unit Vector3
  68440. */
  68441. static One(): Vector3;
  68442. /**
  68443. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  68444. * @returns a new up Vector3
  68445. */
  68446. static Up(): Vector3;
  68447. /**
  68448. * Gets a up Vector3 that must not be updated
  68449. */
  68450. static readonly UpReadOnly: DeepImmutable<Vector3>;
  68451. /**
  68452. * Gets a zero Vector3 that must not be updated
  68453. */
  68454. static readonly ZeroReadOnly: DeepImmutable<Vector3>;
  68455. /**
  68456. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  68457. * @returns a new down Vector3
  68458. */
  68459. static Down(): Vector3;
  68460. /**
  68461. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  68462. * @returns a new forward Vector3
  68463. */
  68464. static Forward(): Vector3;
  68465. /**
  68466. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  68467. * @returns a new forward Vector3
  68468. */
  68469. static Backward(): Vector3;
  68470. /**
  68471. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  68472. * @returns a new right Vector3
  68473. */
  68474. static Right(): Vector3;
  68475. /**
  68476. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  68477. * @returns a new left Vector3
  68478. */
  68479. static Left(): Vector3;
  68480. /**
  68481. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  68482. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68483. * @param vector defines the Vector3 to transform
  68484. * @param transformation defines the transformation matrix
  68485. * @returns the transformed Vector3
  68486. */
  68487. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68488. /**
  68489. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  68490. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  68491. * @param vector defines the Vector3 to transform
  68492. * @param transformation defines the transformation matrix
  68493. * @param result defines the Vector3 where to store the result
  68494. */
  68495. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68496. /**
  68497. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  68498. * This method computes tranformed coordinates only, not transformed direction vectors
  68499. * @param x define the x coordinate of the source vector
  68500. * @param y define the y coordinate of the source vector
  68501. * @param z define the z coordinate of the source vector
  68502. * @param transformation defines the transformation matrix
  68503. * @param result defines the Vector3 where to store the result
  68504. */
  68505. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68506. /**
  68507. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  68508. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68509. * @param vector defines the Vector3 to transform
  68510. * @param transformation defines the transformation matrix
  68511. * @returns the new Vector3
  68512. */
  68513. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  68514. /**
  68515. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  68516. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68517. * @param vector defines the Vector3 to transform
  68518. * @param transformation defines the transformation matrix
  68519. * @param result defines the Vector3 where to store the result
  68520. */
  68521. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68522. /**
  68523. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  68524. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  68525. * @param x define the x coordinate of the source vector
  68526. * @param y define the y coordinate of the source vector
  68527. * @param z define the z coordinate of the source vector
  68528. * @param transformation defines the transformation matrix
  68529. * @param result defines the Vector3 where to store the result
  68530. */
  68531. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  68532. /**
  68533. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  68534. * @param value1 defines the first control point
  68535. * @param value2 defines the second control point
  68536. * @param value3 defines the third control point
  68537. * @param value4 defines the fourth control point
  68538. * @param amount defines the amount on the spline to use
  68539. * @returns the new Vector3
  68540. */
  68541. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  68542. /**
  68543. * 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"
  68544. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68545. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68546. * @param value defines the current value
  68547. * @param min defines the lower range value
  68548. * @param max defines the upper range value
  68549. * @returns the new Vector3
  68550. */
  68551. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  68552. /**
  68553. * 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"
  68554. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  68555. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  68556. * @param value defines the current value
  68557. * @param min defines the lower range value
  68558. * @param max defines the upper range value
  68559. * @param result defines the Vector3 where to store the result
  68560. */
  68561. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  68562. /**
  68563. * Checks if a given vector is inside a specific range
  68564. * @param v defines the vector to test
  68565. * @param min defines the minimum range
  68566. * @param max defines the maximum range
  68567. */
  68568. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  68569. /**
  68570. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  68571. * @param value1 defines the first control point
  68572. * @param tangent1 defines the first tangent vector
  68573. * @param value2 defines the second control point
  68574. * @param tangent2 defines the second tangent vector
  68575. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  68576. * @returns the new Vector3
  68577. */
  68578. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  68579. /**
  68580. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  68581. * @param start defines the start value
  68582. * @param end defines the end value
  68583. * @param amount max defines amount between both (between 0 and 1)
  68584. * @returns the new Vector3
  68585. */
  68586. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  68587. /**
  68588. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  68589. * @param start defines the start value
  68590. * @param end defines the end value
  68591. * @param amount max defines amount between both (between 0 and 1)
  68592. * @param result defines the Vector3 where to store the result
  68593. */
  68594. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  68595. /**
  68596. * Returns the dot product (float) between the vectors "left" and "right"
  68597. * @param left defines the left operand
  68598. * @param right defines the right operand
  68599. * @returns the dot product
  68600. */
  68601. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  68602. /**
  68603. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  68604. * The cross product is then orthogonal to both "left" and "right"
  68605. * @param left defines the left operand
  68606. * @param right defines the right operand
  68607. * @returns the cross product
  68608. */
  68609. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68610. /**
  68611. * Sets the given vector "result" with the cross product of "left" and "right"
  68612. * The cross product is then orthogonal to both "left" and "right"
  68613. * @param left defines the left operand
  68614. * @param right defines the right operand
  68615. * @param result defines the Vector3 where to store the result
  68616. */
  68617. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  68618. /**
  68619. * Returns a new Vector3 as the normalization of the given vector
  68620. * @param vector defines the Vector3 to normalize
  68621. * @returns the new Vector3
  68622. */
  68623. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  68624. /**
  68625. * Sets the given vector "result" with the normalization of the given first vector
  68626. * @param vector defines the Vector3 to normalize
  68627. * @param result defines the Vector3 where to store the result
  68628. */
  68629. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  68630. /**
  68631. * Project a Vector3 onto screen space
  68632. * @param vector defines the Vector3 to project
  68633. * @param world defines the world matrix to use
  68634. * @param transform defines the transform (view x projection) matrix to use
  68635. * @param viewport defines the screen viewport to use
  68636. * @returns the new Vector3
  68637. */
  68638. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  68639. /** @hidden */
  68640. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  68641. /**
  68642. * Unproject from screen space to object space
  68643. * @param source defines the screen space Vector3 to use
  68644. * @param viewportWidth defines the current width of the viewport
  68645. * @param viewportHeight defines the current height of the viewport
  68646. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68647. * @param transform defines the transform (view x projection) matrix to use
  68648. * @returns the new Vector3
  68649. */
  68650. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  68651. /**
  68652. * Unproject from screen space to object space
  68653. * @param source defines the screen space Vector3 to use
  68654. * @param viewportWidth defines the current width of the viewport
  68655. * @param viewportHeight defines the current height of the viewport
  68656. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68657. * @param view defines the view matrix to use
  68658. * @param projection defines the projection matrix to use
  68659. * @returns the new Vector3
  68660. */
  68661. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  68662. /**
  68663. * Unproject from screen space to object space
  68664. * @param source defines the screen space Vector3 to use
  68665. * @param viewportWidth defines the current width of the viewport
  68666. * @param viewportHeight defines the current height of the viewport
  68667. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68668. * @param view defines the view matrix to use
  68669. * @param projection defines the projection matrix to use
  68670. * @param result defines the Vector3 where to store the result
  68671. */
  68672. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68673. /**
  68674. * Unproject from screen space to object space
  68675. * @param sourceX defines the screen space x coordinate to use
  68676. * @param sourceY defines the screen space y coordinate to use
  68677. * @param sourceZ defines the screen space z coordinate to use
  68678. * @param viewportWidth defines the current width of the viewport
  68679. * @param viewportHeight defines the current height of the viewport
  68680. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  68681. * @param view defines the view matrix to use
  68682. * @param projection defines the projection matrix to use
  68683. * @param result defines the Vector3 where to store the result
  68684. */
  68685. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  68686. /**
  68687. * Gets the minimal coordinate values between two Vector3
  68688. * @param left defines the first operand
  68689. * @param right defines the second operand
  68690. * @returns the new Vector3
  68691. */
  68692. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68693. /**
  68694. * Gets the maximal coordinate values between two Vector3
  68695. * @param left defines the first operand
  68696. * @param right defines the second operand
  68697. * @returns the new Vector3
  68698. */
  68699. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  68700. /**
  68701. * Returns the distance between the vectors "value1" and "value2"
  68702. * @param value1 defines the first operand
  68703. * @param value2 defines the second operand
  68704. * @returns the distance
  68705. */
  68706. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68707. /**
  68708. * Returns the squared distance between the vectors "value1" and "value2"
  68709. * @param value1 defines the first operand
  68710. * @param value2 defines the second operand
  68711. * @returns the squared distance
  68712. */
  68713. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  68714. /**
  68715. * Returns a new Vector3 located at the center between "value1" and "value2"
  68716. * @param value1 defines the first operand
  68717. * @param value2 defines the second operand
  68718. * @returns the new Vector3
  68719. */
  68720. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  68721. /**
  68722. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  68723. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  68724. * to something in order to rotate it from its local system to the given target system
  68725. * Note: axis1, axis2 and axis3 are normalized during this operation
  68726. * @param axis1 defines the first axis
  68727. * @param axis2 defines the second axis
  68728. * @param axis3 defines the third axis
  68729. * @returns a new Vector3
  68730. */
  68731. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  68732. /**
  68733. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  68734. * @param axis1 defines the first axis
  68735. * @param axis2 defines the second axis
  68736. * @param axis3 defines the third axis
  68737. * @param ref defines the Vector3 where to store the result
  68738. */
  68739. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  68740. }
  68741. /**
  68742. * Vector4 class created for EulerAngle class conversion to Quaternion
  68743. */
  68744. export class Vector4 {
  68745. /** x value of the vector */
  68746. x: number;
  68747. /** y value of the vector */
  68748. y: number;
  68749. /** z value of the vector */
  68750. z: number;
  68751. /** w value of the vector */
  68752. w: number;
  68753. /**
  68754. * Creates a Vector4 object from the given floats.
  68755. * @param x x value of the vector
  68756. * @param y y value of the vector
  68757. * @param z z value of the vector
  68758. * @param w w value of the vector
  68759. */
  68760. constructor(
  68761. /** x value of the vector */
  68762. x: number,
  68763. /** y value of the vector */
  68764. y: number,
  68765. /** z value of the vector */
  68766. z: number,
  68767. /** w value of the vector */
  68768. w: number);
  68769. /**
  68770. * Returns the string with the Vector4 coordinates.
  68771. * @returns a string containing all the vector values
  68772. */
  68773. toString(): string;
  68774. /**
  68775. * Returns the string "Vector4".
  68776. * @returns "Vector4"
  68777. */
  68778. getClassName(): string;
  68779. /**
  68780. * Returns the Vector4 hash code.
  68781. * @returns a unique hash code
  68782. */
  68783. getHashCode(): number;
  68784. /**
  68785. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  68786. * @returns the resulting array
  68787. */
  68788. asArray(): number[];
  68789. /**
  68790. * Populates the given array from the given index with the Vector4 coordinates.
  68791. * @param array array to populate
  68792. * @param index index of the array to start at (default: 0)
  68793. * @returns the Vector4.
  68794. */
  68795. toArray(array: FloatArray, index?: number): Vector4;
  68796. /**
  68797. * Adds the given vector to the current Vector4.
  68798. * @param otherVector the vector to add
  68799. * @returns the updated Vector4.
  68800. */
  68801. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68802. /**
  68803. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  68804. * @param otherVector the vector to add
  68805. * @returns the resulting vector
  68806. */
  68807. add(otherVector: DeepImmutable<Vector4>): Vector4;
  68808. /**
  68809. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  68810. * @param otherVector the vector to add
  68811. * @param result the vector to store the result
  68812. * @returns the current Vector4.
  68813. */
  68814. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68815. /**
  68816. * Subtract in place the given vector from the current Vector4.
  68817. * @param otherVector the vector to subtract
  68818. * @returns the updated Vector4.
  68819. */
  68820. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68821. /**
  68822. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  68823. * @param otherVector the vector to add
  68824. * @returns the new vector with the result
  68825. */
  68826. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  68827. /**
  68828. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  68829. * @param otherVector the vector to subtract
  68830. * @param result the vector to store the result
  68831. * @returns the current Vector4.
  68832. */
  68833. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68834. /**
  68835. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68836. */
  68837. /**
  68838. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68839. * @param x value to subtract
  68840. * @param y value to subtract
  68841. * @param z value to subtract
  68842. * @param w value to subtract
  68843. * @returns new vector containing the result
  68844. */
  68845. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  68846. /**
  68847. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  68848. * @param x value to subtract
  68849. * @param y value to subtract
  68850. * @param z value to subtract
  68851. * @param w value to subtract
  68852. * @param result the vector to store the result in
  68853. * @returns the current Vector4.
  68854. */
  68855. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  68856. /**
  68857. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  68858. * @returns a new vector with the negated values
  68859. */
  68860. negate(): Vector4;
  68861. /**
  68862. * Multiplies the current Vector4 coordinates by scale (float).
  68863. * @param scale the number to scale with
  68864. * @returns the updated Vector4.
  68865. */
  68866. scaleInPlace(scale: number): Vector4;
  68867. /**
  68868. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  68869. * @param scale the number to scale with
  68870. * @returns a new vector with the result
  68871. */
  68872. scale(scale: number): Vector4;
  68873. /**
  68874. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  68875. * @param scale the number to scale with
  68876. * @param result a vector to store the result in
  68877. * @returns the current Vector4.
  68878. */
  68879. scaleToRef(scale: number, result: Vector4): Vector4;
  68880. /**
  68881. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  68882. * @param scale defines the scale factor
  68883. * @param result defines the Vector4 object where to store the result
  68884. * @returns the unmodified current Vector4
  68885. */
  68886. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  68887. /**
  68888. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  68889. * @param otherVector the vector to compare against
  68890. * @returns true if they are equal
  68891. */
  68892. equals(otherVector: DeepImmutable<Vector4>): boolean;
  68893. /**
  68894. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  68895. * @param otherVector vector to compare against
  68896. * @param epsilon (Default: very small number)
  68897. * @returns true if they are equal
  68898. */
  68899. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  68900. /**
  68901. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  68902. * @param x x value to compare against
  68903. * @param y y value to compare against
  68904. * @param z z value to compare against
  68905. * @param w w value to compare against
  68906. * @returns true if equal
  68907. */
  68908. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  68909. /**
  68910. * Multiplies in place the current Vector4 by the given one.
  68911. * @param otherVector vector to multiple with
  68912. * @returns the updated Vector4.
  68913. */
  68914. multiplyInPlace(otherVector: Vector4): Vector4;
  68915. /**
  68916. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  68917. * @param otherVector vector to multiple with
  68918. * @returns resulting new vector
  68919. */
  68920. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  68921. /**
  68922. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  68923. * @param otherVector vector to multiple with
  68924. * @param result vector to store the result
  68925. * @returns the current Vector4.
  68926. */
  68927. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68928. /**
  68929. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  68930. * @param x x value multiply with
  68931. * @param y y value multiply with
  68932. * @param z z value multiply with
  68933. * @param w w value multiply with
  68934. * @returns resulting new vector
  68935. */
  68936. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  68937. /**
  68938. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  68939. * @param otherVector vector to devide with
  68940. * @returns resulting new vector
  68941. */
  68942. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  68943. /**
  68944. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  68945. * @param otherVector vector to devide with
  68946. * @param result vector to store the result
  68947. * @returns the current Vector4.
  68948. */
  68949. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  68950. /**
  68951. * Divides the current Vector3 coordinates by the given ones.
  68952. * @param otherVector vector to devide with
  68953. * @returns the updated Vector3.
  68954. */
  68955. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  68956. /**
  68957. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  68958. * @param other defines the second operand
  68959. * @returns the current updated Vector4
  68960. */
  68961. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68962. /**
  68963. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  68964. * @param other defines the second operand
  68965. * @returns the current updated Vector4
  68966. */
  68967. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  68968. /**
  68969. * Gets a new Vector4 from current Vector4 floored values
  68970. * @returns a new Vector4
  68971. */
  68972. floor(): Vector4;
  68973. /**
  68974. * Gets a new Vector4 from current Vector3 floored values
  68975. * @returns a new Vector4
  68976. */
  68977. fract(): Vector4;
  68978. /**
  68979. * Returns the Vector4 length (float).
  68980. * @returns the length
  68981. */
  68982. length(): number;
  68983. /**
  68984. * Returns the Vector4 squared length (float).
  68985. * @returns the length squared
  68986. */
  68987. lengthSquared(): number;
  68988. /**
  68989. * Normalizes in place the Vector4.
  68990. * @returns the updated Vector4.
  68991. */
  68992. normalize(): Vector4;
  68993. /**
  68994. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  68995. * @returns this converted to a new vector3
  68996. */
  68997. toVector3(): Vector3;
  68998. /**
  68999. * Returns a new Vector4 copied from the current one.
  69000. * @returns the new cloned vector
  69001. */
  69002. clone(): Vector4;
  69003. /**
  69004. * Updates the current Vector4 with the given one coordinates.
  69005. * @param source the source vector to copy from
  69006. * @returns the updated Vector4.
  69007. */
  69008. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  69009. /**
  69010. * Updates the current Vector4 coordinates with the given floats.
  69011. * @param x float to copy from
  69012. * @param y float to copy from
  69013. * @param z float to copy from
  69014. * @param w float to copy from
  69015. * @returns the updated Vector4.
  69016. */
  69017. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  69018. /**
  69019. * Updates the current Vector4 coordinates with the given floats.
  69020. * @param x float to set from
  69021. * @param y float to set from
  69022. * @param z float to set from
  69023. * @param w float to set from
  69024. * @returns the updated Vector4.
  69025. */
  69026. set(x: number, y: number, z: number, w: number): Vector4;
  69027. /**
  69028. * Copies the given float to the current Vector3 coordinates
  69029. * @param v defines the x, y, z and w coordinates of the operand
  69030. * @returns the current updated Vector3
  69031. */
  69032. setAll(v: number): Vector4;
  69033. /**
  69034. * Returns a new Vector4 set from the starting index of the given array.
  69035. * @param array the array to pull values from
  69036. * @param offset the offset into the array to start at
  69037. * @returns the new vector
  69038. */
  69039. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  69040. /**
  69041. * Updates the given vector "result" from the starting index of the given array.
  69042. * @param array the array to pull values from
  69043. * @param offset the offset into the array to start at
  69044. * @param result the vector to store the result in
  69045. */
  69046. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  69047. /**
  69048. * Updates the given vector "result" from the starting index of the given Float32Array.
  69049. * @param array the array to pull values from
  69050. * @param offset the offset into the array to start at
  69051. * @param result the vector to store the result in
  69052. */
  69053. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  69054. /**
  69055. * Updates the given vector "result" coordinates from the given floats.
  69056. * @param x float to set from
  69057. * @param y float to set from
  69058. * @param z float to set from
  69059. * @param w float to set from
  69060. * @param result the vector to the floats in
  69061. */
  69062. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  69063. /**
  69064. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  69065. * @returns the new vector
  69066. */
  69067. static Zero(): Vector4;
  69068. /**
  69069. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  69070. * @returns the new vector
  69071. */
  69072. static One(): Vector4;
  69073. /**
  69074. * Returns a new normalized Vector4 from the given one.
  69075. * @param vector the vector to normalize
  69076. * @returns the vector
  69077. */
  69078. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  69079. /**
  69080. * Updates the given vector "result" from the normalization of the given one.
  69081. * @param vector the vector to normalize
  69082. * @param result the vector to store the result in
  69083. */
  69084. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  69085. /**
  69086. * Returns a vector with the minimum values from the left and right vectors
  69087. * @param left left vector to minimize
  69088. * @param right right vector to minimize
  69089. * @returns a new vector with the minimum of the left and right vector values
  69090. */
  69091. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69092. /**
  69093. * Returns a vector with the maximum values from the left and right vectors
  69094. * @param left left vector to maximize
  69095. * @param right right vector to maximize
  69096. * @returns a new vector with the maximum of the left and right vector values
  69097. */
  69098. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  69099. /**
  69100. * Returns the distance (float) between the vectors "value1" and "value2".
  69101. * @param value1 value to calulate the distance between
  69102. * @param value2 value to calulate the distance between
  69103. * @return the distance between the two vectors
  69104. */
  69105. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69106. /**
  69107. * Returns the squared distance (float) between the vectors "value1" and "value2".
  69108. * @param value1 value to calulate the distance between
  69109. * @param value2 value to calulate the distance between
  69110. * @return the distance between the two vectors squared
  69111. */
  69112. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  69113. /**
  69114. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  69115. * @param value1 value to calulate the center between
  69116. * @param value2 value to calulate the center between
  69117. * @return the center between the two vectors
  69118. */
  69119. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  69120. /**
  69121. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  69122. * This methods computes transformed normalized direction vectors only.
  69123. * @param vector the vector to transform
  69124. * @param transformation the transformation matrix to apply
  69125. * @returns the new vector
  69126. */
  69127. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  69128. /**
  69129. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  69130. * This methods computes transformed normalized direction vectors only.
  69131. * @param vector the vector to transform
  69132. * @param transformation the transformation matrix to apply
  69133. * @param result the vector to store the result in
  69134. */
  69135. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69136. /**
  69137. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  69138. * This methods computes transformed normalized direction vectors only.
  69139. * @param x value to transform
  69140. * @param y value to transform
  69141. * @param z value to transform
  69142. * @param w value to transform
  69143. * @param transformation the transformation matrix to apply
  69144. * @param result the vector to store the results in
  69145. */
  69146. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  69147. /**
  69148. * Creates a new Vector4 from a Vector3
  69149. * @param source defines the source data
  69150. * @param w defines the 4th component (default is 0)
  69151. * @returns a new Vector4
  69152. */
  69153. static FromVector3(source: Vector3, w?: number): Vector4;
  69154. }
  69155. /**
  69156. * Class used to store quaternion data
  69157. * @see https://en.wikipedia.org/wiki/Quaternion
  69158. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  69159. */
  69160. export class Quaternion {
  69161. /** defines the first component (0 by default) */
  69162. x: number;
  69163. /** defines the second component (0 by default) */
  69164. y: number;
  69165. /** defines the third component (0 by default) */
  69166. z: number;
  69167. /** defines the fourth component (1.0 by default) */
  69168. w: number;
  69169. /**
  69170. * Creates a new Quaternion from the given floats
  69171. * @param x defines the first component (0 by default)
  69172. * @param y defines the second component (0 by default)
  69173. * @param z defines the third component (0 by default)
  69174. * @param w defines the fourth component (1.0 by default)
  69175. */
  69176. constructor(
  69177. /** defines the first component (0 by default) */
  69178. x?: number,
  69179. /** defines the second component (0 by default) */
  69180. y?: number,
  69181. /** defines the third component (0 by default) */
  69182. z?: number,
  69183. /** defines the fourth component (1.0 by default) */
  69184. w?: number);
  69185. /**
  69186. * Gets a string representation for the current quaternion
  69187. * @returns a string with the Quaternion coordinates
  69188. */
  69189. toString(): string;
  69190. /**
  69191. * Gets the class name of the quaternion
  69192. * @returns the string "Quaternion"
  69193. */
  69194. getClassName(): string;
  69195. /**
  69196. * Gets a hash code for this quaternion
  69197. * @returns the quaternion hash code
  69198. */
  69199. getHashCode(): number;
  69200. /**
  69201. * Copy the quaternion to an array
  69202. * @returns a new array populated with 4 elements from the quaternion coordinates
  69203. */
  69204. asArray(): number[];
  69205. /**
  69206. * Check if two quaternions are equals
  69207. * @param otherQuaternion defines the second operand
  69208. * @return true if the current quaternion and the given one coordinates are strictly equals
  69209. */
  69210. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  69211. /**
  69212. * Clone the current quaternion
  69213. * @returns a new quaternion copied from the current one
  69214. */
  69215. clone(): Quaternion;
  69216. /**
  69217. * Copy a quaternion to the current one
  69218. * @param other defines the other quaternion
  69219. * @returns the updated current quaternion
  69220. */
  69221. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  69222. /**
  69223. * Updates the current quaternion with the given float coordinates
  69224. * @param x defines the x coordinate
  69225. * @param y defines the y coordinate
  69226. * @param z defines the z coordinate
  69227. * @param w defines the w coordinate
  69228. * @returns the updated current quaternion
  69229. */
  69230. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  69231. /**
  69232. * Updates the current quaternion from the given float coordinates
  69233. * @param x defines the x coordinate
  69234. * @param y defines the y coordinate
  69235. * @param z defines the z coordinate
  69236. * @param w defines the w coordinate
  69237. * @returns the updated current quaternion
  69238. */
  69239. set(x: number, y: number, z: number, w: number): Quaternion;
  69240. /**
  69241. * Adds two quaternions
  69242. * @param other defines the second operand
  69243. * @returns a new quaternion as the addition result of the given one and the current quaternion
  69244. */
  69245. add(other: DeepImmutable<Quaternion>): Quaternion;
  69246. /**
  69247. * Add a quaternion to the current one
  69248. * @param other defines the quaternion to add
  69249. * @returns the current quaternion
  69250. */
  69251. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  69252. /**
  69253. * Subtract two quaternions
  69254. * @param other defines the second operand
  69255. * @returns a new quaternion as the subtraction result of the given one from the current one
  69256. */
  69257. subtract(other: Quaternion): Quaternion;
  69258. /**
  69259. * Multiplies the current quaternion by a scale factor
  69260. * @param value defines the scale factor
  69261. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  69262. */
  69263. scale(value: number): Quaternion;
  69264. /**
  69265. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  69266. * @param scale defines the scale factor
  69267. * @param result defines the Quaternion object where to store the result
  69268. * @returns the unmodified current quaternion
  69269. */
  69270. scaleToRef(scale: number, result: Quaternion): Quaternion;
  69271. /**
  69272. * Multiplies in place the current quaternion by a scale factor
  69273. * @param value defines the scale factor
  69274. * @returns the current modified quaternion
  69275. */
  69276. scaleInPlace(value: number): Quaternion;
  69277. /**
  69278. * Scale the current quaternion values by a factor and add the result to a given quaternion
  69279. * @param scale defines the scale factor
  69280. * @param result defines the Quaternion object where to store the result
  69281. * @returns the unmodified current quaternion
  69282. */
  69283. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  69284. /**
  69285. * Multiplies two quaternions
  69286. * @param q1 defines the second operand
  69287. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  69288. */
  69289. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  69290. /**
  69291. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  69292. * @param q1 defines the second operand
  69293. * @param result defines the target quaternion
  69294. * @returns the current quaternion
  69295. */
  69296. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  69297. /**
  69298. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  69299. * @param q1 defines the second operand
  69300. * @returns the currentupdated quaternion
  69301. */
  69302. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  69303. /**
  69304. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  69305. * @param ref defines the target quaternion
  69306. * @returns the current quaternion
  69307. */
  69308. conjugateToRef(ref: Quaternion): Quaternion;
  69309. /**
  69310. * Conjugates in place (1-q) the current quaternion
  69311. * @returns the current updated quaternion
  69312. */
  69313. conjugateInPlace(): Quaternion;
  69314. /**
  69315. * Conjugates in place (1-q) the current quaternion
  69316. * @returns a new quaternion
  69317. */
  69318. conjugate(): Quaternion;
  69319. /**
  69320. * Gets length of current quaternion
  69321. * @returns the quaternion length (float)
  69322. */
  69323. length(): number;
  69324. /**
  69325. * Normalize in place the current quaternion
  69326. * @returns the current updated quaternion
  69327. */
  69328. normalize(): Quaternion;
  69329. /**
  69330. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  69331. * @param order is a reserved parameter and is ignore for now
  69332. * @returns a new Vector3 containing the Euler angles
  69333. */
  69334. toEulerAngles(order?: string): Vector3;
  69335. /**
  69336. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  69337. * @param result defines the vector which will be filled with the Euler angles
  69338. * @param order is a reserved parameter and is ignore for now
  69339. * @returns the current unchanged quaternion
  69340. */
  69341. toEulerAnglesToRef(result: Vector3): Quaternion;
  69342. /**
  69343. * Updates the given rotation matrix with the current quaternion values
  69344. * @param result defines the target matrix
  69345. * @returns the current unchanged quaternion
  69346. */
  69347. toRotationMatrix(result: Matrix): Quaternion;
  69348. /**
  69349. * Updates the current quaternion from the given rotation matrix values
  69350. * @param matrix defines the source matrix
  69351. * @returns the current updated quaternion
  69352. */
  69353. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69354. /**
  69355. * Creates a new quaternion from a rotation matrix
  69356. * @param matrix defines the source matrix
  69357. * @returns a new quaternion created from the given rotation matrix values
  69358. */
  69359. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  69360. /**
  69361. * Updates the given quaternion with the given rotation matrix values
  69362. * @param matrix defines the source matrix
  69363. * @param result defines the target quaternion
  69364. */
  69365. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  69366. /**
  69367. * Returns the dot product (float) between the quaternions "left" and "right"
  69368. * @param left defines the left operand
  69369. * @param right defines the right operand
  69370. * @returns the dot product
  69371. */
  69372. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  69373. /**
  69374. * Checks if the two quaternions are close to each other
  69375. * @param quat0 defines the first quaternion to check
  69376. * @param quat1 defines the second quaternion to check
  69377. * @returns true if the two quaternions are close to each other
  69378. */
  69379. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  69380. /**
  69381. * Creates an empty quaternion
  69382. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  69383. */
  69384. static Zero(): Quaternion;
  69385. /**
  69386. * Inverse a given quaternion
  69387. * @param q defines the source quaternion
  69388. * @returns a new quaternion as the inverted current quaternion
  69389. */
  69390. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  69391. /**
  69392. * Inverse a given quaternion
  69393. * @param q defines the source quaternion
  69394. * @param result the quaternion the result will be stored in
  69395. * @returns the result quaternion
  69396. */
  69397. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  69398. /**
  69399. * Creates an identity quaternion
  69400. * @returns the identity quaternion
  69401. */
  69402. static Identity(): Quaternion;
  69403. /**
  69404. * Gets a boolean indicating if the given quaternion is identity
  69405. * @param quaternion defines the quaternion to check
  69406. * @returns true if the quaternion is identity
  69407. */
  69408. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  69409. /**
  69410. * Creates a quaternion from a rotation around an axis
  69411. * @param axis defines the axis to use
  69412. * @param angle defines the angle to use
  69413. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  69414. */
  69415. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  69416. /**
  69417. * Creates a rotation around an axis and stores it into the given quaternion
  69418. * @param axis defines the axis to use
  69419. * @param angle defines the angle to use
  69420. * @param result defines the target quaternion
  69421. * @returns the target quaternion
  69422. */
  69423. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  69424. /**
  69425. * Creates a new quaternion from data stored into an array
  69426. * @param array defines the data source
  69427. * @param offset defines the offset in the source array where the data starts
  69428. * @returns a new quaternion
  69429. */
  69430. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  69431. /**
  69432. * Create a quaternion from Euler rotation angles
  69433. * @param x Pitch
  69434. * @param y Yaw
  69435. * @param z Roll
  69436. * @returns the new Quaternion
  69437. */
  69438. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  69439. /**
  69440. * Updates a quaternion from Euler rotation angles
  69441. * @param x Pitch
  69442. * @param y Yaw
  69443. * @param z Roll
  69444. * @param result the quaternion to store the result
  69445. * @returns the updated quaternion
  69446. */
  69447. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  69448. /**
  69449. * Create a quaternion from Euler rotation vector
  69450. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69451. * @returns the new Quaternion
  69452. */
  69453. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  69454. /**
  69455. * Updates a quaternion from Euler rotation vector
  69456. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  69457. * @param result the quaternion to store the result
  69458. * @returns the updated quaternion
  69459. */
  69460. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  69461. /**
  69462. * Creates a new quaternion from the given Euler float angles (y, x, z)
  69463. * @param yaw defines the rotation around Y axis
  69464. * @param pitch defines the rotation around X axis
  69465. * @param roll defines the rotation around Z axis
  69466. * @returns the new quaternion
  69467. */
  69468. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  69469. /**
  69470. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  69471. * @param yaw defines the rotation around Y axis
  69472. * @param pitch defines the rotation around X axis
  69473. * @param roll defines the rotation around Z axis
  69474. * @param result defines the target quaternion
  69475. */
  69476. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  69477. /**
  69478. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  69479. * @param alpha defines the rotation around first axis
  69480. * @param beta defines the rotation around second axis
  69481. * @param gamma defines the rotation around third axis
  69482. * @returns the new quaternion
  69483. */
  69484. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  69485. /**
  69486. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  69487. * @param alpha defines the rotation around first axis
  69488. * @param beta defines the rotation around second axis
  69489. * @param gamma defines the rotation around third axis
  69490. * @param result defines the target quaternion
  69491. */
  69492. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  69493. /**
  69494. * 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)
  69495. * @param axis1 defines the first axis
  69496. * @param axis2 defines the second axis
  69497. * @param axis3 defines the third axis
  69498. * @returns the new quaternion
  69499. */
  69500. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  69501. /**
  69502. * 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
  69503. * @param axis1 defines the first axis
  69504. * @param axis2 defines the second axis
  69505. * @param axis3 defines the third axis
  69506. * @param ref defines the target quaternion
  69507. */
  69508. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  69509. /**
  69510. * Interpolates between two quaternions
  69511. * @param left defines first quaternion
  69512. * @param right defines second quaternion
  69513. * @param amount defines the gradient to use
  69514. * @returns the new interpolated quaternion
  69515. */
  69516. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69517. /**
  69518. * Interpolates between two quaternions and stores it into a target quaternion
  69519. * @param left defines first quaternion
  69520. * @param right defines second quaternion
  69521. * @param amount defines the gradient to use
  69522. * @param result defines the target quaternion
  69523. */
  69524. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  69525. /**
  69526. * Interpolate between two quaternions using Hermite interpolation
  69527. * @param value1 defines first quaternion
  69528. * @param tangent1 defines the incoming tangent
  69529. * @param value2 defines second quaternion
  69530. * @param tangent2 defines the outgoing tangent
  69531. * @param amount defines the target quaternion
  69532. * @returns the new interpolated quaternion
  69533. */
  69534. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  69535. }
  69536. /**
  69537. * Class used to store matrix data (4x4)
  69538. */
  69539. export class Matrix {
  69540. private static _updateFlagSeed;
  69541. private static _identityReadOnly;
  69542. private _isIdentity;
  69543. private _isIdentityDirty;
  69544. private _isIdentity3x2;
  69545. private _isIdentity3x2Dirty;
  69546. /**
  69547. * Gets the update flag of the matrix which is an unique number for the matrix.
  69548. * It will be incremented every time the matrix data change.
  69549. * You can use it to speed the comparison between two versions of the same matrix.
  69550. */
  69551. updateFlag: number;
  69552. private readonly _m;
  69553. /**
  69554. * Gets the internal data of the matrix
  69555. */
  69556. readonly m: DeepImmutable<Float32Array>;
  69557. /** @hidden */
  69558. _markAsUpdated(): void;
  69559. /** @hidden */
  69560. private _updateIdentityStatus;
  69561. /**
  69562. * Creates an empty matrix (filled with zeros)
  69563. */
  69564. constructor();
  69565. /**
  69566. * Check if the current matrix is identity
  69567. * @returns true is the matrix is the identity matrix
  69568. */
  69569. isIdentity(): boolean;
  69570. /**
  69571. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  69572. * @returns true is the matrix is the identity matrix
  69573. */
  69574. isIdentityAs3x2(): boolean;
  69575. /**
  69576. * Gets the determinant of the matrix
  69577. * @returns the matrix determinant
  69578. */
  69579. determinant(): number;
  69580. /**
  69581. * Returns the matrix as a Float32Array
  69582. * @returns the matrix underlying array
  69583. */
  69584. toArray(): DeepImmutable<Float32Array>;
  69585. /**
  69586. * Returns the matrix as a Float32Array
  69587. * @returns the matrix underlying array.
  69588. */
  69589. asArray(): DeepImmutable<Float32Array>;
  69590. /**
  69591. * Inverts the current matrix in place
  69592. * @returns the current inverted matrix
  69593. */
  69594. invert(): Matrix;
  69595. /**
  69596. * Sets all the matrix elements to zero
  69597. * @returns the current matrix
  69598. */
  69599. reset(): Matrix;
  69600. /**
  69601. * Adds the current matrix with a second one
  69602. * @param other defines the matrix to add
  69603. * @returns a new matrix as the addition of the current matrix and the given one
  69604. */
  69605. add(other: DeepImmutable<Matrix>): Matrix;
  69606. /**
  69607. * Sets the given matrix "result" to the addition of the current matrix and the given one
  69608. * @param other defines the matrix to add
  69609. * @param result defines the target matrix
  69610. * @returns the current matrix
  69611. */
  69612. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69613. /**
  69614. * Adds in place the given matrix to the current matrix
  69615. * @param other defines the second operand
  69616. * @returns the current updated matrix
  69617. */
  69618. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  69619. /**
  69620. * Sets the given matrix to the current inverted Matrix
  69621. * @param other defines the target matrix
  69622. * @returns the unmodified current matrix
  69623. */
  69624. invertToRef(other: Matrix): Matrix;
  69625. /**
  69626. * add a value at the specified position in the current Matrix
  69627. * @param index the index of the value within the matrix. between 0 and 15.
  69628. * @param value the value to be added
  69629. * @returns the current updated matrix
  69630. */
  69631. addAtIndex(index: number, value: number): Matrix;
  69632. /**
  69633. * mutiply the specified position in the current Matrix by a value
  69634. * @param index the index of the value within the matrix. between 0 and 15.
  69635. * @param value the value to be added
  69636. * @returns the current updated matrix
  69637. */
  69638. multiplyAtIndex(index: number, value: number): Matrix;
  69639. /**
  69640. * Inserts the translation vector (using 3 floats) in the current matrix
  69641. * @param x defines the 1st component of the translation
  69642. * @param y defines the 2nd component of the translation
  69643. * @param z defines the 3rd component of the translation
  69644. * @returns the current updated matrix
  69645. */
  69646. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69647. /**
  69648. * Adds the translation vector (using 3 floats) in the current matrix
  69649. * @param x defines the 1st component of the translation
  69650. * @param y defines the 2nd component of the translation
  69651. * @param z defines the 3rd component of the translation
  69652. * @returns the current updated matrix
  69653. */
  69654. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  69655. /**
  69656. * Inserts the translation vector in the current matrix
  69657. * @param vector3 defines the translation to insert
  69658. * @returns the current updated matrix
  69659. */
  69660. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  69661. /**
  69662. * Gets the translation value of the current matrix
  69663. * @returns a new Vector3 as the extracted translation from the matrix
  69664. */
  69665. getTranslation(): Vector3;
  69666. /**
  69667. * Fill a Vector3 with the extracted translation from the matrix
  69668. * @param result defines the Vector3 where to store the translation
  69669. * @returns the current matrix
  69670. */
  69671. getTranslationToRef(result: Vector3): Matrix;
  69672. /**
  69673. * Remove rotation and scaling part from the matrix
  69674. * @returns the updated matrix
  69675. */
  69676. removeRotationAndScaling(): Matrix;
  69677. /**
  69678. * Multiply two matrices
  69679. * @param other defines the second operand
  69680. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  69681. */
  69682. multiply(other: DeepImmutable<Matrix>): Matrix;
  69683. /**
  69684. * Copy the current matrix from the given one
  69685. * @param other defines the source matrix
  69686. * @returns the current updated matrix
  69687. */
  69688. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  69689. /**
  69690. * Populates the given array from the starting index with the current matrix values
  69691. * @param array defines the target array
  69692. * @param offset defines the offset in the target array where to start storing values
  69693. * @returns the current matrix
  69694. */
  69695. copyToArray(array: Float32Array, offset?: number): Matrix;
  69696. /**
  69697. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  69698. * @param other defines the second operand
  69699. * @param result defines the matrix where to store the multiplication
  69700. * @returns the current matrix
  69701. */
  69702. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  69703. /**
  69704. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  69705. * @param other defines the second operand
  69706. * @param result defines the array where to store the multiplication
  69707. * @param offset defines the offset in the target array where to start storing values
  69708. * @returns the current matrix
  69709. */
  69710. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  69711. /**
  69712. * Check equality between this matrix and a second one
  69713. * @param value defines the second matrix to compare
  69714. * @returns true is the current matrix and the given one values are strictly equal
  69715. */
  69716. equals(value: DeepImmutable<Matrix>): boolean;
  69717. /**
  69718. * Clone the current matrix
  69719. * @returns a new matrix from the current matrix
  69720. */
  69721. clone(): Matrix;
  69722. /**
  69723. * Returns the name of the current matrix class
  69724. * @returns the string "Matrix"
  69725. */
  69726. getClassName(): string;
  69727. /**
  69728. * Gets the hash code of the current matrix
  69729. * @returns the hash code
  69730. */
  69731. getHashCode(): number;
  69732. /**
  69733. * Decomposes the current Matrix into a translation, rotation and scaling components
  69734. * @param scale defines the scale vector3 given as a reference to update
  69735. * @param rotation defines the rotation quaternion given as a reference to update
  69736. * @param translation defines the translation vector3 given as a reference to update
  69737. * @returns true if operation was successful
  69738. */
  69739. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  69740. /**
  69741. * Gets specific row of the matrix
  69742. * @param index defines the number of the row to get
  69743. * @returns the index-th row of the current matrix as a new Vector4
  69744. */
  69745. getRow(index: number): Nullable<Vector4>;
  69746. /**
  69747. * Sets the index-th row of the current matrix to the vector4 values
  69748. * @param index defines the number of the row to set
  69749. * @param row defines the target vector4
  69750. * @returns the updated current matrix
  69751. */
  69752. setRow(index: number, row: Vector4): Matrix;
  69753. /**
  69754. * Compute the transpose of the matrix
  69755. * @returns the new transposed matrix
  69756. */
  69757. transpose(): Matrix;
  69758. /**
  69759. * Compute the transpose of the matrix and store it in a given matrix
  69760. * @param result defines the target matrix
  69761. * @returns the current matrix
  69762. */
  69763. transposeToRef(result: Matrix): Matrix;
  69764. /**
  69765. * Sets the index-th row of the current matrix with the given 4 x float values
  69766. * @param index defines the row index
  69767. * @param x defines the x component to set
  69768. * @param y defines the y component to set
  69769. * @param z defines the z component to set
  69770. * @param w defines the w component to set
  69771. * @returns the updated current matrix
  69772. */
  69773. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  69774. /**
  69775. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  69776. * @param scale defines the scale factor
  69777. * @returns a new matrix
  69778. */
  69779. scale(scale: number): Matrix;
  69780. /**
  69781. * Scale the current matrix values by a factor to a given result matrix
  69782. * @param scale defines the scale factor
  69783. * @param result defines the matrix to store the result
  69784. * @returns the current matrix
  69785. */
  69786. scaleToRef(scale: number, result: Matrix): Matrix;
  69787. /**
  69788. * Scale the current matrix values by a factor and add the result to a given matrix
  69789. * @param scale defines the scale factor
  69790. * @param result defines the Matrix to store the result
  69791. * @returns the current matrix
  69792. */
  69793. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  69794. /**
  69795. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  69796. * @param ref matrix to store the result
  69797. */
  69798. toNormalMatrix(ref: Matrix): void;
  69799. /**
  69800. * Gets only rotation part of the current matrix
  69801. * @returns a new matrix sets to the extracted rotation matrix from the current one
  69802. */
  69803. getRotationMatrix(): Matrix;
  69804. /**
  69805. * Extracts the rotation matrix from the current one and sets it as the given "result"
  69806. * @param result defines the target matrix to store data to
  69807. * @returns the current matrix
  69808. */
  69809. getRotationMatrixToRef(result: Matrix): Matrix;
  69810. /**
  69811. * Toggles model matrix from being right handed to left handed in place and vice versa
  69812. */
  69813. toggleModelMatrixHandInPlace(): void;
  69814. /**
  69815. * Toggles projection matrix from being right handed to left handed in place and vice versa
  69816. */
  69817. toggleProjectionMatrixHandInPlace(): void;
  69818. /**
  69819. * Creates a matrix from an array
  69820. * @param array defines the source array
  69821. * @param offset defines an offset in the source array
  69822. * @returns a new Matrix set from the starting index of the given array
  69823. */
  69824. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  69825. /**
  69826. * Copy the content of an array into a given matrix
  69827. * @param array defines the source array
  69828. * @param offset defines an offset in the source array
  69829. * @param result defines the target matrix
  69830. */
  69831. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  69832. /**
  69833. * Stores an array into a matrix after having multiplied each component by a given factor
  69834. * @param array defines the source array
  69835. * @param offset defines the offset in the source array
  69836. * @param scale defines the scaling factor
  69837. * @param result defines the target matrix
  69838. */
  69839. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  69840. /**
  69841. * Gets an identity matrix that must not be updated
  69842. */
  69843. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  69844. /**
  69845. * Stores a list of values (16) inside a given matrix
  69846. * @param initialM11 defines 1st value of 1st row
  69847. * @param initialM12 defines 2nd value of 1st row
  69848. * @param initialM13 defines 3rd value of 1st row
  69849. * @param initialM14 defines 4th value of 1st row
  69850. * @param initialM21 defines 1st value of 2nd row
  69851. * @param initialM22 defines 2nd value of 2nd row
  69852. * @param initialM23 defines 3rd value of 2nd row
  69853. * @param initialM24 defines 4th value of 2nd row
  69854. * @param initialM31 defines 1st value of 3rd row
  69855. * @param initialM32 defines 2nd value of 3rd row
  69856. * @param initialM33 defines 3rd value of 3rd row
  69857. * @param initialM34 defines 4th value of 3rd row
  69858. * @param initialM41 defines 1st value of 4th row
  69859. * @param initialM42 defines 2nd value of 4th row
  69860. * @param initialM43 defines 3rd value of 4th row
  69861. * @param initialM44 defines 4th value of 4th row
  69862. * @param result defines the target matrix
  69863. */
  69864. 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;
  69865. /**
  69866. * Creates new matrix from a list of values (16)
  69867. * @param initialM11 defines 1st value of 1st row
  69868. * @param initialM12 defines 2nd value of 1st row
  69869. * @param initialM13 defines 3rd value of 1st row
  69870. * @param initialM14 defines 4th value of 1st row
  69871. * @param initialM21 defines 1st value of 2nd row
  69872. * @param initialM22 defines 2nd value of 2nd row
  69873. * @param initialM23 defines 3rd value of 2nd row
  69874. * @param initialM24 defines 4th value of 2nd row
  69875. * @param initialM31 defines 1st value of 3rd row
  69876. * @param initialM32 defines 2nd value of 3rd row
  69877. * @param initialM33 defines 3rd value of 3rd row
  69878. * @param initialM34 defines 4th value of 3rd row
  69879. * @param initialM41 defines 1st value of 4th row
  69880. * @param initialM42 defines 2nd value of 4th row
  69881. * @param initialM43 defines 3rd value of 4th row
  69882. * @param initialM44 defines 4th value of 4th row
  69883. * @returns the new matrix
  69884. */
  69885. 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;
  69886. /**
  69887. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69888. * @param scale defines the scale vector3
  69889. * @param rotation defines the rotation quaternion
  69890. * @param translation defines the translation vector3
  69891. * @returns a new matrix
  69892. */
  69893. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  69894. /**
  69895. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  69896. * @param scale defines the scale vector3
  69897. * @param rotation defines the rotation quaternion
  69898. * @param translation defines the translation vector3
  69899. * @param result defines the target matrix
  69900. */
  69901. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  69902. /**
  69903. * Creates a new identity matrix
  69904. * @returns a new identity matrix
  69905. */
  69906. static Identity(): Matrix;
  69907. /**
  69908. * Creates a new identity matrix and stores the result in a given matrix
  69909. * @param result defines the target matrix
  69910. */
  69911. static IdentityToRef(result: Matrix): void;
  69912. /**
  69913. * Creates a new zero matrix
  69914. * @returns a new zero matrix
  69915. */
  69916. static Zero(): Matrix;
  69917. /**
  69918. * Creates a new rotation matrix for "angle" radians around the X axis
  69919. * @param angle defines the angle (in radians) to use
  69920. * @return the new matrix
  69921. */
  69922. static RotationX(angle: number): Matrix;
  69923. /**
  69924. * Creates a new matrix as the invert of a given matrix
  69925. * @param source defines the source matrix
  69926. * @returns the new matrix
  69927. */
  69928. static Invert(source: DeepImmutable<Matrix>): Matrix;
  69929. /**
  69930. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  69931. * @param angle defines the angle (in radians) to use
  69932. * @param result defines the target matrix
  69933. */
  69934. static RotationXToRef(angle: number, result: Matrix): void;
  69935. /**
  69936. * Creates a new rotation matrix for "angle" radians around the Y axis
  69937. * @param angle defines the angle (in radians) to use
  69938. * @return the new matrix
  69939. */
  69940. static RotationY(angle: number): Matrix;
  69941. /**
  69942. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  69943. * @param angle defines the angle (in radians) to use
  69944. * @param result defines the target matrix
  69945. */
  69946. static RotationYToRef(angle: number, result: Matrix): void;
  69947. /**
  69948. * Creates a new rotation matrix for "angle" radians around the Z axis
  69949. * @param angle defines the angle (in radians) to use
  69950. * @return the new matrix
  69951. */
  69952. static RotationZ(angle: number): Matrix;
  69953. /**
  69954. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  69955. * @param angle defines the angle (in radians) to use
  69956. * @param result defines the target matrix
  69957. */
  69958. static RotationZToRef(angle: number, result: Matrix): void;
  69959. /**
  69960. * Creates a new rotation matrix for "angle" radians around the given axis
  69961. * @param axis defines the axis to use
  69962. * @param angle defines the angle (in radians) to use
  69963. * @return the new matrix
  69964. */
  69965. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  69966. /**
  69967. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  69968. * @param axis defines the axis to use
  69969. * @param angle defines the angle (in radians) to use
  69970. * @param result defines the target matrix
  69971. */
  69972. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  69973. /**
  69974. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  69975. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  69976. * @param from defines the vector to align
  69977. * @param to defines the vector to align to
  69978. * @param result defines the target matrix
  69979. */
  69980. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  69981. /**
  69982. * Creates a rotation matrix
  69983. * @param yaw defines the yaw angle in radians (Y axis)
  69984. * @param pitch defines the pitch angle in radians (X axis)
  69985. * @param roll defines the roll angle in radians (X axis)
  69986. * @returns the new rotation matrix
  69987. */
  69988. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  69989. /**
  69990. * Creates a rotation matrix and stores it in a given matrix
  69991. * @param yaw defines the yaw angle in radians (Y axis)
  69992. * @param pitch defines the pitch angle in radians (X axis)
  69993. * @param roll defines the roll angle in radians (X axis)
  69994. * @param result defines the target matrix
  69995. */
  69996. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  69997. /**
  69998. * Creates a scaling matrix
  69999. * @param x defines the scale factor on X axis
  70000. * @param y defines the scale factor on Y axis
  70001. * @param z defines the scale factor on Z axis
  70002. * @returns the new matrix
  70003. */
  70004. static Scaling(x: number, y: number, z: number): Matrix;
  70005. /**
  70006. * Creates a scaling matrix and stores it in a given matrix
  70007. * @param x defines the scale factor on X axis
  70008. * @param y defines the scale factor on Y axis
  70009. * @param z defines the scale factor on Z axis
  70010. * @param result defines the target matrix
  70011. */
  70012. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  70013. /**
  70014. * Creates a translation matrix
  70015. * @param x defines the translation on X axis
  70016. * @param y defines the translation on Y axis
  70017. * @param z defines the translationon Z axis
  70018. * @returns the new matrix
  70019. */
  70020. static Translation(x: number, y: number, z: number): Matrix;
  70021. /**
  70022. * Creates a translation matrix and stores it in a given matrix
  70023. * @param x defines the translation on X axis
  70024. * @param y defines the translation on Y axis
  70025. * @param z defines the translationon Z axis
  70026. * @param result defines the target matrix
  70027. */
  70028. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  70029. /**
  70030. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  70031. * @param startValue defines the start value
  70032. * @param endValue defines the end value
  70033. * @param gradient defines the gradient factor
  70034. * @returns the new matrix
  70035. */
  70036. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  70037. /**
  70038. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  70039. * @param startValue defines the start value
  70040. * @param endValue defines the end value
  70041. * @param gradient defines the gradient factor
  70042. * @param result defines the Matrix object where to store data
  70043. */
  70044. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70045. /**
  70046. * Builds a new matrix whose values are computed by:
  70047. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70048. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70049. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70050. * @param startValue defines the first matrix
  70051. * @param endValue defines the second matrix
  70052. * @param gradient defines the gradient between the two matrices
  70053. * @returns the new matrix
  70054. */
  70055. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  70056. /**
  70057. * Update a matrix to values which are computed by:
  70058. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  70059. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  70060. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  70061. * @param startValue defines the first matrix
  70062. * @param endValue defines the second matrix
  70063. * @param gradient defines the gradient between the two matrices
  70064. * @param result defines the target matrix
  70065. */
  70066. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  70067. /**
  70068. * 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"
  70069. * This function works in left handed mode
  70070. * @param eye defines the final position of the entity
  70071. * @param target defines where the entity should look at
  70072. * @param up defines the up vector for the entity
  70073. * @returns the new matrix
  70074. */
  70075. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70076. /**
  70077. * 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".
  70078. * This function works in left handed mode
  70079. * @param eye defines the final position of the entity
  70080. * @param target defines where the entity should look at
  70081. * @param up defines the up vector for the entity
  70082. * @param result defines the target matrix
  70083. */
  70084. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70085. /**
  70086. * 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"
  70087. * This function works in right handed mode
  70088. * @param eye defines the final position of the entity
  70089. * @param target defines where the entity should look at
  70090. * @param up defines the up vector for the entity
  70091. * @returns the new matrix
  70092. */
  70093. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  70094. /**
  70095. * 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".
  70096. * This function works in right handed mode
  70097. * @param eye defines the final position of the entity
  70098. * @param target defines where the entity should look at
  70099. * @param up defines the up vector for the entity
  70100. * @param result defines the target matrix
  70101. */
  70102. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  70103. /**
  70104. * Create a left-handed orthographic projection matrix
  70105. * @param width defines the viewport width
  70106. * @param height defines the viewport height
  70107. * @param znear defines the near clip plane
  70108. * @param zfar defines the far clip plane
  70109. * @returns a new matrix as a left-handed orthographic projection matrix
  70110. */
  70111. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70112. /**
  70113. * Store a left-handed orthographic projection to a given matrix
  70114. * @param width defines the viewport width
  70115. * @param height defines the viewport height
  70116. * @param znear defines the near clip plane
  70117. * @param zfar defines the far clip plane
  70118. * @param result defines the target matrix
  70119. */
  70120. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  70121. /**
  70122. * Create a left-handed orthographic projection matrix
  70123. * @param left defines the viewport left coordinate
  70124. * @param right defines the viewport right coordinate
  70125. * @param bottom defines the viewport bottom coordinate
  70126. * @param top defines the viewport top coordinate
  70127. * @param znear defines the near clip plane
  70128. * @param zfar defines the far clip plane
  70129. * @returns a new matrix as a left-handed orthographic projection matrix
  70130. */
  70131. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70132. /**
  70133. * Stores a left-handed orthographic projection into a given matrix
  70134. * @param left defines the viewport left coordinate
  70135. * @param right defines the viewport right coordinate
  70136. * @param bottom defines the viewport bottom coordinate
  70137. * @param top defines the viewport top coordinate
  70138. * @param znear defines the near clip plane
  70139. * @param zfar defines the far clip plane
  70140. * @param result defines the target matrix
  70141. */
  70142. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70143. /**
  70144. * Creates a right-handed orthographic projection matrix
  70145. * @param left defines the viewport left coordinate
  70146. * @param right defines the viewport right coordinate
  70147. * @param bottom defines the viewport bottom coordinate
  70148. * @param top defines the viewport top coordinate
  70149. * @param znear defines the near clip plane
  70150. * @param zfar defines the far clip plane
  70151. * @returns a new matrix as a right-handed orthographic projection matrix
  70152. */
  70153. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  70154. /**
  70155. * Stores a right-handed orthographic projection into a given matrix
  70156. * @param left defines the viewport left coordinate
  70157. * @param right defines the viewport right coordinate
  70158. * @param bottom defines the viewport bottom coordinate
  70159. * @param top defines the viewport top coordinate
  70160. * @param znear defines the near clip plane
  70161. * @param zfar defines the far clip plane
  70162. * @param result defines the target matrix
  70163. */
  70164. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  70165. /**
  70166. * Creates a left-handed perspective projection matrix
  70167. * @param width defines the viewport width
  70168. * @param height defines the viewport height
  70169. * @param znear defines the near clip plane
  70170. * @param zfar defines the far clip plane
  70171. * @returns a new matrix as a left-handed perspective projection matrix
  70172. */
  70173. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  70174. /**
  70175. * Creates a left-handed perspective projection matrix
  70176. * @param fov defines the horizontal field of view
  70177. * @param aspect defines the aspect ratio
  70178. * @param znear defines the near clip plane
  70179. * @param zfar defines the far clip plane
  70180. * @returns a new matrix as a left-handed perspective projection matrix
  70181. */
  70182. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70183. /**
  70184. * Stores a left-handed perspective projection into a given matrix
  70185. * @param fov defines the horizontal field of view
  70186. * @param aspect defines the aspect ratio
  70187. * @param znear defines the near clip plane
  70188. * @param zfar defines the far clip plane
  70189. * @param result defines the target matrix
  70190. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70191. */
  70192. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70193. /**
  70194. * Creates a right-handed perspective projection matrix
  70195. * @param fov defines the horizontal field of view
  70196. * @param aspect defines the aspect ratio
  70197. * @param znear defines the near clip plane
  70198. * @param zfar defines the far clip plane
  70199. * @returns a new matrix as a right-handed perspective projection matrix
  70200. */
  70201. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  70202. /**
  70203. * Stores a right-handed perspective projection into a given matrix
  70204. * @param fov defines the horizontal field of view
  70205. * @param aspect defines the aspect ratio
  70206. * @param znear defines the near clip plane
  70207. * @param zfar defines the far clip plane
  70208. * @param result defines the target matrix
  70209. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  70210. */
  70211. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  70212. /**
  70213. * Stores a perspective projection for WebVR info a given matrix
  70214. * @param fov defines the field of view
  70215. * @param znear defines the near clip plane
  70216. * @param zfar defines the far clip plane
  70217. * @param result defines the target matrix
  70218. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  70219. */
  70220. static PerspectiveFovWebVRToRef(fov: {
  70221. upDegrees: number;
  70222. downDegrees: number;
  70223. leftDegrees: number;
  70224. rightDegrees: number;
  70225. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  70226. /**
  70227. * Computes a complete transformation matrix
  70228. * @param viewport defines the viewport to use
  70229. * @param world defines the world matrix
  70230. * @param view defines the view matrix
  70231. * @param projection defines the projection matrix
  70232. * @param zmin defines the near clip plane
  70233. * @param zmax defines the far clip plane
  70234. * @returns the transformation matrix
  70235. */
  70236. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  70237. /**
  70238. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  70239. * @param matrix defines the matrix to use
  70240. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  70241. */
  70242. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  70243. /**
  70244. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  70245. * @param matrix defines the matrix to use
  70246. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  70247. */
  70248. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  70249. /**
  70250. * Compute the transpose of a given matrix
  70251. * @param matrix defines the matrix to transpose
  70252. * @returns the new matrix
  70253. */
  70254. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  70255. /**
  70256. * Compute the transpose of a matrix and store it in a target matrix
  70257. * @param matrix defines the matrix to transpose
  70258. * @param result defines the target matrix
  70259. */
  70260. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  70261. /**
  70262. * Computes a reflection matrix from a plane
  70263. * @param plane defines the reflection plane
  70264. * @returns a new matrix
  70265. */
  70266. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  70267. /**
  70268. * Computes a reflection matrix from a plane
  70269. * @param plane defines the reflection plane
  70270. * @param result defines the target matrix
  70271. */
  70272. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  70273. /**
  70274. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  70275. * @param xaxis defines the value of the 1st axis
  70276. * @param yaxis defines the value of the 2nd axis
  70277. * @param zaxis defines the value of the 3rd axis
  70278. * @param result defines the target matrix
  70279. */
  70280. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  70281. /**
  70282. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  70283. * @param quat defines the quaternion to use
  70284. * @param result defines the target matrix
  70285. */
  70286. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  70287. }
  70288. /**
  70289. * @hidden
  70290. */
  70291. export class TmpVectors {
  70292. static Vector2: Vector2[];
  70293. static Vector3: Vector3[];
  70294. static Vector4: Vector4[];
  70295. static Quaternion: Quaternion[];
  70296. static Matrix: Matrix[];
  70297. }
  70298. }
  70299. declare module BABYLON {
  70300. /**
  70301. * Class used to hold a RBG color
  70302. */
  70303. export class Color3 {
  70304. /**
  70305. * Defines the red component (between 0 and 1, default is 0)
  70306. */
  70307. r: number;
  70308. /**
  70309. * Defines the green component (between 0 and 1, default is 0)
  70310. */
  70311. g: number;
  70312. /**
  70313. * Defines the blue component (between 0 and 1, default is 0)
  70314. */
  70315. b: number;
  70316. /**
  70317. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  70318. * @param r defines the red component (between 0 and 1, default is 0)
  70319. * @param g defines the green component (between 0 and 1, default is 0)
  70320. * @param b defines the blue component (between 0 and 1, default is 0)
  70321. */
  70322. constructor(
  70323. /**
  70324. * Defines the red component (between 0 and 1, default is 0)
  70325. */
  70326. r?: number,
  70327. /**
  70328. * Defines the green component (between 0 and 1, default is 0)
  70329. */
  70330. g?: number,
  70331. /**
  70332. * Defines the blue component (between 0 and 1, default is 0)
  70333. */
  70334. b?: number);
  70335. /**
  70336. * Creates a string with the Color3 current values
  70337. * @returns the string representation of the Color3 object
  70338. */
  70339. toString(): string;
  70340. /**
  70341. * Returns the string "Color3"
  70342. * @returns "Color3"
  70343. */
  70344. getClassName(): string;
  70345. /**
  70346. * Compute the Color3 hash code
  70347. * @returns an unique number that can be used to hash Color3 objects
  70348. */
  70349. getHashCode(): number;
  70350. /**
  70351. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  70352. * @param array defines the array where to store the r,g,b components
  70353. * @param index defines an optional index in the target array to define where to start storing values
  70354. * @returns the current Color3 object
  70355. */
  70356. toArray(array: FloatArray, index?: number): Color3;
  70357. /**
  70358. * Returns a new Color4 object from the current Color3 and the given alpha
  70359. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  70360. * @returns a new Color4 object
  70361. */
  70362. toColor4(alpha?: number): Color4;
  70363. /**
  70364. * Returns a new array populated with 3 numeric elements : red, green and blue values
  70365. * @returns the new array
  70366. */
  70367. asArray(): number[];
  70368. /**
  70369. * Returns the luminance value
  70370. * @returns a float value
  70371. */
  70372. toLuminance(): number;
  70373. /**
  70374. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  70375. * @param otherColor defines the second operand
  70376. * @returns the new Color3 object
  70377. */
  70378. multiply(otherColor: DeepImmutable<Color3>): Color3;
  70379. /**
  70380. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  70381. * @param otherColor defines the second operand
  70382. * @param result defines the Color3 object where to store the result
  70383. * @returns the current Color3
  70384. */
  70385. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70386. /**
  70387. * Determines equality between Color3 objects
  70388. * @param otherColor defines the second operand
  70389. * @returns true if the rgb values are equal to the given ones
  70390. */
  70391. equals(otherColor: DeepImmutable<Color3>): boolean;
  70392. /**
  70393. * Determines equality between the current Color3 object and a set of r,b,g values
  70394. * @param r defines the red component to check
  70395. * @param g defines the green component to check
  70396. * @param b defines the blue component to check
  70397. * @returns true if the rgb values are equal to the given ones
  70398. */
  70399. equalsFloats(r: number, g: number, b: number): boolean;
  70400. /**
  70401. * Multiplies in place each rgb value by scale
  70402. * @param scale defines the scaling factor
  70403. * @returns the updated Color3
  70404. */
  70405. scale(scale: number): Color3;
  70406. /**
  70407. * Multiplies the rgb values by scale and stores the result into "result"
  70408. * @param scale defines the scaling factor
  70409. * @param result defines the Color3 object where to store the result
  70410. * @returns the unmodified current Color3
  70411. */
  70412. scaleToRef(scale: number, result: Color3): Color3;
  70413. /**
  70414. * Scale the current Color3 values by a factor and add the result to a given Color3
  70415. * @param scale defines the scale factor
  70416. * @param result defines color to store the result into
  70417. * @returns the unmodified current Color3
  70418. */
  70419. scaleAndAddToRef(scale: number, result: Color3): Color3;
  70420. /**
  70421. * Clamps the rgb values by the min and max values and stores the result into "result"
  70422. * @param min defines minimum clamping value (default is 0)
  70423. * @param max defines maximum clamping value (default is 1)
  70424. * @param result defines color to store the result into
  70425. * @returns the original Color3
  70426. */
  70427. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  70428. /**
  70429. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  70430. * @param otherColor defines the second operand
  70431. * @returns the new Color3
  70432. */
  70433. add(otherColor: DeepImmutable<Color3>): Color3;
  70434. /**
  70435. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  70436. * @param otherColor defines the second operand
  70437. * @param result defines Color3 object to store the result into
  70438. * @returns the unmodified current Color3
  70439. */
  70440. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70441. /**
  70442. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  70443. * @param otherColor defines the second operand
  70444. * @returns the new Color3
  70445. */
  70446. subtract(otherColor: DeepImmutable<Color3>): Color3;
  70447. /**
  70448. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  70449. * @param otherColor defines the second operand
  70450. * @param result defines Color3 object to store the result into
  70451. * @returns the unmodified current Color3
  70452. */
  70453. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  70454. /**
  70455. * Copy the current object
  70456. * @returns a new Color3 copied the current one
  70457. */
  70458. clone(): Color3;
  70459. /**
  70460. * Copies the rgb values from the source in the current Color3
  70461. * @param source defines the source Color3 object
  70462. * @returns the updated Color3 object
  70463. */
  70464. copyFrom(source: DeepImmutable<Color3>): Color3;
  70465. /**
  70466. * Updates the Color3 rgb values from the given floats
  70467. * @param r defines the red component to read from
  70468. * @param g defines the green component to read from
  70469. * @param b defines the blue component to read from
  70470. * @returns the current Color3 object
  70471. */
  70472. copyFromFloats(r: number, g: number, b: number): Color3;
  70473. /**
  70474. * Updates the Color3 rgb values from the given floats
  70475. * @param r defines the red component to read from
  70476. * @param g defines the green component to read from
  70477. * @param b defines the blue component to read from
  70478. * @returns the current Color3 object
  70479. */
  70480. set(r: number, g: number, b: number): Color3;
  70481. /**
  70482. * Compute the Color3 hexadecimal code as a string
  70483. * @returns a string containing the hexadecimal representation of the Color3 object
  70484. */
  70485. toHexString(): string;
  70486. /**
  70487. * Computes a new Color3 converted from the current one to linear space
  70488. * @returns a new Color3 object
  70489. */
  70490. toLinearSpace(): Color3;
  70491. /**
  70492. * Converts current color in rgb space to HSV values
  70493. * @returns a new color3 representing the HSV values
  70494. */
  70495. toHSV(): Color3;
  70496. /**
  70497. * Converts current color in rgb space to HSV values
  70498. * @param result defines the Color3 where to store the HSV values
  70499. */
  70500. toHSVToRef(result: Color3): void;
  70501. /**
  70502. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  70503. * @param convertedColor defines the Color3 object where to store the linear space version
  70504. * @returns the unmodified Color3
  70505. */
  70506. toLinearSpaceToRef(convertedColor: Color3): Color3;
  70507. /**
  70508. * Computes a new Color3 converted from the current one to gamma space
  70509. * @returns a new Color3 object
  70510. */
  70511. toGammaSpace(): Color3;
  70512. /**
  70513. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  70514. * @param convertedColor defines the Color3 object where to store the gamma space version
  70515. * @returns the unmodified Color3
  70516. */
  70517. toGammaSpaceToRef(convertedColor: Color3): Color3;
  70518. private static _BlackReadOnly;
  70519. /**
  70520. * Convert Hue, saturation and value to a Color3 (RGB)
  70521. * @param hue defines the hue
  70522. * @param saturation defines the saturation
  70523. * @param value defines the value
  70524. * @param result defines the Color3 where to store the RGB values
  70525. */
  70526. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  70527. /**
  70528. * Creates a new Color3 from the string containing valid hexadecimal values
  70529. * @param hex defines a string containing valid hexadecimal values
  70530. * @returns a new Color3 object
  70531. */
  70532. static FromHexString(hex: string): Color3;
  70533. /**
  70534. * Creates a new Color3 from the starting index of the given array
  70535. * @param array defines the source array
  70536. * @param offset defines an offset in the source array
  70537. * @returns a new Color3 object
  70538. */
  70539. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  70540. /**
  70541. * Creates a new Color3 from integer values (< 256)
  70542. * @param r defines the red component to read from (value between 0 and 255)
  70543. * @param g defines the green component to read from (value between 0 and 255)
  70544. * @param b defines the blue component to read from (value between 0 and 255)
  70545. * @returns a new Color3 object
  70546. */
  70547. static FromInts(r: number, g: number, b: number): Color3;
  70548. /**
  70549. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70550. * @param start defines the start Color3 value
  70551. * @param end defines the end Color3 value
  70552. * @param amount defines the gradient value between start and end
  70553. * @returns a new Color3 object
  70554. */
  70555. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  70556. /**
  70557. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  70558. * @param left defines the start value
  70559. * @param right defines the end value
  70560. * @param amount defines the gradient factor
  70561. * @param result defines the Color3 object where to store the result
  70562. */
  70563. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  70564. /**
  70565. * Returns a Color3 value containing a red color
  70566. * @returns a new Color3 object
  70567. */
  70568. static Red(): Color3;
  70569. /**
  70570. * Returns a Color3 value containing a green color
  70571. * @returns a new Color3 object
  70572. */
  70573. static Green(): Color3;
  70574. /**
  70575. * Returns a Color3 value containing a blue color
  70576. * @returns a new Color3 object
  70577. */
  70578. static Blue(): Color3;
  70579. /**
  70580. * Returns a Color3 value containing a black color
  70581. * @returns a new Color3 object
  70582. */
  70583. static Black(): Color3;
  70584. /**
  70585. * Gets a Color3 value containing a black color that must not be updated
  70586. */
  70587. static readonly BlackReadOnly: DeepImmutable<Color3>;
  70588. /**
  70589. * Returns a Color3 value containing a white color
  70590. * @returns a new Color3 object
  70591. */
  70592. static White(): Color3;
  70593. /**
  70594. * Returns a Color3 value containing a purple color
  70595. * @returns a new Color3 object
  70596. */
  70597. static Purple(): Color3;
  70598. /**
  70599. * Returns a Color3 value containing a magenta color
  70600. * @returns a new Color3 object
  70601. */
  70602. static Magenta(): Color3;
  70603. /**
  70604. * Returns a Color3 value containing a yellow color
  70605. * @returns a new Color3 object
  70606. */
  70607. static Yellow(): Color3;
  70608. /**
  70609. * Returns a Color3 value containing a gray color
  70610. * @returns a new Color3 object
  70611. */
  70612. static Gray(): Color3;
  70613. /**
  70614. * Returns a Color3 value containing a teal color
  70615. * @returns a new Color3 object
  70616. */
  70617. static Teal(): Color3;
  70618. /**
  70619. * Returns a Color3 value containing a random color
  70620. * @returns a new Color3 object
  70621. */
  70622. static Random(): Color3;
  70623. }
  70624. /**
  70625. * Class used to hold a RBGA color
  70626. */
  70627. export class Color4 {
  70628. /**
  70629. * Defines the red component (between 0 and 1, default is 0)
  70630. */
  70631. r: number;
  70632. /**
  70633. * Defines the green component (between 0 and 1, default is 0)
  70634. */
  70635. g: number;
  70636. /**
  70637. * Defines the blue component (between 0 and 1, default is 0)
  70638. */
  70639. b: number;
  70640. /**
  70641. * Defines the alpha component (between 0 and 1, default is 1)
  70642. */
  70643. a: number;
  70644. /**
  70645. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  70646. * @param r defines the red component (between 0 and 1, default is 0)
  70647. * @param g defines the green component (between 0 and 1, default is 0)
  70648. * @param b defines the blue component (between 0 and 1, default is 0)
  70649. * @param a defines the alpha component (between 0 and 1, default is 1)
  70650. */
  70651. constructor(
  70652. /**
  70653. * Defines the red component (between 0 and 1, default is 0)
  70654. */
  70655. r?: number,
  70656. /**
  70657. * Defines the green component (between 0 and 1, default is 0)
  70658. */
  70659. g?: number,
  70660. /**
  70661. * Defines the blue component (between 0 and 1, default is 0)
  70662. */
  70663. b?: number,
  70664. /**
  70665. * Defines the alpha component (between 0 and 1, default is 1)
  70666. */
  70667. a?: number);
  70668. /**
  70669. * Adds in place the given Color4 values to the current Color4 object
  70670. * @param right defines the second operand
  70671. * @returns the current updated Color4 object
  70672. */
  70673. addInPlace(right: DeepImmutable<Color4>): Color4;
  70674. /**
  70675. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  70676. * @returns the new array
  70677. */
  70678. asArray(): number[];
  70679. /**
  70680. * Stores from the starting index in the given array the Color4 successive values
  70681. * @param array defines the array where to store the r,g,b components
  70682. * @param index defines an optional index in the target array to define where to start storing values
  70683. * @returns the current Color4 object
  70684. */
  70685. toArray(array: number[], index?: number): Color4;
  70686. /**
  70687. * Determines equality between Color4 objects
  70688. * @param otherColor defines the second operand
  70689. * @returns true if the rgba values are equal to the given ones
  70690. */
  70691. equals(otherColor: DeepImmutable<Color4>): boolean;
  70692. /**
  70693. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  70694. * @param right defines the second operand
  70695. * @returns a new Color4 object
  70696. */
  70697. add(right: DeepImmutable<Color4>): Color4;
  70698. /**
  70699. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  70700. * @param right defines the second operand
  70701. * @returns a new Color4 object
  70702. */
  70703. subtract(right: DeepImmutable<Color4>): Color4;
  70704. /**
  70705. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  70706. * @param right defines the second operand
  70707. * @param result defines the Color4 object where to store the result
  70708. * @returns the current Color4 object
  70709. */
  70710. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  70711. /**
  70712. * Creates a new Color4 with the current Color4 values multiplied by scale
  70713. * @param scale defines the scaling factor to apply
  70714. * @returns a new Color4 object
  70715. */
  70716. scale(scale: number): Color4;
  70717. /**
  70718. * Multiplies the current Color4 values by scale and stores the result in "result"
  70719. * @param scale defines the scaling factor to apply
  70720. * @param result defines the Color4 object where to store the result
  70721. * @returns the current unmodified Color4
  70722. */
  70723. scaleToRef(scale: number, result: Color4): Color4;
  70724. /**
  70725. * Scale the current Color4 values by a factor and add the result to a given Color4
  70726. * @param scale defines the scale factor
  70727. * @param result defines the Color4 object where to store the result
  70728. * @returns the unmodified current Color4
  70729. */
  70730. scaleAndAddToRef(scale: number, result: Color4): Color4;
  70731. /**
  70732. * Clamps the rgb values by the min and max values and stores the result into "result"
  70733. * @param min defines minimum clamping value (default is 0)
  70734. * @param max defines maximum clamping value (default is 1)
  70735. * @param result defines color to store the result into.
  70736. * @returns the cuurent Color4
  70737. */
  70738. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  70739. /**
  70740. * Multipy an Color4 value by another and return a new Color4 object
  70741. * @param color defines the Color4 value to multiply by
  70742. * @returns a new Color4 object
  70743. */
  70744. multiply(color: Color4): Color4;
  70745. /**
  70746. * Multipy a Color4 value by another and push the result in a reference value
  70747. * @param color defines the Color4 value to multiply by
  70748. * @param result defines the Color4 to fill the result in
  70749. * @returns the result Color4
  70750. */
  70751. multiplyToRef(color: Color4, result: Color4): Color4;
  70752. /**
  70753. * Creates a string with the Color4 current values
  70754. * @returns the string representation of the Color4 object
  70755. */
  70756. toString(): string;
  70757. /**
  70758. * Returns the string "Color4"
  70759. * @returns "Color4"
  70760. */
  70761. getClassName(): string;
  70762. /**
  70763. * Compute the Color4 hash code
  70764. * @returns an unique number that can be used to hash Color4 objects
  70765. */
  70766. getHashCode(): number;
  70767. /**
  70768. * Creates a new Color4 copied from the current one
  70769. * @returns a new Color4 object
  70770. */
  70771. clone(): Color4;
  70772. /**
  70773. * Copies the given Color4 values into the current one
  70774. * @param source defines the source Color4 object
  70775. * @returns the current updated Color4 object
  70776. */
  70777. copyFrom(source: Color4): Color4;
  70778. /**
  70779. * Copies the given float values into the current one
  70780. * @param r defines the red component to read from
  70781. * @param g defines the green component to read from
  70782. * @param b defines the blue component to read from
  70783. * @param a defines the alpha component to read from
  70784. * @returns the current updated Color4 object
  70785. */
  70786. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  70787. /**
  70788. * Copies the given float values into the current one
  70789. * @param r defines the red component to read from
  70790. * @param g defines the green component to read from
  70791. * @param b defines the blue component to read from
  70792. * @param a defines the alpha component to read from
  70793. * @returns the current updated Color4 object
  70794. */
  70795. set(r: number, g: number, b: number, a: number): Color4;
  70796. /**
  70797. * Compute the Color4 hexadecimal code as a string
  70798. * @returns a string containing the hexadecimal representation of the Color4 object
  70799. */
  70800. toHexString(): string;
  70801. /**
  70802. * Computes a new Color4 converted from the current one to linear space
  70803. * @returns a new Color4 object
  70804. */
  70805. toLinearSpace(): Color4;
  70806. /**
  70807. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  70808. * @param convertedColor defines the Color4 object where to store the linear space version
  70809. * @returns the unmodified Color4
  70810. */
  70811. toLinearSpaceToRef(convertedColor: Color4): Color4;
  70812. /**
  70813. * Computes a new Color4 converted from the current one to gamma space
  70814. * @returns a new Color4 object
  70815. */
  70816. toGammaSpace(): Color4;
  70817. /**
  70818. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  70819. * @param convertedColor defines the Color4 object where to store the gamma space version
  70820. * @returns the unmodified Color4
  70821. */
  70822. toGammaSpaceToRef(convertedColor: Color4): Color4;
  70823. /**
  70824. * Creates a new Color4 from the string containing valid hexadecimal values
  70825. * @param hex defines a string containing valid hexadecimal values
  70826. * @returns a new Color4 object
  70827. */
  70828. static FromHexString(hex: string): Color4;
  70829. /**
  70830. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70831. * @param left defines the start value
  70832. * @param right defines the end value
  70833. * @param amount defines the gradient factor
  70834. * @returns a new Color4 object
  70835. */
  70836. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  70837. /**
  70838. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  70839. * @param left defines the start value
  70840. * @param right defines the end value
  70841. * @param amount defines the gradient factor
  70842. * @param result defines the Color4 object where to store data
  70843. */
  70844. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  70845. /**
  70846. * Creates a new Color4 from a Color3 and an alpha value
  70847. * @param color3 defines the source Color3 to read from
  70848. * @param alpha defines the alpha component (1.0 by default)
  70849. * @returns a new Color4 object
  70850. */
  70851. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  70852. /**
  70853. * Creates a new Color4 from the starting index element of the given array
  70854. * @param array defines the source array to read from
  70855. * @param offset defines the offset in the source array
  70856. * @returns a new Color4 object
  70857. */
  70858. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  70859. /**
  70860. * Creates a new Color3 from integer values (< 256)
  70861. * @param r defines the red component to read from (value between 0 and 255)
  70862. * @param g defines the green component to read from (value between 0 and 255)
  70863. * @param b defines the blue component to read from (value between 0 and 255)
  70864. * @param a defines the alpha component to read from (value between 0 and 255)
  70865. * @returns a new Color3 object
  70866. */
  70867. static FromInts(r: number, g: number, b: number, a: number): Color4;
  70868. /**
  70869. * Check the content of a given array and convert it to an array containing RGBA data
  70870. * If the original array was already containing count * 4 values then it is returned directly
  70871. * @param colors defines the array to check
  70872. * @param count defines the number of RGBA data to expect
  70873. * @returns an array containing count * 4 values (RGBA)
  70874. */
  70875. static CheckColors4(colors: number[], count: number): number[];
  70876. }
  70877. /**
  70878. * @hidden
  70879. */
  70880. export class TmpColors {
  70881. static Color3: Color3[];
  70882. static Color4: Color4[];
  70883. }
  70884. }
  70885. declare module BABYLON {
  70886. /**
  70887. * Class representing spherical harmonics coefficients to the 3rd degree
  70888. */
  70889. export class SphericalHarmonics {
  70890. /**
  70891. * Defines whether or not the harmonics have been prescaled for rendering.
  70892. */
  70893. preScaled: boolean;
  70894. /**
  70895. * The l0,0 coefficients of the spherical harmonics
  70896. */
  70897. l00: Vector3;
  70898. /**
  70899. * The l1,-1 coefficients of the spherical harmonics
  70900. */
  70901. l1_1: Vector3;
  70902. /**
  70903. * The l1,0 coefficients of the spherical harmonics
  70904. */
  70905. l10: Vector3;
  70906. /**
  70907. * The l1,1 coefficients of the spherical harmonics
  70908. */
  70909. l11: Vector3;
  70910. /**
  70911. * The l2,-2 coefficients of the spherical harmonics
  70912. */
  70913. l2_2: Vector3;
  70914. /**
  70915. * The l2,-1 coefficients of the spherical harmonics
  70916. */
  70917. l2_1: Vector3;
  70918. /**
  70919. * The l2,0 coefficients of the spherical harmonics
  70920. */
  70921. l20: Vector3;
  70922. /**
  70923. * The l2,1 coefficients of the spherical harmonics
  70924. */
  70925. l21: Vector3;
  70926. /**
  70927. * The l2,2 coefficients of the spherical harmonics
  70928. */
  70929. l22: Vector3;
  70930. /**
  70931. * Adds a light to the spherical harmonics
  70932. * @param direction the direction of the light
  70933. * @param color the color of the light
  70934. * @param deltaSolidAngle the delta solid angle of the light
  70935. */
  70936. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  70937. /**
  70938. * Scales the spherical harmonics by the given amount
  70939. * @param scale the amount to scale
  70940. */
  70941. scaleInPlace(scale: number): void;
  70942. /**
  70943. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  70944. *
  70945. * ```
  70946. * E_lm = A_l * L_lm
  70947. * ```
  70948. *
  70949. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  70950. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  70951. * the scaling factors are given in equation 9.
  70952. */
  70953. convertIncidentRadianceToIrradiance(): void;
  70954. /**
  70955. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  70956. *
  70957. * ```
  70958. * L = (1/pi) * E * rho
  70959. * ```
  70960. *
  70961. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  70962. */
  70963. convertIrradianceToLambertianRadiance(): void;
  70964. /**
  70965. * Integrates the reconstruction coefficients directly in to the SH preventing further
  70966. * required operations at run time.
  70967. *
  70968. * This is simply done by scaling back the SH with Ylm constants parameter.
  70969. * The trigonometric part being applied by the shader at run time.
  70970. */
  70971. preScaleForRendering(): void;
  70972. /**
  70973. * Constructs a spherical harmonics from an array.
  70974. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  70975. * @returns the spherical harmonics
  70976. */
  70977. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  70978. /**
  70979. * Gets the spherical harmonics from polynomial
  70980. * @param polynomial the spherical polynomial
  70981. * @returns the spherical harmonics
  70982. */
  70983. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  70984. }
  70985. /**
  70986. * Class representing spherical polynomial coefficients to the 3rd degree
  70987. */
  70988. export class SphericalPolynomial {
  70989. private _harmonics;
  70990. /**
  70991. * The spherical harmonics used to create the polynomials.
  70992. */
  70993. readonly preScaledHarmonics: SphericalHarmonics;
  70994. /**
  70995. * The x coefficients of the spherical polynomial
  70996. */
  70997. x: Vector3;
  70998. /**
  70999. * The y coefficients of the spherical polynomial
  71000. */
  71001. y: Vector3;
  71002. /**
  71003. * The z coefficients of the spherical polynomial
  71004. */
  71005. z: Vector3;
  71006. /**
  71007. * The xx coefficients of the spherical polynomial
  71008. */
  71009. xx: Vector3;
  71010. /**
  71011. * The yy coefficients of the spherical polynomial
  71012. */
  71013. yy: Vector3;
  71014. /**
  71015. * The zz coefficients of the spherical polynomial
  71016. */
  71017. zz: Vector3;
  71018. /**
  71019. * The xy coefficients of the spherical polynomial
  71020. */
  71021. xy: Vector3;
  71022. /**
  71023. * The yz coefficients of the spherical polynomial
  71024. */
  71025. yz: Vector3;
  71026. /**
  71027. * The zx coefficients of the spherical polynomial
  71028. */
  71029. zx: Vector3;
  71030. /**
  71031. * Adds an ambient color to the spherical polynomial
  71032. * @param color the color to add
  71033. */
  71034. addAmbient(color: Color3): void;
  71035. /**
  71036. * Scales the spherical polynomial by the given amount
  71037. * @param scale the amount to scale
  71038. */
  71039. scaleInPlace(scale: number): void;
  71040. /**
  71041. * Gets the spherical polynomial from harmonics
  71042. * @param harmonics the spherical harmonics
  71043. * @returns the spherical polynomial
  71044. */
  71045. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  71046. /**
  71047. * Constructs a spherical polynomial from an array.
  71048. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  71049. * @returns the spherical polynomial
  71050. */
  71051. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  71052. }
  71053. }
  71054. declare module BABYLON {
  71055. /**
  71056. * Define options used to create a render target texture
  71057. */
  71058. export class RenderTargetCreationOptions {
  71059. /**
  71060. * Specifies is mipmaps must be generated
  71061. */
  71062. generateMipMaps?: boolean;
  71063. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  71064. generateDepthBuffer?: boolean;
  71065. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  71066. generateStencilBuffer?: boolean;
  71067. /** Defines texture type (int by default) */
  71068. type?: number;
  71069. /** Defines sampling mode (trilinear by default) */
  71070. samplingMode?: number;
  71071. /** Defines format (RGBA by default) */
  71072. format?: number;
  71073. }
  71074. }
  71075. declare module BABYLON {
  71076. /**
  71077. * @hidden
  71078. **/
  71079. export class _TimeToken {
  71080. _startTimeQuery: Nullable<WebGLQuery>;
  71081. _endTimeQuery: Nullable<WebGLQuery>;
  71082. _timeElapsedQuery: Nullable<WebGLQuery>;
  71083. _timeElapsedQueryEnded: boolean;
  71084. }
  71085. }
  71086. declare module BABYLON {
  71087. /** Defines the cross module used constants to avoid circular dependncies */
  71088. export class Constants {
  71089. /** Defines that alpha blending is disabled */
  71090. static readonly ALPHA_DISABLE: number;
  71091. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  71092. static readonly ALPHA_ADD: number;
  71093. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  71094. static readonly ALPHA_COMBINE: number;
  71095. /** Defines that alpha blending to DEST - SRC * DEST */
  71096. static readonly ALPHA_SUBTRACT: number;
  71097. /** Defines that alpha blending to SRC * DEST */
  71098. static readonly ALPHA_MULTIPLY: number;
  71099. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  71100. static readonly ALPHA_MAXIMIZED: number;
  71101. /** Defines that alpha blending to SRC + DEST */
  71102. static readonly ALPHA_ONEONE: number;
  71103. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  71104. static readonly ALPHA_PREMULTIPLIED: number;
  71105. /**
  71106. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  71107. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  71108. */
  71109. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  71110. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  71111. static readonly ALPHA_INTERPOLATE: number;
  71112. /**
  71113. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  71114. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  71115. */
  71116. static readonly ALPHA_SCREENMODE: number;
  71117. /**
  71118. * Defines that alpha blending to SRC + DST
  71119. * Alpha will be set to SRC ALPHA + DST ALPHA
  71120. */
  71121. static readonly ALPHA_ONEONE_ONEONE: number;
  71122. /**
  71123. * Defines that alpha blending to SRC * DST ALPHA + DST
  71124. * Alpha will be set to 0
  71125. */
  71126. static readonly ALPHA_ALPHATOCOLOR: number;
  71127. /**
  71128. * Defines that alpha blending to SRC * (1 - DST) + DST * (1 - SRC)
  71129. */
  71130. static readonly ALPHA_REVERSEONEMINUS: number;
  71131. /**
  71132. * Defines that alpha blending to SRC + DST * (1 - SRC ALPHA)
  71133. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  71134. */
  71135. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  71136. /**
  71137. * Defines that alpha blending to SRC + DST
  71138. * Alpha will be set to SRC ALPHA
  71139. */
  71140. static readonly ALPHA_ONEONE_ONEZERO: number;
  71141. /** Defines that alpha blending equation a SUM */
  71142. static readonly ALPHA_EQUATION_ADD: number;
  71143. /** Defines that alpha blending equation a SUBSTRACTION */
  71144. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  71145. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  71146. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  71147. /** Defines that alpha blending equation a MAX operation */
  71148. static readonly ALPHA_EQUATION_MAX: number;
  71149. /** Defines that alpha blending equation a MIN operation */
  71150. static readonly ALPHA_EQUATION_MIN: number;
  71151. /**
  71152. * Defines that alpha blending equation a DARKEN operation:
  71153. * It takes the min of the src and sums the alpha channels.
  71154. */
  71155. static readonly ALPHA_EQUATION_DARKEN: number;
  71156. /** Defines that the ressource is not delayed*/
  71157. static readonly DELAYLOADSTATE_NONE: number;
  71158. /** Defines that the ressource was successfully delay loaded */
  71159. static readonly DELAYLOADSTATE_LOADED: number;
  71160. /** Defines that the ressource is currently delay loading */
  71161. static readonly DELAYLOADSTATE_LOADING: number;
  71162. /** Defines that the ressource is delayed and has not started loading */
  71163. static readonly DELAYLOADSTATE_NOTLOADED: number;
  71164. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  71165. static readonly NEVER: number;
  71166. /** 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 */
  71167. static readonly ALWAYS: number;
  71168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  71169. static readonly LESS: number;
  71170. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  71171. static readonly EQUAL: number;
  71172. /** 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 */
  71173. static readonly LEQUAL: number;
  71174. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  71175. static readonly GREATER: number;
  71176. /** 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 */
  71177. static readonly GEQUAL: number;
  71178. /** 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 */
  71179. static readonly NOTEQUAL: number;
  71180. /** Passed to stencilOperation to specify that stencil value must be kept */
  71181. static readonly KEEP: number;
  71182. /** Passed to stencilOperation to specify that stencil value must be replaced */
  71183. static readonly REPLACE: number;
  71184. /** Passed to stencilOperation to specify that stencil value must be incremented */
  71185. static readonly INCR: number;
  71186. /** Passed to stencilOperation to specify that stencil value must be decremented */
  71187. static readonly DECR: number;
  71188. /** Passed to stencilOperation to specify that stencil value must be inverted */
  71189. static readonly INVERT: number;
  71190. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  71191. static readonly INCR_WRAP: number;
  71192. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  71193. static readonly DECR_WRAP: number;
  71194. /** Texture is not repeating outside of 0..1 UVs */
  71195. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  71196. /** Texture is repeating outside of 0..1 UVs */
  71197. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  71198. /** Texture is repeating and mirrored */
  71199. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  71200. /** ALPHA */
  71201. static readonly TEXTUREFORMAT_ALPHA: number;
  71202. /** LUMINANCE */
  71203. static readonly TEXTUREFORMAT_LUMINANCE: number;
  71204. /** LUMINANCE_ALPHA */
  71205. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  71206. /** RGB */
  71207. static readonly TEXTUREFORMAT_RGB: number;
  71208. /** RGBA */
  71209. static readonly TEXTUREFORMAT_RGBA: number;
  71210. /** RED */
  71211. static readonly TEXTUREFORMAT_RED: number;
  71212. /** RED (2nd reference) */
  71213. static readonly TEXTUREFORMAT_R: number;
  71214. /** RG */
  71215. static readonly TEXTUREFORMAT_RG: number;
  71216. /** RED_INTEGER */
  71217. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  71218. /** RED_INTEGER (2nd reference) */
  71219. static readonly TEXTUREFORMAT_R_INTEGER: number;
  71220. /** RG_INTEGER */
  71221. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  71222. /** RGB_INTEGER */
  71223. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  71224. /** RGBA_INTEGER */
  71225. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  71226. /** UNSIGNED_BYTE */
  71227. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  71228. /** UNSIGNED_BYTE (2nd reference) */
  71229. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  71230. /** FLOAT */
  71231. static readonly TEXTURETYPE_FLOAT: number;
  71232. /** HALF_FLOAT */
  71233. static readonly TEXTURETYPE_HALF_FLOAT: number;
  71234. /** BYTE */
  71235. static readonly TEXTURETYPE_BYTE: number;
  71236. /** SHORT */
  71237. static readonly TEXTURETYPE_SHORT: number;
  71238. /** UNSIGNED_SHORT */
  71239. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  71240. /** INT */
  71241. static readonly TEXTURETYPE_INT: number;
  71242. /** UNSIGNED_INT */
  71243. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  71244. /** UNSIGNED_SHORT_4_4_4_4 */
  71245. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  71246. /** UNSIGNED_SHORT_5_5_5_1 */
  71247. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  71248. /** UNSIGNED_SHORT_5_6_5 */
  71249. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  71250. /** UNSIGNED_INT_2_10_10_10_REV */
  71251. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  71252. /** UNSIGNED_INT_24_8 */
  71253. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  71254. /** UNSIGNED_INT_10F_11F_11F_REV */
  71255. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  71256. /** UNSIGNED_INT_5_9_9_9_REV */
  71257. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  71258. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  71259. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  71260. /** nearest is mag = nearest and min = nearest and mip = linear */
  71261. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  71262. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71263. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  71264. /** Trilinear is mag = linear and min = linear and mip = linear */
  71265. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  71266. /** nearest is mag = nearest and min = nearest and mip = linear */
  71267. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  71268. /** Bilinear is mag = linear and min = linear and mip = nearest */
  71269. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  71270. /** Trilinear is mag = linear and min = linear and mip = linear */
  71271. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  71272. /** mag = nearest and min = nearest and mip = nearest */
  71273. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  71274. /** mag = nearest and min = linear and mip = nearest */
  71275. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  71276. /** mag = nearest and min = linear and mip = linear */
  71277. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  71278. /** mag = nearest and min = linear and mip = none */
  71279. static readonly TEXTURE_NEAREST_LINEAR: number;
  71280. /** mag = nearest and min = nearest and mip = none */
  71281. static readonly TEXTURE_NEAREST_NEAREST: number;
  71282. /** mag = linear and min = nearest and mip = nearest */
  71283. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  71284. /** mag = linear and min = nearest and mip = linear */
  71285. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  71286. /** mag = linear and min = linear and mip = none */
  71287. static readonly TEXTURE_LINEAR_LINEAR: number;
  71288. /** mag = linear and min = nearest and mip = none */
  71289. static readonly TEXTURE_LINEAR_NEAREST: number;
  71290. /** Explicit coordinates mode */
  71291. static readonly TEXTURE_EXPLICIT_MODE: number;
  71292. /** Spherical coordinates mode */
  71293. static readonly TEXTURE_SPHERICAL_MODE: number;
  71294. /** Planar coordinates mode */
  71295. static readonly TEXTURE_PLANAR_MODE: number;
  71296. /** Cubic coordinates mode */
  71297. static readonly TEXTURE_CUBIC_MODE: number;
  71298. /** Projection coordinates mode */
  71299. static readonly TEXTURE_PROJECTION_MODE: number;
  71300. /** Skybox coordinates mode */
  71301. static readonly TEXTURE_SKYBOX_MODE: number;
  71302. /** Inverse Cubic coordinates mode */
  71303. static readonly TEXTURE_INVCUBIC_MODE: number;
  71304. /** Equirectangular coordinates mode */
  71305. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  71306. /** Equirectangular Fixed coordinates mode */
  71307. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  71308. /** Equirectangular Fixed Mirrored coordinates mode */
  71309. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  71310. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  71311. static readonly SCALEMODE_FLOOR: number;
  71312. /** Defines that texture rescaling will look for the nearest power of 2 size */
  71313. static readonly SCALEMODE_NEAREST: number;
  71314. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  71315. static readonly SCALEMODE_CEILING: number;
  71316. /**
  71317. * The dirty texture flag value
  71318. */
  71319. static readonly MATERIAL_TextureDirtyFlag: number;
  71320. /**
  71321. * The dirty light flag value
  71322. */
  71323. static readonly MATERIAL_LightDirtyFlag: number;
  71324. /**
  71325. * The dirty fresnel flag value
  71326. */
  71327. static readonly MATERIAL_FresnelDirtyFlag: number;
  71328. /**
  71329. * The dirty attribute flag value
  71330. */
  71331. static readonly MATERIAL_AttributesDirtyFlag: number;
  71332. /**
  71333. * The dirty misc flag value
  71334. */
  71335. static readonly MATERIAL_MiscDirtyFlag: number;
  71336. /**
  71337. * The all dirty flag value
  71338. */
  71339. static readonly MATERIAL_AllDirtyFlag: number;
  71340. /**
  71341. * Returns the triangle fill mode
  71342. */
  71343. static readonly MATERIAL_TriangleFillMode: number;
  71344. /**
  71345. * Returns the wireframe mode
  71346. */
  71347. static readonly MATERIAL_WireFrameFillMode: number;
  71348. /**
  71349. * Returns the point fill mode
  71350. */
  71351. static readonly MATERIAL_PointFillMode: number;
  71352. /**
  71353. * Returns the point list draw mode
  71354. */
  71355. static readonly MATERIAL_PointListDrawMode: number;
  71356. /**
  71357. * Returns the line list draw mode
  71358. */
  71359. static readonly MATERIAL_LineListDrawMode: number;
  71360. /**
  71361. * Returns the line loop draw mode
  71362. */
  71363. static readonly MATERIAL_LineLoopDrawMode: number;
  71364. /**
  71365. * Returns the line strip draw mode
  71366. */
  71367. static readonly MATERIAL_LineStripDrawMode: number;
  71368. /**
  71369. * Returns the triangle strip draw mode
  71370. */
  71371. static readonly MATERIAL_TriangleStripDrawMode: number;
  71372. /**
  71373. * Returns the triangle fan draw mode
  71374. */
  71375. static readonly MATERIAL_TriangleFanDrawMode: number;
  71376. /**
  71377. * Stores the clock-wise side orientation
  71378. */
  71379. static readonly MATERIAL_ClockWiseSideOrientation: number;
  71380. /**
  71381. * Stores the counter clock-wise side orientation
  71382. */
  71383. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  71384. /**
  71385. * Nothing
  71386. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71387. */
  71388. static readonly ACTION_NothingTrigger: number;
  71389. /**
  71390. * On pick
  71391. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71392. */
  71393. static readonly ACTION_OnPickTrigger: number;
  71394. /**
  71395. * On left pick
  71396. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71397. */
  71398. static readonly ACTION_OnLeftPickTrigger: number;
  71399. /**
  71400. * On right pick
  71401. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71402. */
  71403. static readonly ACTION_OnRightPickTrigger: number;
  71404. /**
  71405. * On center pick
  71406. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71407. */
  71408. static readonly ACTION_OnCenterPickTrigger: number;
  71409. /**
  71410. * On pick down
  71411. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71412. */
  71413. static readonly ACTION_OnPickDownTrigger: number;
  71414. /**
  71415. * On double pick
  71416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71417. */
  71418. static readonly ACTION_OnDoublePickTrigger: number;
  71419. /**
  71420. * On pick up
  71421. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71422. */
  71423. static readonly ACTION_OnPickUpTrigger: number;
  71424. /**
  71425. * On pick out.
  71426. * This trigger will only be raised if you also declared a OnPickDown
  71427. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71428. */
  71429. static readonly ACTION_OnPickOutTrigger: number;
  71430. /**
  71431. * On long press
  71432. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71433. */
  71434. static readonly ACTION_OnLongPressTrigger: number;
  71435. /**
  71436. * On pointer over
  71437. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71438. */
  71439. static readonly ACTION_OnPointerOverTrigger: number;
  71440. /**
  71441. * On pointer out
  71442. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71443. */
  71444. static readonly ACTION_OnPointerOutTrigger: number;
  71445. /**
  71446. * On every frame
  71447. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71448. */
  71449. static readonly ACTION_OnEveryFrameTrigger: number;
  71450. /**
  71451. * On intersection enter
  71452. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71453. */
  71454. static readonly ACTION_OnIntersectionEnterTrigger: number;
  71455. /**
  71456. * On intersection exit
  71457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71458. */
  71459. static readonly ACTION_OnIntersectionExitTrigger: number;
  71460. /**
  71461. * On key down
  71462. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71463. */
  71464. static readonly ACTION_OnKeyDownTrigger: number;
  71465. /**
  71466. * On key up
  71467. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  71468. */
  71469. static readonly ACTION_OnKeyUpTrigger: number;
  71470. /**
  71471. * Billboard mode will only apply to Y axis
  71472. */
  71473. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  71474. /**
  71475. * Billboard mode will apply to all axes
  71476. */
  71477. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  71478. /**
  71479. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  71480. */
  71481. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  71482. /**
  71483. * Gets or sets base Assets URL
  71484. */
  71485. static PARTICLES_BaseAssetsUrl: string;
  71486. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  71487. * Test order :
  71488. * Is the bounding sphere outside the frustum ?
  71489. * If not, are the bounding box vertices outside the frustum ?
  71490. * It not, then the cullable object is in the frustum.
  71491. */
  71492. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  71493. /** Culling strategy : Bounding Sphere Only.
  71494. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  71495. * It's also less accurate than the standard because some not visible objects can still be selected.
  71496. * Test : is the bounding sphere outside the frustum ?
  71497. * If not, then the cullable object is in the frustum.
  71498. */
  71499. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  71500. /** Culling strategy : Optimistic Inclusion.
  71501. * This in an inclusion test first, then the standard exclusion test.
  71502. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  71503. * 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.
  71504. * Anyway, it's as accurate as the standard strategy.
  71505. * Test :
  71506. * Is the cullable object bounding sphere center in the frustum ?
  71507. * If not, apply the default culling strategy.
  71508. */
  71509. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  71510. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  71511. * This in an inclusion test first, then the bounding sphere only exclusion test.
  71512. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  71513. * 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.
  71514. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  71515. * Test :
  71516. * Is the cullable object bounding sphere center in the frustum ?
  71517. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  71518. */
  71519. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  71520. /**
  71521. * No logging while loading
  71522. */
  71523. static readonly SCENELOADER_NO_LOGGING: number;
  71524. /**
  71525. * Minimal logging while loading
  71526. */
  71527. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  71528. /**
  71529. * Summary logging while loading
  71530. */
  71531. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  71532. /**
  71533. * Detailled logging while loading
  71534. */
  71535. static readonly SCENELOADER_DETAILED_LOGGING: number;
  71536. }
  71537. }
  71538. declare module BABYLON {
  71539. /**
  71540. * This represents the required contract to create a new type of texture loader.
  71541. */
  71542. export interface IInternalTextureLoader {
  71543. /**
  71544. * Defines wether the loader supports cascade loading the different faces.
  71545. */
  71546. supportCascades: boolean;
  71547. /**
  71548. * This returns if the loader support the current file information.
  71549. * @param extension defines the file extension of the file being loaded
  71550. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71551. * @param fallback defines the fallback internal texture if any
  71552. * @param isBase64 defines whether the texture is encoded as a base64
  71553. * @param isBuffer defines whether the texture data are stored as a buffer
  71554. * @returns true if the loader can load the specified file
  71555. */
  71556. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  71557. /**
  71558. * Transform the url before loading if required.
  71559. * @param rootUrl the url of the texture
  71560. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71561. * @returns the transformed texture
  71562. */
  71563. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  71564. /**
  71565. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  71566. * @param rootUrl the url of the texture
  71567. * @param textureFormatInUse defines the current compressed format in use iun the engine
  71568. * @returns the fallback texture
  71569. */
  71570. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  71571. /**
  71572. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  71573. * @param data contains the texture data
  71574. * @param texture defines the BabylonJS internal texture
  71575. * @param createPolynomials will be true if polynomials have been requested
  71576. * @param onLoad defines the callback to trigger once the texture is ready
  71577. * @param onError defines the callback to trigger in case of error
  71578. */
  71579. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  71580. /**
  71581. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  71582. * @param data contains the texture data
  71583. * @param texture defines the BabylonJS internal texture
  71584. * @param callback defines the method to call once ready to upload
  71585. */
  71586. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  71587. }
  71588. }
  71589. declare module BABYLON {
  71590. /**
  71591. * Class used to store and describe the pipeline context associated with an effect
  71592. */
  71593. export interface IPipelineContext {
  71594. /**
  71595. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  71596. */
  71597. isAsync: boolean;
  71598. /**
  71599. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  71600. */
  71601. isReady: boolean;
  71602. /** @hidden */
  71603. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  71604. }
  71605. }
  71606. declare module BABYLON {
  71607. /**
  71608. * Class used to store gfx data (like WebGLBuffer)
  71609. */
  71610. export class DataBuffer {
  71611. /**
  71612. * Gets or sets the number of objects referencing this buffer
  71613. */
  71614. references: number;
  71615. /** Gets or sets the size of the underlying buffer */
  71616. capacity: number;
  71617. /**
  71618. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  71619. */
  71620. is32Bits: boolean;
  71621. /**
  71622. * Gets the underlying buffer
  71623. */
  71624. readonly underlyingResource: any;
  71625. }
  71626. }
  71627. declare module BABYLON {
  71628. /** @hidden */
  71629. export interface IShaderProcessor {
  71630. attributeProcessor?: (attribute: string) => string;
  71631. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  71632. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  71633. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  71634. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  71635. lineProcessor?: (line: string, isFragment: boolean) => string;
  71636. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71637. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  71638. }
  71639. }
  71640. declare module BABYLON {
  71641. /** @hidden */
  71642. export interface ProcessingOptions {
  71643. defines: string[];
  71644. indexParameters: any;
  71645. isFragment: boolean;
  71646. shouldUseHighPrecisionShader: boolean;
  71647. supportsUniformBuffers: boolean;
  71648. shadersRepository: string;
  71649. includesShadersStore: {
  71650. [key: string]: string;
  71651. };
  71652. processor?: IShaderProcessor;
  71653. version: string;
  71654. platformName: string;
  71655. lookForClosingBracketForUniformBuffer?: boolean;
  71656. }
  71657. }
  71658. declare module BABYLON {
  71659. /**
  71660. * Helper to manipulate strings
  71661. */
  71662. export class StringTools {
  71663. /**
  71664. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  71665. * @param str Source string
  71666. * @param suffix Suffix to search for in the source string
  71667. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71668. */
  71669. static EndsWith(str: string, suffix: string): boolean;
  71670. /**
  71671. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  71672. * @param str Source string
  71673. * @param suffix Suffix to search for in the source string
  71674. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  71675. */
  71676. static StartsWith(str: string, suffix: string): boolean;
  71677. }
  71678. }
  71679. declare module BABYLON {
  71680. /** @hidden */
  71681. export class ShaderCodeNode {
  71682. line: string;
  71683. children: ShaderCodeNode[];
  71684. additionalDefineKey?: string;
  71685. additionalDefineValue?: string;
  71686. isValid(preprocessors: {
  71687. [key: string]: string;
  71688. }): boolean;
  71689. process(preprocessors: {
  71690. [key: string]: string;
  71691. }, options: ProcessingOptions): string;
  71692. }
  71693. }
  71694. declare module BABYLON {
  71695. /** @hidden */
  71696. export class ShaderCodeCursor {
  71697. private _lines;
  71698. lineIndex: number;
  71699. readonly currentLine: string;
  71700. readonly canRead: boolean;
  71701. lines: string[];
  71702. }
  71703. }
  71704. declare module BABYLON {
  71705. /** @hidden */
  71706. export class ShaderCodeConditionNode extends ShaderCodeNode {
  71707. process(preprocessors: {
  71708. [key: string]: string;
  71709. }, options: ProcessingOptions): string;
  71710. }
  71711. }
  71712. declare module BABYLON {
  71713. /** @hidden */
  71714. export class ShaderDefineExpression {
  71715. isTrue(preprocessors: {
  71716. [key: string]: string;
  71717. }): boolean;
  71718. }
  71719. }
  71720. declare module BABYLON {
  71721. /** @hidden */
  71722. export class ShaderCodeTestNode extends ShaderCodeNode {
  71723. testExpression: ShaderDefineExpression;
  71724. isValid(preprocessors: {
  71725. [key: string]: string;
  71726. }): boolean;
  71727. }
  71728. }
  71729. declare module BABYLON {
  71730. /** @hidden */
  71731. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  71732. define: string;
  71733. not: boolean;
  71734. constructor(define: string, not?: boolean);
  71735. isTrue(preprocessors: {
  71736. [key: string]: string;
  71737. }): boolean;
  71738. }
  71739. }
  71740. declare module BABYLON {
  71741. /** @hidden */
  71742. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  71743. leftOperand: ShaderDefineExpression;
  71744. rightOperand: ShaderDefineExpression;
  71745. isTrue(preprocessors: {
  71746. [key: string]: string;
  71747. }): boolean;
  71748. }
  71749. }
  71750. declare module BABYLON {
  71751. /** @hidden */
  71752. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  71753. leftOperand: ShaderDefineExpression;
  71754. rightOperand: ShaderDefineExpression;
  71755. isTrue(preprocessors: {
  71756. [key: string]: string;
  71757. }): boolean;
  71758. }
  71759. }
  71760. declare module BABYLON {
  71761. /** @hidden */
  71762. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  71763. define: string;
  71764. operand: string;
  71765. testValue: string;
  71766. constructor(define: string, operand: string, testValue: string);
  71767. isTrue(preprocessors: {
  71768. [key: string]: string;
  71769. }): boolean;
  71770. }
  71771. }
  71772. declare module BABYLON {
  71773. /**
  71774. * @ignore
  71775. * Application error to support additional information when loading a file
  71776. */
  71777. export class LoadFileError extends Error {
  71778. /** defines the optional web request */
  71779. request?: WebRequest | undefined;
  71780. private static _setPrototypeOf;
  71781. /**
  71782. * Creates a new LoadFileError
  71783. * @param message defines the message of the error
  71784. * @param request defines the optional web request
  71785. */
  71786. constructor(message: string,
  71787. /** defines the optional web request */
  71788. request?: WebRequest | undefined);
  71789. }
  71790. }
  71791. declare module BABYLON {
  71792. /**
  71793. * Class used to enable access to offline support
  71794. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71795. */
  71796. export interface IOfflineProvider {
  71797. /**
  71798. * Gets a boolean indicating if scene must be saved in the database
  71799. */
  71800. enableSceneOffline: boolean;
  71801. /**
  71802. * Gets a boolean indicating if textures must be saved in the database
  71803. */
  71804. enableTexturesOffline: boolean;
  71805. /**
  71806. * Open the offline support and make it available
  71807. * @param successCallback defines the callback to call on success
  71808. * @param errorCallback defines the callback to call on error
  71809. */
  71810. open(successCallback: () => void, errorCallback: () => void): void;
  71811. /**
  71812. * Loads an image from the offline support
  71813. * @param url defines the url to load from
  71814. * @param image defines the target DOM image
  71815. */
  71816. loadImage(url: string, image: HTMLImageElement): void;
  71817. /**
  71818. * Loads a file from offline support
  71819. * @param url defines the URL to load from
  71820. * @param sceneLoaded defines a callback to call on success
  71821. * @param progressCallBack defines a callback to call when progress changed
  71822. * @param errorCallback defines a callback to call on error
  71823. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71824. */
  71825. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71826. }
  71827. }
  71828. declare module BABYLON {
  71829. /**
  71830. * Class used to help managing file picking and drag'n'drop
  71831. * File Storage
  71832. */
  71833. export class FilesInputStore {
  71834. /**
  71835. * List of files ready to be loaded
  71836. */
  71837. static FilesToLoad: {
  71838. [key: string]: File;
  71839. };
  71840. }
  71841. }
  71842. declare module BABYLON {
  71843. /**
  71844. * Class used to define a retry strategy when error happens while loading assets
  71845. */
  71846. export class RetryStrategy {
  71847. /**
  71848. * Function used to defines an exponential back off strategy
  71849. * @param maxRetries defines the maximum number of retries (3 by default)
  71850. * @param baseInterval defines the interval between retries
  71851. * @returns the strategy function to use
  71852. */
  71853. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  71854. }
  71855. }
  71856. declare module BABYLON {
  71857. /**
  71858. * @hidden
  71859. */
  71860. export class FileTools {
  71861. /**
  71862. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  71863. */
  71864. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  71865. /**
  71866. * Gets or sets the base URL to use to load assets
  71867. */
  71868. static BaseUrl: string;
  71869. /**
  71870. * Default behaviour for cors in the application.
  71871. * It can be a string if the expected behavior is identical in the entire app.
  71872. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  71873. */
  71874. static CorsBehavior: string | ((url: string | string[]) => string);
  71875. /**
  71876. * Gets or sets a function used to pre-process url before using them to load assets
  71877. */
  71878. static PreprocessUrl: (url: string) => string;
  71879. /**
  71880. * Removes unwanted characters from an url
  71881. * @param url defines the url to clean
  71882. * @returns the cleaned url
  71883. */
  71884. private static _CleanUrl;
  71885. /**
  71886. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  71887. * @param url define the url we are trying
  71888. * @param element define the dom element where to configure the cors policy
  71889. */
  71890. static SetCorsBehavior(url: string | string[], element: {
  71891. crossOrigin: string | null;
  71892. }): void;
  71893. /**
  71894. * Loads an image as an HTMLImageElement.
  71895. * @param input url string, ArrayBuffer, or Blob to load
  71896. * @param onLoad callback called when the image successfully loads
  71897. * @param onError callback called when the image fails to load
  71898. * @param offlineProvider offline provider for caching
  71899. * @returns the HTMLImageElement of the loaded image
  71900. */
  71901. static LoadImage(input: string | ArrayBuffer | ArrayBufferView | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  71902. /**
  71903. * Loads a file
  71904. * @param fileToLoad defines the file to load
  71905. * @param callback defines the callback to call when data is loaded
  71906. * @param progressCallBack defines the callback to call during loading process
  71907. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  71908. * @returns a file request object
  71909. */
  71910. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  71911. /**
  71912. * Loads a file
  71913. * @param url url string, ArrayBuffer, or Blob to load
  71914. * @param onSuccess callback called when the file successfully loads
  71915. * @param onProgress callback called while file is loading (if the server supports this mode)
  71916. * @param offlineProvider defines the offline provider for caching
  71917. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  71918. * @param onError callback called when the file fails to load
  71919. * @returns a file request object
  71920. */
  71921. 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;
  71922. /**
  71923. * Checks if the loaded document was accessed via `file:`-Protocol.
  71924. * @returns boolean
  71925. */
  71926. static IsFileURL(): boolean;
  71927. }
  71928. }
  71929. declare module BABYLON {
  71930. /** @hidden */
  71931. export class ShaderProcessor {
  71932. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  71933. private static _ProcessPrecision;
  71934. private static _ExtractOperation;
  71935. private static _BuildSubExpression;
  71936. private static _BuildExpression;
  71937. private static _MoveCursorWithinIf;
  71938. private static _MoveCursor;
  71939. private static _EvaluatePreProcessors;
  71940. private static _PreparePreProcessors;
  71941. private static _ProcessShaderConversion;
  71942. private static _ProcessIncludes;
  71943. }
  71944. }
  71945. declare module BABYLON {
  71946. /**
  71947. * Interface used to define common properties for effect fallbacks
  71948. */
  71949. export interface IEffectFallbacks {
  71950. /**
  71951. * Removes the defines that should be removed when falling back.
  71952. * @param currentDefines defines the current define statements for the shader.
  71953. * @param effect defines the current effect we try to compile
  71954. * @returns The resulting defines with defines of the current rank removed.
  71955. */
  71956. reduce(currentDefines: string, effect: Effect): string;
  71957. /**
  71958. * Removes the fallback from the bound mesh.
  71959. */
  71960. unBindMesh(): void;
  71961. /**
  71962. * Checks to see if more fallbacks are still availible.
  71963. */
  71964. hasMoreFallbacks: boolean;
  71965. }
  71966. }
  71967. declare module BABYLON {
  71968. /**
  71969. * Class used to evalaute queries containing `and` and `or` operators
  71970. */
  71971. export class AndOrNotEvaluator {
  71972. /**
  71973. * Evaluate a query
  71974. * @param query defines the query to evaluate
  71975. * @param evaluateCallback defines the callback used to filter result
  71976. * @returns true if the query matches
  71977. */
  71978. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  71979. private static _HandleParenthesisContent;
  71980. private static _SimplifyNegation;
  71981. }
  71982. }
  71983. declare module BABYLON {
  71984. /**
  71985. * Class used to store custom tags
  71986. */
  71987. export class Tags {
  71988. /**
  71989. * Adds support for tags on the given object
  71990. * @param obj defines the object to use
  71991. */
  71992. static EnableFor(obj: any): void;
  71993. /**
  71994. * Removes tags support
  71995. * @param obj defines the object to use
  71996. */
  71997. static DisableFor(obj: any): void;
  71998. /**
  71999. * Gets a boolean indicating if the given object has tags
  72000. * @param obj defines the object to use
  72001. * @returns a boolean
  72002. */
  72003. static HasTags(obj: any): boolean;
  72004. /**
  72005. * Gets the tags available on a given object
  72006. * @param obj defines the object to use
  72007. * @param asString defines if the tags must be returned as a string instead of an array of strings
  72008. * @returns the tags
  72009. */
  72010. static GetTags(obj: any, asString?: boolean): any;
  72011. /**
  72012. * Adds tags to an object
  72013. * @param obj defines the object to use
  72014. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  72015. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  72016. */
  72017. static AddTagsTo(obj: any, tagsString: string): void;
  72018. /**
  72019. * @hidden
  72020. */
  72021. static _AddTagTo(obj: any, tag: string): void;
  72022. /**
  72023. * Removes specific tags from a specific object
  72024. * @param obj defines the object to use
  72025. * @param tagsString defines the tags to remove
  72026. */
  72027. static RemoveTagsFrom(obj: any, tagsString: string): void;
  72028. /**
  72029. * @hidden
  72030. */
  72031. static _RemoveTagFrom(obj: any, tag: string): void;
  72032. /**
  72033. * Defines if tags hosted on an object match a given query
  72034. * @param obj defines the object to use
  72035. * @param tagsQuery defines the tag query
  72036. * @returns a boolean
  72037. */
  72038. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  72039. }
  72040. }
  72041. declare module BABYLON {
  72042. /**
  72043. * Defines potential orientation for back face culling
  72044. */
  72045. export enum Orientation {
  72046. /**
  72047. * Clockwise
  72048. */
  72049. CW = 0,
  72050. /** Counter clockwise */
  72051. CCW = 1
  72052. }
  72053. /** Class used to represent a Bezier curve */
  72054. export class BezierCurve {
  72055. /**
  72056. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  72057. * @param t defines the time
  72058. * @param x1 defines the left coordinate on X axis
  72059. * @param y1 defines the left coordinate on Y axis
  72060. * @param x2 defines the right coordinate on X axis
  72061. * @param y2 defines the right coordinate on Y axis
  72062. * @returns the interpolated value
  72063. */
  72064. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  72065. }
  72066. /**
  72067. * Defines angle representation
  72068. */
  72069. export class Angle {
  72070. private _radians;
  72071. /**
  72072. * Creates an Angle object of "radians" radians (float).
  72073. * @param radians the angle in radians
  72074. */
  72075. constructor(radians: number);
  72076. /**
  72077. * Get value in degrees
  72078. * @returns the Angle value in degrees (float)
  72079. */
  72080. degrees(): number;
  72081. /**
  72082. * Get value in radians
  72083. * @returns the Angle value in radians (float)
  72084. */
  72085. radians(): number;
  72086. /**
  72087. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  72088. * @param a defines first vector
  72089. * @param b defines second vector
  72090. * @returns a new Angle
  72091. */
  72092. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  72093. /**
  72094. * Gets a new Angle object from the given float in radians
  72095. * @param radians defines the angle value in radians
  72096. * @returns a new Angle
  72097. */
  72098. static FromRadians(radians: number): Angle;
  72099. /**
  72100. * Gets a new Angle object from the given float in degrees
  72101. * @param degrees defines the angle value in degrees
  72102. * @returns a new Angle
  72103. */
  72104. static FromDegrees(degrees: number): Angle;
  72105. }
  72106. /**
  72107. * This represents an arc in a 2d space.
  72108. */
  72109. export class Arc2 {
  72110. /** Defines the start point of the arc */
  72111. startPoint: Vector2;
  72112. /** Defines the mid point of the arc */
  72113. midPoint: Vector2;
  72114. /** Defines the end point of the arc */
  72115. endPoint: Vector2;
  72116. /**
  72117. * Defines the center point of the arc.
  72118. */
  72119. centerPoint: Vector2;
  72120. /**
  72121. * Defines the radius of the arc.
  72122. */
  72123. radius: number;
  72124. /**
  72125. * Defines the angle of the arc (from mid point to end point).
  72126. */
  72127. angle: Angle;
  72128. /**
  72129. * Defines the start angle of the arc (from start point to middle point).
  72130. */
  72131. startAngle: Angle;
  72132. /**
  72133. * Defines the orientation of the arc (clock wise/counter clock wise).
  72134. */
  72135. orientation: Orientation;
  72136. /**
  72137. * Creates an Arc object from the three given points : start, middle and end.
  72138. * @param startPoint Defines the start point of the arc
  72139. * @param midPoint Defines the midlle point of the arc
  72140. * @param endPoint Defines the end point of the arc
  72141. */
  72142. constructor(
  72143. /** Defines the start point of the arc */
  72144. startPoint: Vector2,
  72145. /** Defines the mid point of the arc */
  72146. midPoint: Vector2,
  72147. /** Defines the end point of the arc */
  72148. endPoint: Vector2);
  72149. }
  72150. /**
  72151. * Represents a 2D path made up of multiple 2D points
  72152. */
  72153. export class Path2 {
  72154. private _points;
  72155. private _length;
  72156. /**
  72157. * If the path start and end point are the same
  72158. */
  72159. closed: boolean;
  72160. /**
  72161. * Creates a Path2 object from the starting 2D coordinates x and y.
  72162. * @param x the starting points x value
  72163. * @param y the starting points y value
  72164. */
  72165. constructor(x: number, y: number);
  72166. /**
  72167. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  72168. * @param x the added points x value
  72169. * @param y the added points y value
  72170. * @returns the updated Path2.
  72171. */
  72172. addLineTo(x: number, y: number): Path2;
  72173. /**
  72174. * 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.
  72175. * @param midX middle point x value
  72176. * @param midY middle point y value
  72177. * @param endX end point x value
  72178. * @param endY end point y value
  72179. * @param numberOfSegments (default: 36)
  72180. * @returns the updated Path2.
  72181. */
  72182. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  72183. /**
  72184. * Closes the Path2.
  72185. * @returns the Path2.
  72186. */
  72187. close(): Path2;
  72188. /**
  72189. * Gets the sum of the distance between each sequential point in the path
  72190. * @returns the Path2 total length (float).
  72191. */
  72192. length(): number;
  72193. /**
  72194. * Gets the points which construct the path
  72195. * @returns the Path2 internal array of points.
  72196. */
  72197. getPoints(): Vector2[];
  72198. /**
  72199. * Retreives the point at the distance aways from the starting point
  72200. * @param normalizedLengthPosition the length along the path to retreive the point from
  72201. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  72202. */
  72203. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  72204. /**
  72205. * Creates a new path starting from an x and y position
  72206. * @param x starting x value
  72207. * @param y starting y value
  72208. * @returns a new Path2 starting at the coordinates (x, y).
  72209. */
  72210. static StartingAt(x: number, y: number): Path2;
  72211. }
  72212. /**
  72213. * Represents a 3D path made up of multiple 3D points
  72214. */
  72215. export class Path3D {
  72216. /**
  72217. * an array of Vector3, the curve axis of the Path3D
  72218. */
  72219. path: Vector3[];
  72220. private _curve;
  72221. private _distances;
  72222. private _tangents;
  72223. private _normals;
  72224. private _binormals;
  72225. private _raw;
  72226. /**
  72227. * new Path3D(path, normal, raw)
  72228. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  72229. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  72230. * @param path an array of Vector3, the curve axis of the Path3D
  72231. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  72232. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  72233. */
  72234. constructor(
  72235. /**
  72236. * an array of Vector3, the curve axis of the Path3D
  72237. */
  72238. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  72239. /**
  72240. * Returns the Path3D array of successive Vector3 designing its curve.
  72241. * @returns the Path3D array of successive Vector3 designing its curve.
  72242. */
  72243. getCurve(): Vector3[];
  72244. /**
  72245. * Returns an array populated with tangent vectors on each Path3D curve point.
  72246. * @returns an array populated with tangent vectors on each Path3D curve point.
  72247. */
  72248. getTangents(): Vector3[];
  72249. /**
  72250. * Returns an array populated with normal vectors on each Path3D curve point.
  72251. * @returns an array populated with normal vectors on each Path3D curve point.
  72252. */
  72253. getNormals(): Vector3[];
  72254. /**
  72255. * Returns an array populated with binormal vectors on each Path3D curve point.
  72256. * @returns an array populated with binormal vectors on each Path3D curve point.
  72257. */
  72258. getBinormals(): Vector3[];
  72259. /**
  72260. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  72261. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  72262. */
  72263. getDistances(): number[];
  72264. /**
  72265. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  72266. * @param path path which all values are copied into the curves points
  72267. * @param firstNormal which should be projected onto the curve
  72268. * @returns the same object updated.
  72269. */
  72270. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  72271. private _compute;
  72272. private _getFirstNonNullVector;
  72273. private _getLastNonNullVector;
  72274. private _normalVector;
  72275. }
  72276. /**
  72277. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72278. * A Curve3 is designed from a series of successive Vector3.
  72279. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  72280. */
  72281. export class Curve3 {
  72282. private _points;
  72283. private _length;
  72284. /**
  72285. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  72286. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  72287. * @param v1 (Vector3) the control point
  72288. * @param v2 (Vector3) the end point of the Quadratic Bezier
  72289. * @param nbPoints (integer) the wanted number of points in the curve
  72290. * @returns the created Curve3
  72291. */
  72292. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72293. /**
  72294. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  72295. * @param v0 (Vector3) the origin point of the Cubic Bezier
  72296. * @param v1 (Vector3) the first control point
  72297. * @param v2 (Vector3) the second control point
  72298. * @param v3 (Vector3) the end point of the Cubic Bezier
  72299. * @param nbPoints (integer) the wanted number of points in the curve
  72300. * @returns the created Curve3
  72301. */
  72302. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72303. /**
  72304. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  72305. * @param p1 (Vector3) the origin point of the Hermite Spline
  72306. * @param t1 (Vector3) the tangent vector at the origin point
  72307. * @param p2 (Vector3) the end point of the Hermite Spline
  72308. * @param t2 (Vector3) the tangent vector at the end point
  72309. * @param nbPoints (integer) the wanted number of points in the curve
  72310. * @returns the created Curve3
  72311. */
  72312. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  72313. /**
  72314. * Returns a Curve3 object along a CatmullRom Spline curve :
  72315. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  72316. * @param nbPoints (integer) the wanted number of points between each curve control points
  72317. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  72318. * @returns the created Curve3
  72319. */
  72320. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  72321. /**
  72322. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  72323. * A Curve3 is designed from a series of successive Vector3.
  72324. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  72325. * @param points points which make up the curve
  72326. */
  72327. constructor(points: Vector3[]);
  72328. /**
  72329. * @returns the Curve3 stored array of successive Vector3
  72330. */
  72331. getPoints(): Vector3[];
  72332. /**
  72333. * @returns the computed length (float) of the curve.
  72334. */
  72335. length(): number;
  72336. /**
  72337. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  72338. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  72339. * curveA and curveB keep unchanged.
  72340. * @param curve the curve to continue from this curve
  72341. * @returns the newly constructed curve
  72342. */
  72343. continue(curve: DeepImmutable<Curve3>): Curve3;
  72344. private _computeLength;
  72345. }
  72346. }
  72347. declare module BABYLON {
  72348. /**
  72349. * This represents the main contract an easing function should follow.
  72350. * Easing functions are used throughout the animation system.
  72351. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72352. */
  72353. export interface IEasingFunction {
  72354. /**
  72355. * Given an input gradient between 0 and 1, this returns the corrseponding value
  72356. * of the easing function.
  72357. * The link below provides some of the most common examples of easing functions.
  72358. * @see https://easings.net/
  72359. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72360. * @returns the corresponding value on the curve defined by the easing function
  72361. */
  72362. ease(gradient: number): number;
  72363. }
  72364. /**
  72365. * Base class used for every default easing function.
  72366. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72367. */
  72368. export class EasingFunction implements IEasingFunction {
  72369. /**
  72370. * Interpolation follows the mathematical formula associated with the easing function.
  72371. */
  72372. static readonly EASINGMODE_EASEIN: number;
  72373. /**
  72374. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  72375. */
  72376. static readonly EASINGMODE_EASEOUT: number;
  72377. /**
  72378. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  72379. */
  72380. static readonly EASINGMODE_EASEINOUT: number;
  72381. private _easingMode;
  72382. /**
  72383. * Sets the easing mode of the current function.
  72384. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  72385. */
  72386. setEasingMode(easingMode: number): void;
  72387. /**
  72388. * Gets the current easing mode.
  72389. * @returns the easing mode
  72390. */
  72391. getEasingMode(): number;
  72392. /**
  72393. * @hidden
  72394. */
  72395. easeInCore(gradient: number): number;
  72396. /**
  72397. * Given an input gradient between 0 and 1, this returns the corresponding value
  72398. * of the easing function.
  72399. * @param gradient Defines the value between 0 and 1 we want the easing value for
  72400. * @returns the corresponding value on the curve defined by the easing function
  72401. */
  72402. ease(gradient: number): number;
  72403. }
  72404. /**
  72405. * Easing function with a circle shape (see link below).
  72406. * @see https://easings.net/#easeInCirc
  72407. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72408. */
  72409. export class CircleEase extends EasingFunction implements IEasingFunction {
  72410. /** @hidden */
  72411. easeInCore(gradient: number): number;
  72412. }
  72413. /**
  72414. * Easing function with a ease back shape (see link below).
  72415. * @see https://easings.net/#easeInBack
  72416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72417. */
  72418. export class BackEase extends EasingFunction implements IEasingFunction {
  72419. /** Defines the amplitude of the function */
  72420. amplitude: number;
  72421. /**
  72422. * Instantiates a back ease easing
  72423. * @see https://easings.net/#easeInBack
  72424. * @param amplitude Defines the amplitude of the function
  72425. */
  72426. constructor(
  72427. /** Defines the amplitude of the function */
  72428. amplitude?: number);
  72429. /** @hidden */
  72430. easeInCore(gradient: number): number;
  72431. }
  72432. /**
  72433. * Easing function with a bouncing shape (see link below).
  72434. * @see https://easings.net/#easeInBounce
  72435. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72436. */
  72437. export class BounceEase extends EasingFunction implements IEasingFunction {
  72438. /** Defines the number of bounces */
  72439. bounces: number;
  72440. /** Defines the amplitude of the bounce */
  72441. bounciness: number;
  72442. /**
  72443. * Instantiates a bounce easing
  72444. * @see https://easings.net/#easeInBounce
  72445. * @param bounces Defines the number of bounces
  72446. * @param bounciness Defines the amplitude of the bounce
  72447. */
  72448. constructor(
  72449. /** Defines the number of bounces */
  72450. bounces?: number,
  72451. /** Defines the amplitude of the bounce */
  72452. bounciness?: number);
  72453. /** @hidden */
  72454. easeInCore(gradient: number): number;
  72455. }
  72456. /**
  72457. * Easing function with a power of 3 shape (see link below).
  72458. * @see https://easings.net/#easeInCubic
  72459. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72460. */
  72461. export class CubicEase extends EasingFunction implements IEasingFunction {
  72462. /** @hidden */
  72463. easeInCore(gradient: number): number;
  72464. }
  72465. /**
  72466. * Easing function with an elastic shape (see link below).
  72467. * @see https://easings.net/#easeInElastic
  72468. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72469. */
  72470. export class ElasticEase extends EasingFunction implements IEasingFunction {
  72471. /** Defines the number of oscillations*/
  72472. oscillations: number;
  72473. /** Defines the amplitude of the oscillations*/
  72474. springiness: number;
  72475. /**
  72476. * Instantiates an elastic easing function
  72477. * @see https://easings.net/#easeInElastic
  72478. * @param oscillations Defines the number of oscillations
  72479. * @param springiness Defines the amplitude of the oscillations
  72480. */
  72481. constructor(
  72482. /** Defines the number of oscillations*/
  72483. oscillations?: number,
  72484. /** Defines the amplitude of the oscillations*/
  72485. springiness?: number);
  72486. /** @hidden */
  72487. easeInCore(gradient: number): number;
  72488. }
  72489. /**
  72490. * Easing function with an exponential shape (see link below).
  72491. * @see https://easings.net/#easeInExpo
  72492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72493. */
  72494. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  72495. /** Defines the exponent of the function */
  72496. exponent: number;
  72497. /**
  72498. * Instantiates an exponential easing function
  72499. * @see https://easings.net/#easeInExpo
  72500. * @param exponent Defines the exponent of the function
  72501. */
  72502. constructor(
  72503. /** Defines the exponent of the function */
  72504. exponent?: number);
  72505. /** @hidden */
  72506. easeInCore(gradient: number): number;
  72507. }
  72508. /**
  72509. * Easing function with a power shape (see link below).
  72510. * @see https://easings.net/#easeInQuad
  72511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72512. */
  72513. export class PowerEase extends EasingFunction implements IEasingFunction {
  72514. /** Defines the power of the function */
  72515. power: number;
  72516. /**
  72517. * Instantiates an power base easing function
  72518. * @see https://easings.net/#easeInQuad
  72519. * @param power Defines the power of the function
  72520. */
  72521. constructor(
  72522. /** Defines the power of the function */
  72523. power?: number);
  72524. /** @hidden */
  72525. easeInCore(gradient: number): number;
  72526. }
  72527. /**
  72528. * Easing function with a power of 2 shape (see link below).
  72529. * @see https://easings.net/#easeInQuad
  72530. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72531. */
  72532. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  72533. /** @hidden */
  72534. easeInCore(gradient: number): number;
  72535. }
  72536. /**
  72537. * Easing function with a power of 4 shape (see link below).
  72538. * @see https://easings.net/#easeInQuart
  72539. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72540. */
  72541. export class QuarticEase extends EasingFunction implements IEasingFunction {
  72542. /** @hidden */
  72543. easeInCore(gradient: number): number;
  72544. }
  72545. /**
  72546. * Easing function with a power of 5 shape (see link below).
  72547. * @see https://easings.net/#easeInQuint
  72548. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72549. */
  72550. export class QuinticEase extends EasingFunction implements IEasingFunction {
  72551. /** @hidden */
  72552. easeInCore(gradient: number): number;
  72553. }
  72554. /**
  72555. * Easing function with a sin shape (see link below).
  72556. * @see https://easings.net/#easeInSine
  72557. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72558. */
  72559. export class SineEase extends EasingFunction implements IEasingFunction {
  72560. /** @hidden */
  72561. easeInCore(gradient: number): number;
  72562. }
  72563. /**
  72564. * Easing function with a bezier shape (see link below).
  72565. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72566. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  72567. */
  72568. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  72569. /** Defines the x component of the start tangent in the bezier curve */
  72570. x1: number;
  72571. /** Defines the y component of the start tangent in the bezier curve */
  72572. y1: number;
  72573. /** Defines the x component of the end tangent in the bezier curve */
  72574. x2: number;
  72575. /** Defines the y component of the end tangent in the bezier curve */
  72576. y2: number;
  72577. /**
  72578. * Instantiates a bezier function
  72579. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  72580. * @param x1 Defines the x component of the start tangent in the bezier curve
  72581. * @param y1 Defines the y component of the start tangent in the bezier curve
  72582. * @param x2 Defines the x component of the end tangent in the bezier curve
  72583. * @param y2 Defines the y component of the end tangent in the bezier curve
  72584. */
  72585. constructor(
  72586. /** Defines the x component of the start tangent in the bezier curve */
  72587. x1?: number,
  72588. /** Defines the y component of the start tangent in the bezier curve */
  72589. y1?: number,
  72590. /** Defines the x component of the end tangent in the bezier curve */
  72591. x2?: number,
  72592. /** Defines the y component of the end tangent in the bezier curve */
  72593. y2?: number);
  72594. /** @hidden */
  72595. easeInCore(gradient: number): number;
  72596. }
  72597. }
  72598. declare module BABYLON {
  72599. /**
  72600. * Defines an interface which represents an animation key frame
  72601. */
  72602. export interface IAnimationKey {
  72603. /**
  72604. * Frame of the key frame
  72605. */
  72606. frame: number;
  72607. /**
  72608. * Value at the specifies key frame
  72609. */
  72610. value: any;
  72611. /**
  72612. * The input tangent for the cubic hermite spline
  72613. */
  72614. inTangent?: any;
  72615. /**
  72616. * The output tangent for the cubic hermite spline
  72617. */
  72618. outTangent?: any;
  72619. /**
  72620. * The animation interpolation type
  72621. */
  72622. interpolation?: AnimationKeyInterpolation;
  72623. }
  72624. /**
  72625. * Enum for the animation key frame interpolation type
  72626. */
  72627. export enum AnimationKeyInterpolation {
  72628. /**
  72629. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  72630. */
  72631. STEP = 1
  72632. }
  72633. }
  72634. declare module BABYLON {
  72635. /**
  72636. * Represents the range of an animation
  72637. */
  72638. export class AnimationRange {
  72639. /**The name of the animation range**/
  72640. name: string;
  72641. /**The starting frame of the animation */
  72642. from: number;
  72643. /**The ending frame of the animation*/
  72644. to: number;
  72645. /**
  72646. * Initializes the range of an animation
  72647. * @param name The name of the animation range
  72648. * @param from The starting frame of the animation
  72649. * @param to The ending frame of the animation
  72650. */
  72651. constructor(
  72652. /**The name of the animation range**/
  72653. name: string,
  72654. /**The starting frame of the animation */
  72655. from: number,
  72656. /**The ending frame of the animation*/
  72657. to: number);
  72658. /**
  72659. * Makes a copy of the animation range
  72660. * @returns A copy of the animation range
  72661. */
  72662. clone(): AnimationRange;
  72663. }
  72664. }
  72665. declare module BABYLON {
  72666. /**
  72667. * Composed of a frame, and an action function
  72668. */
  72669. export class AnimationEvent {
  72670. /** The frame for which the event is triggered **/
  72671. frame: number;
  72672. /** The event to perform when triggered **/
  72673. action: (currentFrame: number) => void;
  72674. /** Specifies if the event should be triggered only once**/
  72675. onlyOnce?: boolean | undefined;
  72676. /**
  72677. * Specifies if the animation event is done
  72678. */
  72679. isDone: boolean;
  72680. /**
  72681. * Initializes the animation event
  72682. * @param frame The frame for which the event is triggered
  72683. * @param action The event to perform when triggered
  72684. * @param onlyOnce Specifies if the event should be triggered only once
  72685. */
  72686. constructor(
  72687. /** The frame for which the event is triggered **/
  72688. frame: number,
  72689. /** The event to perform when triggered **/
  72690. action: (currentFrame: number) => void,
  72691. /** Specifies if the event should be triggered only once**/
  72692. onlyOnce?: boolean | undefined);
  72693. /** @hidden */
  72694. _clone(): AnimationEvent;
  72695. }
  72696. }
  72697. declare module BABYLON {
  72698. /**
  72699. * Interface used to define a behavior
  72700. */
  72701. export interface Behavior<T> {
  72702. /** gets or sets behavior's name */
  72703. name: string;
  72704. /**
  72705. * Function called when the behavior needs to be initialized (after attaching it to a target)
  72706. */
  72707. init(): void;
  72708. /**
  72709. * Called when the behavior is attached to a target
  72710. * @param target defines the target where the behavior is attached to
  72711. */
  72712. attach(target: T): void;
  72713. /**
  72714. * Called when the behavior is detached from its target
  72715. */
  72716. detach(): void;
  72717. }
  72718. /**
  72719. * Interface implemented by classes supporting behaviors
  72720. */
  72721. export interface IBehaviorAware<T> {
  72722. /**
  72723. * Attach a behavior
  72724. * @param behavior defines the behavior to attach
  72725. * @returns the current host
  72726. */
  72727. addBehavior(behavior: Behavior<T>): T;
  72728. /**
  72729. * Remove a behavior from the current object
  72730. * @param behavior defines the behavior to detach
  72731. * @returns the current host
  72732. */
  72733. removeBehavior(behavior: Behavior<T>): T;
  72734. /**
  72735. * Gets a behavior using its name to search
  72736. * @param name defines the name to search
  72737. * @returns the behavior or null if not found
  72738. */
  72739. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  72740. }
  72741. }
  72742. declare module BABYLON {
  72743. /**
  72744. * Defines an array and its length.
  72745. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  72746. */
  72747. export interface ISmartArrayLike<T> {
  72748. /**
  72749. * The data of the array.
  72750. */
  72751. data: Array<T>;
  72752. /**
  72753. * The active length of the array.
  72754. */
  72755. length: number;
  72756. }
  72757. /**
  72758. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72759. */
  72760. export class SmartArray<T> implements ISmartArrayLike<T> {
  72761. /**
  72762. * The full set of data from the array.
  72763. */
  72764. data: Array<T>;
  72765. /**
  72766. * The active length of the array.
  72767. */
  72768. length: number;
  72769. protected _id: number;
  72770. /**
  72771. * Instantiates a Smart Array.
  72772. * @param capacity defines the default capacity of the array.
  72773. */
  72774. constructor(capacity: number);
  72775. /**
  72776. * Pushes a value at the end of the active data.
  72777. * @param value defines the object to push in the array.
  72778. */
  72779. push(value: T): void;
  72780. /**
  72781. * Iterates over the active data and apply the lambda to them.
  72782. * @param func defines the action to apply on each value.
  72783. */
  72784. forEach(func: (content: T) => void): void;
  72785. /**
  72786. * Sorts the full sets of data.
  72787. * @param compareFn defines the comparison function to apply.
  72788. */
  72789. sort(compareFn: (a: T, b: T) => number): void;
  72790. /**
  72791. * Resets the active data to an empty array.
  72792. */
  72793. reset(): void;
  72794. /**
  72795. * Releases all the data from the array as well as the array.
  72796. */
  72797. dispose(): void;
  72798. /**
  72799. * Concats the active data with a given array.
  72800. * @param array defines the data to concatenate with.
  72801. */
  72802. concat(array: any): void;
  72803. /**
  72804. * Returns the position of a value in the active data.
  72805. * @param value defines the value to find the index for
  72806. * @returns the index if found in the active data otherwise -1
  72807. */
  72808. indexOf(value: T): number;
  72809. /**
  72810. * Returns whether an element is part of the active data.
  72811. * @param value defines the value to look for
  72812. * @returns true if found in the active data otherwise false
  72813. */
  72814. contains(value: T): boolean;
  72815. private static _GlobalId;
  72816. }
  72817. /**
  72818. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  72819. * The data in this array can only be present once
  72820. */
  72821. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  72822. private _duplicateId;
  72823. /**
  72824. * Pushes a value at the end of the active data.
  72825. * THIS DOES NOT PREVENT DUPPLICATE DATA
  72826. * @param value defines the object to push in the array.
  72827. */
  72828. push(value: T): void;
  72829. /**
  72830. * Pushes a value at the end of the active data.
  72831. * If the data is already present, it won t be added again
  72832. * @param value defines the object to push in the array.
  72833. * @returns true if added false if it was already present
  72834. */
  72835. pushNoDuplicate(value: T): boolean;
  72836. /**
  72837. * Resets the active data to an empty array.
  72838. */
  72839. reset(): void;
  72840. /**
  72841. * Concats the active data with a given array.
  72842. * This ensures no dupplicate will be present in the result.
  72843. * @param array defines the data to concatenate with.
  72844. */
  72845. concatWithNoDuplicate(array: any): void;
  72846. }
  72847. }
  72848. declare module BABYLON {
  72849. /**
  72850. * @ignore
  72851. * This is a list of all the different input types that are available in the application.
  72852. * Fo instance: ArcRotateCameraGamepadInput...
  72853. */
  72854. export var CameraInputTypes: {};
  72855. /**
  72856. * This is the contract to implement in order to create a new input class.
  72857. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  72858. */
  72859. export interface ICameraInput<TCamera extends Camera> {
  72860. /**
  72861. * Defines the camera the input is attached to.
  72862. */
  72863. camera: Nullable<TCamera>;
  72864. /**
  72865. * Gets the class name of the current intput.
  72866. * @returns the class name
  72867. */
  72868. getClassName(): string;
  72869. /**
  72870. * Get the friendly name associated with the input class.
  72871. * @returns the input friendly name
  72872. */
  72873. getSimpleName(): string;
  72874. /**
  72875. * Attach the input controls to a specific dom element to get the input from.
  72876. * @param element Defines the element the controls should be listened from
  72877. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72878. */
  72879. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72880. /**
  72881. * Detach the current controls from the specified dom element.
  72882. * @param element Defines the element to stop listening the inputs from
  72883. */
  72884. detachControl(element: Nullable<HTMLElement>): void;
  72885. /**
  72886. * Update the current camera state depending on the inputs that have been used this frame.
  72887. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72888. */
  72889. checkInputs?: () => void;
  72890. }
  72891. /**
  72892. * Represents a map of input types to input instance or input index to input instance.
  72893. */
  72894. export interface CameraInputsMap<TCamera extends Camera> {
  72895. /**
  72896. * Accessor to the input by input type.
  72897. */
  72898. [name: string]: ICameraInput<TCamera>;
  72899. /**
  72900. * Accessor to the input by input index.
  72901. */
  72902. [idx: number]: ICameraInput<TCamera>;
  72903. }
  72904. /**
  72905. * This represents the input manager used within a camera.
  72906. * It helps dealing with all the different kind of input attached to a camera.
  72907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72908. */
  72909. export class CameraInputsManager<TCamera extends Camera> {
  72910. /**
  72911. * Defines the list of inputs attahed to the camera.
  72912. */
  72913. attached: CameraInputsMap<TCamera>;
  72914. /**
  72915. * Defines the dom element the camera is collecting inputs from.
  72916. * This is null if the controls have not been attached.
  72917. */
  72918. attachedElement: Nullable<HTMLElement>;
  72919. /**
  72920. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72921. */
  72922. noPreventDefault: boolean;
  72923. /**
  72924. * Defined the camera the input manager belongs to.
  72925. */
  72926. camera: TCamera;
  72927. /**
  72928. * Update the current camera state depending on the inputs that have been used this frame.
  72929. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  72930. */
  72931. checkInputs: () => void;
  72932. /**
  72933. * Instantiate a new Camera Input Manager.
  72934. * @param camera Defines the camera the input manager blongs to
  72935. */
  72936. constructor(camera: TCamera);
  72937. /**
  72938. * Add an input method to a camera
  72939. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  72940. * @param input camera input method
  72941. */
  72942. add(input: ICameraInput<TCamera>): void;
  72943. /**
  72944. * Remove a specific input method from a camera
  72945. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  72946. * @param inputToRemove camera input method
  72947. */
  72948. remove(inputToRemove: ICameraInput<TCamera>): void;
  72949. /**
  72950. * Remove a specific input type from a camera
  72951. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  72952. * @param inputType the type of the input to remove
  72953. */
  72954. removeByType(inputType: string): void;
  72955. private _addCheckInputs;
  72956. /**
  72957. * Attach the input controls to the currently attached dom element to listen the events from.
  72958. * @param input Defines the input to attach
  72959. */
  72960. attachInput(input: ICameraInput<TCamera>): void;
  72961. /**
  72962. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  72963. * @param element Defines the dom element to collect the events from
  72964. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  72965. */
  72966. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  72967. /**
  72968. * Detach the current manager inputs controls from a specific dom element.
  72969. * @param element Defines the dom element to collect the events from
  72970. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  72971. */
  72972. detachElement(element: HTMLElement, disconnect?: boolean): void;
  72973. /**
  72974. * Rebuild the dynamic inputCheck function from the current list of
  72975. * defined inputs in the manager.
  72976. */
  72977. rebuildInputCheck(): void;
  72978. /**
  72979. * Remove all attached input methods from a camera
  72980. */
  72981. clear(): void;
  72982. /**
  72983. * Serialize the current input manager attached to a camera.
  72984. * This ensures than once parsed,
  72985. * the input associated to the camera will be identical to the current ones
  72986. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  72987. */
  72988. serialize(serializedCamera: any): void;
  72989. /**
  72990. * Parses an input manager serialized JSON to restore the previous list of inputs
  72991. * and states associated to a camera.
  72992. * @param parsedCamera Defines the JSON to parse
  72993. */
  72994. parse(parsedCamera: any): void;
  72995. }
  72996. }
  72997. declare module BABYLON {
  72998. /**
  72999. * Class used to store data that will be store in GPU memory
  73000. */
  73001. export class Buffer {
  73002. private _engine;
  73003. private _buffer;
  73004. /** @hidden */
  73005. _data: Nullable<DataArray>;
  73006. private _updatable;
  73007. private _instanced;
  73008. /**
  73009. * Gets the byte stride.
  73010. */
  73011. readonly byteStride: number;
  73012. /**
  73013. * Constructor
  73014. * @param engine the engine
  73015. * @param data the data to use for this buffer
  73016. * @param updatable whether the data is updatable
  73017. * @param stride the stride (optional)
  73018. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73019. * @param instanced whether the buffer is instanced (optional)
  73020. * @param useBytes set to true if the stride in in bytes (optional)
  73021. */
  73022. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  73023. /**
  73024. * Create a new VertexBuffer based on the current buffer
  73025. * @param kind defines the vertex buffer kind (position, normal, etc.)
  73026. * @param offset defines offset in the buffer (0 by default)
  73027. * @param size defines the size in floats of attributes (position is 3 for instance)
  73028. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  73029. * @param instanced defines if the vertex buffer contains indexed data
  73030. * @param useBytes defines if the offset and stride are in bytes
  73031. * @returns the new vertex buffer
  73032. */
  73033. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  73034. /**
  73035. * Gets a boolean indicating if the Buffer is updatable?
  73036. * @returns true if the buffer is updatable
  73037. */
  73038. isUpdatable(): boolean;
  73039. /**
  73040. * Gets current buffer's data
  73041. * @returns a DataArray or null
  73042. */
  73043. getData(): Nullable<DataArray>;
  73044. /**
  73045. * Gets underlying native buffer
  73046. * @returns underlying native buffer
  73047. */
  73048. getBuffer(): Nullable<DataBuffer>;
  73049. /**
  73050. * Gets the stride in float32 units (i.e. byte stride / 4).
  73051. * May not be an integer if the byte stride is not divisible by 4.
  73052. * DEPRECATED. Use byteStride instead.
  73053. * @returns the stride in float32 units
  73054. */
  73055. getStrideSize(): number;
  73056. /**
  73057. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73058. * @param data defines the data to store
  73059. */
  73060. create(data?: Nullable<DataArray>): void;
  73061. /** @hidden */
  73062. _rebuild(): void;
  73063. /**
  73064. * Update current buffer data
  73065. * @param data defines the data to store
  73066. */
  73067. update(data: DataArray): void;
  73068. /**
  73069. * Updates the data directly.
  73070. * @param data the new data
  73071. * @param offset the new offset
  73072. * @param vertexCount the vertex count (optional)
  73073. * @param useBytes set to true if the offset is in bytes
  73074. */
  73075. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  73076. /**
  73077. * Release all resources
  73078. */
  73079. dispose(): void;
  73080. }
  73081. /**
  73082. * Specialized buffer used to store vertex data
  73083. */
  73084. export class VertexBuffer {
  73085. /** @hidden */
  73086. _buffer: Buffer;
  73087. private _kind;
  73088. private _size;
  73089. private _ownsBuffer;
  73090. private _instanced;
  73091. private _instanceDivisor;
  73092. /**
  73093. * The byte type.
  73094. */
  73095. static readonly BYTE: number;
  73096. /**
  73097. * The unsigned byte type.
  73098. */
  73099. static readonly UNSIGNED_BYTE: number;
  73100. /**
  73101. * The short type.
  73102. */
  73103. static readonly SHORT: number;
  73104. /**
  73105. * The unsigned short type.
  73106. */
  73107. static readonly UNSIGNED_SHORT: number;
  73108. /**
  73109. * The integer type.
  73110. */
  73111. static readonly INT: number;
  73112. /**
  73113. * The unsigned integer type.
  73114. */
  73115. static readonly UNSIGNED_INT: number;
  73116. /**
  73117. * The float type.
  73118. */
  73119. static readonly FLOAT: number;
  73120. /**
  73121. * Gets or sets the instance divisor when in instanced mode
  73122. */
  73123. instanceDivisor: number;
  73124. /**
  73125. * Gets the byte stride.
  73126. */
  73127. readonly byteStride: number;
  73128. /**
  73129. * Gets the byte offset.
  73130. */
  73131. readonly byteOffset: number;
  73132. /**
  73133. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  73134. */
  73135. readonly normalized: boolean;
  73136. /**
  73137. * Gets the data type of each component in the array.
  73138. */
  73139. readonly type: number;
  73140. /**
  73141. * Constructor
  73142. * @param engine the engine
  73143. * @param data the data to use for this vertex buffer
  73144. * @param kind the vertex buffer kind
  73145. * @param updatable whether the data is updatable
  73146. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  73147. * @param stride the stride (optional)
  73148. * @param instanced whether the buffer is instanced (optional)
  73149. * @param offset the offset of the data (optional)
  73150. * @param size the number of components (optional)
  73151. * @param type the type of the component (optional)
  73152. * @param normalized whether the data contains normalized data (optional)
  73153. * @param useBytes set to true if stride and offset are in bytes (optional)
  73154. */
  73155. 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);
  73156. /** @hidden */
  73157. _rebuild(): void;
  73158. /**
  73159. * Returns the kind of the VertexBuffer (string)
  73160. * @returns a string
  73161. */
  73162. getKind(): string;
  73163. /**
  73164. * Gets a boolean indicating if the VertexBuffer is updatable?
  73165. * @returns true if the buffer is updatable
  73166. */
  73167. isUpdatable(): boolean;
  73168. /**
  73169. * Gets current buffer's data
  73170. * @returns a DataArray or null
  73171. */
  73172. getData(): Nullable<DataArray>;
  73173. /**
  73174. * Gets underlying native buffer
  73175. * @returns underlying native buffer
  73176. */
  73177. getBuffer(): Nullable<DataBuffer>;
  73178. /**
  73179. * Gets the stride in float32 units (i.e. byte stride / 4).
  73180. * May not be an integer if the byte stride is not divisible by 4.
  73181. * DEPRECATED. Use byteStride instead.
  73182. * @returns the stride in float32 units
  73183. */
  73184. getStrideSize(): number;
  73185. /**
  73186. * Returns the offset as a multiple of the type byte length.
  73187. * DEPRECATED. Use byteOffset instead.
  73188. * @returns the offset in bytes
  73189. */
  73190. getOffset(): number;
  73191. /**
  73192. * Returns the number of components per vertex attribute (integer)
  73193. * @returns the size in float
  73194. */
  73195. getSize(): number;
  73196. /**
  73197. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  73198. * @returns true if this buffer is instanced
  73199. */
  73200. getIsInstanced(): boolean;
  73201. /**
  73202. * Returns the instancing divisor, zero for non-instanced (integer).
  73203. * @returns a number
  73204. */
  73205. getInstanceDivisor(): number;
  73206. /**
  73207. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  73208. * @param data defines the data to store
  73209. */
  73210. create(data?: DataArray): void;
  73211. /**
  73212. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  73213. * This function will create a new buffer if the current one is not updatable
  73214. * @param data defines the data to store
  73215. */
  73216. update(data: DataArray): void;
  73217. /**
  73218. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  73219. * Returns the directly updated WebGLBuffer.
  73220. * @param data the new data
  73221. * @param offset the new offset
  73222. * @param useBytes set to true if the offset is in bytes
  73223. */
  73224. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  73225. /**
  73226. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  73227. */
  73228. dispose(): void;
  73229. /**
  73230. * Enumerates each value of this vertex buffer as numbers.
  73231. * @param count the number of values to enumerate
  73232. * @param callback the callback function called for each value
  73233. */
  73234. forEach(count: number, callback: (value: number, index: number) => void): void;
  73235. /**
  73236. * Positions
  73237. */
  73238. static readonly PositionKind: string;
  73239. /**
  73240. * Normals
  73241. */
  73242. static readonly NormalKind: string;
  73243. /**
  73244. * Tangents
  73245. */
  73246. static readonly TangentKind: string;
  73247. /**
  73248. * Texture coordinates
  73249. */
  73250. static readonly UVKind: string;
  73251. /**
  73252. * Texture coordinates 2
  73253. */
  73254. static readonly UV2Kind: string;
  73255. /**
  73256. * Texture coordinates 3
  73257. */
  73258. static readonly UV3Kind: string;
  73259. /**
  73260. * Texture coordinates 4
  73261. */
  73262. static readonly UV4Kind: string;
  73263. /**
  73264. * Texture coordinates 5
  73265. */
  73266. static readonly UV5Kind: string;
  73267. /**
  73268. * Texture coordinates 6
  73269. */
  73270. static readonly UV6Kind: string;
  73271. /**
  73272. * Colors
  73273. */
  73274. static readonly ColorKind: string;
  73275. /**
  73276. * Matrix indices (for bones)
  73277. */
  73278. static readonly MatricesIndicesKind: string;
  73279. /**
  73280. * Matrix weights (for bones)
  73281. */
  73282. static readonly MatricesWeightsKind: string;
  73283. /**
  73284. * Additional matrix indices (for bones)
  73285. */
  73286. static readonly MatricesIndicesExtraKind: string;
  73287. /**
  73288. * Additional matrix weights (for bones)
  73289. */
  73290. static readonly MatricesWeightsExtraKind: string;
  73291. /**
  73292. * Deduces the stride given a kind.
  73293. * @param kind The kind string to deduce
  73294. * @returns The deduced stride
  73295. */
  73296. static DeduceStride(kind: string): number;
  73297. /**
  73298. * Gets the byte length of the given type.
  73299. * @param type the type
  73300. * @returns the number of bytes
  73301. */
  73302. static GetTypeByteLength(type: number): number;
  73303. /**
  73304. * Enumerates each value of the given parameters as numbers.
  73305. * @param data the data to enumerate
  73306. * @param byteOffset the byte offset of the data
  73307. * @param byteStride the byte stride of the data
  73308. * @param componentCount the number of components per element
  73309. * @param componentType the type of the component
  73310. * @param count the number of values to enumerate
  73311. * @param normalized whether the data is normalized
  73312. * @param callback the callback function called for each value
  73313. */
  73314. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  73315. private static _GetFloatValue;
  73316. }
  73317. }
  73318. declare module BABYLON {
  73319. /**
  73320. * @hidden
  73321. */
  73322. export class IntersectionInfo {
  73323. bu: Nullable<number>;
  73324. bv: Nullable<number>;
  73325. distance: number;
  73326. faceId: number;
  73327. subMeshId: number;
  73328. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  73329. }
  73330. }
  73331. declare module BABYLON {
  73332. /**
  73333. * Represens a plane by the equation ax + by + cz + d = 0
  73334. */
  73335. export class Plane {
  73336. private static _TmpMatrix;
  73337. /**
  73338. * Normal of the plane (a,b,c)
  73339. */
  73340. normal: Vector3;
  73341. /**
  73342. * d component of the plane
  73343. */
  73344. d: number;
  73345. /**
  73346. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73347. * @param a a component of the plane
  73348. * @param b b component of the plane
  73349. * @param c c component of the plane
  73350. * @param d d component of the plane
  73351. */
  73352. constructor(a: number, b: number, c: number, d: number);
  73353. /**
  73354. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73355. */
  73356. asArray(): number[];
  73357. /**
  73358. * @returns a new plane copied from the current Plane.
  73359. */
  73360. clone(): Plane;
  73361. /**
  73362. * @returns the string "Plane".
  73363. */
  73364. getClassName(): string;
  73365. /**
  73366. * @returns the Plane hash code.
  73367. */
  73368. getHashCode(): number;
  73369. /**
  73370. * Normalize the current Plane in place.
  73371. * @returns the updated Plane.
  73372. */
  73373. normalize(): Plane;
  73374. /**
  73375. * Applies a transformation the plane and returns the result
  73376. * @param transformation the transformation matrix to be applied to the plane
  73377. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73378. */
  73379. transform(transformation: DeepImmutable<Matrix>): Plane;
  73380. /**
  73381. * Calcualtte the dot product between the point and the plane normal
  73382. * @param point point to calculate the dot product with
  73383. * @returns the dot product (float) of the point coordinates and the plane normal.
  73384. */
  73385. dotCoordinate(point: DeepImmutable<Vector3>): number;
  73386. /**
  73387. * Updates the current Plane from the plane defined by the three given points.
  73388. * @param point1 one of the points used to contruct the plane
  73389. * @param point2 one of the points used to contruct the plane
  73390. * @param point3 one of the points used to contruct the plane
  73391. * @returns the updated Plane.
  73392. */
  73393. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73394. /**
  73395. * Checks if the plane is facing a given direction
  73396. * @param direction the direction to check if the plane is facing
  73397. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73398. * @returns True is the vector "direction" is the same side than the plane normal.
  73399. */
  73400. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  73401. /**
  73402. * Calculates the distance to a point
  73403. * @param point point to calculate distance to
  73404. * @returns the signed distance (float) from the given point to the Plane.
  73405. */
  73406. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  73407. /**
  73408. * Creates a plane from an array
  73409. * @param array the array to create a plane from
  73410. * @returns a new Plane from the given array.
  73411. */
  73412. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  73413. /**
  73414. * Creates a plane from three points
  73415. * @param point1 point used to create the plane
  73416. * @param point2 point used to create the plane
  73417. * @param point3 point used to create the plane
  73418. * @returns a new Plane defined by the three given points.
  73419. */
  73420. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  73421. /**
  73422. * Creates a plane from an origin point and a normal
  73423. * @param origin origin of the plane to be constructed
  73424. * @param normal normal of the plane to be constructed
  73425. * @returns a new Plane the normal vector to this plane at the given origin point.
  73426. * Note : the vector "normal" is updated because normalized.
  73427. */
  73428. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  73429. /**
  73430. * Calculates the distance from a plane and a point
  73431. * @param origin origin of the plane to be constructed
  73432. * @param normal normal of the plane to be constructed
  73433. * @param point point to calculate distance to
  73434. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  73435. */
  73436. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  73437. }
  73438. }
  73439. declare module BABYLON {
  73440. /**
  73441. * Class used to store bounding sphere information
  73442. */
  73443. export class BoundingSphere {
  73444. /**
  73445. * Gets the center of the bounding sphere in local space
  73446. */
  73447. readonly center: Vector3;
  73448. /**
  73449. * Radius of the bounding sphere in local space
  73450. */
  73451. radius: number;
  73452. /**
  73453. * Gets the center of the bounding sphere in world space
  73454. */
  73455. readonly centerWorld: Vector3;
  73456. /**
  73457. * Radius of the bounding sphere in world space
  73458. */
  73459. radiusWorld: number;
  73460. /**
  73461. * Gets the minimum vector in local space
  73462. */
  73463. readonly minimum: Vector3;
  73464. /**
  73465. * Gets the maximum vector in local space
  73466. */
  73467. readonly maximum: Vector3;
  73468. private _worldMatrix;
  73469. private static readonly TmpVector3;
  73470. /**
  73471. * Creates a new bounding sphere
  73472. * @param min defines the minimum vector (in local space)
  73473. * @param max defines the maximum vector (in local space)
  73474. * @param worldMatrix defines the new world matrix
  73475. */
  73476. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73477. /**
  73478. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  73479. * @param min defines the new minimum vector (in local space)
  73480. * @param max defines the new maximum vector (in local space)
  73481. * @param worldMatrix defines the new world matrix
  73482. */
  73483. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73484. /**
  73485. * Scale the current bounding sphere by applying a scale factor
  73486. * @param factor defines the scale factor to apply
  73487. * @returns the current bounding box
  73488. */
  73489. scale(factor: number): BoundingSphere;
  73490. /**
  73491. * Gets the world matrix of the bounding box
  73492. * @returns a matrix
  73493. */
  73494. getWorldMatrix(): DeepImmutable<Matrix>;
  73495. /** @hidden */
  73496. _update(worldMatrix: DeepImmutable<Matrix>): void;
  73497. /**
  73498. * Tests if the bounding sphere is intersecting the frustum planes
  73499. * @param frustumPlanes defines the frustum planes to test
  73500. * @returns true if there is an intersection
  73501. */
  73502. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73503. /**
  73504. * Tests if the bounding sphere center is in between the frustum planes.
  73505. * Used for optimistic fast inclusion.
  73506. * @param frustumPlanes defines the frustum planes to test
  73507. * @returns true if the sphere center is in between the frustum planes
  73508. */
  73509. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73510. /**
  73511. * Tests if a point is inside the bounding sphere
  73512. * @param point defines the point to test
  73513. * @returns true if the point is inside the bounding sphere
  73514. */
  73515. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73516. /**
  73517. * Checks if two sphere intersct
  73518. * @param sphere0 sphere 0
  73519. * @param sphere1 sphere 1
  73520. * @returns true if the speres intersect
  73521. */
  73522. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  73523. }
  73524. }
  73525. declare module BABYLON {
  73526. /**
  73527. * Class used to store bounding box information
  73528. */
  73529. export class BoundingBox implements ICullable {
  73530. /**
  73531. * Gets the 8 vectors representing the bounding box in local space
  73532. */
  73533. readonly vectors: Vector3[];
  73534. /**
  73535. * Gets the center of the bounding box in local space
  73536. */
  73537. readonly center: Vector3;
  73538. /**
  73539. * Gets the center of the bounding box in world space
  73540. */
  73541. readonly centerWorld: Vector3;
  73542. /**
  73543. * Gets the extend size in local space
  73544. */
  73545. readonly extendSize: Vector3;
  73546. /**
  73547. * Gets the extend size in world space
  73548. */
  73549. readonly extendSizeWorld: Vector3;
  73550. /**
  73551. * Gets the OBB (object bounding box) directions
  73552. */
  73553. readonly directions: Vector3[];
  73554. /**
  73555. * Gets the 8 vectors representing the bounding box in world space
  73556. */
  73557. readonly vectorsWorld: Vector3[];
  73558. /**
  73559. * Gets the minimum vector in world space
  73560. */
  73561. readonly minimumWorld: Vector3;
  73562. /**
  73563. * Gets the maximum vector in world space
  73564. */
  73565. readonly maximumWorld: Vector3;
  73566. /**
  73567. * Gets the minimum vector in local space
  73568. */
  73569. readonly minimum: Vector3;
  73570. /**
  73571. * Gets the maximum vector in local space
  73572. */
  73573. readonly maximum: Vector3;
  73574. private _worldMatrix;
  73575. private static readonly TmpVector3;
  73576. /**
  73577. * @hidden
  73578. */
  73579. _tag: number;
  73580. /**
  73581. * Creates a new bounding box
  73582. * @param min defines the minimum vector (in local space)
  73583. * @param max defines the maximum vector (in local space)
  73584. * @param worldMatrix defines the new world matrix
  73585. */
  73586. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73587. /**
  73588. * Recreates the entire bounding box from scratch as if we call the constructor in place
  73589. * @param min defines the new minimum vector (in local space)
  73590. * @param max defines the new maximum vector (in local space)
  73591. * @param worldMatrix defines the new world matrix
  73592. */
  73593. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73594. /**
  73595. * Scale the current bounding box by applying a scale factor
  73596. * @param factor defines the scale factor to apply
  73597. * @returns the current bounding box
  73598. */
  73599. scale(factor: number): BoundingBox;
  73600. /**
  73601. * Gets the world matrix of the bounding box
  73602. * @returns a matrix
  73603. */
  73604. getWorldMatrix(): DeepImmutable<Matrix>;
  73605. /** @hidden */
  73606. _update(world: DeepImmutable<Matrix>): void;
  73607. /**
  73608. * Tests if the bounding box is intersecting the frustum planes
  73609. * @param frustumPlanes defines the frustum planes to test
  73610. * @returns true if there is an intersection
  73611. */
  73612. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73613. /**
  73614. * Tests if the bounding box is entirely inside the frustum planes
  73615. * @param frustumPlanes defines the frustum planes to test
  73616. * @returns true if there is an inclusion
  73617. */
  73618. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73619. /**
  73620. * Tests if a point is inside the bounding box
  73621. * @param point defines the point to test
  73622. * @returns true if the point is inside the bounding box
  73623. */
  73624. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73625. /**
  73626. * Tests if the bounding box intersects with a bounding sphere
  73627. * @param sphere defines the sphere to test
  73628. * @returns true if there is an intersection
  73629. */
  73630. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  73631. /**
  73632. * Tests if the bounding box intersects with a box defined by a min and max vectors
  73633. * @param min defines the min vector to use
  73634. * @param max defines the max vector to use
  73635. * @returns true if there is an intersection
  73636. */
  73637. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  73638. /**
  73639. * Tests if two bounding boxes are intersections
  73640. * @param box0 defines the first box to test
  73641. * @param box1 defines the second box to test
  73642. * @returns true if there is an intersection
  73643. */
  73644. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  73645. /**
  73646. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  73647. * @param minPoint defines the minimum vector of the bounding box
  73648. * @param maxPoint defines the maximum vector of the bounding box
  73649. * @param sphereCenter defines the sphere center
  73650. * @param sphereRadius defines the sphere radius
  73651. * @returns true if there is an intersection
  73652. */
  73653. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  73654. /**
  73655. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  73656. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73657. * @param frustumPlanes defines the frustum planes to test
  73658. * @return true if there is an inclusion
  73659. */
  73660. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73661. /**
  73662. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  73663. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  73664. * @param frustumPlanes defines the frustum planes to test
  73665. * @return true if there is an intersection
  73666. */
  73667. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73668. }
  73669. }
  73670. declare module BABYLON {
  73671. /** @hidden */
  73672. export class Collider {
  73673. /** Define if a collision was found */
  73674. collisionFound: boolean;
  73675. /**
  73676. * Define last intersection point in local space
  73677. */
  73678. intersectionPoint: Vector3;
  73679. /**
  73680. * Define last collided mesh
  73681. */
  73682. collidedMesh: Nullable<AbstractMesh>;
  73683. private _collisionPoint;
  73684. private _planeIntersectionPoint;
  73685. private _tempVector;
  73686. private _tempVector2;
  73687. private _tempVector3;
  73688. private _tempVector4;
  73689. private _edge;
  73690. private _baseToVertex;
  73691. private _destinationPoint;
  73692. private _slidePlaneNormal;
  73693. private _displacementVector;
  73694. /** @hidden */
  73695. _radius: Vector3;
  73696. /** @hidden */
  73697. _retry: number;
  73698. private _velocity;
  73699. private _basePoint;
  73700. private _epsilon;
  73701. /** @hidden */
  73702. _velocityWorldLength: number;
  73703. /** @hidden */
  73704. _basePointWorld: Vector3;
  73705. private _velocityWorld;
  73706. private _normalizedVelocity;
  73707. /** @hidden */
  73708. _initialVelocity: Vector3;
  73709. /** @hidden */
  73710. _initialPosition: Vector3;
  73711. private _nearestDistance;
  73712. private _collisionMask;
  73713. collisionMask: number;
  73714. /**
  73715. * Gets the plane normal used to compute the sliding response (in local space)
  73716. */
  73717. readonly slidePlaneNormal: Vector3;
  73718. /** @hidden */
  73719. _initialize(source: Vector3, dir: Vector3, e: number): void;
  73720. /** @hidden */
  73721. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  73722. /** @hidden */
  73723. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  73724. /** @hidden */
  73725. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73726. /** @hidden */
  73727. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  73728. /** @hidden */
  73729. _getResponse(pos: Vector3, vel: Vector3): void;
  73730. }
  73731. }
  73732. declare module BABYLON {
  73733. /**
  73734. * Interface for cullable objects
  73735. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  73736. */
  73737. export interface ICullable {
  73738. /**
  73739. * Checks if the object or part of the object is in the frustum
  73740. * @param frustumPlanes Camera near/planes
  73741. * @returns true if the object is in frustum otherwise false
  73742. */
  73743. isInFrustum(frustumPlanes: Plane[]): boolean;
  73744. /**
  73745. * Checks if a cullable object (mesh...) is in the camera frustum
  73746. * Unlike isInFrustum this cheks the full bounding box
  73747. * @param frustumPlanes Camera near/planes
  73748. * @returns true if the object is in frustum otherwise false
  73749. */
  73750. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  73751. }
  73752. /**
  73753. * Info for a bounding data of a mesh
  73754. */
  73755. export class BoundingInfo implements ICullable {
  73756. /**
  73757. * Bounding box for the mesh
  73758. */
  73759. readonly boundingBox: BoundingBox;
  73760. /**
  73761. * Bounding sphere for the mesh
  73762. */
  73763. readonly boundingSphere: BoundingSphere;
  73764. private _isLocked;
  73765. private static readonly TmpVector3;
  73766. /**
  73767. * Constructs bounding info
  73768. * @param minimum min vector of the bounding box/sphere
  73769. * @param maximum max vector of the bounding box/sphere
  73770. * @param worldMatrix defines the new world matrix
  73771. */
  73772. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  73773. /**
  73774. * Recreates the entire bounding info from scratch as if we call the constructor in place
  73775. * @param min defines the new minimum vector (in local space)
  73776. * @param max defines the new maximum vector (in local space)
  73777. * @param worldMatrix defines the new world matrix
  73778. */
  73779. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  73780. /**
  73781. * min vector of the bounding box/sphere
  73782. */
  73783. readonly minimum: Vector3;
  73784. /**
  73785. * max vector of the bounding box/sphere
  73786. */
  73787. readonly maximum: Vector3;
  73788. /**
  73789. * If the info is locked and won't be updated to avoid perf overhead
  73790. */
  73791. isLocked: boolean;
  73792. /**
  73793. * Updates the bounding sphere and box
  73794. * @param world world matrix to be used to update
  73795. */
  73796. update(world: DeepImmutable<Matrix>): void;
  73797. /**
  73798. * Recreate the bounding info to be centered around a specific point given a specific extend.
  73799. * @param center New center of the bounding info
  73800. * @param extend New extend of the bounding info
  73801. * @returns the current bounding info
  73802. */
  73803. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  73804. /**
  73805. * Scale the current bounding info by applying a scale factor
  73806. * @param factor defines the scale factor to apply
  73807. * @returns the current bounding info
  73808. */
  73809. scale(factor: number): BoundingInfo;
  73810. /**
  73811. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  73812. * @param frustumPlanes defines the frustum to test
  73813. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  73814. * @returns true if the bounding info is in the frustum planes
  73815. */
  73816. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  73817. /**
  73818. * Gets the world distance between the min and max points of the bounding box
  73819. */
  73820. readonly diagonalLength: number;
  73821. /**
  73822. * Checks if a cullable object (mesh...) is in the camera frustum
  73823. * Unlike isInFrustum this cheks the full bounding box
  73824. * @param frustumPlanes Camera near/planes
  73825. * @returns true if the object is in frustum otherwise false
  73826. */
  73827. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  73828. /** @hidden */
  73829. _checkCollision(collider: Collider): boolean;
  73830. /**
  73831. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  73832. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73833. * @param point the point to check intersection with
  73834. * @returns if the point intersects
  73835. */
  73836. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  73837. /**
  73838. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  73839. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  73840. * @param boundingInfo the bounding info to check intersection with
  73841. * @param precise if the intersection should be done using OBB
  73842. * @returns if the bounding info intersects
  73843. */
  73844. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  73845. }
  73846. }
  73847. declare module BABYLON {
  73848. /**
  73849. * Extracts minimum and maximum values from a list of indexed positions
  73850. * @param positions defines the positions to use
  73851. * @param indices defines the indices to the positions
  73852. * @param indexStart defines the start index
  73853. * @param indexCount defines the end index
  73854. * @param bias defines bias value to add to the result
  73855. * @return minimum and maximum values
  73856. */
  73857. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  73858. minimum: Vector3;
  73859. maximum: Vector3;
  73860. };
  73861. /**
  73862. * Extracts minimum and maximum values from a list of positions
  73863. * @param positions defines the positions to use
  73864. * @param start defines the start index in the positions array
  73865. * @param count defines the number of positions to handle
  73866. * @param bias defines bias value to add to the result
  73867. * @param stride defines the stride size to use (distance between two positions in the positions array)
  73868. * @return minimum and maximum values
  73869. */
  73870. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  73871. minimum: Vector3;
  73872. maximum: Vector3;
  73873. };
  73874. }
  73875. declare module BABYLON {
  73876. /** @hidden */
  73877. export class WebGLDataBuffer extends DataBuffer {
  73878. private _buffer;
  73879. constructor(resource: WebGLBuffer);
  73880. readonly underlyingResource: any;
  73881. }
  73882. }
  73883. declare module BABYLON {
  73884. /** @hidden */
  73885. export class WebGLPipelineContext implements IPipelineContext {
  73886. engine: ThinEngine;
  73887. program: Nullable<WebGLProgram>;
  73888. context?: WebGLRenderingContext;
  73889. vertexShader?: WebGLShader;
  73890. fragmentShader?: WebGLShader;
  73891. isParallelCompiled: boolean;
  73892. onCompiled?: () => void;
  73893. transformFeedback?: WebGLTransformFeedback | null;
  73894. readonly isAsync: boolean;
  73895. readonly isReady: boolean;
  73896. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  73897. }
  73898. }
  73899. declare module BABYLON {
  73900. interface ThinEngine {
  73901. /**
  73902. * Create an uniform buffer
  73903. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73904. * @param elements defines the content of the uniform buffer
  73905. * @returns the webGL uniform buffer
  73906. */
  73907. createUniformBuffer(elements: FloatArray): DataBuffer;
  73908. /**
  73909. * Create a dynamic uniform buffer
  73910. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73911. * @param elements defines the content of the uniform buffer
  73912. * @returns the webGL uniform buffer
  73913. */
  73914. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  73915. /**
  73916. * Update an existing uniform buffer
  73917. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  73918. * @param uniformBuffer defines the target uniform buffer
  73919. * @param elements defines the content to update
  73920. * @param offset defines the offset in the uniform buffer where update should start
  73921. * @param count defines the size of the data to update
  73922. */
  73923. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  73924. /**
  73925. * Bind an uniform buffer to the current webGL context
  73926. * @param buffer defines the buffer to bind
  73927. */
  73928. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  73929. /**
  73930. * Bind a buffer to the current webGL context at a given location
  73931. * @param buffer defines the buffer to bind
  73932. * @param location defines the index where to bind the buffer
  73933. */
  73934. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  73935. /**
  73936. * Bind a specific block at a given index in a specific shader program
  73937. * @param pipelineContext defines the pipeline context to use
  73938. * @param blockName defines the block name
  73939. * @param index defines the index where to bind the block
  73940. */
  73941. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  73942. }
  73943. }
  73944. declare module BABYLON {
  73945. /**
  73946. * Uniform buffer objects.
  73947. *
  73948. * Handles blocks of uniform on the GPU.
  73949. *
  73950. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  73951. *
  73952. * For more information, please refer to :
  73953. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  73954. */
  73955. export class UniformBuffer {
  73956. private _engine;
  73957. private _buffer;
  73958. private _data;
  73959. private _bufferData;
  73960. private _dynamic?;
  73961. private _uniformLocations;
  73962. private _uniformSizes;
  73963. private _uniformLocationPointer;
  73964. private _needSync;
  73965. private _noUBO;
  73966. private _currentEffect;
  73967. private static _MAX_UNIFORM_SIZE;
  73968. private static _tempBuffer;
  73969. /**
  73970. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  73971. * This is dynamic to allow compat with webgl 1 and 2.
  73972. * You will need to pass the name of the uniform as well as the value.
  73973. */
  73974. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  73975. /**
  73976. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  73977. * This is dynamic to allow compat with webgl 1 and 2.
  73978. * You will need to pass the name of the uniform as well as the value.
  73979. */
  73980. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  73981. /**
  73982. * Lambda to Update a single float in a uniform buffer.
  73983. * This is dynamic to allow compat with webgl 1 and 2.
  73984. * You will need to pass the name of the uniform as well as the value.
  73985. */
  73986. updateFloat: (name: string, x: number) => void;
  73987. /**
  73988. * Lambda to Update a vec2 of float in a uniform buffer.
  73989. * This is dynamic to allow compat with webgl 1 and 2.
  73990. * You will need to pass the name of the uniform as well as the value.
  73991. */
  73992. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  73993. /**
  73994. * Lambda to Update a vec3 of float in a uniform buffer.
  73995. * This is dynamic to allow compat with webgl 1 and 2.
  73996. * You will need to pass the name of the uniform as well as the value.
  73997. */
  73998. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  73999. /**
  74000. * Lambda to Update a vec4 of float in a uniform buffer.
  74001. * This is dynamic to allow compat with webgl 1 and 2.
  74002. * You will need to pass the name of the uniform as well as the value.
  74003. */
  74004. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  74005. /**
  74006. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  74007. * This is dynamic to allow compat with webgl 1 and 2.
  74008. * You will need to pass the name of the uniform as well as the value.
  74009. */
  74010. updateMatrix: (name: string, mat: Matrix) => void;
  74011. /**
  74012. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  74013. * This is dynamic to allow compat with webgl 1 and 2.
  74014. * You will need to pass the name of the uniform as well as the value.
  74015. */
  74016. updateVector3: (name: string, vector: Vector3) => void;
  74017. /**
  74018. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  74019. * This is dynamic to allow compat with webgl 1 and 2.
  74020. * You will need to pass the name of the uniform as well as the value.
  74021. */
  74022. updateVector4: (name: string, vector: Vector4) => void;
  74023. /**
  74024. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  74025. * This is dynamic to allow compat with webgl 1 and 2.
  74026. * You will need to pass the name of the uniform as well as the value.
  74027. */
  74028. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  74029. /**
  74030. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  74031. * This is dynamic to allow compat with webgl 1 and 2.
  74032. * You will need to pass the name of the uniform as well as the value.
  74033. */
  74034. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  74035. /**
  74036. * Instantiates a new Uniform buffer objects.
  74037. *
  74038. * Handles blocks of uniform on the GPU.
  74039. *
  74040. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  74041. *
  74042. * For more information, please refer to :
  74043. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  74044. * @param engine Define the engine the buffer is associated with
  74045. * @param data Define the data contained in the buffer
  74046. * @param dynamic Define if the buffer is updatable
  74047. */
  74048. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  74049. /**
  74050. * Indicates if the buffer is using the WebGL2 UBO implementation,
  74051. * or just falling back on setUniformXXX calls.
  74052. */
  74053. readonly useUbo: boolean;
  74054. /**
  74055. * Indicates if the WebGL underlying uniform buffer is in sync
  74056. * with the javascript cache data.
  74057. */
  74058. readonly isSync: boolean;
  74059. /**
  74060. * Indicates if the WebGL underlying uniform buffer is dynamic.
  74061. * Also, a dynamic UniformBuffer will disable cache verification and always
  74062. * update the underlying WebGL uniform buffer to the GPU.
  74063. * @returns if Dynamic, otherwise false
  74064. */
  74065. isDynamic(): boolean;
  74066. /**
  74067. * The data cache on JS side.
  74068. * @returns the underlying data as a float array
  74069. */
  74070. getData(): Float32Array;
  74071. /**
  74072. * The underlying WebGL Uniform buffer.
  74073. * @returns the webgl buffer
  74074. */
  74075. getBuffer(): Nullable<DataBuffer>;
  74076. /**
  74077. * std140 layout specifies how to align data within an UBO structure.
  74078. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  74079. * for specs.
  74080. */
  74081. private _fillAlignment;
  74082. /**
  74083. * Adds an uniform in the buffer.
  74084. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  74085. * for the layout to be correct !
  74086. * @param name Name of the uniform, as used in the uniform block in the shader.
  74087. * @param size Data size, or data directly.
  74088. */
  74089. addUniform(name: string, size: number | number[]): void;
  74090. /**
  74091. * Adds a Matrix 4x4 to the uniform buffer.
  74092. * @param name Name of the uniform, as used in the uniform block in the shader.
  74093. * @param mat A 4x4 matrix.
  74094. */
  74095. addMatrix(name: string, mat: Matrix): void;
  74096. /**
  74097. * Adds a vec2 to the uniform buffer.
  74098. * @param name Name of the uniform, as used in the uniform block in the shader.
  74099. * @param x Define the x component value of the vec2
  74100. * @param y Define the y component value of the vec2
  74101. */
  74102. addFloat2(name: string, x: number, y: number): void;
  74103. /**
  74104. * Adds a vec3 to the uniform buffer.
  74105. * @param name Name of the uniform, as used in the uniform block in the shader.
  74106. * @param x Define the x component value of the vec3
  74107. * @param y Define the y component value of the vec3
  74108. * @param z Define the z component value of the vec3
  74109. */
  74110. addFloat3(name: string, x: number, y: number, z: number): void;
  74111. /**
  74112. * Adds a vec3 to the uniform buffer.
  74113. * @param name Name of the uniform, as used in the uniform block in the shader.
  74114. * @param color Define the vec3 from a Color
  74115. */
  74116. addColor3(name: string, color: Color3): void;
  74117. /**
  74118. * Adds a vec4 to the uniform buffer.
  74119. * @param name Name of the uniform, as used in the uniform block in the shader.
  74120. * @param color Define the rgb components from a Color
  74121. * @param alpha Define the a component of the vec4
  74122. */
  74123. addColor4(name: string, color: Color3, alpha: number): void;
  74124. /**
  74125. * Adds a vec3 to the uniform buffer.
  74126. * @param name Name of the uniform, as used in the uniform block in the shader.
  74127. * @param vector Define the vec3 components from a Vector
  74128. */
  74129. addVector3(name: string, vector: Vector3): void;
  74130. /**
  74131. * Adds a Matrix 3x3 to the uniform buffer.
  74132. * @param name Name of the uniform, as used in the uniform block in the shader.
  74133. */
  74134. addMatrix3x3(name: string): void;
  74135. /**
  74136. * Adds a Matrix 2x2 to the uniform buffer.
  74137. * @param name Name of the uniform, as used in the uniform block in the shader.
  74138. */
  74139. addMatrix2x2(name: string): void;
  74140. /**
  74141. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  74142. */
  74143. create(): void;
  74144. /** @hidden */
  74145. _rebuild(): void;
  74146. /**
  74147. * Updates the WebGL Uniform Buffer on the GPU.
  74148. * If the `dynamic` flag is set to true, no cache comparison is done.
  74149. * Otherwise, the buffer will be updated only if the cache differs.
  74150. */
  74151. update(): void;
  74152. /**
  74153. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  74154. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74155. * @param data Define the flattened data
  74156. * @param size Define the size of the data.
  74157. */
  74158. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  74159. private _valueCache;
  74160. private _cacheMatrix;
  74161. private _updateMatrix3x3ForUniform;
  74162. private _updateMatrix3x3ForEffect;
  74163. private _updateMatrix2x2ForEffect;
  74164. private _updateMatrix2x2ForUniform;
  74165. private _updateFloatForEffect;
  74166. private _updateFloatForUniform;
  74167. private _updateFloat2ForEffect;
  74168. private _updateFloat2ForUniform;
  74169. private _updateFloat3ForEffect;
  74170. private _updateFloat3ForUniform;
  74171. private _updateFloat4ForEffect;
  74172. private _updateFloat4ForUniform;
  74173. private _updateMatrixForEffect;
  74174. private _updateMatrixForUniform;
  74175. private _updateVector3ForEffect;
  74176. private _updateVector3ForUniform;
  74177. private _updateVector4ForEffect;
  74178. private _updateVector4ForUniform;
  74179. private _updateColor3ForEffect;
  74180. private _updateColor3ForUniform;
  74181. private _updateColor4ForEffect;
  74182. private _updateColor4ForUniform;
  74183. /**
  74184. * Sets a sampler uniform on the effect.
  74185. * @param name Define the name of the sampler.
  74186. * @param texture Define the texture to set in the sampler
  74187. */
  74188. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  74189. /**
  74190. * Directly updates the value of the uniform in the cache AND on the GPU.
  74191. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  74192. * @param data Define the flattened data
  74193. */
  74194. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  74195. /**
  74196. * Binds this uniform buffer to an effect.
  74197. * @param effect Define the effect to bind the buffer to
  74198. * @param name Name of the uniform block in the shader.
  74199. */
  74200. bindToEffect(effect: Effect, name: string): void;
  74201. /**
  74202. * Disposes the uniform buffer.
  74203. */
  74204. dispose(): void;
  74205. }
  74206. }
  74207. declare module BABYLON {
  74208. /**
  74209. * Enum that determines the text-wrapping mode to use.
  74210. */
  74211. export enum InspectableType {
  74212. /**
  74213. * Checkbox for booleans
  74214. */
  74215. Checkbox = 0,
  74216. /**
  74217. * Sliders for numbers
  74218. */
  74219. Slider = 1,
  74220. /**
  74221. * Vector3
  74222. */
  74223. Vector3 = 2,
  74224. /**
  74225. * Quaternions
  74226. */
  74227. Quaternion = 3,
  74228. /**
  74229. * Color3
  74230. */
  74231. Color3 = 4,
  74232. /**
  74233. * String
  74234. */
  74235. String = 5
  74236. }
  74237. /**
  74238. * Interface used to define custom inspectable properties.
  74239. * This interface is used by the inspector to display custom property grids
  74240. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74241. */
  74242. export interface IInspectable {
  74243. /**
  74244. * Gets the label to display
  74245. */
  74246. label: string;
  74247. /**
  74248. * Gets the name of the property to edit
  74249. */
  74250. propertyName: string;
  74251. /**
  74252. * Gets the type of the editor to use
  74253. */
  74254. type: InspectableType;
  74255. /**
  74256. * Gets the minimum value of the property when using in "slider" mode
  74257. */
  74258. min?: number;
  74259. /**
  74260. * Gets the maximum value of the property when using in "slider" mode
  74261. */
  74262. max?: number;
  74263. /**
  74264. * Gets the setp to use when using in "slider" mode
  74265. */
  74266. step?: number;
  74267. }
  74268. }
  74269. declare module BABYLON {
  74270. /**
  74271. * Class used to provide helper for timing
  74272. */
  74273. export class TimingTools {
  74274. /**
  74275. * Polyfill for setImmediate
  74276. * @param action defines the action to execute after the current execution block
  74277. */
  74278. static SetImmediate(action: () => void): void;
  74279. }
  74280. }
  74281. declare module BABYLON {
  74282. /**
  74283. * Class used to enable instatition of objects by class name
  74284. */
  74285. export class InstantiationTools {
  74286. /**
  74287. * Use this object to register external classes like custom textures or material
  74288. * to allow the laoders to instantiate them
  74289. */
  74290. static RegisteredExternalClasses: {
  74291. [key: string]: Object;
  74292. };
  74293. /**
  74294. * Tries to instantiate a new object from a given class name
  74295. * @param className defines the class name to instantiate
  74296. * @returns the new object or null if the system was not able to do the instantiation
  74297. */
  74298. static Instantiate(className: string): any;
  74299. }
  74300. }
  74301. declare module BABYLON {
  74302. /**
  74303. * Define options used to create a depth texture
  74304. */
  74305. export class DepthTextureCreationOptions {
  74306. /** Specifies whether or not a stencil should be allocated in the texture */
  74307. generateStencil?: boolean;
  74308. /** Specifies whether or not bilinear filtering is enable on the texture */
  74309. bilinearFiltering?: boolean;
  74310. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  74311. comparisonFunction?: number;
  74312. /** Specifies if the created texture is a cube texture */
  74313. isCube?: boolean;
  74314. }
  74315. }
  74316. declare module BABYLON {
  74317. interface ThinEngine {
  74318. /**
  74319. * Creates a depth stencil cube texture.
  74320. * This is only available in WebGL 2.
  74321. * @param size The size of face edge in the cube texture.
  74322. * @param options The options defining the cube texture.
  74323. * @returns The cube texture
  74324. */
  74325. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  74326. /**
  74327. * Creates a cube texture
  74328. * @param rootUrl defines the url where the files to load is located
  74329. * @param scene defines the current scene
  74330. * @param files defines the list of files to load (1 per face)
  74331. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74332. * @param onLoad defines an optional callback raised when the texture is loaded
  74333. * @param onError defines an optional callback raised if there is an issue to load the texture
  74334. * @param format defines the format of the data
  74335. * @param forcedExtension defines the extension to use to pick the right loader
  74336. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74337. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74338. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74339. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  74340. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  74341. * @returns the cube texture as an InternalTexture
  74342. */
  74343. 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;
  74344. /**
  74345. * Creates a cube texture
  74346. * @param rootUrl defines the url where the files to load is located
  74347. * @param scene defines the current scene
  74348. * @param files defines the list of files to load (1 per face)
  74349. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74350. * @param onLoad defines an optional callback raised when the texture is loaded
  74351. * @param onError defines an optional callback raised if there is an issue to load the texture
  74352. * @param format defines the format of the data
  74353. * @param forcedExtension defines the extension to use to pick the right loader
  74354. * @returns the cube texture as an InternalTexture
  74355. */
  74356. 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;
  74357. /**
  74358. * Creates a cube texture
  74359. * @param rootUrl defines the url where the files to load is located
  74360. * @param scene defines the current scene
  74361. * @param files defines the list of files to load (1 per face)
  74362. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  74363. * @param onLoad defines an optional callback raised when the texture is loaded
  74364. * @param onError defines an optional callback raised if there is an issue to load the texture
  74365. * @param format defines the format of the data
  74366. * @param forcedExtension defines the extension to use to pick the right loader
  74367. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  74368. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74369. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74370. * @returns the cube texture as an InternalTexture
  74371. */
  74372. 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;
  74373. /** @hidden */
  74374. _partialLoadFile(url: string, index: number, loadedFiles: (string | ArrayBuffer)[], onfinish: (files: (string | ArrayBuffer)[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74375. /** @hidden */
  74376. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: (string | ArrayBuffer)[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74377. /** @hidden */
  74378. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  74379. /** @hidden */
  74380. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  74381. }
  74382. }
  74383. declare module BABYLON {
  74384. /**
  74385. * Class for creating a cube texture
  74386. */
  74387. export class CubeTexture extends BaseTexture {
  74388. private _delayedOnLoad;
  74389. /**
  74390. * The url of the texture
  74391. */
  74392. url: string;
  74393. /**
  74394. * Gets or sets the center of the bounding box associated with the cube texture.
  74395. * It must define where the camera used to render the texture was set
  74396. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74397. */
  74398. boundingBoxPosition: Vector3;
  74399. private _boundingBoxSize;
  74400. /**
  74401. * Gets or sets the size of the bounding box associated with the cube texture
  74402. * When defined, the cubemap will switch to local mode
  74403. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  74404. * @example https://www.babylonjs-playground.com/#RNASML
  74405. */
  74406. /**
  74407. * Returns the bounding box size
  74408. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  74409. */
  74410. boundingBoxSize: Vector3;
  74411. protected _rotationY: number;
  74412. /**
  74413. * Sets texture matrix rotation angle around Y axis in radians.
  74414. */
  74415. /**
  74416. * Gets texture matrix rotation angle around Y axis radians.
  74417. */
  74418. rotationY: number;
  74419. /**
  74420. * Are mip maps generated for this texture or not.
  74421. */
  74422. readonly noMipmap: boolean;
  74423. private _noMipmap;
  74424. private _files;
  74425. protected _forcedExtension: Nullable<string>;
  74426. private _extensions;
  74427. private _textureMatrix;
  74428. private _format;
  74429. private _createPolynomials;
  74430. /** @hidden */
  74431. _prefiltered: boolean;
  74432. /**
  74433. * Creates a cube texture from an array of image urls
  74434. * @param files defines an array of image urls
  74435. * @param scene defines the hosting scene
  74436. * @param noMipmap specifies if mip maps are not used
  74437. * @returns a cube texture
  74438. */
  74439. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  74440. /**
  74441. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  74442. * @param url defines the url of the prefiltered texture
  74443. * @param scene defines the scene the texture is attached to
  74444. * @param forcedExtension defines the extension of the file if different from the url
  74445. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74446. * @return the prefiltered texture
  74447. */
  74448. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  74449. /**
  74450. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  74451. * as prefiltered data.
  74452. * @param rootUrl defines the url of the texture or the root name of the six images
  74453. * @param scene defines the scene the texture is attached to
  74454. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  74455. * @param noMipmap defines if mipmaps should be created or not
  74456. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  74457. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  74458. * @param onError defines a callback triggered in case of error during load
  74459. * @param format defines the internal format to use for the texture once loaded
  74460. * @param prefiltered defines whether or not the texture is created from prefiltered data
  74461. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  74462. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  74463. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  74464. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  74465. * @return the cube texture
  74466. */
  74467. 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);
  74468. /**
  74469. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  74470. */
  74471. readonly isPrefiltered: boolean;
  74472. /**
  74473. * Get the current class name of the texture useful for serialization or dynamic coding.
  74474. * @returns "CubeTexture"
  74475. */
  74476. getClassName(): string;
  74477. /**
  74478. * Update the url (and optional buffer) of this texture if url was null during construction.
  74479. * @param url the url of the texture
  74480. * @param forcedExtension defines the extension to use
  74481. * @param onLoad callback called when the texture is loaded (defaults to null)
  74482. */
  74483. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  74484. /**
  74485. * Delays loading of the cube texture
  74486. * @param forcedExtension defines the extension to use
  74487. */
  74488. delayLoad(forcedExtension?: string): void;
  74489. /**
  74490. * Returns the reflection texture matrix
  74491. * @returns the reflection texture matrix
  74492. */
  74493. getReflectionTextureMatrix(): Matrix;
  74494. /**
  74495. * Sets the reflection texture matrix
  74496. * @param value Reflection texture matrix
  74497. */
  74498. setReflectionTextureMatrix(value: Matrix): void;
  74499. /**
  74500. * Parses text to create a cube texture
  74501. * @param parsedTexture define the serialized text to read from
  74502. * @param scene defines the hosting scene
  74503. * @param rootUrl defines the root url of the cube texture
  74504. * @returns a cube texture
  74505. */
  74506. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  74507. /**
  74508. * Makes a clone, or deep copy, of the cube texture
  74509. * @returns a new cube texture
  74510. */
  74511. clone(): CubeTexture;
  74512. }
  74513. }
  74514. declare module BABYLON {
  74515. /**
  74516. * Manages the defines for the Material
  74517. */
  74518. export class MaterialDefines {
  74519. /** @hidden */
  74520. protected _keys: string[];
  74521. private _isDirty;
  74522. /** @hidden */
  74523. _renderId: number;
  74524. /** @hidden */
  74525. _areLightsDirty: boolean;
  74526. /** @hidden */
  74527. _areLightsDisposed: boolean;
  74528. /** @hidden */
  74529. _areAttributesDirty: boolean;
  74530. /** @hidden */
  74531. _areTexturesDirty: boolean;
  74532. /** @hidden */
  74533. _areFresnelDirty: boolean;
  74534. /** @hidden */
  74535. _areMiscDirty: boolean;
  74536. /** @hidden */
  74537. _areImageProcessingDirty: boolean;
  74538. /** @hidden */
  74539. _normals: boolean;
  74540. /** @hidden */
  74541. _uvs: boolean;
  74542. /** @hidden */
  74543. _needNormals: boolean;
  74544. /** @hidden */
  74545. _needUVs: boolean;
  74546. [id: string]: any;
  74547. /**
  74548. * Specifies if the material needs to be re-calculated
  74549. */
  74550. readonly isDirty: boolean;
  74551. /**
  74552. * Marks the material to indicate that it has been re-calculated
  74553. */
  74554. markAsProcessed(): void;
  74555. /**
  74556. * Marks the material to indicate that it needs to be re-calculated
  74557. */
  74558. markAsUnprocessed(): void;
  74559. /**
  74560. * Marks the material to indicate all of its defines need to be re-calculated
  74561. */
  74562. markAllAsDirty(): void;
  74563. /**
  74564. * Marks the material to indicate that image processing needs to be re-calculated
  74565. */
  74566. markAsImageProcessingDirty(): void;
  74567. /**
  74568. * Marks the material to indicate the lights need to be re-calculated
  74569. * @param disposed Defines whether the light is dirty due to dispose or not
  74570. */
  74571. markAsLightDirty(disposed?: boolean): void;
  74572. /**
  74573. * Marks the attribute state as changed
  74574. */
  74575. markAsAttributesDirty(): void;
  74576. /**
  74577. * Marks the texture state as changed
  74578. */
  74579. markAsTexturesDirty(): void;
  74580. /**
  74581. * Marks the fresnel state as changed
  74582. */
  74583. markAsFresnelDirty(): void;
  74584. /**
  74585. * Marks the misc state as changed
  74586. */
  74587. markAsMiscDirty(): void;
  74588. /**
  74589. * Rebuilds the material defines
  74590. */
  74591. rebuild(): void;
  74592. /**
  74593. * Specifies if two material defines are equal
  74594. * @param other - A material define instance to compare to
  74595. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  74596. */
  74597. isEqual(other: MaterialDefines): boolean;
  74598. /**
  74599. * Clones this instance's defines to another instance
  74600. * @param other - material defines to clone values to
  74601. */
  74602. cloneTo(other: MaterialDefines): void;
  74603. /**
  74604. * Resets the material define values
  74605. */
  74606. reset(): void;
  74607. /**
  74608. * Converts the material define values to a string
  74609. * @returns - String of material define information
  74610. */
  74611. toString(): string;
  74612. }
  74613. }
  74614. declare module BABYLON {
  74615. /**
  74616. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  74617. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  74618. * 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;
  74619. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  74620. */
  74621. export class ColorCurves {
  74622. private _dirty;
  74623. private _tempColor;
  74624. private _globalCurve;
  74625. private _highlightsCurve;
  74626. private _midtonesCurve;
  74627. private _shadowsCurve;
  74628. private _positiveCurve;
  74629. private _negativeCurve;
  74630. private _globalHue;
  74631. private _globalDensity;
  74632. private _globalSaturation;
  74633. private _globalExposure;
  74634. /**
  74635. * Gets the global Hue value.
  74636. * 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).
  74637. */
  74638. /**
  74639. * Sets the global Hue value.
  74640. * 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).
  74641. */
  74642. globalHue: number;
  74643. /**
  74644. * Gets the global Density value.
  74645. * 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.
  74646. * Values less than zero provide a filter of opposite hue.
  74647. */
  74648. /**
  74649. * Sets the global Density value.
  74650. * 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.
  74651. * Values less than zero provide a filter of opposite hue.
  74652. */
  74653. globalDensity: number;
  74654. /**
  74655. * Gets the global Saturation value.
  74656. * 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.
  74657. */
  74658. /**
  74659. * Sets the global Saturation value.
  74660. * 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.
  74661. */
  74662. globalSaturation: number;
  74663. /**
  74664. * Gets the global Exposure value.
  74665. * 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.
  74666. */
  74667. /**
  74668. * Sets the global Exposure value.
  74669. * 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.
  74670. */
  74671. globalExposure: number;
  74672. private _highlightsHue;
  74673. private _highlightsDensity;
  74674. private _highlightsSaturation;
  74675. private _highlightsExposure;
  74676. /**
  74677. * Gets the highlights Hue value.
  74678. * 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).
  74679. */
  74680. /**
  74681. * Sets the highlights Hue value.
  74682. * 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).
  74683. */
  74684. highlightsHue: number;
  74685. /**
  74686. * Gets the highlights Density value.
  74687. * 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.
  74688. * Values less than zero provide a filter of opposite hue.
  74689. */
  74690. /**
  74691. * Sets the highlights Density value.
  74692. * 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.
  74693. * Values less than zero provide a filter of opposite hue.
  74694. */
  74695. highlightsDensity: number;
  74696. /**
  74697. * Gets the highlights Saturation value.
  74698. * 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.
  74699. */
  74700. /**
  74701. * Sets the highlights Saturation value.
  74702. * 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.
  74703. */
  74704. highlightsSaturation: number;
  74705. /**
  74706. * Gets the highlights Exposure value.
  74707. * 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.
  74708. */
  74709. /**
  74710. * Sets the highlights Exposure value.
  74711. * 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.
  74712. */
  74713. highlightsExposure: number;
  74714. private _midtonesHue;
  74715. private _midtonesDensity;
  74716. private _midtonesSaturation;
  74717. private _midtonesExposure;
  74718. /**
  74719. * Gets the midtones Hue value.
  74720. * 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).
  74721. */
  74722. /**
  74723. * Sets the midtones Hue value.
  74724. * 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).
  74725. */
  74726. midtonesHue: number;
  74727. /**
  74728. * Gets the midtones Density value.
  74729. * 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.
  74730. * Values less than zero provide a filter of opposite hue.
  74731. */
  74732. /**
  74733. * Sets the midtones Density value.
  74734. * 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.
  74735. * Values less than zero provide a filter of opposite hue.
  74736. */
  74737. midtonesDensity: number;
  74738. /**
  74739. * Gets the midtones Saturation value.
  74740. * 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.
  74741. */
  74742. /**
  74743. * Sets the midtones Saturation value.
  74744. * 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.
  74745. */
  74746. midtonesSaturation: number;
  74747. /**
  74748. * Gets the midtones Exposure value.
  74749. * 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.
  74750. */
  74751. /**
  74752. * Sets the midtones Exposure value.
  74753. * 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.
  74754. */
  74755. midtonesExposure: number;
  74756. private _shadowsHue;
  74757. private _shadowsDensity;
  74758. private _shadowsSaturation;
  74759. private _shadowsExposure;
  74760. /**
  74761. * Gets the shadows Hue value.
  74762. * 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).
  74763. */
  74764. /**
  74765. * Sets the shadows Hue value.
  74766. * 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).
  74767. */
  74768. shadowsHue: number;
  74769. /**
  74770. * Gets the shadows Density value.
  74771. * 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.
  74772. * Values less than zero provide a filter of opposite hue.
  74773. */
  74774. /**
  74775. * Sets the shadows Density value.
  74776. * 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.
  74777. * Values less than zero provide a filter of opposite hue.
  74778. */
  74779. shadowsDensity: number;
  74780. /**
  74781. * Gets the shadows Saturation value.
  74782. * 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.
  74783. */
  74784. /**
  74785. * Sets the shadows Saturation value.
  74786. * 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.
  74787. */
  74788. shadowsSaturation: number;
  74789. /**
  74790. * Gets the shadows Exposure value.
  74791. * 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.
  74792. */
  74793. /**
  74794. * Sets the shadows Exposure value.
  74795. * 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.
  74796. */
  74797. shadowsExposure: number;
  74798. /**
  74799. * Returns the class name
  74800. * @returns The class name
  74801. */
  74802. getClassName(): string;
  74803. /**
  74804. * Binds the color curves to the shader.
  74805. * @param colorCurves The color curve to bind
  74806. * @param effect The effect to bind to
  74807. * @param positiveUniform The positive uniform shader parameter
  74808. * @param neutralUniform The neutral uniform shader parameter
  74809. * @param negativeUniform The negative uniform shader parameter
  74810. */
  74811. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  74812. /**
  74813. * Prepare the list of uniforms associated with the ColorCurves effects.
  74814. * @param uniformsList The list of uniforms used in the effect
  74815. */
  74816. static PrepareUniforms(uniformsList: string[]): void;
  74817. /**
  74818. * Returns color grading data based on a hue, density, saturation and exposure value.
  74819. * @param filterHue The hue of the color filter.
  74820. * @param filterDensity The density of the color filter.
  74821. * @param saturation The saturation.
  74822. * @param exposure The exposure.
  74823. * @param result The result data container.
  74824. */
  74825. private getColorGradingDataToRef;
  74826. /**
  74827. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  74828. * @param value The input slider value in range [-100,100].
  74829. * @returns Adjusted value.
  74830. */
  74831. private static applyColorGradingSliderNonlinear;
  74832. /**
  74833. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  74834. * @param hue The hue (H) input.
  74835. * @param saturation The saturation (S) input.
  74836. * @param brightness The brightness (B) input.
  74837. * @result An RGBA color represented as Vector4.
  74838. */
  74839. private static fromHSBToRef;
  74840. /**
  74841. * Returns a value clamped between min and max
  74842. * @param value The value to clamp
  74843. * @param min The minimum of value
  74844. * @param max The maximum of value
  74845. * @returns The clamped value.
  74846. */
  74847. private static clamp;
  74848. /**
  74849. * Clones the current color curve instance.
  74850. * @return The cloned curves
  74851. */
  74852. clone(): ColorCurves;
  74853. /**
  74854. * Serializes the current color curve instance to a json representation.
  74855. * @return a JSON representation
  74856. */
  74857. serialize(): any;
  74858. /**
  74859. * Parses the color curve from a json representation.
  74860. * @param source the JSON source to parse
  74861. * @return The parsed curves
  74862. */
  74863. static Parse(source: any): ColorCurves;
  74864. }
  74865. }
  74866. declare module BABYLON {
  74867. /**
  74868. * Interface to follow in your material defines to integrate easily the
  74869. * Image proccessing functions.
  74870. * @hidden
  74871. */
  74872. export interface IImageProcessingConfigurationDefines {
  74873. IMAGEPROCESSING: boolean;
  74874. VIGNETTE: boolean;
  74875. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74876. VIGNETTEBLENDMODEOPAQUE: boolean;
  74877. TONEMAPPING: boolean;
  74878. TONEMAPPING_ACES: boolean;
  74879. CONTRAST: boolean;
  74880. EXPOSURE: boolean;
  74881. COLORCURVES: boolean;
  74882. COLORGRADING: boolean;
  74883. COLORGRADING3D: boolean;
  74884. SAMPLER3DGREENDEPTH: boolean;
  74885. SAMPLER3DBGRMAP: boolean;
  74886. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74887. }
  74888. /**
  74889. * @hidden
  74890. */
  74891. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  74892. IMAGEPROCESSING: boolean;
  74893. VIGNETTE: boolean;
  74894. VIGNETTEBLENDMODEMULTIPLY: boolean;
  74895. VIGNETTEBLENDMODEOPAQUE: boolean;
  74896. TONEMAPPING: boolean;
  74897. TONEMAPPING_ACES: boolean;
  74898. CONTRAST: boolean;
  74899. COLORCURVES: boolean;
  74900. COLORGRADING: boolean;
  74901. COLORGRADING3D: boolean;
  74902. SAMPLER3DGREENDEPTH: boolean;
  74903. SAMPLER3DBGRMAP: boolean;
  74904. IMAGEPROCESSINGPOSTPROCESS: boolean;
  74905. EXPOSURE: boolean;
  74906. constructor();
  74907. }
  74908. /**
  74909. * This groups together the common properties used for image processing either in direct forward pass
  74910. * or through post processing effect depending on the use of the image processing pipeline in your scene
  74911. * or not.
  74912. */
  74913. export class ImageProcessingConfiguration {
  74914. /**
  74915. * Default tone mapping applied in BabylonJS.
  74916. */
  74917. static readonly TONEMAPPING_STANDARD: number;
  74918. /**
  74919. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  74920. * to other engines rendering to increase portability.
  74921. */
  74922. static readonly TONEMAPPING_ACES: number;
  74923. /**
  74924. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  74925. */
  74926. colorCurves: Nullable<ColorCurves>;
  74927. private _colorCurvesEnabled;
  74928. /**
  74929. * Gets wether the color curves effect is enabled.
  74930. */
  74931. /**
  74932. * Sets wether the color curves effect is enabled.
  74933. */
  74934. colorCurvesEnabled: boolean;
  74935. private _colorGradingTexture;
  74936. /**
  74937. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74938. */
  74939. /**
  74940. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  74941. */
  74942. colorGradingTexture: Nullable<BaseTexture>;
  74943. private _colorGradingEnabled;
  74944. /**
  74945. * Gets wether the color grading effect is enabled.
  74946. */
  74947. /**
  74948. * Sets wether the color grading effect is enabled.
  74949. */
  74950. colorGradingEnabled: boolean;
  74951. private _colorGradingWithGreenDepth;
  74952. /**
  74953. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  74954. */
  74955. /**
  74956. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  74957. */
  74958. colorGradingWithGreenDepth: boolean;
  74959. private _colorGradingBGR;
  74960. /**
  74961. * Gets wether the color grading texture contains BGR values.
  74962. */
  74963. /**
  74964. * Sets wether the color grading texture contains BGR values.
  74965. */
  74966. colorGradingBGR: boolean;
  74967. /** @hidden */
  74968. _exposure: number;
  74969. /**
  74970. * Gets the Exposure used in the effect.
  74971. */
  74972. /**
  74973. * Sets the Exposure used in the effect.
  74974. */
  74975. exposure: number;
  74976. private _toneMappingEnabled;
  74977. /**
  74978. * Gets wether the tone mapping effect is enabled.
  74979. */
  74980. /**
  74981. * Sets wether the tone mapping effect is enabled.
  74982. */
  74983. toneMappingEnabled: boolean;
  74984. private _toneMappingType;
  74985. /**
  74986. * Gets the type of tone mapping effect.
  74987. */
  74988. /**
  74989. * Sets the type of tone mapping effect used in BabylonJS.
  74990. */
  74991. toneMappingType: number;
  74992. protected _contrast: number;
  74993. /**
  74994. * Gets the contrast used in the effect.
  74995. */
  74996. /**
  74997. * Sets the contrast used in the effect.
  74998. */
  74999. contrast: number;
  75000. /**
  75001. * Vignette stretch size.
  75002. */
  75003. vignetteStretch: number;
  75004. /**
  75005. * Vignette centre X Offset.
  75006. */
  75007. vignetteCentreX: number;
  75008. /**
  75009. * Vignette centre Y Offset.
  75010. */
  75011. vignetteCentreY: number;
  75012. /**
  75013. * Vignette weight or intensity of the vignette effect.
  75014. */
  75015. vignetteWeight: number;
  75016. /**
  75017. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  75018. * if vignetteEnabled is set to true.
  75019. */
  75020. vignetteColor: Color4;
  75021. /**
  75022. * Camera field of view used by the Vignette effect.
  75023. */
  75024. vignetteCameraFov: number;
  75025. private _vignetteBlendMode;
  75026. /**
  75027. * Gets the vignette blend mode allowing different kind of effect.
  75028. */
  75029. /**
  75030. * Sets the vignette blend mode allowing different kind of effect.
  75031. */
  75032. vignetteBlendMode: number;
  75033. private _vignetteEnabled;
  75034. /**
  75035. * Gets wether the vignette effect is enabled.
  75036. */
  75037. /**
  75038. * Sets wether the vignette effect is enabled.
  75039. */
  75040. vignetteEnabled: boolean;
  75041. private _applyByPostProcess;
  75042. /**
  75043. * Gets wether the image processing is applied through a post process or not.
  75044. */
  75045. /**
  75046. * Sets wether the image processing is applied through a post process or not.
  75047. */
  75048. applyByPostProcess: boolean;
  75049. private _isEnabled;
  75050. /**
  75051. * Gets wether the image processing is enabled or not.
  75052. */
  75053. /**
  75054. * Sets wether the image processing is enabled or not.
  75055. */
  75056. isEnabled: boolean;
  75057. /**
  75058. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  75059. */
  75060. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  75061. /**
  75062. * Method called each time the image processing information changes requires to recompile the effect.
  75063. */
  75064. protected _updateParameters(): void;
  75065. /**
  75066. * Gets the current class name.
  75067. * @return "ImageProcessingConfiguration"
  75068. */
  75069. getClassName(): string;
  75070. /**
  75071. * Prepare the list of uniforms associated with the Image Processing effects.
  75072. * @param uniforms The list of uniforms used in the effect
  75073. * @param defines the list of defines currently in use
  75074. */
  75075. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  75076. /**
  75077. * Prepare the list of samplers associated with the Image Processing effects.
  75078. * @param samplersList The list of uniforms used in the effect
  75079. * @param defines the list of defines currently in use
  75080. */
  75081. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  75082. /**
  75083. * Prepare the list of defines associated to the shader.
  75084. * @param defines the list of defines to complete
  75085. * @param forPostProcess Define if we are currently in post process mode or not
  75086. */
  75087. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  75088. /**
  75089. * Returns true if all the image processing information are ready.
  75090. * @returns True if ready, otherwise, false
  75091. */
  75092. isReady(): boolean;
  75093. /**
  75094. * Binds the image processing to the shader.
  75095. * @param effect The effect to bind to
  75096. * @param aspectRatio Define the current aspect ratio of the effect
  75097. */
  75098. bind(effect: Effect, aspectRatio?: number): void;
  75099. /**
  75100. * Clones the current image processing instance.
  75101. * @return The cloned image processing
  75102. */
  75103. clone(): ImageProcessingConfiguration;
  75104. /**
  75105. * Serializes the current image processing instance to a json representation.
  75106. * @return a JSON representation
  75107. */
  75108. serialize(): any;
  75109. /**
  75110. * Parses the image processing from a json representation.
  75111. * @param source the JSON source to parse
  75112. * @return The parsed image processing
  75113. */
  75114. static Parse(source: any): ImageProcessingConfiguration;
  75115. private static _VIGNETTEMODE_MULTIPLY;
  75116. private static _VIGNETTEMODE_OPAQUE;
  75117. /**
  75118. * Used to apply the vignette as a mix with the pixel color.
  75119. */
  75120. static readonly VIGNETTEMODE_MULTIPLY: number;
  75121. /**
  75122. * Used to apply the vignette as a replacement of the pixel color.
  75123. */
  75124. static readonly VIGNETTEMODE_OPAQUE: number;
  75125. }
  75126. }
  75127. declare module BABYLON {
  75128. /** @hidden */
  75129. export var postprocessVertexShader: {
  75130. name: string;
  75131. shader: string;
  75132. };
  75133. }
  75134. declare module BABYLON {
  75135. /** Defines supported spaces */
  75136. export enum Space {
  75137. /** Local (object) space */
  75138. LOCAL = 0,
  75139. /** World space */
  75140. WORLD = 1,
  75141. /** Bone space */
  75142. BONE = 2
  75143. }
  75144. /** Defines the 3 main axes */
  75145. export class Axis {
  75146. /** X axis */
  75147. static X: Vector3;
  75148. /** Y axis */
  75149. static Y: Vector3;
  75150. /** Z axis */
  75151. static Z: Vector3;
  75152. }
  75153. }
  75154. declare module BABYLON {
  75155. /**
  75156. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  75157. * This is the base of the follow, arc rotate cameras and Free camera
  75158. * @see http://doc.babylonjs.com/features/cameras
  75159. */
  75160. export class TargetCamera extends Camera {
  75161. private static _RigCamTransformMatrix;
  75162. private static _TargetTransformMatrix;
  75163. private static _TargetFocalPoint;
  75164. /**
  75165. * Define the current direction the camera is moving to
  75166. */
  75167. cameraDirection: Vector3;
  75168. /**
  75169. * Define the current rotation the camera is rotating to
  75170. */
  75171. cameraRotation: Vector2;
  75172. /**
  75173. * When set, the up vector of the camera will be updated by the rotation of the camera
  75174. */
  75175. updateUpVectorFromRotation: boolean;
  75176. private _tmpQuaternion;
  75177. /**
  75178. * Define the current rotation of the camera
  75179. */
  75180. rotation: Vector3;
  75181. /**
  75182. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  75183. */
  75184. rotationQuaternion: Quaternion;
  75185. /**
  75186. * Define the current speed of the camera
  75187. */
  75188. speed: number;
  75189. /**
  75190. * Add cconstraint to the camera to prevent it to move freely in all directions and
  75191. * around all axis.
  75192. */
  75193. noRotationConstraint: boolean;
  75194. /**
  75195. * Define the current target of the camera as an object or a position.
  75196. */
  75197. lockedTarget: any;
  75198. /** @hidden */
  75199. _currentTarget: Vector3;
  75200. /** @hidden */
  75201. _initialFocalDistance: number;
  75202. /** @hidden */
  75203. _viewMatrix: Matrix;
  75204. /** @hidden */
  75205. _camMatrix: Matrix;
  75206. /** @hidden */
  75207. _cameraTransformMatrix: Matrix;
  75208. /** @hidden */
  75209. _cameraRotationMatrix: Matrix;
  75210. /** @hidden */
  75211. _referencePoint: Vector3;
  75212. /** @hidden */
  75213. _transformedReferencePoint: Vector3;
  75214. protected _globalCurrentTarget: Vector3;
  75215. protected _globalCurrentUpVector: Vector3;
  75216. /** @hidden */
  75217. _reset: () => void;
  75218. private _defaultUp;
  75219. /**
  75220. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  75221. * This is the base of the follow, arc rotate cameras and Free camera
  75222. * @see http://doc.babylonjs.com/features/cameras
  75223. * @param name Defines the name of the camera in the scene
  75224. * @param position Defines the start position of the camera in the scene
  75225. * @param scene Defines the scene the camera belongs to
  75226. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  75227. */
  75228. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  75229. /**
  75230. * Gets the position in front of the camera at a given distance.
  75231. * @param distance The distance from the camera we want the position to be
  75232. * @returns the position
  75233. */
  75234. getFrontPosition(distance: number): Vector3;
  75235. /** @hidden */
  75236. _getLockedTargetPosition(): Nullable<Vector3>;
  75237. private _storedPosition;
  75238. private _storedRotation;
  75239. private _storedRotationQuaternion;
  75240. /**
  75241. * Store current camera state of the camera (fov, position, rotation, etc..)
  75242. * @returns the camera
  75243. */
  75244. storeState(): Camera;
  75245. /**
  75246. * Restored camera state. You must call storeState() first
  75247. * @returns whether it was successful or not
  75248. * @hidden
  75249. */
  75250. _restoreStateValues(): boolean;
  75251. /** @hidden */
  75252. _initCache(): void;
  75253. /** @hidden */
  75254. _updateCache(ignoreParentClass?: boolean): void;
  75255. /** @hidden */
  75256. _isSynchronizedViewMatrix(): boolean;
  75257. /** @hidden */
  75258. _computeLocalCameraSpeed(): number;
  75259. /**
  75260. * Defines the target the camera should look at.
  75261. * @param target Defines the new target as a Vector or a mesh
  75262. */
  75263. setTarget(target: Vector3): void;
  75264. /**
  75265. * Return the current target position of the camera. This value is expressed in local space.
  75266. * @returns the target position
  75267. */
  75268. getTarget(): Vector3;
  75269. /** @hidden */
  75270. _decideIfNeedsToMove(): boolean;
  75271. /** @hidden */
  75272. _updatePosition(): void;
  75273. /** @hidden */
  75274. _checkInputs(): void;
  75275. protected _updateCameraRotationMatrix(): void;
  75276. /**
  75277. * 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)
  75278. * @returns the current camera
  75279. */
  75280. private _rotateUpVectorWithCameraRotationMatrix;
  75281. private _cachedRotationZ;
  75282. private _cachedQuaternionRotationZ;
  75283. /** @hidden */
  75284. _getViewMatrix(): Matrix;
  75285. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  75286. /**
  75287. * @hidden
  75288. */
  75289. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  75290. /**
  75291. * @hidden
  75292. */
  75293. _updateRigCameras(): void;
  75294. private _getRigCamPositionAndTarget;
  75295. /**
  75296. * Gets the current object class name.
  75297. * @return the class name
  75298. */
  75299. getClassName(): string;
  75300. }
  75301. }
  75302. declare module BABYLON {
  75303. /**
  75304. * Gather the list of keyboard event types as constants.
  75305. */
  75306. export class KeyboardEventTypes {
  75307. /**
  75308. * The keydown event is fired when a key becomes active (pressed).
  75309. */
  75310. static readonly KEYDOWN: number;
  75311. /**
  75312. * The keyup event is fired when a key has been released.
  75313. */
  75314. static readonly KEYUP: number;
  75315. }
  75316. /**
  75317. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75318. */
  75319. export class KeyboardInfo {
  75320. /**
  75321. * Defines the type of event (KeyboardEventTypes)
  75322. */
  75323. type: number;
  75324. /**
  75325. * Defines the related dom event
  75326. */
  75327. event: KeyboardEvent;
  75328. /**
  75329. * Instantiates a new keyboard info.
  75330. * This class is used to store keyboard related info for the onKeyboardObservable event.
  75331. * @param type Defines the type of event (KeyboardEventTypes)
  75332. * @param event Defines the related dom event
  75333. */
  75334. constructor(
  75335. /**
  75336. * Defines the type of event (KeyboardEventTypes)
  75337. */
  75338. type: number,
  75339. /**
  75340. * Defines the related dom event
  75341. */
  75342. event: KeyboardEvent);
  75343. }
  75344. /**
  75345. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75346. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  75347. */
  75348. export class KeyboardInfoPre extends KeyboardInfo {
  75349. /**
  75350. * Defines the type of event (KeyboardEventTypes)
  75351. */
  75352. type: number;
  75353. /**
  75354. * Defines the related dom event
  75355. */
  75356. event: KeyboardEvent;
  75357. /**
  75358. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  75359. */
  75360. skipOnPointerObservable: boolean;
  75361. /**
  75362. * Instantiates a new keyboard pre info.
  75363. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  75364. * @param type Defines the type of event (KeyboardEventTypes)
  75365. * @param event Defines the related dom event
  75366. */
  75367. constructor(
  75368. /**
  75369. * Defines the type of event (KeyboardEventTypes)
  75370. */
  75371. type: number,
  75372. /**
  75373. * Defines the related dom event
  75374. */
  75375. event: KeyboardEvent);
  75376. }
  75377. }
  75378. declare module BABYLON {
  75379. /**
  75380. * Manage the keyboard inputs to control the movement of a free camera.
  75381. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  75382. */
  75383. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  75384. /**
  75385. * Defines the camera the input is attached to.
  75386. */
  75387. camera: FreeCamera;
  75388. /**
  75389. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  75390. */
  75391. keysUp: number[];
  75392. /**
  75393. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  75394. */
  75395. keysDown: number[];
  75396. /**
  75397. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  75398. */
  75399. keysLeft: number[];
  75400. /**
  75401. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  75402. */
  75403. keysRight: number[];
  75404. private _keys;
  75405. private _onCanvasBlurObserver;
  75406. private _onKeyboardObserver;
  75407. private _engine;
  75408. private _scene;
  75409. /**
  75410. * Attach the input controls to a specific dom element to get the input from.
  75411. * @param element Defines the element the controls should be listened from
  75412. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  75413. */
  75414. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  75415. /**
  75416. * Detach the current controls from the specified dom element.
  75417. * @param element Defines the element to stop listening the inputs from
  75418. */
  75419. detachControl(element: Nullable<HTMLElement>): void;
  75420. /**
  75421. * Update the current camera state depending on the inputs that have been used this frame.
  75422. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  75423. */
  75424. checkInputs(): void;
  75425. /**
  75426. * Gets the class name of the current intput.
  75427. * @returns the class name
  75428. */
  75429. getClassName(): string;
  75430. /** @hidden */
  75431. _onLostFocus(): void;
  75432. /**
  75433. * Get the friendly name associated with the input class.
  75434. * @returns the input friendly name
  75435. */
  75436. getSimpleName(): string;
  75437. }
  75438. }
  75439. declare module BABYLON {
  75440. /**
  75441. * Interface describing all the common properties and methods a shadow light needs to implement.
  75442. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  75443. * as well as binding the different shadow properties to the effects.
  75444. */
  75445. export interface IShadowLight extends Light {
  75446. /**
  75447. * The light id in the scene (used in scene.findLighById for instance)
  75448. */
  75449. id: string;
  75450. /**
  75451. * The position the shdow will be casted from.
  75452. */
  75453. position: Vector3;
  75454. /**
  75455. * In 2d mode (needCube being false), the direction used to cast the shadow.
  75456. */
  75457. direction: Vector3;
  75458. /**
  75459. * The transformed position. Position of the light in world space taking parenting in account.
  75460. */
  75461. transformedPosition: Vector3;
  75462. /**
  75463. * The transformed direction. Direction of the light in world space taking parenting in account.
  75464. */
  75465. transformedDirection: Vector3;
  75466. /**
  75467. * The friendly name of the light in the scene.
  75468. */
  75469. name: string;
  75470. /**
  75471. * Defines the shadow projection clipping minimum z value.
  75472. */
  75473. shadowMinZ: number;
  75474. /**
  75475. * Defines the shadow projection clipping maximum z value.
  75476. */
  75477. shadowMaxZ: number;
  75478. /**
  75479. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75480. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75481. */
  75482. computeTransformedInformation(): boolean;
  75483. /**
  75484. * Gets the scene the light belongs to.
  75485. * @returns The scene
  75486. */
  75487. getScene(): Scene;
  75488. /**
  75489. * Callback defining a custom Projection Matrix Builder.
  75490. * This can be used to override the default projection matrix computation.
  75491. */
  75492. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75493. /**
  75494. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75495. * @param matrix The materix to updated with the projection information
  75496. * @param viewMatrix The transform matrix of the light
  75497. * @param renderList The list of mesh to render in the map
  75498. * @returns The current light
  75499. */
  75500. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75501. /**
  75502. * Gets the current depth scale used in ESM.
  75503. * @returns The scale
  75504. */
  75505. getDepthScale(): number;
  75506. /**
  75507. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75508. * @returns true if a cube texture needs to be use
  75509. */
  75510. needCube(): boolean;
  75511. /**
  75512. * Detects if the projection matrix requires to be recomputed this frame.
  75513. * @returns true if it requires to be recomputed otherwise, false.
  75514. */
  75515. needProjectionMatrixCompute(): boolean;
  75516. /**
  75517. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75518. */
  75519. forceProjectionMatrixCompute(): void;
  75520. /**
  75521. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75522. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75523. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75524. */
  75525. getShadowDirection(faceIndex?: number): Vector3;
  75526. /**
  75527. * Gets the minZ used for shadow according to both the scene and the light.
  75528. * @param activeCamera The camera we are returning the min for
  75529. * @returns the depth min z
  75530. */
  75531. getDepthMinZ(activeCamera: Camera): number;
  75532. /**
  75533. * Gets the maxZ used for shadow according to both the scene and the light.
  75534. * @param activeCamera The camera we are returning the max for
  75535. * @returns the depth max z
  75536. */
  75537. getDepthMaxZ(activeCamera: Camera): number;
  75538. }
  75539. /**
  75540. * Base implementation IShadowLight
  75541. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  75542. */
  75543. export abstract class ShadowLight extends Light implements IShadowLight {
  75544. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  75545. protected _position: Vector3;
  75546. protected _setPosition(value: Vector3): void;
  75547. /**
  75548. * Sets the position the shadow will be casted from. Also use as the light position for both
  75549. * point and spot lights.
  75550. */
  75551. /**
  75552. * Sets the position the shadow will be casted from. Also use as the light position for both
  75553. * point and spot lights.
  75554. */
  75555. position: Vector3;
  75556. protected _direction: Vector3;
  75557. protected _setDirection(value: Vector3): void;
  75558. /**
  75559. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  75560. * Also use as the light direction on spot and directional lights.
  75561. */
  75562. /**
  75563. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  75564. * Also use as the light direction on spot and directional lights.
  75565. */
  75566. direction: Vector3;
  75567. private _shadowMinZ;
  75568. /**
  75569. * Gets the shadow projection clipping minimum z value.
  75570. */
  75571. /**
  75572. * Sets the shadow projection clipping minimum z value.
  75573. */
  75574. shadowMinZ: number;
  75575. private _shadowMaxZ;
  75576. /**
  75577. * Sets the shadow projection clipping maximum z value.
  75578. */
  75579. /**
  75580. * Gets the shadow projection clipping maximum z value.
  75581. */
  75582. shadowMaxZ: number;
  75583. /**
  75584. * Callback defining a custom Projection Matrix Builder.
  75585. * This can be used to override the default projection matrix computation.
  75586. */
  75587. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  75588. /**
  75589. * The transformed position. Position of the light in world space taking parenting in account.
  75590. */
  75591. transformedPosition: Vector3;
  75592. /**
  75593. * The transformed direction. Direction of the light in world space taking parenting in account.
  75594. */
  75595. transformedDirection: Vector3;
  75596. private _needProjectionMatrixCompute;
  75597. /**
  75598. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  75599. * @returns true if the information has been computed, false if it does not need to (no parenting)
  75600. */
  75601. computeTransformedInformation(): boolean;
  75602. /**
  75603. * Return the depth scale used for the shadow map.
  75604. * @returns the depth scale.
  75605. */
  75606. getDepthScale(): number;
  75607. /**
  75608. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  75609. * @param faceIndex The index of the face we are computed the direction to generate shadow
  75610. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  75611. */
  75612. getShadowDirection(faceIndex?: number): Vector3;
  75613. /**
  75614. * Returns the ShadowLight absolute position in the World.
  75615. * @returns the position vector in world space
  75616. */
  75617. getAbsolutePosition(): Vector3;
  75618. /**
  75619. * Sets the ShadowLight direction toward the passed target.
  75620. * @param target The point to target in local space
  75621. * @returns the updated ShadowLight direction
  75622. */
  75623. setDirectionToTarget(target: Vector3): Vector3;
  75624. /**
  75625. * Returns the light rotation in euler definition.
  75626. * @returns the x y z rotation in local space.
  75627. */
  75628. getRotation(): Vector3;
  75629. /**
  75630. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  75631. * @returns true if a cube texture needs to be use
  75632. */
  75633. needCube(): boolean;
  75634. /**
  75635. * Detects if the projection matrix requires to be recomputed this frame.
  75636. * @returns true if it requires to be recomputed otherwise, false.
  75637. */
  75638. needProjectionMatrixCompute(): boolean;
  75639. /**
  75640. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  75641. */
  75642. forceProjectionMatrixCompute(): void;
  75643. /** @hidden */
  75644. _initCache(): void;
  75645. /** @hidden */
  75646. _isSynchronized(): boolean;
  75647. /**
  75648. * Computes the world matrix of the node
  75649. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  75650. * @returns the world matrix
  75651. */
  75652. computeWorldMatrix(force?: boolean): Matrix;
  75653. /**
  75654. * Gets the minZ used for shadow according to both the scene and the light.
  75655. * @param activeCamera The camera we are returning the min for
  75656. * @returns the depth min z
  75657. */
  75658. getDepthMinZ(activeCamera: Camera): number;
  75659. /**
  75660. * Gets the maxZ used for shadow according to both the scene and the light.
  75661. * @param activeCamera The camera we are returning the max for
  75662. * @returns the depth max z
  75663. */
  75664. getDepthMaxZ(activeCamera: Camera): number;
  75665. /**
  75666. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  75667. * @param matrix The materix to updated with the projection information
  75668. * @param viewMatrix The transform matrix of the light
  75669. * @param renderList The list of mesh to render in the map
  75670. * @returns The current light
  75671. */
  75672. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  75673. }
  75674. }
  75675. declare module BABYLON {
  75676. /**
  75677. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  75678. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  75679. */
  75680. export class EffectFallbacks implements IEffectFallbacks {
  75681. private _defines;
  75682. private _currentRank;
  75683. private _maxRank;
  75684. private _mesh;
  75685. /**
  75686. * Removes the fallback from the bound mesh.
  75687. */
  75688. unBindMesh(): void;
  75689. /**
  75690. * Adds a fallback on the specified property.
  75691. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75692. * @param define The name of the define in the shader
  75693. */
  75694. addFallback(rank: number, define: string): void;
  75695. /**
  75696. * Sets the mesh to use CPU skinning when needing to fallback.
  75697. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  75698. * @param mesh The mesh to use the fallbacks.
  75699. */
  75700. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  75701. /**
  75702. * Checks to see if more fallbacks are still availible.
  75703. */
  75704. readonly hasMoreFallbacks: boolean;
  75705. /**
  75706. * Removes the defines that should be removed when falling back.
  75707. * @param currentDefines defines the current define statements for the shader.
  75708. * @param effect defines the current effect we try to compile
  75709. * @returns The resulting defines with defines of the current rank removed.
  75710. */
  75711. reduce(currentDefines: string, effect: Effect): string;
  75712. }
  75713. }
  75714. declare module BABYLON {
  75715. /**
  75716. * "Static Class" containing the most commonly used helper while dealing with material for
  75717. * rendering purpose.
  75718. *
  75719. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  75720. *
  75721. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  75722. */
  75723. export class MaterialHelper {
  75724. /**
  75725. * Bind the current view position to an effect.
  75726. * @param effect The effect to be bound
  75727. * @param scene The scene the eyes position is used from
  75728. */
  75729. static BindEyePosition(effect: Effect, scene: Scene): void;
  75730. /**
  75731. * Helps preparing the defines values about the UVs in used in the effect.
  75732. * UVs are shared as much as we can accross channels in the shaders.
  75733. * @param texture The texture we are preparing the UVs for
  75734. * @param defines The defines to update
  75735. * @param key The channel key "diffuse", "specular"... used in the shader
  75736. */
  75737. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  75738. /**
  75739. * Binds a texture matrix value to its corrsponding uniform
  75740. * @param texture The texture to bind the matrix for
  75741. * @param uniformBuffer The uniform buffer receivin the data
  75742. * @param key The channel key "diffuse", "specular"... used in the shader
  75743. */
  75744. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  75745. /**
  75746. * Gets the current status of the fog (should it be enabled?)
  75747. * @param mesh defines the mesh to evaluate for fog support
  75748. * @param scene defines the hosting scene
  75749. * @returns true if fog must be enabled
  75750. */
  75751. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  75752. /**
  75753. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  75754. * @param mesh defines the current mesh
  75755. * @param scene defines the current scene
  75756. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  75757. * @param pointsCloud defines if point cloud rendering has to be turned on
  75758. * @param fogEnabled defines if fog has to be turned on
  75759. * @param alphaTest defines if alpha testing has to be turned on
  75760. * @param defines defines the current list of defines
  75761. */
  75762. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  75763. /**
  75764. * Helper used to prepare the list of defines associated with frame values for shader compilation
  75765. * @param scene defines the current scene
  75766. * @param engine defines the current engine
  75767. * @param defines specifies the list of active defines
  75768. * @param useInstances defines if instances have to be turned on
  75769. * @param useClipPlane defines if clip plane have to be turned on
  75770. */
  75771. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  75772. /**
  75773. * Prepares the defines for bones
  75774. * @param mesh The mesh containing the geometry data we will draw
  75775. * @param defines The defines to update
  75776. */
  75777. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  75778. /**
  75779. * Prepares the defines for morph targets
  75780. * @param mesh The mesh containing the geometry data we will draw
  75781. * @param defines The defines to update
  75782. */
  75783. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  75784. /**
  75785. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  75786. * @param mesh The mesh containing the geometry data we will draw
  75787. * @param defines The defines to update
  75788. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  75789. * @param useBones Precise whether bones should be used or not (override mesh info)
  75790. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  75791. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  75792. * @returns false if defines are considered not dirty and have not been checked
  75793. */
  75794. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  75795. /**
  75796. * Prepares the defines related to multiview
  75797. * @param scene The scene we are intending to draw
  75798. * @param defines The defines to update
  75799. */
  75800. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  75801. /**
  75802. * Prepares the defines related to the light information passed in parameter
  75803. * @param scene The scene we are intending to draw
  75804. * @param mesh The mesh the effect is compiling for
  75805. * @param light The light the effect is compiling for
  75806. * @param lightIndex The index of the light
  75807. * @param defines The defines to update
  75808. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75809. * @param state Defines the current state regarding what is needed (normals, etc...)
  75810. */
  75811. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  75812. needNormals: boolean;
  75813. needRebuild: boolean;
  75814. shadowEnabled: boolean;
  75815. specularEnabled: boolean;
  75816. lightmapMode: boolean;
  75817. }): void;
  75818. /**
  75819. * Prepares the defines related to the light information passed in parameter
  75820. * @param scene The scene we are intending to draw
  75821. * @param mesh The mesh the effect is compiling for
  75822. * @param defines The defines to update
  75823. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  75824. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  75825. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  75826. * @returns true if normals will be required for the rest of the effect
  75827. */
  75828. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  75829. /**
  75830. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  75831. * @param lightIndex defines the light index
  75832. * @param uniformsList The uniform list
  75833. * @param samplersList The sampler list
  75834. * @param projectedLightTexture defines if projected texture must be used
  75835. * @param uniformBuffersList defines an optional list of uniform buffers
  75836. */
  75837. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  75838. /**
  75839. * Prepares the uniforms and samplers list to be used in the effect
  75840. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  75841. * @param samplersList The sampler list
  75842. * @param defines The defines helping in the list generation
  75843. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  75844. */
  75845. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  75846. /**
  75847. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  75848. * @param defines The defines to update while falling back
  75849. * @param fallbacks The authorized effect fallbacks
  75850. * @param maxSimultaneousLights The maximum number of lights allowed
  75851. * @param rank the current rank of the Effect
  75852. * @returns The newly affected rank
  75853. */
  75854. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  75855. private static _TmpMorphInfluencers;
  75856. /**
  75857. * Prepares the list of attributes required for morph targets according to the effect defines.
  75858. * @param attribs The current list of supported attribs
  75859. * @param mesh The mesh to prepare the morph targets attributes for
  75860. * @param influencers The number of influencers
  75861. */
  75862. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  75863. /**
  75864. * Prepares the list of attributes required for morph targets according to the effect defines.
  75865. * @param attribs The current list of supported attribs
  75866. * @param mesh The mesh to prepare the morph targets attributes for
  75867. * @param defines The current Defines of the effect
  75868. */
  75869. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  75870. /**
  75871. * Prepares the list of attributes required for bones according to the effect defines.
  75872. * @param attribs The current list of supported attribs
  75873. * @param mesh The mesh to prepare the bones attributes for
  75874. * @param defines The current Defines of the effect
  75875. * @param fallbacks The current efffect fallback strategy
  75876. */
  75877. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  75878. /**
  75879. * Check and prepare the list of attributes required for instances according to the effect defines.
  75880. * @param attribs The current list of supported attribs
  75881. * @param defines The current MaterialDefines of the effect
  75882. */
  75883. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  75884. /**
  75885. * Add the list of attributes required for instances to the attribs array.
  75886. * @param attribs The current list of supported attribs
  75887. */
  75888. static PushAttributesForInstances(attribs: string[]): void;
  75889. /**
  75890. * Binds the light shadow information to the effect for the given mesh.
  75891. * @param light The light containing the generator
  75892. * @param scene The scene the lights belongs to
  75893. * @param mesh The mesh we are binding the information to render
  75894. * @param lightIndex The light index in the effect used to render the mesh
  75895. * @param effect The effect we are binding the data to
  75896. */
  75897. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  75898. /**
  75899. * Binds the light information to the effect.
  75900. * @param light The light containing the generator
  75901. * @param effect The effect we are binding the data to
  75902. * @param lightIndex The light index in the effect used to render
  75903. */
  75904. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  75905. /**
  75906. * Binds the lights information from the scene to the effect for the given mesh.
  75907. * @param light Light to bind
  75908. * @param lightIndex Light index
  75909. * @param scene The scene where the light belongs to
  75910. * @param mesh The mesh we are binding the information to render
  75911. * @param effect The effect we are binding the data to
  75912. * @param useSpecular Defines if specular is supported
  75913. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75914. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75915. */
  75916. static BindLight(light: Light, lightIndex: number, scene: Scene, mesh: AbstractMesh, effect: Effect, useSpecular: boolean, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75917. /**
  75918. * Binds the lights information from the scene to the effect for the given mesh.
  75919. * @param scene The scene the lights belongs to
  75920. * @param mesh The mesh we are binding the information to render
  75921. * @param effect The effect we are binding the data to
  75922. * @param defines The generated defines for the effect
  75923. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  75924. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  75925. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  75926. */
  75927. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean, rebuildInParallel?: boolean): void;
  75928. private static _tempFogColor;
  75929. /**
  75930. * Binds the fog information from the scene to the effect for the given mesh.
  75931. * @param scene The scene the lights belongs to
  75932. * @param mesh The mesh we are binding the information to render
  75933. * @param effect The effect we are binding the data to
  75934. * @param linearSpace Defines if the fog effect is applied in linear space
  75935. */
  75936. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  75937. /**
  75938. * Binds the bones information from the mesh to the effect.
  75939. * @param mesh The mesh we are binding the information to render
  75940. * @param effect The effect we are binding the data to
  75941. */
  75942. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  75943. /**
  75944. * Binds the morph targets information from the mesh to the effect.
  75945. * @param abstractMesh The mesh we are binding the information to render
  75946. * @param effect The effect we are binding the data to
  75947. */
  75948. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  75949. /**
  75950. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  75951. * @param defines The generated defines used in the effect
  75952. * @param effect The effect we are binding the data to
  75953. * @param scene The scene we are willing to render with logarithmic scale for
  75954. */
  75955. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  75956. /**
  75957. * Binds the clip plane information from the scene to the effect.
  75958. * @param scene The scene the clip plane information are extracted from
  75959. * @param effect The effect we are binding the data to
  75960. */
  75961. static BindClipPlane(effect: Effect, scene: Scene): void;
  75962. }
  75963. }
  75964. declare module BABYLON {
  75965. /** @hidden */
  75966. export var packingFunctions: {
  75967. name: string;
  75968. shader: string;
  75969. };
  75970. }
  75971. declare module BABYLON {
  75972. /** @hidden */
  75973. export var shadowMapPixelShader: {
  75974. name: string;
  75975. shader: string;
  75976. };
  75977. }
  75978. declare module BABYLON {
  75979. /** @hidden */
  75980. export var bonesDeclaration: {
  75981. name: string;
  75982. shader: string;
  75983. };
  75984. }
  75985. declare module BABYLON {
  75986. /** @hidden */
  75987. export var morphTargetsVertexGlobalDeclaration: {
  75988. name: string;
  75989. shader: string;
  75990. };
  75991. }
  75992. declare module BABYLON {
  75993. /** @hidden */
  75994. export var morphTargetsVertexDeclaration: {
  75995. name: string;
  75996. shader: string;
  75997. };
  75998. }
  75999. declare module BABYLON {
  76000. /** @hidden */
  76001. export var instancesDeclaration: {
  76002. name: string;
  76003. shader: string;
  76004. };
  76005. }
  76006. declare module BABYLON {
  76007. /** @hidden */
  76008. export var helperFunctions: {
  76009. name: string;
  76010. shader: string;
  76011. };
  76012. }
  76013. declare module BABYLON {
  76014. /** @hidden */
  76015. export var morphTargetsVertex: {
  76016. name: string;
  76017. shader: string;
  76018. };
  76019. }
  76020. declare module BABYLON {
  76021. /** @hidden */
  76022. export var instancesVertex: {
  76023. name: string;
  76024. shader: string;
  76025. };
  76026. }
  76027. declare module BABYLON {
  76028. /** @hidden */
  76029. export var bonesVertex: {
  76030. name: string;
  76031. shader: string;
  76032. };
  76033. }
  76034. declare module BABYLON {
  76035. /** @hidden */
  76036. export var shadowMapVertexShader: {
  76037. name: string;
  76038. shader: string;
  76039. };
  76040. }
  76041. declare module BABYLON {
  76042. /** @hidden */
  76043. export var depthBoxBlurPixelShader: {
  76044. name: string;
  76045. shader: string;
  76046. };
  76047. }
  76048. declare module BABYLON {
  76049. /**
  76050. * Defines the options associated with the creation of a custom shader for a shadow generator.
  76051. */
  76052. export interface ICustomShaderOptions {
  76053. /**
  76054. * Gets or sets the custom shader name to use
  76055. */
  76056. shaderName: string;
  76057. /**
  76058. * The list of attribute names used in the shader
  76059. */
  76060. attributes?: string[];
  76061. /**
  76062. * The list of unifrom names used in the shader
  76063. */
  76064. uniforms?: string[];
  76065. /**
  76066. * The list of sampler names used in the shader
  76067. */
  76068. samplers?: string[];
  76069. /**
  76070. * The list of defines used in the shader
  76071. */
  76072. defines?: string[];
  76073. }
  76074. /**
  76075. * Interface to implement to create a shadow generator compatible with BJS.
  76076. */
  76077. export interface IShadowGenerator {
  76078. /**
  76079. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76080. * @returns The render target texture if present otherwise, null
  76081. */
  76082. getShadowMap(): Nullable<RenderTargetTexture>;
  76083. /**
  76084. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76085. * @returns The render target texture if the shadow map is present otherwise, null
  76086. */
  76087. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76088. /**
  76089. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76090. * @param subMesh The submesh we want to render in the shadow map
  76091. * @param useInstances Defines wether will draw in the map using instances
  76092. * @returns true if ready otherwise, false
  76093. */
  76094. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76095. /**
  76096. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76097. * @param defines Defines of the material we want to update
  76098. * @param lightIndex Index of the light in the enabled light list of the material
  76099. */
  76100. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  76101. /**
  76102. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76103. * defined in the generator but impacting the effect).
  76104. * It implies the unifroms available on the materials are the standard BJS ones.
  76105. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76106. * @param effect The effect we are binfing the information for
  76107. */
  76108. bindShadowLight(lightIndex: string, effect: Effect): void;
  76109. /**
  76110. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76111. * (eq to shadow prjection matrix * light transform matrix)
  76112. * @returns The transform matrix used to create the shadow map
  76113. */
  76114. getTransformMatrix(): Matrix;
  76115. /**
  76116. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76117. * Cube and 2D textures for instance.
  76118. */
  76119. recreateShadowMap(): void;
  76120. /**
  76121. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76122. * @param onCompiled Callback triggered at the and of the effects compilation
  76123. * @param options Sets of optional options forcing the compilation with different modes
  76124. */
  76125. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76126. useInstances: boolean;
  76127. }>): void;
  76128. /**
  76129. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76130. * @param options Sets of optional options forcing the compilation with different modes
  76131. * @returns A promise that resolves when the compilation completes
  76132. */
  76133. forceCompilationAsync(options?: Partial<{
  76134. useInstances: boolean;
  76135. }>): Promise<void>;
  76136. /**
  76137. * Serializes the shadow generator setup to a json object.
  76138. * @returns The serialized JSON object
  76139. */
  76140. serialize(): any;
  76141. /**
  76142. * Disposes the Shadow map and related Textures and effects.
  76143. */
  76144. dispose(): void;
  76145. }
  76146. /**
  76147. * Default implementation IShadowGenerator.
  76148. * This is the main object responsible of generating shadows in the framework.
  76149. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  76150. */
  76151. export class ShadowGenerator implements IShadowGenerator {
  76152. /**
  76153. * Shadow generator mode None: no filtering applied.
  76154. */
  76155. static readonly FILTER_NONE: number;
  76156. /**
  76157. * Shadow generator mode ESM: Exponential Shadow Mapping.
  76158. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76159. */
  76160. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  76161. /**
  76162. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  76163. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  76164. */
  76165. static readonly FILTER_POISSONSAMPLING: number;
  76166. /**
  76167. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  76168. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76169. */
  76170. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  76171. /**
  76172. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  76173. * edge artifacts on steep falloff.
  76174. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76175. */
  76176. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  76177. /**
  76178. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  76179. * edge artifacts on steep falloff.
  76180. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  76181. */
  76182. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  76183. /**
  76184. * Shadow generator mode PCF: Percentage Closer Filtering
  76185. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76186. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  76187. */
  76188. static readonly FILTER_PCF: number;
  76189. /**
  76190. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  76191. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  76192. * Contact Hardening
  76193. */
  76194. static readonly FILTER_PCSS: number;
  76195. /**
  76196. * Reserved for PCF and PCSS
  76197. * Highest Quality.
  76198. *
  76199. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  76200. *
  76201. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  76202. */
  76203. static readonly QUALITY_HIGH: number;
  76204. /**
  76205. * Reserved for PCF and PCSS
  76206. * Good tradeoff for quality/perf cross devices
  76207. *
  76208. * Execute PCF on a 3*3 kernel.
  76209. *
  76210. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  76211. */
  76212. static readonly QUALITY_MEDIUM: number;
  76213. /**
  76214. * Reserved for PCF and PCSS
  76215. * The lowest quality but the fastest.
  76216. *
  76217. * Execute PCF on a 1*1 kernel.
  76218. *
  76219. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  76220. */
  76221. static readonly QUALITY_LOW: number;
  76222. /** Gets or sets the custom shader name to use */
  76223. customShaderOptions: ICustomShaderOptions;
  76224. /**
  76225. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  76226. */
  76227. onBeforeShadowMapRenderObservable: Observable<Effect>;
  76228. /**
  76229. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  76230. */
  76231. onAfterShadowMapRenderObservable: Observable<Effect>;
  76232. /**
  76233. * Observable triggered before a mesh is rendered in the shadow map.
  76234. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  76235. */
  76236. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  76237. /**
  76238. * Observable triggered after a mesh is rendered in the shadow map.
  76239. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  76240. */
  76241. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  76242. private _bias;
  76243. /**
  76244. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  76245. */
  76246. /**
  76247. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  76248. */
  76249. bias: number;
  76250. private _normalBias;
  76251. /**
  76252. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76253. */
  76254. /**
  76255. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  76256. */
  76257. normalBias: number;
  76258. private _blurBoxOffset;
  76259. /**
  76260. * Gets the blur box offset: offset applied during the blur pass.
  76261. * Only useful if useKernelBlur = false
  76262. */
  76263. /**
  76264. * Sets the blur box offset: offset applied during the blur pass.
  76265. * Only useful if useKernelBlur = false
  76266. */
  76267. blurBoxOffset: number;
  76268. private _blurScale;
  76269. /**
  76270. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  76271. * 2 means half of the size.
  76272. */
  76273. /**
  76274. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  76275. * 2 means half of the size.
  76276. */
  76277. blurScale: number;
  76278. private _blurKernel;
  76279. /**
  76280. * Gets the blur kernel: kernel size of the blur pass.
  76281. * Only useful if useKernelBlur = true
  76282. */
  76283. /**
  76284. * Sets the blur kernel: kernel size of the blur pass.
  76285. * Only useful if useKernelBlur = true
  76286. */
  76287. blurKernel: number;
  76288. private _useKernelBlur;
  76289. /**
  76290. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  76291. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76292. */
  76293. /**
  76294. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  76295. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  76296. */
  76297. useKernelBlur: boolean;
  76298. private _depthScale;
  76299. /**
  76300. * Gets the depth scale used in ESM mode.
  76301. */
  76302. /**
  76303. * Sets the depth scale used in ESM mode.
  76304. * This can override the scale stored on the light.
  76305. */
  76306. depthScale: number;
  76307. private _filter;
  76308. /**
  76309. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  76310. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76311. */
  76312. /**
  76313. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  76314. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  76315. */
  76316. filter: number;
  76317. /**
  76318. * Gets if the current filter is set to Poisson Sampling.
  76319. */
  76320. /**
  76321. * Sets the current filter to Poisson Sampling.
  76322. */
  76323. usePoissonSampling: boolean;
  76324. /**
  76325. * Gets if the current filter is set to ESM.
  76326. */
  76327. /**
  76328. * Sets the current filter is to ESM.
  76329. */
  76330. useExponentialShadowMap: boolean;
  76331. /**
  76332. * Gets if the current filter is set to filtered ESM.
  76333. */
  76334. /**
  76335. * Gets if the current filter is set to filtered ESM.
  76336. */
  76337. useBlurExponentialShadowMap: boolean;
  76338. /**
  76339. * Gets if the current filter is set to "close ESM" (using the inverse of the
  76340. * exponential to prevent steep falloff artifacts).
  76341. */
  76342. /**
  76343. * Sets the current filter to "close ESM" (using the inverse of the
  76344. * exponential to prevent steep falloff artifacts).
  76345. */
  76346. useCloseExponentialShadowMap: boolean;
  76347. /**
  76348. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  76349. * exponential to prevent steep falloff artifacts).
  76350. */
  76351. /**
  76352. * Sets the current filter to filtered "close ESM" (using the inverse of the
  76353. * exponential to prevent steep falloff artifacts).
  76354. */
  76355. useBlurCloseExponentialShadowMap: boolean;
  76356. /**
  76357. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  76358. */
  76359. /**
  76360. * Sets the current filter to "PCF" (percentage closer filtering).
  76361. */
  76362. usePercentageCloserFiltering: boolean;
  76363. private _filteringQuality;
  76364. /**
  76365. * Gets the PCF or PCSS Quality.
  76366. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76367. */
  76368. /**
  76369. * Sets the PCF or PCSS Quality.
  76370. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  76371. */
  76372. filteringQuality: number;
  76373. /**
  76374. * Gets if the current filter is set to "PCSS" (contact hardening).
  76375. */
  76376. /**
  76377. * Sets the current filter to "PCSS" (contact hardening).
  76378. */
  76379. useContactHardeningShadow: boolean;
  76380. private _contactHardeningLightSizeUVRatio;
  76381. /**
  76382. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76383. * Using a ratio helps keeping shape stability independently of the map size.
  76384. *
  76385. * It does not account for the light projection as it was having too much
  76386. * instability during the light setup or during light position changes.
  76387. *
  76388. * Only valid if useContactHardeningShadow is true.
  76389. */
  76390. /**
  76391. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  76392. * Using a ratio helps keeping shape stability independently of the map size.
  76393. *
  76394. * It does not account for the light projection as it was having too much
  76395. * instability during the light setup or during light position changes.
  76396. *
  76397. * Only valid if useContactHardeningShadow is true.
  76398. */
  76399. contactHardeningLightSizeUVRatio: number;
  76400. private _darkness;
  76401. /** Gets or sets the actual darkness of a shadow */
  76402. darkness: number;
  76403. /**
  76404. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  76405. * 0 means strongest and 1 would means no shadow.
  76406. * @returns the darkness.
  76407. */
  76408. getDarkness(): number;
  76409. /**
  76410. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  76411. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  76412. * @returns the shadow generator allowing fluent coding.
  76413. */
  76414. setDarkness(darkness: number): ShadowGenerator;
  76415. private _transparencyShadow;
  76416. /** Gets or sets the ability to have transparent shadow */
  76417. transparencyShadow: boolean;
  76418. /**
  76419. * Sets the ability to have transparent shadow (boolean).
  76420. * @param transparent True if transparent else False
  76421. * @returns the shadow generator allowing fluent coding
  76422. */
  76423. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  76424. private _shadowMap;
  76425. private _shadowMap2;
  76426. /**
  76427. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  76428. * @returns The render target texture if present otherwise, null
  76429. */
  76430. getShadowMap(): Nullable<RenderTargetTexture>;
  76431. /**
  76432. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  76433. * @returns The render target texture if the shadow map is present otherwise, null
  76434. */
  76435. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  76436. /**
  76437. * Gets the class name of that object
  76438. * @returns "ShadowGenerator"
  76439. */
  76440. getClassName(): string;
  76441. /**
  76442. * Helper function to add a mesh and its descendants to the list of shadow casters.
  76443. * @param mesh Mesh to add
  76444. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  76445. * @returns the Shadow Generator itself
  76446. */
  76447. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76448. /**
  76449. * Helper function to remove a mesh and its descendants from the list of shadow casters
  76450. * @param mesh Mesh to remove
  76451. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  76452. * @returns the Shadow Generator itself
  76453. */
  76454. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  76455. /**
  76456. * Controls the extent to which the shadows fade out at the edge of the frustum
  76457. * Used only by directionals and spots
  76458. */
  76459. frustumEdgeFalloff: number;
  76460. private _light;
  76461. /**
  76462. * Returns the associated light object.
  76463. * @returns the light generating the shadow
  76464. */
  76465. getLight(): IShadowLight;
  76466. /**
  76467. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  76468. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  76469. * It might on the other hand introduce peter panning.
  76470. */
  76471. forceBackFacesOnly: boolean;
  76472. private _scene;
  76473. private _lightDirection;
  76474. private _effect;
  76475. private _viewMatrix;
  76476. private _projectionMatrix;
  76477. private _transformMatrix;
  76478. private _cachedPosition;
  76479. private _cachedDirection;
  76480. private _cachedDefines;
  76481. private _currentRenderID;
  76482. private _boxBlurPostprocess;
  76483. private _kernelBlurXPostprocess;
  76484. private _kernelBlurYPostprocess;
  76485. private _blurPostProcesses;
  76486. private _mapSize;
  76487. private _currentFaceIndex;
  76488. private _currentFaceIndexCache;
  76489. private _textureType;
  76490. private _defaultTextureMatrix;
  76491. private _storedUniqueId;
  76492. /** @hidden */
  76493. static _SceneComponentInitialization: (scene: Scene) => void;
  76494. /**
  76495. * Creates a ShadowGenerator object.
  76496. * A ShadowGenerator is the required tool to use the shadows.
  76497. * Each light casting shadows needs to use its own ShadowGenerator.
  76498. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  76499. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  76500. * @param light The light object generating the shadows.
  76501. * @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.
  76502. */
  76503. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  76504. private _initializeGenerator;
  76505. private _initializeShadowMap;
  76506. private _initializeBlurRTTAndPostProcesses;
  76507. private _renderForShadowMap;
  76508. private _renderSubMeshForShadowMap;
  76509. private _applyFilterValues;
  76510. /**
  76511. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76512. * @param onCompiled Callback triggered at the and of the effects compilation
  76513. * @param options Sets of optional options forcing the compilation with different modes
  76514. */
  76515. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  76516. useInstances: boolean;
  76517. }>): void;
  76518. /**
  76519. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  76520. * @param options Sets of optional options forcing the compilation with different modes
  76521. * @returns A promise that resolves when the compilation completes
  76522. */
  76523. forceCompilationAsync(options?: Partial<{
  76524. useInstances: boolean;
  76525. }>): Promise<void>;
  76526. /**
  76527. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  76528. * @param subMesh The submesh we want to render in the shadow map
  76529. * @param useInstances Defines wether will draw in the map using instances
  76530. * @returns true if ready otherwise, false
  76531. */
  76532. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76533. /**
  76534. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  76535. * @param defines Defines of the material we want to update
  76536. * @param lightIndex Index of the light in the enabled light list of the material
  76537. */
  76538. prepareDefines(defines: any, lightIndex: number): void;
  76539. /**
  76540. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  76541. * defined in the generator but impacting the effect).
  76542. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  76543. * @param effect The effect we are binfing the information for
  76544. */
  76545. bindShadowLight(lightIndex: string, effect: Effect): void;
  76546. /**
  76547. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  76548. * (eq to shadow prjection matrix * light transform matrix)
  76549. * @returns The transform matrix used to create the shadow map
  76550. */
  76551. getTransformMatrix(): Matrix;
  76552. /**
  76553. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  76554. * Cube and 2D textures for instance.
  76555. */
  76556. recreateShadowMap(): void;
  76557. private _disposeBlurPostProcesses;
  76558. private _disposeRTTandPostProcesses;
  76559. /**
  76560. * Disposes the ShadowGenerator.
  76561. * Returns nothing.
  76562. */
  76563. dispose(): void;
  76564. /**
  76565. * Serializes the shadow generator setup to a json object.
  76566. * @returns The serialized JSON object
  76567. */
  76568. serialize(): any;
  76569. /**
  76570. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  76571. * @param parsedShadowGenerator The JSON object to parse
  76572. * @param scene The scene to create the shadow map for
  76573. * @returns The parsed shadow generator
  76574. */
  76575. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  76576. }
  76577. }
  76578. declare module BABYLON {
  76579. /**
  76580. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  76581. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  76582. * 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.
  76583. */
  76584. export abstract class Light extends Node {
  76585. /**
  76586. * Falloff Default: light is falling off following the material specification:
  76587. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  76588. */
  76589. static readonly FALLOFF_DEFAULT: number;
  76590. /**
  76591. * Falloff Physical: light is falling off following the inverse squared distance law.
  76592. */
  76593. static readonly FALLOFF_PHYSICAL: number;
  76594. /**
  76595. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  76596. * to enhance interoperability with other engines.
  76597. */
  76598. static readonly FALLOFF_GLTF: number;
  76599. /**
  76600. * Falloff Standard: light is falling off like in the standard material
  76601. * to enhance interoperability with other materials.
  76602. */
  76603. static readonly FALLOFF_STANDARD: number;
  76604. /**
  76605. * If every light affecting the material is in this lightmapMode,
  76606. * material.lightmapTexture adds or multiplies
  76607. * (depends on material.useLightmapAsShadowmap)
  76608. * after every other light calculations.
  76609. */
  76610. static readonly LIGHTMAP_DEFAULT: number;
  76611. /**
  76612. * material.lightmapTexture as only diffuse lighting from this light
  76613. * adds only specular lighting from this light
  76614. * adds dynamic shadows
  76615. */
  76616. static readonly LIGHTMAP_SPECULAR: number;
  76617. /**
  76618. * material.lightmapTexture as only lighting
  76619. * no light calculation from this light
  76620. * only adds dynamic shadows from this light
  76621. */
  76622. static readonly LIGHTMAP_SHADOWSONLY: number;
  76623. /**
  76624. * Each light type uses the default quantity according to its type:
  76625. * point/spot lights use luminous intensity
  76626. * directional lights use illuminance
  76627. */
  76628. static readonly INTENSITYMODE_AUTOMATIC: number;
  76629. /**
  76630. * lumen (lm)
  76631. */
  76632. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  76633. /**
  76634. * candela (lm/sr)
  76635. */
  76636. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  76637. /**
  76638. * lux (lm/m^2)
  76639. */
  76640. static readonly INTENSITYMODE_ILLUMINANCE: number;
  76641. /**
  76642. * nit (cd/m^2)
  76643. */
  76644. static readonly INTENSITYMODE_LUMINANCE: number;
  76645. /**
  76646. * Light type const id of the point light.
  76647. */
  76648. static readonly LIGHTTYPEID_POINTLIGHT: number;
  76649. /**
  76650. * Light type const id of the directional light.
  76651. */
  76652. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  76653. /**
  76654. * Light type const id of the spot light.
  76655. */
  76656. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  76657. /**
  76658. * Light type const id of the hemispheric light.
  76659. */
  76660. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  76661. /**
  76662. * Diffuse gives the basic color to an object.
  76663. */
  76664. diffuse: Color3;
  76665. /**
  76666. * Specular produces a highlight color on an object.
  76667. * Note: This is note affecting PBR materials.
  76668. */
  76669. specular: Color3;
  76670. /**
  76671. * Defines the falloff type for this light. This lets overrriding how punctual light are
  76672. * falling off base on range or angle.
  76673. * This can be set to any values in Light.FALLOFF_x.
  76674. *
  76675. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  76676. * other types of materials.
  76677. */
  76678. falloffType: number;
  76679. /**
  76680. * Strength of the light.
  76681. * Note: By default it is define in the framework own unit.
  76682. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  76683. */
  76684. intensity: number;
  76685. private _range;
  76686. protected _inverseSquaredRange: number;
  76687. /**
  76688. * Defines how far from the source the light is impacting in scene units.
  76689. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76690. */
  76691. /**
  76692. * Defines how far from the source the light is impacting in scene units.
  76693. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  76694. */
  76695. range: number;
  76696. /**
  76697. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  76698. * of light.
  76699. */
  76700. private _photometricScale;
  76701. private _intensityMode;
  76702. /**
  76703. * Gets the photometric scale used to interpret the intensity.
  76704. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76705. */
  76706. /**
  76707. * Sets the photometric scale used to interpret the intensity.
  76708. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  76709. */
  76710. intensityMode: number;
  76711. private _radius;
  76712. /**
  76713. * Gets the light radius used by PBR Materials to simulate soft area lights.
  76714. */
  76715. /**
  76716. * sets the light radius used by PBR Materials to simulate soft area lights.
  76717. */
  76718. radius: number;
  76719. private _renderPriority;
  76720. /**
  76721. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  76722. * exceeding the number allowed of the materials.
  76723. */
  76724. renderPriority: number;
  76725. private _shadowEnabled;
  76726. /**
  76727. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76728. * the current shadow generator.
  76729. */
  76730. /**
  76731. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  76732. * the current shadow generator.
  76733. */
  76734. shadowEnabled: boolean;
  76735. private _includedOnlyMeshes;
  76736. /**
  76737. * Gets the only meshes impacted by this light.
  76738. */
  76739. /**
  76740. * Sets the only meshes impacted by this light.
  76741. */
  76742. includedOnlyMeshes: AbstractMesh[];
  76743. private _excludedMeshes;
  76744. /**
  76745. * Gets the meshes not impacted by this light.
  76746. */
  76747. /**
  76748. * Sets the meshes not impacted by this light.
  76749. */
  76750. excludedMeshes: AbstractMesh[];
  76751. private _excludeWithLayerMask;
  76752. /**
  76753. * Gets the layer id use to find what meshes are not impacted by the light.
  76754. * Inactive if 0
  76755. */
  76756. /**
  76757. * Sets the layer id use to find what meshes are not impacted by the light.
  76758. * Inactive if 0
  76759. */
  76760. excludeWithLayerMask: number;
  76761. private _includeOnlyWithLayerMask;
  76762. /**
  76763. * Gets the layer id use to find what meshes are impacted by the light.
  76764. * Inactive if 0
  76765. */
  76766. /**
  76767. * Sets the layer id use to find what meshes are impacted by the light.
  76768. * Inactive if 0
  76769. */
  76770. includeOnlyWithLayerMask: number;
  76771. private _lightmapMode;
  76772. /**
  76773. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76774. */
  76775. /**
  76776. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  76777. */
  76778. lightmapMode: number;
  76779. /**
  76780. * Shadow generator associted to the light.
  76781. * @hidden Internal use only.
  76782. */
  76783. _shadowGenerator: Nullable<IShadowGenerator>;
  76784. /**
  76785. * @hidden Internal use only.
  76786. */
  76787. _excludedMeshesIds: string[];
  76788. /**
  76789. * @hidden Internal use only.
  76790. */
  76791. _includedOnlyMeshesIds: string[];
  76792. /**
  76793. * The current light unifom buffer.
  76794. * @hidden Internal use only.
  76795. */
  76796. _uniformBuffer: UniformBuffer;
  76797. /**
  76798. * Creates a Light object in the scene.
  76799. * Documentation : https://doc.babylonjs.com/babylon101/lights
  76800. * @param name The firendly name of the light
  76801. * @param scene The scene the light belongs too
  76802. */
  76803. constructor(name: string, scene: Scene);
  76804. protected abstract _buildUniformLayout(): void;
  76805. /**
  76806. * Sets the passed Effect "effect" with the Light information.
  76807. * @param effect The effect to update
  76808. * @param lightIndex The index of the light in the effect to update
  76809. * @returns The light
  76810. */
  76811. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  76812. /**
  76813. * Sets the passed Effect "effect" with the Light information.
  76814. * @param effect The effect to update
  76815. * @param lightDataUniformName The uniform used to store light data (position or direction)
  76816. * @returns The light
  76817. */
  76818. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  76819. /**
  76820. * Returns the string "Light".
  76821. * @returns the class name
  76822. */
  76823. getClassName(): string;
  76824. /** @hidden */
  76825. readonly _isLight: boolean;
  76826. /**
  76827. * Converts the light information to a readable string for debug purpose.
  76828. * @param fullDetails Supports for multiple levels of logging within scene loading
  76829. * @returns the human readable light info
  76830. */
  76831. toString(fullDetails?: boolean): string;
  76832. /** @hidden */
  76833. protected _syncParentEnabledState(): void;
  76834. /**
  76835. * Set the enabled state of this node.
  76836. * @param value - the new enabled state
  76837. */
  76838. setEnabled(value: boolean): void;
  76839. /**
  76840. * Returns the Light associated shadow generator if any.
  76841. * @return the associated shadow generator.
  76842. */
  76843. getShadowGenerator(): Nullable<IShadowGenerator>;
  76844. /**
  76845. * Returns a Vector3, the absolute light position in the World.
  76846. * @returns the world space position of the light
  76847. */
  76848. getAbsolutePosition(): Vector3;
  76849. /**
  76850. * Specifies if the light will affect the passed mesh.
  76851. * @param mesh The mesh to test against the light
  76852. * @return true the mesh is affected otherwise, false.
  76853. */
  76854. canAffectMesh(mesh: AbstractMesh): boolean;
  76855. /**
  76856. * Sort function to order lights for rendering.
  76857. * @param a First Light object to compare to second.
  76858. * @param b Second Light object to compare first.
  76859. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  76860. */
  76861. static CompareLightsPriority(a: Light, b: Light): number;
  76862. /**
  76863. * Releases resources associated with this node.
  76864. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  76865. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  76866. */
  76867. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76868. /**
  76869. * Returns the light type ID (integer).
  76870. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  76871. */
  76872. getTypeID(): number;
  76873. /**
  76874. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  76875. * @returns the scaled intensity in intensity mode unit
  76876. */
  76877. getScaledIntensity(): number;
  76878. /**
  76879. * Returns a new Light object, named "name", from the current one.
  76880. * @param name The name of the cloned light
  76881. * @returns the new created light
  76882. */
  76883. clone(name: string): Nullable<Light>;
  76884. /**
  76885. * Serializes the current light into a Serialization object.
  76886. * @returns the serialized object.
  76887. */
  76888. serialize(): any;
  76889. /**
  76890. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  76891. * This new light is named "name" and added to the passed scene.
  76892. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  76893. * @param name The friendly name of the light
  76894. * @param scene The scene the new light will belong to
  76895. * @returns the constructor function
  76896. */
  76897. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  76898. /**
  76899. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  76900. * @param parsedLight The JSON representation of the light
  76901. * @param scene The scene to create the parsed light in
  76902. * @returns the created light after parsing
  76903. */
  76904. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  76905. private _hookArrayForExcluded;
  76906. private _hookArrayForIncludedOnly;
  76907. private _resyncMeshes;
  76908. /**
  76909. * Forces the meshes to update their light related information in their rendering used effects
  76910. * @hidden Internal Use Only
  76911. */
  76912. _markMeshesAsLightDirty(): void;
  76913. /**
  76914. * Recomputes the cached photometric scale if needed.
  76915. */
  76916. private _computePhotometricScale;
  76917. /**
  76918. * Returns the Photometric Scale according to the light type and intensity mode.
  76919. */
  76920. private _getPhotometricScale;
  76921. /**
  76922. * Reorder the light in the scene according to their defined priority.
  76923. * @hidden Internal Use Only
  76924. */
  76925. _reorderLightsInScene(): void;
  76926. /**
  76927. * Prepares the list of defines specific to the light type.
  76928. * @param defines the list of defines
  76929. * @param lightIndex defines the index of the light for the effect
  76930. */
  76931. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  76932. }
  76933. }
  76934. declare module BABYLON {
  76935. /**
  76936. * Interface used to define Action
  76937. */
  76938. export interface IAction {
  76939. /**
  76940. * Trigger for the action
  76941. */
  76942. trigger: number;
  76943. /** Options of the trigger */
  76944. triggerOptions: any;
  76945. /**
  76946. * Gets the trigger parameters
  76947. * @returns the trigger parameters
  76948. */
  76949. getTriggerParameter(): any;
  76950. /**
  76951. * Internal only - executes current action event
  76952. * @hidden
  76953. */
  76954. _executeCurrent(evt?: ActionEvent): void;
  76955. /**
  76956. * Serialize placeholder for child classes
  76957. * @param parent of child
  76958. * @returns the serialized object
  76959. */
  76960. serialize(parent: any): any;
  76961. /**
  76962. * Internal only
  76963. * @hidden
  76964. */
  76965. _prepare(): void;
  76966. /**
  76967. * Internal only - manager for action
  76968. * @hidden
  76969. */
  76970. _actionManager: AbstractActionManager;
  76971. /**
  76972. * Adds action to chain of actions, may be a DoNothingAction
  76973. * @param action defines the next action to execute
  76974. * @returns The action passed in
  76975. * @see https://www.babylonjs-playground.com/#1T30HR#0
  76976. */
  76977. then(action: IAction): IAction;
  76978. }
  76979. /**
  76980. * The action to be carried out following a trigger
  76981. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  76982. */
  76983. export class Action implements IAction {
  76984. /** the trigger, with or without parameters, for the action */
  76985. triggerOptions: any;
  76986. /**
  76987. * Trigger for the action
  76988. */
  76989. trigger: number;
  76990. /**
  76991. * Internal only - manager for action
  76992. * @hidden
  76993. */
  76994. _actionManager: ActionManager;
  76995. private _nextActiveAction;
  76996. private _child;
  76997. private _condition?;
  76998. private _triggerParameter;
  76999. /**
  77000. * An event triggered prior to action being executed.
  77001. */
  77002. onBeforeExecuteObservable: Observable<Action>;
  77003. /**
  77004. * Creates a new Action
  77005. * @param triggerOptions the trigger, with or without parameters, for the action
  77006. * @param condition an optional determinant of action
  77007. */
  77008. constructor(
  77009. /** the trigger, with or without parameters, for the action */
  77010. triggerOptions: any, condition?: Condition);
  77011. /**
  77012. * Internal only
  77013. * @hidden
  77014. */
  77015. _prepare(): void;
  77016. /**
  77017. * Gets the trigger parameters
  77018. * @returns the trigger parameters
  77019. */
  77020. getTriggerParameter(): any;
  77021. /**
  77022. * Internal only - executes current action event
  77023. * @hidden
  77024. */
  77025. _executeCurrent(evt?: ActionEvent): void;
  77026. /**
  77027. * Execute placeholder for child classes
  77028. * @param evt optional action event
  77029. */
  77030. execute(evt?: ActionEvent): void;
  77031. /**
  77032. * Skips to next active action
  77033. */
  77034. skipToNextActiveAction(): void;
  77035. /**
  77036. * Adds action to chain of actions, may be a DoNothingAction
  77037. * @param action defines the next action to execute
  77038. * @returns The action passed in
  77039. * @see https://www.babylonjs-playground.com/#1T30HR#0
  77040. */
  77041. then(action: Action): Action;
  77042. /**
  77043. * Internal only
  77044. * @hidden
  77045. */
  77046. _getProperty(propertyPath: string): string;
  77047. /**
  77048. * Internal only
  77049. * @hidden
  77050. */
  77051. _getEffectiveTarget(target: any, propertyPath: string): any;
  77052. /**
  77053. * Serialize placeholder for child classes
  77054. * @param parent of child
  77055. * @returns the serialized object
  77056. */
  77057. serialize(parent: any): any;
  77058. /**
  77059. * Internal only called by serialize
  77060. * @hidden
  77061. */
  77062. protected _serialize(serializedAction: any, parent?: any): any;
  77063. /**
  77064. * Internal only
  77065. * @hidden
  77066. */
  77067. static _SerializeValueAsString: (value: any) => string;
  77068. /**
  77069. * Internal only
  77070. * @hidden
  77071. */
  77072. static _GetTargetProperty: (target: Node | Scene) => {
  77073. name: string;
  77074. targetType: string;
  77075. value: string;
  77076. };
  77077. }
  77078. }
  77079. declare module BABYLON {
  77080. /**
  77081. * A Condition applied to an Action
  77082. */
  77083. export class Condition {
  77084. /**
  77085. * Internal only - manager for action
  77086. * @hidden
  77087. */
  77088. _actionManager: ActionManager;
  77089. /**
  77090. * Internal only
  77091. * @hidden
  77092. */
  77093. _evaluationId: number;
  77094. /**
  77095. * Internal only
  77096. * @hidden
  77097. */
  77098. _currentResult: boolean;
  77099. /**
  77100. * Creates a new Condition
  77101. * @param actionManager the manager of the action the condition is applied to
  77102. */
  77103. constructor(actionManager: ActionManager);
  77104. /**
  77105. * Check if the current condition is valid
  77106. * @returns a boolean
  77107. */
  77108. isValid(): boolean;
  77109. /**
  77110. * Internal only
  77111. * @hidden
  77112. */
  77113. _getProperty(propertyPath: string): string;
  77114. /**
  77115. * Internal only
  77116. * @hidden
  77117. */
  77118. _getEffectiveTarget(target: any, propertyPath: string): any;
  77119. /**
  77120. * Serialize placeholder for child classes
  77121. * @returns the serialized object
  77122. */
  77123. serialize(): any;
  77124. /**
  77125. * Internal only
  77126. * @hidden
  77127. */
  77128. protected _serialize(serializedCondition: any): any;
  77129. }
  77130. /**
  77131. * Defines specific conditional operators as extensions of Condition
  77132. */
  77133. export class ValueCondition extends Condition {
  77134. /** path to specify the property of the target the conditional operator uses */
  77135. propertyPath: string;
  77136. /** the value compared by the conditional operator against the current value of the property */
  77137. value: any;
  77138. /** the conditional operator, default ValueCondition.IsEqual */
  77139. operator: number;
  77140. /**
  77141. * Internal only
  77142. * @hidden
  77143. */
  77144. private static _IsEqual;
  77145. /**
  77146. * Internal only
  77147. * @hidden
  77148. */
  77149. private static _IsDifferent;
  77150. /**
  77151. * Internal only
  77152. * @hidden
  77153. */
  77154. private static _IsGreater;
  77155. /**
  77156. * Internal only
  77157. * @hidden
  77158. */
  77159. private static _IsLesser;
  77160. /**
  77161. * returns the number for IsEqual
  77162. */
  77163. static readonly IsEqual: number;
  77164. /**
  77165. * Returns the number for IsDifferent
  77166. */
  77167. static readonly IsDifferent: number;
  77168. /**
  77169. * Returns the number for IsGreater
  77170. */
  77171. static readonly IsGreater: number;
  77172. /**
  77173. * Returns the number for IsLesser
  77174. */
  77175. static readonly IsLesser: number;
  77176. /**
  77177. * Internal only The action manager for the condition
  77178. * @hidden
  77179. */
  77180. _actionManager: ActionManager;
  77181. /**
  77182. * Internal only
  77183. * @hidden
  77184. */
  77185. private _target;
  77186. /**
  77187. * Internal only
  77188. * @hidden
  77189. */
  77190. private _effectiveTarget;
  77191. /**
  77192. * Internal only
  77193. * @hidden
  77194. */
  77195. private _property;
  77196. /**
  77197. * Creates a new ValueCondition
  77198. * @param actionManager manager for the action the condition applies to
  77199. * @param target for the action
  77200. * @param propertyPath path to specify the property of the target the conditional operator uses
  77201. * @param value the value compared by the conditional operator against the current value of the property
  77202. * @param operator the conditional operator, default ValueCondition.IsEqual
  77203. */
  77204. constructor(actionManager: ActionManager, target: any,
  77205. /** path to specify the property of the target the conditional operator uses */
  77206. propertyPath: string,
  77207. /** the value compared by the conditional operator against the current value of the property */
  77208. value: any,
  77209. /** the conditional operator, default ValueCondition.IsEqual */
  77210. operator?: number);
  77211. /**
  77212. * Compares the given value with the property value for the specified conditional operator
  77213. * @returns the result of the comparison
  77214. */
  77215. isValid(): boolean;
  77216. /**
  77217. * Serialize the ValueCondition into a JSON compatible object
  77218. * @returns serialization object
  77219. */
  77220. serialize(): any;
  77221. /**
  77222. * Gets the name of the conditional operator for the ValueCondition
  77223. * @param operator the conditional operator
  77224. * @returns the name
  77225. */
  77226. static GetOperatorName(operator: number): string;
  77227. }
  77228. /**
  77229. * Defines a predicate condition as an extension of Condition
  77230. */
  77231. export class PredicateCondition extends Condition {
  77232. /** defines the predicate function used to validate the condition */
  77233. predicate: () => boolean;
  77234. /**
  77235. * Internal only - manager for action
  77236. * @hidden
  77237. */
  77238. _actionManager: ActionManager;
  77239. /**
  77240. * Creates a new PredicateCondition
  77241. * @param actionManager manager for the action the condition applies to
  77242. * @param predicate defines the predicate function used to validate the condition
  77243. */
  77244. constructor(actionManager: ActionManager,
  77245. /** defines the predicate function used to validate the condition */
  77246. predicate: () => boolean);
  77247. /**
  77248. * @returns the validity of the predicate condition
  77249. */
  77250. isValid(): boolean;
  77251. }
  77252. /**
  77253. * Defines a state condition as an extension of Condition
  77254. */
  77255. export class StateCondition extends Condition {
  77256. /** Value to compare with target state */
  77257. value: string;
  77258. /**
  77259. * Internal only - manager for action
  77260. * @hidden
  77261. */
  77262. _actionManager: ActionManager;
  77263. /**
  77264. * Internal only
  77265. * @hidden
  77266. */
  77267. private _target;
  77268. /**
  77269. * Creates a new StateCondition
  77270. * @param actionManager manager for the action the condition applies to
  77271. * @param target of the condition
  77272. * @param value to compare with target state
  77273. */
  77274. constructor(actionManager: ActionManager, target: any,
  77275. /** Value to compare with target state */
  77276. value: string);
  77277. /**
  77278. * Gets a boolean indicating if the current condition is met
  77279. * @returns the validity of the state
  77280. */
  77281. isValid(): boolean;
  77282. /**
  77283. * Serialize the StateCondition into a JSON compatible object
  77284. * @returns serialization object
  77285. */
  77286. serialize(): any;
  77287. }
  77288. }
  77289. declare module BABYLON {
  77290. /**
  77291. * This defines an action responsible to toggle a boolean once triggered.
  77292. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77293. */
  77294. export class SwitchBooleanAction extends Action {
  77295. /**
  77296. * The path to the boolean property in the target object
  77297. */
  77298. propertyPath: string;
  77299. private _target;
  77300. private _effectiveTarget;
  77301. private _property;
  77302. /**
  77303. * Instantiate the action
  77304. * @param triggerOptions defines the trigger options
  77305. * @param target defines the object containing the boolean
  77306. * @param propertyPath defines the path to the boolean property in the target object
  77307. * @param condition defines the trigger related conditions
  77308. */
  77309. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  77310. /** @hidden */
  77311. _prepare(): void;
  77312. /**
  77313. * Execute the action toggle the boolean value.
  77314. */
  77315. execute(): void;
  77316. /**
  77317. * Serializes the actions and its related information.
  77318. * @param parent defines the object to serialize in
  77319. * @returns the serialized object
  77320. */
  77321. serialize(parent: any): any;
  77322. }
  77323. /**
  77324. * This defines an action responsible to set a the state field of the target
  77325. * to a desired value once triggered.
  77326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77327. */
  77328. export class SetStateAction extends Action {
  77329. /**
  77330. * The value to store in the state field.
  77331. */
  77332. value: string;
  77333. private _target;
  77334. /**
  77335. * Instantiate the action
  77336. * @param triggerOptions defines the trigger options
  77337. * @param target defines the object containing the state property
  77338. * @param value defines the value to store in the state field
  77339. * @param condition defines the trigger related conditions
  77340. */
  77341. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  77342. /**
  77343. * Execute the action and store the value on the target state property.
  77344. */
  77345. execute(): void;
  77346. /**
  77347. * Serializes the actions and its related information.
  77348. * @param parent defines the object to serialize in
  77349. * @returns the serialized object
  77350. */
  77351. serialize(parent: any): any;
  77352. }
  77353. /**
  77354. * This defines an action responsible to set a property of the target
  77355. * to a desired value once triggered.
  77356. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77357. */
  77358. export class SetValueAction extends Action {
  77359. /**
  77360. * The path of the property to set in the target.
  77361. */
  77362. propertyPath: string;
  77363. /**
  77364. * The value to set in the property
  77365. */
  77366. value: any;
  77367. private _target;
  77368. private _effectiveTarget;
  77369. private _property;
  77370. /**
  77371. * Instantiate the action
  77372. * @param triggerOptions defines the trigger options
  77373. * @param target defines the object containing the property
  77374. * @param propertyPath defines the path of the property to set in the target
  77375. * @param value defines the value to set in the property
  77376. * @param condition defines the trigger related conditions
  77377. */
  77378. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77379. /** @hidden */
  77380. _prepare(): void;
  77381. /**
  77382. * Execute the action and set the targetted property to the desired value.
  77383. */
  77384. execute(): void;
  77385. /**
  77386. * Serializes the actions and its related information.
  77387. * @param parent defines the object to serialize in
  77388. * @returns the serialized object
  77389. */
  77390. serialize(parent: any): any;
  77391. }
  77392. /**
  77393. * This defines an action responsible to increment the target value
  77394. * to a desired value once triggered.
  77395. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77396. */
  77397. export class IncrementValueAction extends Action {
  77398. /**
  77399. * The path of the property to increment in the target.
  77400. */
  77401. propertyPath: string;
  77402. /**
  77403. * The value we should increment the property by.
  77404. */
  77405. value: any;
  77406. private _target;
  77407. private _effectiveTarget;
  77408. private _property;
  77409. /**
  77410. * Instantiate the action
  77411. * @param triggerOptions defines the trigger options
  77412. * @param target defines the object containing the property
  77413. * @param propertyPath defines the path of the property to increment in the target
  77414. * @param value defines the value value we should increment the property by
  77415. * @param condition defines the trigger related conditions
  77416. */
  77417. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  77418. /** @hidden */
  77419. _prepare(): void;
  77420. /**
  77421. * Execute the action and increment the target of the value amount.
  77422. */
  77423. execute(): void;
  77424. /**
  77425. * Serializes the actions and its related information.
  77426. * @param parent defines the object to serialize in
  77427. * @returns the serialized object
  77428. */
  77429. serialize(parent: any): any;
  77430. }
  77431. /**
  77432. * This defines an action responsible to start an animation once triggered.
  77433. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77434. */
  77435. export class PlayAnimationAction extends Action {
  77436. /**
  77437. * Where the animation should start (animation frame)
  77438. */
  77439. from: number;
  77440. /**
  77441. * Where the animation should stop (animation frame)
  77442. */
  77443. to: number;
  77444. /**
  77445. * Define if the animation should loop or stop after the first play.
  77446. */
  77447. loop?: boolean;
  77448. private _target;
  77449. /**
  77450. * Instantiate the action
  77451. * @param triggerOptions defines the trigger options
  77452. * @param target defines the target animation or animation name
  77453. * @param from defines from where the animation should start (animation frame)
  77454. * @param end defines where the animation should stop (animation frame)
  77455. * @param loop defines if the animation should loop or stop after the first play
  77456. * @param condition defines the trigger related conditions
  77457. */
  77458. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  77459. /** @hidden */
  77460. _prepare(): void;
  77461. /**
  77462. * Execute the action and play the animation.
  77463. */
  77464. execute(): void;
  77465. /**
  77466. * Serializes the actions and its related information.
  77467. * @param parent defines the object to serialize in
  77468. * @returns the serialized object
  77469. */
  77470. serialize(parent: any): any;
  77471. }
  77472. /**
  77473. * This defines an action responsible to stop an animation once triggered.
  77474. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77475. */
  77476. export class StopAnimationAction extends Action {
  77477. private _target;
  77478. /**
  77479. * Instantiate the action
  77480. * @param triggerOptions defines the trigger options
  77481. * @param target defines the target animation or animation name
  77482. * @param condition defines the trigger related conditions
  77483. */
  77484. constructor(triggerOptions: any, target: any, condition?: Condition);
  77485. /** @hidden */
  77486. _prepare(): void;
  77487. /**
  77488. * Execute the action and stop the animation.
  77489. */
  77490. execute(): void;
  77491. /**
  77492. * Serializes the actions and its related information.
  77493. * @param parent defines the object to serialize in
  77494. * @returns the serialized object
  77495. */
  77496. serialize(parent: any): any;
  77497. }
  77498. /**
  77499. * This defines an action responsible that does nothing once triggered.
  77500. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77501. */
  77502. export class DoNothingAction extends Action {
  77503. /**
  77504. * Instantiate the action
  77505. * @param triggerOptions defines the trigger options
  77506. * @param condition defines the trigger related conditions
  77507. */
  77508. constructor(triggerOptions?: any, condition?: Condition);
  77509. /**
  77510. * Execute the action and do nothing.
  77511. */
  77512. execute(): void;
  77513. /**
  77514. * Serializes the actions and its related information.
  77515. * @param parent defines the object to serialize in
  77516. * @returns the serialized object
  77517. */
  77518. serialize(parent: any): any;
  77519. }
  77520. /**
  77521. * This defines an action responsible to trigger several actions once triggered.
  77522. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77523. */
  77524. export class CombineAction extends Action {
  77525. /**
  77526. * The list of aggregated animations to run.
  77527. */
  77528. children: Action[];
  77529. /**
  77530. * Instantiate the action
  77531. * @param triggerOptions defines the trigger options
  77532. * @param children defines the list of aggregated animations to run
  77533. * @param condition defines the trigger related conditions
  77534. */
  77535. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  77536. /** @hidden */
  77537. _prepare(): void;
  77538. /**
  77539. * Execute the action and executes all the aggregated actions.
  77540. */
  77541. execute(evt: ActionEvent): void;
  77542. /**
  77543. * Serializes the actions and its related information.
  77544. * @param parent defines the object to serialize in
  77545. * @returns the serialized object
  77546. */
  77547. serialize(parent: any): any;
  77548. }
  77549. /**
  77550. * This defines an action responsible to run code (external event) once triggered.
  77551. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77552. */
  77553. export class ExecuteCodeAction extends Action {
  77554. /**
  77555. * The callback function to run.
  77556. */
  77557. func: (evt: ActionEvent) => void;
  77558. /**
  77559. * Instantiate the action
  77560. * @param triggerOptions defines the trigger options
  77561. * @param func defines the callback function to run
  77562. * @param condition defines the trigger related conditions
  77563. */
  77564. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  77565. /**
  77566. * Execute the action and run the attached code.
  77567. */
  77568. execute(evt: ActionEvent): void;
  77569. }
  77570. /**
  77571. * This defines an action responsible to set the parent property of the target once triggered.
  77572. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77573. */
  77574. export class SetParentAction extends Action {
  77575. private _parent;
  77576. private _target;
  77577. /**
  77578. * Instantiate the action
  77579. * @param triggerOptions defines the trigger options
  77580. * @param target defines the target containing the parent property
  77581. * @param parent defines from where the animation should start (animation frame)
  77582. * @param condition defines the trigger related conditions
  77583. */
  77584. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  77585. /** @hidden */
  77586. _prepare(): void;
  77587. /**
  77588. * Execute the action and set the parent property.
  77589. */
  77590. execute(): void;
  77591. /**
  77592. * Serializes the actions and its related information.
  77593. * @param parent defines the object to serialize in
  77594. * @returns the serialized object
  77595. */
  77596. serialize(parent: any): any;
  77597. }
  77598. }
  77599. declare module BABYLON {
  77600. /**
  77601. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  77602. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  77603. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  77604. */
  77605. export class ActionManager extends AbstractActionManager {
  77606. /**
  77607. * Nothing
  77608. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77609. */
  77610. static readonly NothingTrigger: number;
  77611. /**
  77612. * On pick
  77613. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77614. */
  77615. static readonly OnPickTrigger: number;
  77616. /**
  77617. * On left pick
  77618. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77619. */
  77620. static readonly OnLeftPickTrigger: number;
  77621. /**
  77622. * On right pick
  77623. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77624. */
  77625. static readonly OnRightPickTrigger: number;
  77626. /**
  77627. * On center pick
  77628. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77629. */
  77630. static readonly OnCenterPickTrigger: number;
  77631. /**
  77632. * On pick down
  77633. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77634. */
  77635. static readonly OnPickDownTrigger: number;
  77636. /**
  77637. * On double pick
  77638. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77639. */
  77640. static readonly OnDoublePickTrigger: number;
  77641. /**
  77642. * On pick up
  77643. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77644. */
  77645. static readonly OnPickUpTrigger: number;
  77646. /**
  77647. * On pick out.
  77648. * This trigger will only be raised if you also declared a OnPickDown
  77649. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77650. */
  77651. static readonly OnPickOutTrigger: number;
  77652. /**
  77653. * On long press
  77654. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77655. */
  77656. static readonly OnLongPressTrigger: number;
  77657. /**
  77658. * On pointer over
  77659. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77660. */
  77661. static readonly OnPointerOverTrigger: number;
  77662. /**
  77663. * On pointer out
  77664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77665. */
  77666. static readonly OnPointerOutTrigger: number;
  77667. /**
  77668. * On every frame
  77669. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77670. */
  77671. static readonly OnEveryFrameTrigger: number;
  77672. /**
  77673. * On intersection enter
  77674. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77675. */
  77676. static readonly OnIntersectionEnterTrigger: number;
  77677. /**
  77678. * On intersection exit
  77679. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77680. */
  77681. static readonly OnIntersectionExitTrigger: number;
  77682. /**
  77683. * On key down
  77684. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77685. */
  77686. static readonly OnKeyDownTrigger: number;
  77687. /**
  77688. * On key up
  77689. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  77690. */
  77691. static readonly OnKeyUpTrigger: number;
  77692. private _scene;
  77693. /**
  77694. * Creates a new action manager
  77695. * @param scene defines the hosting scene
  77696. */
  77697. constructor(scene: Scene);
  77698. /**
  77699. * Releases all associated resources
  77700. */
  77701. dispose(): void;
  77702. /**
  77703. * Gets hosting scene
  77704. * @returns the hosting scene
  77705. */
  77706. getScene(): Scene;
  77707. /**
  77708. * Does this action manager handles actions of any of the given triggers
  77709. * @param triggers defines the triggers to be tested
  77710. * @return a boolean indicating whether one (or more) of the triggers is handled
  77711. */
  77712. hasSpecificTriggers(triggers: number[]): boolean;
  77713. /**
  77714. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  77715. * speed.
  77716. * @param triggerA defines the trigger to be tested
  77717. * @param triggerB defines the trigger to be tested
  77718. * @return a boolean indicating whether one (or more) of the triggers is handled
  77719. */
  77720. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  77721. /**
  77722. * Does this action manager handles actions of a given trigger
  77723. * @param trigger defines the trigger to be tested
  77724. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  77725. * @return whether the trigger is handled
  77726. */
  77727. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  77728. /**
  77729. * Does this action manager has pointer triggers
  77730. */
  77731. readonly hasPointerTriggers: boolean;
  77732. /**
  77733. * Does this action manager has pick triggers
  77734. */
  77735. readonly hasPickTriggers: boolean;
  77736. /**
  77737. * Registers an action to this action manager
  77738. * @param action defines the action to be registered
  77739. * @return the action amended (prepared) after registration
  77740. */
  77741. registerAction(action: IAction): Nullable<IAction>;
  77742. /**
  77743. * Unregisters an action to this action manager
  77744. * @param action defines the action to be unregistered
  77745. * @return a boolean indicating whether the action has been unregistered
  77746. */
  77747. unregisterAction(action: IAction): Boolean;
  77748. /**
  77749. * Process a specific trigger
  77750. * @param trigger defines the trigger to process
  77751. * @param evt defines the event details to be processed
  77752. */
  77753. processTrigger(trigger: number, evt?: IActionEvent): void;
  77754. /** @hidden */
  77755. _getEffectiveTarget(target: any, propertyPath: string): any;
  77756. /** @hidden */
  77757. _getProperty(propertyPath: string): string;
  77758. /**
  77759. * Serialize this manager to a JSON object
  77760. * @param name defines the property name to store this manager
  77761. * @returns a JSON representation of this manager
  77762. */
  77763. serialize(name: string): any;
  77764. /**
  77765. * Creates a new ActionManager from a JSON data
  77766. * @param parsedActions defines the JSON data to read from
  77767. * @param object defines the hosting mesh
  77768. * @param scene defines the hosting scene
  77769. */
  77770. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  77771. /**
  77772. * Get a trigger name by index
  77773. * @param trigger defines the trigger index
  77774. * @returns a trigger name
  77775. */
  77776. static GetTriggerName(trigger: number): string;
  77777. }
  77778. }
  77779. declare module BABYLON {
  77780. /**
  77781. * Class representing a ray with position and direction
  77782. */
  77783. export class Ray {
  77784. /** origin point */
  77785. origin: Vector3;
  77786. /** direction */
  77787. direction: Vector3;
  77788. /** length of the ray */
  77789. length: number;
  77790. private static readonly TmpVector3;
  77791. private _tmpRay;
  77792. /**
  77793. * Creates a new ray
  77794. * @param origin origin point
  77795. * @param direction direction
  77796. * @param length length of the ray
  77797. */
  77798. constructor(
  77799. /** origin point */
  77800. origin: Vector3,
  77801. /** direction */
  77802. direction: Vector3,
  77803. /** length of the ray */
  77804. length?: number);
  77805. /**
  77806. * Checks if the ray intersects a box
  77807. * @param minimum bound of the box
  77808. * @param maximum bound of the box
  77809. * @param intersectionTreshold extra extend to be added to the box in all direction
  77810. * @returns if the box was hit
  77811. */
  77812. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  77813. /**
  77814. * Checks if the ray intersects a box
  77815. * @param box the bounding box to check
  77816. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  77817. * @returns if the box was hit
  77818. */
  77819. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  77820. /**
  77821. * If the ray hits a sphere
  77822. * @param sphere the bounding sphere to check
  77823. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  77824. * @returns true if it hits the sphere
  77825. */
  77826. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  77827. /**
  77828. * If the ray hits a triange
  77829. * @param vertex0 triangle vertex
  77830. * @param vertex1 triangle vertex
  77831. * @param vertex2 triangle vertex
  77832. * @returns intersection information if hit
  77833. */
  77834. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  77835. /**
  77836. * Checks if ray intersects a plane
  77837. * @param plane the plane to check
  77838. * @returns the distance away it was hit
  77839. */
  77840. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  77841. /**
  77842. * Calculate the intercept of a ray on a given axis
  77843. * @param axis to check 'x' | 'y' | 'z'
  77844. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  77845. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  77846. */
  77847. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  77848. /**
  77849. * Checks if ray intersects a mesh
  77850. * @param mesh the mesh to check
  77851. * @param fastCheck if only the bounding box should checked
  77852. * @returns picking info of the intersecton
  77853. */
  77854. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  77855. /**
  77856. * Checks if ray intersects a mesh
  77857. * @param meshes the meshes to check
  77858. * @param fastCheck if only the bounding box should checked
  77859. * @param results array to store result in
  77860. * @returns Array of picking infos
  77861. */
  77862. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  77863. private _comparePickingInfo;
  77864. private static smallnum;
  77865. private static rayl;
  77866. /**
  77867. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  77868. * @param sega the first point of the segment to test the intersection against
  77869. * @param segb the second point of the segment to test the intersection against
  77870. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  77871. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  77872. */
  77873. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  77874. /**
  77875. * Update the ray from viewport position
  77876. * @param x position
  77877. * @param y y position
  77878. * @param viewportWidth viewport width
  77879. * @param viewportHeight viewport height
  77880. * @param world world matrix
  77881. * @param view view matrix
  77882. * @param projection projection matrix
  77883. * @returns this ray updated
  77884. */
  77885. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77886. /**
  77887. * Creates a ray with origin and direction of 0,0,0
  77888. * @returns the new ray
  77889. */
  77890. static Zero(): Ray;
  77891. /**
  77892. * Creates a new ray from screen space and viewport
  77893. * @param x position
  77894. * @param y y position
  77895. * @param viewportWidth viewport width
  77896. * @param viewportHeight viewport height
  77897. * @param world world matrix
  77898. * @param view view matrix
  77899. * @param projection projection matrix
  77900. * @returns new ray
  77901. */
  77902. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  77903. /**
  77904. * 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
  77905. * transformed to the given world matrix.
  77906. * @param origin The origin point
  77907. * @param end The end point
  77908. * @param world a matrix to transform the ray to. Default is the identity matrix.
  77909. * @returns the new ray
  77910. */
  77911. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  77912. /**
  77913. * Transforms a ray by a matrix
  77914. * @param ray ray to transform
  77915. * @param matrix matrix to apply
  77916. * @returns the resulting new ray
  77917. */
  77918. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  77919. /**
  77920. * Transforms a ray by a matrix
  77921. * @param ray ray to transform
  77922. * @param matrix matrix to apply
  77923. * @param result ray to store result in
  77924. */
  77925. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  77926. /**
  77927. * Unproject a ray from screen space to object space
  77928. * @param sourceX defines the screen space x coordinate to use
  77929. * @param sourceY defines the screen space y coordinate to use
  77930. * @param viewportWidth defines the current width of the viewport
  77931. * @param viewportHeight defines the current height of the viewport
  77932. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77933. * @param view defines the view matrix to use
  77934. * @param projection defines the projection matrix to use
  77935. */
  77936. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  77937. }
  77938. /**
  77939. * Type used to define predicate used to select faces when a mesh intersection is detected
  77940. */
  77941. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  77942. interface Scene {
  77943. /** @hidden */
  77944. _tempPickingRay: Nullable<Ray>;
  77945. /** @hidden */
  77946. _cachedRayForTransform: Ray;
  77947. /** @hidden */
  77948. _pickWithRayInverseMatrix: Matrix;
  77949. /** @hidden */
  77950. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  77951. /** @hidden */
  77952. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  77953. }
  77954. }
  77955. declare module BABYLON {
  77956. /**
  77957. * Groups all the scene component constants in one place to ease maintenance.
  77958. * @hidden
  77959. */
  77960. export class SceneComponentConstants {
  77961. static readonly NAME_EFFECTLAYER: string;
  77962. static readonly NAME_LAYER: string;
  77963. static readonly NAME_LENSFLARESYSTEM: string;
  77964. static readonly NAME_BOUNDINGBOXRENDERER: string;
  77965. static readonly NAME_PARTICLESYSTEM: string;
  77966. static readonly NAME_GAMEPAD: string;
  77967. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  77968. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  77969. static readonly NAME_DEPTHRENDERER: string;
  77970. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  77971. static readonly NAME_SPRITE: string;
  77972. static readonly NAME_OUTLINERENDERER: string;
  77973. static readonly NAME_PROCEDURALTEXTURE: string;
  77974. static readonly NAME_SHADOWGENERATOR: string;
  77975. static readonly NAME_OCTREE: string;
  77976. static readonly NAME_PHYSICSENGINE: string;
  77977. static readonly NAME_AUDIO: string;
  77978. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  77979. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77980. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  77981. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  77982. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  77983. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  77984. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  77985. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  77986. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  77987. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  77988. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  77989. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  77990. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  77991. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  77992. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  77993. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  77994. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  77995. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  77996. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  77997. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  77998. static readonly STEP_AFTERRENDER_AUDIO: number;
  77999. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  78000. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  78001. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  78002. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  78003. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  78004. static readonly STEP_POINTERMOVE_SPRITE: number;
  78005. static readonly STEP_POINTERDOWN_SPRITE: number;
  78006. static readonly STEP_POINTERUP_SPRITE: number;
  78007. }
  78008. /**
  78009. * This represents a scene component.
  78010. *
  78011. * This is used to decouple the dependency the scene is having on the different workloads like
  78012. * layers, post processes...
  78013. */
  78014. export interface ISceneComponent {
  78015. /**
  78016. * The name of the component. Each component must have a unique name.
  78017. */
  78018. name: string;
  78019. /**
  78020. * The scene the component belongs to.
  78021. */
  78022. scene: Scene;
  78023. /**
  78024. * Register the component to one instance of a scene.
  78025. */
  78026. register(): void;
  78027. /**
  78028. * Rebuilds the elements related to this component in case of
  78029. * context lost for instance.
  78030. */
  78031. rebuild(): void;
  78032. /**
  78033. * Disposes the component and the associated ressources.
  78034. */
  78035. dispose(): void;
  78036. }
  78037. /**
  78038. * This represents a SERIALIZABLE scene component.
  78039. *
  78040. * This extends Scene Component to add Serialization methods on top.
  78041. */
  78042. export interface ISceneSerializableComponent extends ISceneComponent {
  78043. /**
  78044. * Adds all the elements from the container to the scene
  78045. * @param container the container holding the elements
  78046. */
  78047. addFromContainer(container: AbstractScene): void;
  78048. /**
  78049. * Removes all the elements in the container from the scene
  78050. * @param container contains the elements to remove
  78051. * @param dispose if the removed element should be disposed (default: false)
  78052. */
  78053. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  78054. /**
  78055. * Serializes the component data to the specified json object
  78056. * @param serializationObject The object to serialize to
  78057. */
  78058. serialize(serializationObject: any): void;
  78059. }
  78060. /**
  78061. * Strong typing of a Mesh related stage step action
  78062. */
  78063. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  78064. /**
  78065. * Strong typing of a Evaluate Sub Mesh related stage step action
  78066. */
  78067. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  78068. /**
  78069. * Strong typing of a Active Mesh related stage step action
  78070. */
  78071. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  78072. /**
  78073. * Strong typing of a Camera related stage step action
  78074. */
  78075. export type CameraStageAction = (camera: Camera) => void;
  78076. /**
  78077. * Strong typing of a Camera Frame buffer related stage step action
  78078. */
  78079. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  78080. /**
  78081. * Strong typing of a Render Target related stage step action
  78082. */
  78083. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  78084. /**
  78085. * Strong typing of a RenderingGroup related stage step action
  78086. */
  78087. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  78088. /**
  78089. * Strong typing of a Mesh Render related stage step action
  78090. */
  78091. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  78092. /**
  78093. * Strong typing of a simple stage step action
  78094. */
  78095. export type SimpleStageAction = () => void;
  78096. /**
  78097. * Strong typing of a render target action.
  78098. */
  78099. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  78100. /**
  78101. * Strong typing of a pointer move action.
  78102. */
  78103. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  78104. /**
  78105. * Strong typing of a pointer up/down action.
  78106. */
  78107. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  78108. /**
  78109. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  78110. * @hidden
  78111. */
  78112. export class Stage<T extends Function> extends Array<{
  78113. index: number;
  78114. component: ISceneComponent;
  78115. action: T;
  78116. }> {
  78117. /**
  78118. * Hide ctor from the rest of the world.
  78119. * @param items The items to add.
  78120. */
  78121. private constructor();
  78122. /**
  78123. * Creates a new Stage.
  78124. * @returns A new instance of a Stage
  78125. */
  78126. static Create<T extends Function>(): Stage<T>;
  78127. /**
  78128. * Registers a step in an ordered way in the targeted stage.
  78129. * @param index Defines the position to register the step in
  78130. * @param component Defines the component attached to the step
  78131. * @param action Defines the action to launch during the step
  78132. */
  78133. registerStep(index: number, component: ISceneComponent, action: T): void;
  78134. /**
  78135. * Clears all the steps from the stage.
  78136. */
  78137. clear(): void;
  78138. }
  78139. }
  78140. declare module BABYLON {
  78141. interface Scene {
  78142. /** @hidden */
  78143. _pointerOverSprite: Nullable<Sprite>;
  78144. /** @hidden */
  78145. _pickedDownSprite: Nullable<Sprite>;
  78146. /** @hidden */
  78147. _tempSpritePickingRay: Nullable<Ray>;
  78148. /**
  78149. * All of the sprite managers added to this scene
  78150. * @see http://doc.babylonjs.com/babylon101/sprites
  78151. */
  78152. spriteManagers: Array<ISpriteManager>;
  78153. /**
  78154. * An event triggered when sprites rendering is about to start
  78155. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78156. */
  78157. onBeforeSpritesRenderingObservable: Observable<Scene>;
  78158. /**
  78159. * An event triggered when sprites rendering is done
  78160. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  78161. */
  78162. onAfterSpritesRenderingObservable: Observable<Scene>;
  78163. /** @hidden */
  78164. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78165. /** Launch a ray to try to pick a sprite in the scene
  78166. * @param x position on screen
  78167. * @param y position on screen
  78168. * @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
  78169. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78170. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78171. * @returns a PickingInfo
  78172. */
  78173. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78174. /** Use the given ray to pick a sprite in the scene
  78175. * @param ray The ray (in world space) to use to pick meshes
  78176. * @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
  78177. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  78178. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78179. * @returns a PickingInfo
  78180. */
  78181. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  78182. /** @hidden */
  78183. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78184. /** Launch a ray to try to pick sprites in the scene
  78185. * @param x position on screen
  78186. * @param y position on screen
  78187. * @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
  78188. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  78189. * @returns a PickingInfo array
  78190. */
  78191. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78192. /** Use the given ray to pick sprites in the scene
  78193. * @param ray The ray (in world space) to use to pick meshes
  78194. * @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
  78195. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  78196. * @returns a PickingInfo array
  78197. */
  78198. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  78199. /**
  78200. * Force the sprite under the pointer
  78201. * @param sprite defines the sprite to use
  78202. */
  78203. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  78204. /**
  78205. * Gets the sprite under the pointer
  78206. * @returns a Sprite or null if no sprite is under the pointer
  78207. */
  78208. getPointerOverSprite(): Nullable<Sprite>;
  78209. }
  78210. /**
  78211. * Defines the sprite scene component responsible to manage sprites
  78212. * in a given scene.
  78213. */
  78214. export class SpriteSceneComponent implements ISceneComponent {
  78215. /**
  78216. * The component name helpfull to identify the component in the list of scene components.
  78217. */
  78218. readonly name: string;
  78219. /**
  78220. * The scene the component belongs to.
  78221. */
  78222. scene: Scene;
  78223. /** @hidden */
  78224. private _spritePredicate;
  78225. /**
  78226. * Creates a new instance of the component for the given scene
  78227. * @param scene Defines the scene to register the component in
  78228. */
  78229. constructor(scene: Scene);
  78230. /**
  78231. * Registers the component in a given scene
  78232. */
  78233. register(): void;
  78234. /**
  78235. * Rebuilds the elements related to this component in case of
  78236. * context lost for instance.
  78237. */
  78238. rebuild(): void;
  78239. /**
  78240. * Disposes the component and the associated ressources.
  78241. */
  78242. dispose(): void;
  78243. private _pickSpriteButKeepRay;
  78244. private _pointerMove;
  78245. private _pointerDown;
  78246. private _pointerUp;
  78247. }
  78248. }
  78249. declare module BABYLON {
  78250. /** @hidden */
  78251. export var fogFragmentDeclaration: {
  78252. name: string;
  78253. shader: string;
  78254. };
  78255. }
  78256. declare module BABYLON {
  78257. /** @hidden */
  78258. export var fogFragment: {
  78259. name: string;
  78260. shader: string;
  78261. };
  78262. }
  78263. declare module BABYLON {
  78264. /** @hidden */
  78265. export var spritesPixelShader: {
  78266. name: string;
  78267. shader: string;
  78268. };
  78269. }
  78270. declare module BABYLON {
  78271. /** @hidden */
  78272. export var fogVertexDeclaration: {
  78273. name: string;
  78274. shader: string;
  78275. };
  78276. }
  78277. declare module BABYLON {
  78278. /** @hidden */
  78279. export var spritesVertexShader: {
  78280. name: string;
  78281. shader: string;
  78282. };
  78283. }
  78284. declare module BABYLON {
  78285. /**
  78286. * Defines the minimum interface to fullfil in order to be a sprite manager.
  78287. */
  78288. export interface ISpriteManager extends IDisposable {
  78289. /**
  78290. * Restricts the camera to viewing objects with the same layerMask.
  78291. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  78292. */
  78293. layerMask: number;
  78294. /**
  78295. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78296. */
  78297. isPickable: boolean;
  78298. /**
  78299. * Specifies the rendering group id for this mesh (0 by default)
  78300. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78301. */
  78302. renderingGroupId: number;
  78303. /**
  78304. * Defines the list of sprites managed by the manager.
  78305. */
  78306. sprites: Array<Sprite>;
  78307. /**
  78308. * Tests the intersection of a sprite with a specific ray.
  78309. * @param ray The ray we are sending to test the collision
  78310. * @param camera The camera space we are sending rays in
  78311. * @param predicate A predicate allowing excluding sprites from the list of object to test
  78312. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  78313. * @returns picking info or null.
  78314. */
  78315. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78316. /**
  78317. * Intersects the sprites with a ray
  78318. * @param ray defines the ray to intersect with
  78319. * @param camera defines the current active camera
  78320. * @param predicate defines a predicate used to select candidate sprites
  78321. * @returns null if no hit or a PickingInfo array
  78322. */
  78323. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78324. /**
  78325. * Renders the list of sprites on screen.
  78326. */
  78327. render(): void;
  78328. }
  78329. /**
  78330. * Class used to manage multiple sprites on the same spritesheet
  78331. * @see http://doc.babylonjs.com/babylon101/sprites
  78332. */
  78333. export class SpriteManager implements ISpriteManager {
  78334. /** defines the manager's name */
  78335. name: string;
  78336. /** Gets the list of sprites */
  78337. sprites: Sprite[];
  78338. /** Gets or sets the rendering group id (0 by default) */
  78339. renderingGroupId: number;
  78340. /** Gets or sets camera layer mask */
  78341. layerMask: number;
  78342. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  78343. fogEnabled: boolean;
  78344. /** Gets or sets a boolean indicating if the sprites are pickable */
  78345. isPickable: boolean;
  78346. /** Defines the default width of a cell in the spritesheet */
  78347. cellWidth: number;
  78348. /** Defines the default height of a cell in the spritesheet */
  78349. cellHeight: number;
  78350. /** Associative array from JSON sprite data file */
  78351. private _cellData;
  78352. /** Array of sprite names from JSON sprite data file */
  78353. private _spriteMap;
  78354. /** True when packed cell data from JSON file is ready*/
  78355. private _packedAndReady;
  78356. /**
  78357. * An event triggered when the manager is disposed.
  78358. */
  78359. onDisposeObservable: Observable<SpriteManager>;
  78360. private _onDisposeObserver;
  78361. /**
  78362. * Callback called when the manager is disposed
  78363. */
  78364. onDispose: () => void;
  78365. private _capacity;
  78366. private _fromPacked;
  78367. private _spriteTexture;
  78368. private _epsilon;
  78369. private _scene;
  78370. private _vertexData;
  78371. private _buffer;
  78372. private _vertexBuffers;
  78373. private _indexBuffer;
  78374. private _effectBase;
  78375. private _effectFog;
  78376. /**
  78377. * Gets or sets the spritesheet texture
  78378. */
  78379. texture: Texture;
  78380. /**
  78381. * Creates a new sprite manager
  78382. * @param name defines the manager's name
  78383. * @param imgUrl defines the sprite sheet url
  78384. * @param capacity defines the maximum allowed number of sprites
  78385. * @param cellSize defines the size of a sprite cell
  78386. * @param scene defines the hosting scene
  78387. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  78388. * @param samplingMode defines the smapling mode to use with spritesheet
  78389. * @param fromPacked set to false; do not alter
  78390. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  78391. */
  78392. constructor(
  78393. /** defines the manager's name */
  78394. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: string | null);
  78395. private _makePacked;
  78396. private _appendSpriteVertex;
  78397. /**
  78398. * Intersects the sprites with a ray
  78399. * @param ray defines the ray to intersect with
  78400. * @param camera defines the current active camera
  78401. * @param predicate defines a predicate used to select candidate sprites
  78402. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  78403. * @returns null if no hit or a PickingInfo
  78404. */
  78405. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  78406. /**
  78407. * Intersects the sprites with a ray
  78408. * @param ray defines the ray to intersect with
  78409. * @param camera defines the current active camera
  78410. * @param predicate defines a predicate used to select candidate sprites
  78411. * @returns null if no hit or a PickingInfo array
  78412. */
  78413. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  78414. /**
  78415. * Render all child sprites
  78416. */
  78417. render(): void;
  78418. /**
  78419. * Release associated resources
  78420. */
  78421. dispose(): void;
  78422. }
  78423. }
  78424. declare module BABYLON {
  78425. /**
  78426. * Class used to represent a sprite
  78427. * @see http://doc.babylonjs.com/babylon101/sprites
  78428. */
  78429. export class Sprite {
  78430. /** defines the name */
  78431. name: string;
  78432. /** Gets or sets the current world position */
  78433. position: Vector3;
  78434. /** Gets or sets the main color */
  78435. color: Color4;
  78436. /** Gets or sets the width */
  78437. width: number;
  78438. /** Gets or sets the height */
  78439. height: number;
  78440. /** Gets or sets rotation angle */
  78441. angle: number;
  78442. /** Gets or sets the cell index in the sprite sheet */
  78443. cellIndex: number;
  78444. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  78445. cellRef: string;
  78446. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  78447. invertU: number;
  78448. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  78449. invertV: number;
  78450. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  78451. disposeWhenFinishedAnimating: boolean;
  78452. /** Gets the list of attached animations */
  78453. animations: Animation[];
  78454. /** Gets or sets a boolean indicating if the sprite can be picked */
  78455. isPickable: boolean;
  78456. /**
  78457. * Gets or sets the associated action manager
  78458. */
  78459. actionManager: Nullable<ActionManager>;
  78460. private _animationStarted;
  78461. private _loopAnimation;
  78462. private _fromIndex;
  78463. private _toIndex;
  78464. private _delay;
  78465. private _direction;
  78466. private _manager;
  78467. private _time;
  78468. private _onAnimationEnd;
  78469. /**
  78470. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  78471. */
  78472. isVisible: boolean;
  78473. /**
  78474. * Gets or sets the sprite size
  78475. */
  78476. size: number;
  78477. /**
  78478. * Creates a new Sprite
  78479. * @param name defines the name
  78480. * @param manager defines the manager
  78481. */
  78482. constructor(
  78483. /** defines the name */
  78484. name: string, manager: ISpriteManager);
  78485. /**
  78486. * Starts an animation
  78487. * @param from defines the initial key
  78488. * @param to defines the end key
  78489. * @param loop defines if the animation must loop
  78490. * @param delay defines the start delay (in ms)
  78491. * @param onAnimationEnd defines a callback to call when animation ends
  78492. */
  78493. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  78494. /** Stops current animation (if any) */
  78495. stopAnimation(): void;
  78496. /** @hidden */
  78497. _animate(deltaTime: number): void;
  78498. /** Release associated resources */
  78499. dispose(): void;
  78500. }
  78501. }
  78502. declare module BABYLON {
  78503. /**
  78504. * Information about the result of picking within a scene
  78505. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  78506. */
  78507. export class PickingInfo {
  78508. /** @hidden */
  78509. _pickingUnavailable: boolean;
  78510. /**
  78511. * If the pick collided with an object
  78512. */
  78513. hit: boolean;
  78514. /**
  78515. * Distance away where the pick collided
  78516. */
  78517. distance: number;
  78518. /**
  78519. * The location of pick collision
  78520. */
  78521. pickedPoint: Nullable<Vector3>;
  78522. /**
  78523. * The mesh corresponding the the pick collision
  78524. */
  78525. pickedMesh: Nullable<AbstractMesh>;
  78526. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  78527. bu: number;
  78528. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  78529. bv: number;
  78530. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  78531. faceId: number;
  78532. /** Id of the the submesh that was picked */
  78533. subMeshId: number;
  78534. /** If a sprite was picked, this will be the sprite the pick collided with */
  78535. pickedSprite: Nullable<Sprite>;
  78536. /**
  78537. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  78538. */
  78539. originMesh: Nullable<AbstractMesh>;
  78540. /**
  78541. * The ray that was used to perform the picking.
  78542. */
  78543. ray: Nullable<Ray>;
  78544. /**
  78545. * Gets the normal correspodning to the face the pick collided with
  78546. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  78547. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  78548. * @returns The normal correspodning to the face the pick collided with
  78549. */
  78550. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  78551. /**
  78552. * Gets the texture coordinates of where the pick occured
  78553. * @returns the vector containing the coordnates of the texture
  78554. */
  78555. getTextureCoordinates(): Nullable<Vector2>;
  78556. }
  78557. }
  78558. declare module BABYLON {
  78559. /**
  78560. * Gather the list of pointer event types as constants.
  78561. */
  78562. export class PointerEventTypes {
  78563. /**
  78564. * 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.
  78565. */
  78566. static readonly POINTERDOWN: number;
  78567. /**
  78568. * The pointerup event is fired when a pointer is no longer active.
  78569. */
  78570. static readonly POINTERUP: number;
  78571. /**
  78572. * The pointermove event is fired when a pointer changes coordinates.
  78573. */
  78574. static readonly POINTERMOVE: number;
  78575. /**
  78576. * The pointerwheel event is fired when a mouse wheel has been rotated.
  78577. */
  78578. static readonly POINTERWHEEL: number;
  78579. /**
  78580. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  78581. */
  78582. static readonly POINTERPICK: number;
  78583. /**
  78584. * The pointertap event is fired when a the object has been touched and released without drag.
  78585. */
  78586. static readonly POINTERTAP: number;
  78587. /**
  78588. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  78589. */
  78590. static readonly POINTERDOUBLETAP: number;
  78591. }
  78592. /**
  78593. * Base class of pointer info types.
  78594. */
  78595. export class PointerInfoBase {
  78596. /**
  78597. * Defines the type of event (PointerEventTypes)
  78598. */
  78599. type: number;
  78600. /**
  78601. * Defines the related dom event
  78602. */
  78603. event: PointerEvent | MouseWheelEvent;
  78604. /**
  78605. * Instantiates the base class of pointers info.
  78606. * @param type Defines the type of event (PointerEventTypes)
  78607. * @param event Defines the related dom event
  78608. */
  78609. constructor(
  78610. /**
  78611. * Defines the type of event (PointerEventTypes)
  78612. */
  78613. type: number,
  78614. /**
  78615. * Defines the related dom event
  78616. */
  78617. event: PointerEvent | MouseWheelEvent);
  78618. }
  78619. /**
  78620. * This class is used to store pointer related info for the onPrePointerObservable event.
  78621. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  78622. */
  78623. export class PointerInfoPre extends PointerInfoBase {
  78624. /**
  78625. * Ray from a pointer if availible (eg. 6dof controller)
  78626. */
  78627. ray: Nullable<Ray>;
  78628. /**
  78629. * Defines the local position of the pointer on the canvas.
  78630. */
  78631. localPosition: Vector2;
  78632. /**
  78633. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  78634. */
  78635. skipOnPointerObservable: boolean;
  78636. /**
  78637. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  78638. * @param type Defines the type of event (PointerEventTypes)
  78639. * @param event Defines the related dom event
  78640. * @param localX Defines the local x coordinates of the pointer when the event occured
  78641. * @param localY Defines the local y coordinates of the pointer when the event occured
  78642. */
  78643. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  78644. }
  78645. /**
  78646. * This type contains all the data related to a pointer event in Babylon.js.
  78647. * 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.
  78648. */
  78649. export class PointerInfo extends PointerInfoBase {
  78650. /**
  78651. * Defines the picking info associated to the info (if any)\
  78652. */
  78653. pickInfo: Nullable<PickingInfo>;
  78654. /**
  78655. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  78656. * @param type Defines the type of event (PointerEventTypes)
  78657. * @param event Defines the related dom event
  78658. * @param pickInfo Defines the picking info associated to the info (if any)\
  78659. */
  78660. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  78661. /**
  78662. * Defines the picking info associated to the info (if any)\
  78663. */
  78664. pickInfo: Nullable<PickingInfo>);
  78665. }
  78666. /**
  78667. * Data relating to a touch event on the screen.
  78668. */
  78669. export interface PointerTouch {
  78670. /**
  78671. * X coordinate of touch.
  78672. */
  78673. x: number;
  78674. /**
  78675. * Y coordinate of touch.
  78676. */
  78677. y: number;
  78678. /**
  78679. * Id of touch. Unique for each finger.
  78680. */
  78681. pointerId: number;
  78682. /**
  78683. * Event type passed from DOM.
  78684. */
  78685. type: any;
  78686. }
  78687. }
  78688. declare module BABYLON {
  78689. /**
  78690. * Manage the mouse inputs to control the movement of a free camera.
  78691. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78692. */
  78693. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  78694. /**
  78695. * Define if touch is enabled in the mouse input
  78696. */
  78697. touchEnabled: boolean;
  78698. /**
  78699. * Defines the camera the input is attached to.
  78700. */
  78701. camera: FreeCamera;
  78702. /**
  78703. * Defines the buttons associated with the input to handle camera move.
  78704. */
  78705. buttons: number[];
  78706. /**
  78707. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  78708. */
  78709. angularSensibility: number;
  78710. private _pointerInput;
  78711. private _onMouseMove;
  78712. private _observer;
  78713. private previousPosition;
  78714. /**
  78715. * Observable for when a pointer move event occurs containing the move offset
  78716. */
  78717. onPointerMovedObservable: Observable<{
  78718. offsetX: number;
  78719. offsetY: number;
  78720. }>;
  78721. /**
  78722. * @hidden
  78723. * If the camera should be rotated automatically based on pointer movement
  78724. */
  78725. _allowCameraRotation: boolean;
  78726. /**
  78727. * Manage the mouse inputs to control the movement of a free camera.
  78728. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78729. * @param touchEnabled Defines if touch is enabled or not
  78730. */
  78731. constructor(
  78732. /**
  78733. * Define if touch is enabled in the mouse input
  78734. */
  78735. touchEnabled?: boolean);
  78736. /**
  78737. * Attach the input controls to a specific dom element to get the input from.
  78738. * @param element Defines the element the controls should be listened from
  78739. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78740. */
  78741. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78742. /**
  78743. * Called on JS contextmenu event.
  78744. * Override this method to provide functionality.
  78745. */
  78746. protected onContextMenu(evt: PointerEvent): void;
  78747. /**
  78748. * Detach the current controls from the specified dom element.
  78749. * @param element Defines the element to stop listening the inputs from
  78750. */
  78751. detachControl(element: Nullable<HTMLElement>): void;
  78752. /**
  78753. * Gets the class name of the current intput.
  78754. * @returns the class name
  78755. */
  78756. getClassName(): string;
  78757. /**
  78758. * Get the friendly name associated with the input class.
  78759. * @returns the input friendly name
  78760. */
  78761. getSimpleName(): string;
  78762. }
  78763. }
  78764. declare module BABYLON {
  78765. /**
  78766. * Manage the touch inputs to control the movement of a free camera.
  78767. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78768. */
  78769. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  78770. /**
  78771. * Defines the camera the input is attached to.
  78772. */
  78773. camera: FreeCamera;
  78774. /**
  78775. * Defines the touch sensibility for rotation.
  78776. * The higher the faster.
  78777. */
  78778. touchAngularSensibility: number;
  78779. /**
  78780. * Defines the touch sensibility for move.
  78781. * The higher the faster.
  78782. */
  78783. touchMoveSensibility: number;
  78784. private _offsetX;
  78785. private _offsetY;
  78786. private _pointerPressed;
  78787. private _pointerInput;
  78788. private _observer;
  78789. private _onLostFocus;
  78790. /**
  78791. * Attach the input controls to a specific dom element to get the input from.
  78792. * @param element Defines the element the controls should be listened from
  78793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78794. */
  78795. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78796. /**
  78797. * Detach the current controls from the specified dom element.
  78798. * @param element Defines the element to stop listening the inputs from
  78799. */
  78800. detachControl(element: Nullable<HTMLElement>): void;
  78801. /**
  78802. * Update the current camera state depending on the inputs that have been used this frame.
  78803. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  78804. */
  78805. checkInputs(): void;
  78806. /**
  78807. * Gets the class name of the current intput.
  78808. * @returns the class name
  78809. */
  78810. getClassName(): string;
  78811. /**
  78812. * Get the friendly name associated with the input class.
  78813. * @returns the input friendly name
  78814. */
  78815. getSimpleName(): string;
  78816. }
  78817. }
  78818. declare module BABYLON {
  78819. /**
  78820. * Default Inputs manager for the FreeCamera.
  78821. * It groups all the default supported inputs for ease of use.
  78822. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  78823. */
  78824. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  78825. /**
  78826. * @hidden
  78827. */
  78828. _mouseInput: Nullable<FreeCameraMouseInput>;
  78829. /**
  78830. * Instantiates a new FreeCameraInputsManager.
  78831. * @param camera Defines the camera the inputs belong to
  78832. */
  78833. constructor(camera: FreeCamera);
  78834. /**
  78835. * Add keyboard input support to the input manager.
  78836. * @returns the current input manager
  78837. */
  78838. addKeyboard(): FreeCameraInputsManager;
  78839. /**
  78840. * Add mouse input support to the input manager.
  78841. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  78842. * @returns the current input manager
  78843. */
  78844. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  78845. /**
  78846. * Removes the mouse input support from the manager
  78847. * @returns the current input manager
  78848. */
  78849. removeMouse(): FreeCameraInputsManager;
  78850. /**
  78851. * Add touch input support to the input manager.
  78852. * @returns the current input manager
  78853. */
  78854. addTouch(): FreeCameraInputsManager;
  78855. /**
  78856. * Remove all attached input methods from a camera
  78857. */
  78858. clear(): void;
  78859. }
  78860. }
  78861. declare module BABYLON {
  78862. /**
  78863. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78864. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  78865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78866. */
  78867. export class FreeCamera extends TargetCamera {
  78868. /**
  78869. * Define the collision ellipsoid of the camera.
  78870. * This is helpful to simulate a camera body like the player body around the camera
  78871. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  78872. */
  78873. ellipsoid: Vector3;
  78874. /**
  78875. * Define an offset for the position of the ellipsoid around the camera.
  78876. * This can be helpful to determine the center of the body near the gravity center of the body
  78877. * instead of its head.
  78878. */
  78879. ellipsoidOffset: Vector3;
  78880. /**
  78881. * Enable or disable collisions of the camera with the rest of the scene objects.
  78882. */
  78883. checkCollisions: boolean;
  78884. /**
  78885. * Enable or disable gravity on the camera.
  78886. */
  78887. applyGravity: boolean;
  78888. /**
  78889. * Define the input manager associated to the camera.
  78890. */
  78891. inputs: FreeCameraInputsManager;
  78892. /**
  78893. * Gets the input sensibility for a mouse input. (default is 2000.0)
  78894. * Higher values reduce sensitivity.
  78895. */
  78896. /**
  78897. * Sets the input sensibility for a mouse input. (default is 2000.0)
  78898. * Higher values reduce sensitivity.
  78899. */
  78900. angularSensibility: number;
  78901. /**
  78902. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  78903. */
  78904. keysUp: number[];
  78905. /**
  78906. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  78907. */
  78908. keysDown: number[];
  78909. /**
  78910. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  78911. */
  78912. keysLeft: number[];
  78913. /**
  78914. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  78915. */
  78916. keysRight: number[];
  78917. /**
  78918. * Event raised when the camera collide with a mesh in the scene.
  78919. */
  78920. onCollide: (collidedMesh: AbstractMesh) => void;
  78921. private _collider;
  78922. private _needMoveForGravity;
  78923. private _oldPosition;
  78924. private _diffPosition;
  78925. private _newPosition;
  78926. /** @hidden */
  78927. _localDirection: Vector3;
  78928. /** @hidden */
  78929. _transformedDirection: Vector3;
  78930. /**
  78931. * Instantiates a Free Camera.
  78932. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  78933. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  78934. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  78935. * @param name Define the name of the camera in the scene
  78936. * @param position Define the start position of the camera in the scene
  78937. * @param scene Define the scene the camera belongs to
  78938. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  78939. */
  78940. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  78941. /**
  78942. * Attached controls to the current camera.
  78943. * @param element Defines the element the controls should be listened from
  78944. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  78945. */
  78946. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  78947. /**
  78948. * Detach the current controls from the camera.
  78949. * The camera will stop reacting to inputs.
  78950. * @param element Defines the element to stop listening the inputs from
  78951. */
  78952. detachControl(element: HTMLElement): void;
  78953. private _collisionMask;
  78954. /**
  78955. * Define a collision mask to limit the list of object the camera can collide with
  78956. */
  78957. collisionMask: number;
  78958. /** @hidden */
  78959. _collideWithWorld(displacement: Vector3): void;
  78960. private _onCollisionPositionChange;
  78961. /** @hidden */
  78962. _checkInputs(): void;
  78963. /** @hidden */
  78964. _decideIfNeedsToMove(): boolean;
  78965. /** @hidden */
  78966. _updatePosition(): void;
  78967. /**
  78968. * Destroy the camera and release the current resources hold by it.
  78969. */
  78970. dispose(): void;
  78971. /**
  78972. * Gets the current object class name.
  78973. * @return the class name
  78974. */
  78975. getClassName(): string;
  78976. }
  78977. }
  78978. declare module BABYLON {
  78979. /**
  78980. * Represents a gamepad control stick position
  78981. */
  78982. export class StickValues {
  78983. /**
  78984. * The x component of the control stick
  78985. */
  78986. x: number;
  78987. /**
  78988. * The y component of the control stick
  78989. */
  78990. y: number;
  78991. /**
  78992. * Initializes the gamepad x and y control stick values
  78993. * @param x The x component of the gamepad control stick value
  78994. * @param y The y component of the gamepad control stick value
  78995. */
  78996. constructor(
  78997. /**
  78998. * The x component of the control stick
  78999. */
  79000. x: number,
  79001. /**
  79002. * The y component of the control stick
  79003. */
  79004. y: number);
  79005. }
  79006. /**
  79007. * An interface which manages callbacks for gamepad button changes
  79008. */
  79009. export interface GamepadButtonChanges {
  79010. /**
  79011. * Called when a gamepad has been changed
  79012. */
  79013. changed: boolean;
  79014. /**
  79015. * Called when a gamepad press event has been triggered
  79016. */
  79017. pressChanged: boolean;
  79018. /**
  79019. * Called when a touch event has been triggered
  79020. */
  79021. touchChanged: boolean;
  79022. /**
  79023. * Called when a value has changed
  79024. */
  79025. valueChanged: boolean;
  79026. }
  79027. /**
  79028. * Represents a gamepad
  79029. */
  79030. export class Gamepad {
  79031. /**
  79032. * The id of the gamepad
  79033. */
  79034. id: string;
  79035. /**
  79036. * The index of the gamepad
  79037. */
  79038. index: number;
  79039. /**
  79040. * The browser gamepad
  79041. */
  79042. browserGamepad: any;
  79043. /**
  79044. * Specifies what type of gamepad this represents
  79045. */
  79046. type: number;
  79047. private _leftStick;
  79048. private _rightStick;
  79049. /** @hidden */
  79050. _isConnected: boolean;
  79051. private _leftStickAxisX;
  79052. private _leftStickAxisY;
  79053. private _rightStickAxisX;
  79054. private _rightStickAxisY;
  79055. /**
  79056. * Triggered when the left control stick has been changed
  79057. */
  79058. private _onleftstickchanged;
  79059. /**
  79060. * Triggered when the right control stick has been changed
  79061. */
  79062. private _onrightstickchanged;
  79063. /**
  79064. * Represents a gamepad controller
  79065. */
  79066. static GAMEPAD: number;
  79067. /**
  79068. * Represents a generic controller
  79069. */
  79070. static GENERIC: number;
  79071. /**
  79072. * Represents an XBox controller
  79073. */
  79074. static XBOX: number;
  79075. /**
  79076. * Represents a pose-enabled controller
  79077. */
  79078. static POSE_ENABLED: number;
  79079. /**
  79080. * Represents an Dual Shock controller
  79081. */
  79082. static DUALSHOCK: number;
  79083. /**
  79084. * Specifies whether the left control stick should be Y-inverted
  79085. */
  79086. protected _invertLeftStickY: boolean;
  79087. /**
  79088. * Specifies if the gamepad has been connected
  79089. */
  79090. readonly isConnected: boolean;
  79091. /**
  79092. * Initializes the gamepad
  79093. * @param id The id of the gamepad
  79094. * @param index The index of the gamepad
  79095. * @param browserGamepad The browser gamepad
  79096. * @param leftStickX The x component of the left joystick
  79097. * @param leftStickY The y component of the left joystick
  79098. * @param rightStickX The x component of the right joystick
  79099. * @param rightStickY The y component of the right joystick
  79100. */
  79101. constructor(
  79102. /**
  79103. * The id of the gamepad
  79104. */
  79105. id: string,
  79106. /**
  79107. * The index of the gamepad
  79108. */
  79109. index: number,
  79110. /**
  79111. * The browser gamepad
  79112. */
  79113. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  79114. /**
  79115. * Callback triggered when the left joystick has changed
  79116. * @param callback
  79117. */
  79118. onleftstickchanged(callback: (values: StickValues) => void): void;
  79119. /**
  79120. * Callback triggered when the right joystick has changed
  79121. * @param callback
  79122. */
  79123. onrightstickchanged(callback: (values: StickValues) => void): void;
  79124. /**
  79125. * Gets the left joystick
  79126. */
  79127. /**
  79128. * Sets the left joystick values
  79129. */
  79130. leftStick: StickValues;
  79131. /**
  79132. * Gets the right joystick
  79133. */
  79134. /**
  79135. * Sets the right joystick value
  79136. */
  79137. rightStick: StickValues;
  79138. /**
  79139. * Updates the gamepad joystick positions
  79140. */
  79141. update(): void;
  79142. /**
  79143. * Disposes the gamepad
  79144. */
  79145. dispose(): void;
  79146. }
  79147. /**
  79148. * Represents a generic gamepad
  79149. */
  79150. export class GenericPad extends Gamepad {
  79151. private _buttons;
  79152. private _onbuttondown;
  79153. private _onbuttonup;
  79154. /**
  79155. * Observable triggered when a button has been pressed
  79156. */
  79157. onButtonDownObservable: Observable<number>;
  79158. /**
  79159. * Observable triggered when a button has been released
  79160. */
  79161. onButtonUpObservable: Observable<number>;
  79162. /**
  79163. * Callback triggered when a button has been pressed
  79164. * @param callback Called when a button has been pressed
  79165. */
  79166. onbuttondown(callback: (buttonPressed: number) => void): void;
  79167. /**
  79168. * Callback triggered when a button has been released
  79169. * @param callback Called when a button has been released
  79170. */
  79171. onbuttonup(callback: (buttonReleased: number) => void): void;
  79172. /**
  79173. * Initializes the generic gamepad
  79174. * @param id The id of the generic gamepad
  79175. * @param index The index of the generic gamepad
  79176. * @param browserGamepad The browser gamepad
  79177. */
  79178. constructor(id: string, index: number, browserGamepad: any);
  79179. private _setButtonValue;
  79180. /**
  79181. * Updates the generic gamepad
  79182. */
  79183. update(): void;
  79184. /**
  79185. * Disposes the generic gamepad
  79186. */
  79187. dispose(): void;
  79188. }
  79189. }
  79190. declare module BABYLON {
  79191. interface Engine {
  79192. /**
  79193. * Creates a raw texture
  79194. * @param data defines the data to store in the texture
  79195. * @param width defines the width of the texture
  79196. * @param height defines the height of the texture
  79197. * @param format defines the format of the data
  79198. * @param generateMipMaps defines if the engine should generate the mip levels
  79199. * @param invertY defines if data must be stored with Y axis inverted
  79200. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  79201. * @param compression defines the compression used (null by default)
  79202. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79203. * @returns the raw texture inside an InternalTexture
  79204. */
  79205. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  79206. /**
  79207. * Update a raw texture
  79208. * @param texture defines the texture to update
  79209. * @param data defines the data to store in the texture
  79210. * @param format defines the format of the data
  79211. * @param invertY defines if data must be stored with Y axis inverted
  79212. */
  79213. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79214. /**
  79215. * Update a raw texture
  79216. * @param texture defines the texture to update
  79217. * @param data defines the data to store in the texture
  79218. * @param format defines the format of the data
  79219. * @param invertY defines if data must be stored with Y axis inverted
  79220. * @param compression defines the compression used (null by default)
  79221. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79222. */
  79223. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  79224. /**
  79225. * Creates a new raw cube texture
  79226. * @param data defines the array of data to use to create each face
  79227. * @param size defines the size of the textures
  79228. * @param format defines the format of the data
  79229. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79230. * @param generateMipMaps defines if the engine should generate the mip levels
  79231. * @param invertY defines if data must be stored with Y axis inverted
  79232. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79233. * @param compression defines the compression used (null by default)
  79234. * @returns the cube texture as an InternalTexture
  79235. */
  79236. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  79237. /**
  79238. * Update a raw cube texture
  79239. * @param texture defines the texture to udpdate
  79240. * @param data defines the data to store
  79241. * @param format defines the data format
  79242. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79243. * @param invertY defines if data must be stored with Y axis inverted
  79244. */
  79245. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  79246. /**
  79247. * Update a raw cube texture
  79248. * @param texture defines the texture to udpdate
  79249. * @param data defines the data to store
  79250. * @param format defines the data format
  79251. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79252. * @param invertY defines if data must be stored with Y axis inverted
  79253. * @param compression defines the compression used (null by default)
  79254. */
  79255. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  79256. /**
  79257. * Update a raw cube texture
  79258. * @param texture defines the texture to udpdate
  79259. * @param data defines the data to store
  79260. * @param format defines the data format
  79261. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  79262. * @param invertY defines if data must be stored with Y axis inverted
  79263. * @param compression defines the compression used (null by default)
  79264. * @param level defines which level of the texture to update
  79265. */
  79266. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  79267. /**
  79268. * Creates a new raw cube texture from a specified url
  79269. * @param url defines the url where the data is located
  79270. * @param scene defines the current scene
  79271. * @param size defines the size of the textures
  79272. * @param format defines the format of the data
  79273. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79274. * @param noMipmap defines if the engine should avoid generating the mip levels
  79275. * @param callback defines a callback used to extract texture data from loaded data
  79276. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79277. * @param onLoad defines a callback called when texture is loaded
  79278. * @param onError defines a callback called if there is an error
  79279. * @returns the cube texture as an InternalTexture
  79280. */
  79281. 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;
  79282. /**
  79283. * Creates a new raw cube texture from a specified url
  79284. * @param url defines the url where the data is located
  79285. * @param scene defines the current scene
  79286. * @param size defines the size of the textures
  79287. * @param format defines the format of the data
  79288. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  79289. * @param noMipmap defines if the engine should avoid generating the mip levels
  79290. * @param callback defines a callback used to extract texture data from loaded data
  79291. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  79292. * @param onLoad defines a callback called when texture is loaded
  79293. * @param onError defines a callback called if there is an error
  79294. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79295. * @param invertY defines if data must be stored with Y axis inverted
  79296. * @returns the cube texture as an InternalTexture
  79297. */
  79298. 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;
  79299. /**
  79300. * Creates a new raw 3D texture
  79301. * @param data defines the data used to create the texture
  79302. * @param width defines the width of the texture
  79303. * @param height defines the height of the texture
  79304. * @param depth defines the depth of the texture
  79305. * @param format defines the format of the texture
  79306. * @param generateMipMaps defines if the engine must generate mip levels
  79307. * @param invertY defines if data must be stored with Y axis inverted
  79308. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  79309. * @param compression defines the compressed used (can be null)
  79310. * @param textureType defines the compressed used (can be null)
  79311. * @returns a new raw 3D texture (stored in an InternalTexture)
  79312. */
  79313. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  79314. /**
  79315. * Update a raw 3D texture
  79316. * @param texture defines the texture to update
  79317. * @param data defines the data to store
  79318. * @param format defines the data format
  79319. * @param invertY defines if data must be stored with Y axis inverted
  79320. */
  79321. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  79322. /**
  79323. * Update a raw 3D texture
  79324. * @param texture defines the texture to update
  79325. * @param data defines the data to store
  79326. * @param format defines the data format
  79327. * @param invertY defines if data must be stored with Y axis inverted
  79328. * @param compression defines the used compression (can be null)
  79329. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  79330. */
  79331. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  79332. }
  79333. }
  79334. declare module BABYLON {
  79335. /**
  79336. * Raw texture can help creating a texture directly from an array of data.
  79337. * This can be super useful if you either get the data from an uncompressed source or
  79338. * if you wish to create your texture pixel by pixel.
  79339. */
  79340. export class RawTexture extends Texture {
  79341. /**
  79342. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79343. */
  79344. format: number;
  79345. private _engine;
  79346. /**
  79347. * Instantiates a new RawTexture.
  79348. * Raw texture can help creating a texture directly from an array of data.
  79349. * This can be super useful if you either get the data from an uncompressed source or
  79350. * if you wish to create your texture pixel by pixel.
  79351. * @param data define the array of data to use to create the texture
  79352. * @param width define the width of the texture
  79353. * @param height define the height of the texture
  79354. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79355. * @param scene define the scene the texture belongs to
  79356. * @param generateMipMaps define whether mip maps should be generated or not
  79357. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79358. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79359. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79360. */
  79361. constructor(data: ArrayBufferView, width: number, height: number,
  79362. /**
  79363. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  79364. */
  79365. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  79366. /**
  79367. * Updates the texture underlying data.
  79368. * @param data Define the new data of the texture
  79369. */
  79370. update(data: ArrayBufferView): void;
  79371. /**
  79372. * Creates a luminance texture from some data.
  79373. * @param data Define the texture data
  79374. * @param width Define the width of the texture
  79375. * @param height Define the height of the texture
  79376. * @param scene Define the scene the texture belongs to
  79377. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79378. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79379. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79380. * @returns the luminance texture
  79381. */
  79382. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79383. /**
  79384. * Creates a luminance alpha texture from some data.
  79385. * @param data Define the texture data
  79386. * @param width Define the width of the texture
  79387. * @param height Define the height of the texture
  79388. * @param scene Define the scene the texture belongs to
  79389. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79390. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79391. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79392. * @returns the luminance alpha texture
  79393. */
  79394. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79395. /**
  79396. * Creates an alpha texture from some data.
  79397. * @param data Define the texture data
  79398. * @param width Define the width of the texture
  79399. * @param height Define the height of the texture
  79400. * @param scene Define the scene the texture belongs to
  79401. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79402. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79403. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79404. * @returns the alpha texture
  79405. */
  79406. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  79407. /**
  79408. * Creates a RGB texture from some data.
  79409. * @param data Define the texture data
  79410. * @param width Define the width of the texture
  79411. * @param height Define the height of the texture
  79412. * @param scene Define the scene the texture belongs to
  79413. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79414. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79415. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79416. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79417. * @returns the RGB alpha texture
  79418. */
  79419. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79420. /**
  79421. * Creates a RGBA texture from some data.
  79422. * @param data Define the texture data
  79423. * @param width Define the width of the texture
  79424. * @param height Define the height of the texture
  79425. * @param scene Define the scene the texture belongs to
  79426. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79427. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79428. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79429. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79430. * @returns the RGBA texture
  79431. */
  79432. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79433. /**
  79434. * Creates a R texture from some data.
  79435. * @param data Define the texture data
  79436. * @param width Define the width of the texture
  79437. * @param height Define the height of the texture
  79438. * @param scene Define the scene the texture belongs to
  79439. * @param generateMipMaps Define whether or not to create mip maps for the texture
  79440. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  79441. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  79442. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  79443. * @returns the R texture
  79444. */
  79445. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  79446. }
  79447. }
  79448. declare module BABYLON {
  79449. /**
  79450. * Interface for the size containing width and height
  79451. */
  79452. export interface ISize {
  79453. /**
  79454. * Width
  79455. */
  79456. width: number;
  79457. /**
  79458. * Heighht
  79459. */
  79460. height: number;
  79461. }
  79462. /**
  79463. * Size containing widht and height
  79464. */
  79465. export class Size implements ISize {
  79466. /**
  79467. * Width
  79468. */
  79469. width: number;
  79470. /**
  79471. * Height
  79472. */
  79473. height: number;
  79474. /**
  79475. * Creates a Size object from the given width and height (floats).
  79476. * @param width width of the new size
  79477. * @param height height of the new size
  79478. */
  79479. constructor(width: number, height: number);
  79480. /**
  79481. * Returns a string with the Size width and height
  79482. * @returns a string with the Size width and height
  79483. */
  79484. toString(): string;
  79485. /**
  79486. * "Size"
  79487. * @returns the string "Size"
  79488. */
  79489. getClassName(): string;
  79490. /**
  79491. * Returns the Size hash code.
  79492. * @returns a hash code for a unique width and height
  79493. */
  79494. getHashCode(): number;
  79495. /**
  79496. * Updates the current size from the given one.
  79497. * @param src the given size
  79498. */
  79499. copyFrom(src: Size): void;
  79500. /**
  79501. * Updates in place the current Size from the given floats.
  79502. * @param width width of the new size
  79503. * @param height height of the new size
  79504. * @returns the updated Size.
  79505. */
  79506. copyFromFloats(width: number, height: number): Size;
  79507. /**
  79508. * Updates in place the current Size from the given floats.
  79509. * @param width width to set
  79510. * @param height height to set
  79511. * @returns the updated Size.
  79512. */
  79513. set(width: number, height: number): Size;
  79514. /**
  79515. * Multiplies the width and height by numbers
  79516. * @param w factor to multiple the width by
  79517. * @param h factor to multiple the height by
  79518. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  79519. */
  79520. multiplyByFloats(w: number, h: number): Size;
  79521. /**
  79522. * Clones the size
  79523. * @returns a new Size copied from the given one.
  79524. */
  79525. clone(): Size;
  79526. /**
  79527. * True if the current Size and the given one width and height are strictly equal.
  79528. * @param other the other size to compare against
  79529. * @returns True if the current Size and the given one width and height are strictly equal.
  79530. */
  79531. equals(other: Size): boolean;
  79532. /**
  79533. * The surface of the Size : width * height (float).
  79534. */
  79535. readonly surface: number;
  79536. /**
  79537. * Create a new size of zero
  79538. * @returns a new Size set to (0.0, 0.0)
  79539. */
  79540. static Zero(): Size;
  79541. /**
  79542. * Sums the width and height of two sizes
  79543. * @param otherSize size to add to this size
  79544. * @returns a new Size set as the addition result of the current Size and the given one.
  79545. */
  79546. add(otherSize: Size): Size;
  79547. /**
  79548. * Subtracts the width and height of two
  79549. * @param otherSize size to subtract to this size
  79550. * @returns a new Size set as the subtraction result of the given one from the current Size.
  79551. */
  79552. subtract(otherSize: Size): Size;
  79553. /**
  79554. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  79555. * @param start starting size to lerp between
  79556. * @param end end size to lerp between
  79557. * @param amount amount to lerp between the start and end values
  79558. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  79559. */
  79560. static Lerp(start: Size, end: Size, amount: number): Size;
  79561. }
  79562. }
  79563. declare module BABYLON {
  79564. /**
  79565. * Defines a runtime animation
  79566. */
  79567. export class RuntimeAnimation {
  79568. private _events;
  79569. /**
  79570. * The current frame of the runtime animation
  79571. */
  79572. private _currentFrame;
  79573. /**
  79574. * The animation used by the runtime animation
  79575. */
  79576. private _animation;
  79577. /**
  79578. * The target of the runtime animation
  79579. */
  79580. private _target;
  79581. /**
  79582. * The initiating animatable
  79583. */
  79584. private _host;
  79585. /**
  79586. * The original value of the runtime animation
  79587. */
  79588. private _originalValue;
  79589. /**
  79590. * The original blend value of the runtime animation
  79591. */
  79592. private _originalBlendValue;
  79593. /**
  79594. * The offsets cache of the runtime animation
  79595. */
  79596. private _offsetsCache;
  79597. /**
  79598. * The high limits cache of the runtime animation
  79599. */
  79600. private _highLimitsCache;
  79601. /**
  79602. * Specifies if the runtime animation has been stopped
  79603. */
  79604. private _stopped;
  79605. /**
  79606. * The blending factor of the runtime animation
  79607. */
  79608. private _blendingFactor;
  79609. /**
  79610. * The BabylonJS scene
  79611. */
  79612. private _scene;
  79613. /**
  79614. * The current value of the runtime animation
  79615. */
  79616. private _currentValue;
  79617. /** @hidden */
  79618. _animationState: _IAnimationState;
  79619. /**
  79620. * The active target of the runtime animation
  79621. */
  79622. private _activeTargets;
  79623. private _currentActiveTarget;
  79624. private _directTarget;
  79625. /**
  79626. * The target path of the runtime animation
  79627. */
  79628. private _targetPath;
  79629. /**
  79630. * The weight of the runtime animation
  79631. */
  79632. private _weight;
  79633. /**
  79634. * The ratio offset of the runtime animation
  79635. */
  79636. private _ratioOffset;
  79637. /**
  79638. * The previous delay of the runtime animation
  79639. */
  79640. private _previousDelay;
  79641. /**
  79642. * The previous ratio of the runtime animation
  79643. */
  79644. private _previousRatio;
  79645. private _enableBlending;
  79646. private _keys;
  79647. private _minFrame;
  79648. private _maxFrame;
  79649. private _minValue;
  79650. private _maxValue;
  79651. private _targetIsArray;
  79652. /**
  79653. * Gets the current frame of the runtime animation
  79654. */
  79655. readonly currentFrame: number;
  79656. /**
  79657. * Gets the weight of the runtime animation
  79658. */
  79659. readonly weight: number;
  79660. /**
  79661. * Gets the current value of the runtime animation
  79662. */
  79663. readonly currentValue: any;
  79664. /**
  79665. * Gets the target path of the runtime animation
  79666. */
  79667. readonly targetPath: string;
  79668. /**
  79669. * Gets the actual target of the runtime animation
  79670. */
  79671. readonly target: any;
  79672. /** @hidden */
  79673. _onLoop: () => void;
  79674. /**
  79675. * Create a new RuntimeAnimation object
  79676. * @param target defines the target of the animation
  79677. * @param animation defines the source animation object
  79678. * @param scene defines the hosting scene
  79679. * @param host defines the initiating Animatable
  79680. */
  79681. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  79682. private _preparePath;
  79683. /**
  79684. * Gets the animation from the runtime animation
  79685. */
  79686. readonly animation: Animation;
  79687. /**
  79688. * Resets the runtime animation to the beginning
  79689. * @param restoreOriginal defines whether to restore the target property to the original value
  79690. */
  79691. reset(restoreOriginal?: boolean): void;
  79692. /**
  79693. * Specifies if the runtime animation is stopped
  79694. * @returns Boolean specifying if the runtime animation is stopped
  79695. */
  79696. isStopped(): boolean;
  79697. /**
  79698. * Disposes of the runtime animation
  79699. */
  79700. dispose(): void;
  79701. /**
  79702. * Apply the interpolated value to the target
  79703. * @param currentValue defines the value computed by the animation
  79704. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  79705. */
  79706. setValue(currentValue: any, weight: number): void;
  79707. private _getOriginalValues;
  79708. private _setValue;
  79709. /**
  79710. * Gets the loop pmode of the runtime animation
  79711. * @returns Loop Mode
  79712. */
  79713. private _getCorrectLoopMode;
  79714. /**
  79715. * Move the current animation to a given frame
  79716. * @param frame defines the frame to move to
  79717. */
  79718. goToFrame(frame: number): void;
  79719. /**
  79720. * @hidden Internal use only
  79721. */
  79722. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  79723. /**
  79724. * Execute the current animation
  79725. * @param delay defines the delay to add to the current frame
  79726. * @param from defines the lower bound of the animation range
  79727. * @param to defines the upper bound of the animation range
  79728. * @param loop defines if the current animation must loop
  79729. * @param speedRatio defines the current speed ratio
  79730. * @param weight defines the weight of the animation (default is -1 so no weight)
  79731. * @param onLoop optional callback called when animation loops
  79732. * @returns a boolean indicating if the animation is running
  79733. */
  79734. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  79735. }
  79736. }
  79737. declare module BABYLON {
  79738. /**
  79739. * Class used to store an actual running animation
  79740. */
  79741. export class Animatable {
  79742. /** defines the target object */
  79743. target: any;
  79744. /** defines the starting frame number (default is 0) */
  79745. fromFrame: number;
  79746. /** defines the ending frame number (default is 100) */
  79747. toFrame: number;
  79748. /** defines if the animation must loop (default is false) */
  79749. loopAnimation: boolean;
  79750. /** defines a callback to call when animation ends if it is not looping */
  79751. onAnimationEnd?: (() => void) | null | undefined;
  79752. /** defines a callback to call when animation loops */
  79753. onAnimationLoop?: (() => void) | null | undefined;
  79754. private _localDelayOffset;
  79755. private _pausedDelay;
  79756. private _runtimeAnimations;
  79757. private _paused;
  79758. private _scene;
  79759. private _speedRatio;
  79760. private _weight;
  79761. private _syncRoot;
  79762. /**
  79763. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  79764. * This will only apply for non looping animation (default is true)
  79765. */
  79766. disposeOnEnd: boolean;
  79767. /**
  79768. * Gets a boolean indicating if the animation has started
  79769. */
  79770. animationStarted: boolean;
  79771. /**
  79772. * Observer raised when the animation ends
  79773. */
  79774. onAnimationEndObservable: Observable<Animatable>;
  79775. /**
  79776. * Observer raised when the animation loops
  79777. */
  79778. onAnimationLoopObservable: Observable<Animatable>;
  79779. /**
  79780. * Gets the root Animatable used to synchronize and normalize animations
  79781. */
  79782. readonly syncRoot: Nullable<Animatable>;
  79783. /**
  79784. * Gets the current frame of the first RuntimeAnimation
  79785. * Used to synchronize Animatables
  79786. */
  79787. readonly masterFrame: number;
  79788. /**
  79789. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  79790. */
  79791. weight: number;
  79792. /**
  79793. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  79794. */
  79795. speedRatio: number;
  79796. /**
  79797. * Creates a new Animatable
  79798. * @param scene defines the hosting scene
  79799. * @param target defines the target object
  79800. * @param fromFrame defines the starting frame number (default is 0)
  79801. * @param toFrame defines the ending frame number (default is 100)
  79802. * @param loopAnimation defines if the animation must loop (default is false)
  79803. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  79804. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  79805. * @param animations defines a group of animation to add to the new Animatable
  79806. * @param onAnimationLoop defines a callback to call when animation loops
  79807. */
  79808. constructor(scene: Scene,
  79809. /** defines the target object */
  79810. target: any,
  79811. /** defines the starting frame number (default is 0) */
  79812. fromFrame?: number,
  79813. /** defines the ending frame number (default is 100) */
  79814. toFrame?: number,
  79815. /** defines if the animation must loop (default is false) */
  79816. loopAnimation?: boolean, speedRatio?: number,
  79817. /** defines a callback to call when animation ends if it is not looping */
  79818. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  79819. /** defines a callback to call when animation loops */
  79820. onAnimationLoop?: (() => void) | null | undefined);
  79821. /**
  79822. * Synchronize and normalize current Animatable with a source Animatable
  79823. * This is useful when using animation weights and when animations are not of the same length
  79824. * @param root defines the root Animatable to synchronize with
  79825. * @returns the current Animatable
  79826. */
  79827. syncWith(root: Animatable): Animatable;
  79828. /**
  79829. * Gets the list of runtime animations
  79830. * @returns an array of RuntimeAnimation
  79831. */
  79832. getAnimations(): RuntimeAnimation[];
  79833. /**
  79834. * Adds more animations to the current animatable
  79835. * @param target defines the target of the animations
  79836. * @param animations defines the new animations to add
  79837. */
  79838. appendAnimations(target: any, animations: Animation[]): void;
  79839. /**
  79840. * Gets the source animation for a specific property
  79841. * @param property defines the propertyu to look for
  79842. * @returns null or the source animation for the given property
  79843. */
  79844. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  79845. /**
  79846. * Gets the runtime animation for a specific property
  79847. * @param property defines the propertyu to look for
  79848. * @returns null or the runtime animation for the given property
  79849. */
  79850. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  79851. /**
  79852. * Resets the animatable to its original state
  79853. */
  79854. reset(): void;
  79855. /**
  79856. * Allows the animatable to blend with current running animations
  79857. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79858. * @param blendingSpeed defines the blending speed to use
  79859. */
  79860. enableBlending(blendingSpeed: number): void;
  79861. /**
  79862. * Disable animation blending
  79863. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  79864. */
  79865. disableBlending(): void;
  79866. /**
  79867. * Jump directly to a given frame
  79868. * @param frame defines the frame to jump to
  79869. */
  79870. goToFrame(frame: number): void;
  79871. /**
  79872. * Pause the animation
  79873. */
  79874. pause(): void;
  79875. /**
  79876. * Restart the animation
  79877. */
  79878. restart(): void;
  79879. private _raiseOnAnimationEnd;
  79880. /**
  79881. * Stop and delete the current animation
  79882. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  79883. * @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)
  79884. */
  79885. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  79886. /**
  79887. * Wait asynchronously for the animation to end
  79888. * @returns a promise which will be fullfilled when the animation ends
  79889. */
  79890. waitAsync(): Promise<Animatable>;
  79891. /** @hidden */
  79892. _animate(delay: number): boolean;
  79893. }
  79894. interface Scene {
  79895. /** @hidden */
  79896. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  79897. /** @hidden */
  79898. _processLateAnimationBindingsForMatrices(holder: {
  79899. totalWeight: number;
  79900. animations: RuntimeAnimation[];
  79901. originalValue: Matrix;
  79902. }): any;
  79903. /** @hidden */
  79904. _processLateAnimationBindingsForQuaternions(holder: {
  79905. totalWeight: number;
  79906. animations: RuntimeAnimation[];
  79907. originalValue: Quaternion;
  79908. }, refQuaternion: Quaternion): Quaternion;
  79909. /** @hidden */
  79910. _processLateAnimationBindings(): void;
  79911. /**
  79912. * Will start the animation sequence of a given target
  79913. * @param target defines the target
  79914. * @param from defines from which frame should animation start
  79915. * @param to defines until which frame should animation run.
  79916. * @param weight defines the weight to apply to the animation (1.0 by default)
  79917. * @param loop defines if the animation loops
  79918. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79919. * @param onAnimationEnd defines the function to be executed when the animation ends
  79920. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79921. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79922. * @param onAnimationLoop defines the callback to call when an animation loops
  79923. * @returns the animatable object created for this animation
  79924. */
  79925. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79926. /**
  79927. * Will start the animation sequence of a given target
  79928. * @param target defines the target
  79929. * @param from defines from which frame should animation start
  79930. * @param to defines until which frame should animation run.
  79931. * @param loop defines if the animation loops
  79932. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79933. * @param onAnimationEnd defines the function to be executed when the animation ends
  79934. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79935. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79936. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  79937. * @param onAnimationLoop defines the callback to call when an animation loops
  79938. * @returns the animatable object created for this animation
  79939. */
  79940. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  79941. /**
  79942. * Will start the animation sequence of a given target and its hierarchy
  79943. * @param target defines the target
  79944. * @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.
  79945. * @param from defines from which frame should animation start
  79946. * @param to defines until which frame should animation run.
  79947. * @param loop defines if the animation loops
  79948. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  79949. * @param onAnimationEnd defines the function to be executed when the animation ends
  79950. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  79951. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  79952. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  79953. * @param onAnimationLoop defines the callback to call when an animation loops
  79954. * @returns the list of created animatables
  79955. */
  79956. 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[];
  79957. /**
  79958. * Begin a new animation on a given node
  79959. * @param target defines the target where the animation will take place
  79960. * @param animations defines the list of animations to start
  79961. * @param from defines the initial value
  79962. * @param to defines the final value
  79963. * @param loop defines if you want animation to loop (off by default)
  79964. * @param speedRatio defines the speed ratio to apply to all animations
  79965. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79966. * @param onAnimationLoop defines the callback to call when an animation loops
  79967. * @returns the list of created animatables
  79968. */
  79969. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  79970. /**
  79971. * Begin a new animation on a given node and its hierarchy
  79972. * @param target defines the root node where the animation will take place
  79973. * @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.
  79974. * @param animations defines the list of animations to start
  79975. * @param from defines the initial value
  79976. * @param to defines the final value
  79977. * @param loop defines if you want animation to loop (off by default)
  79978. * @param speedRatio defines the speed ratio to apply to all animations
  79979. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  79980. * @param onAnimationLoop defines the callback to call when an animation loops
  79981. * @returns the list of animatables created for all nodes
  79982. */
  79983. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  79984. /**
  79985. * Gets the animatable associated with a specific target
  79986. * @param target defines the target of the animatable
  79987. * @returns the required animatable if found
  79988. */
  79989. getAnimatableByTarget(target: any): Nullable<Animatable>;
  79990. /**
  79991. * Gets all animatables associated with a given target
  79992. * @param target defines the target to look animatables for
  79993. * @returns an array of Animatables
  79994. */
  79995. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  79996. /**
  79997. * Stops and removes all animations that have been applied to the scene
  79998. */
  79999. stopAllAnimations(): void;
  80000. /**
  80001. * Gets the current delta time used by animation engine
  80002. */
  80003. deltaTime: number;
  80004. }
  80005. interface Bone {
  80006. /**
  80007. * Copy an animation range from another bone
  80008. * @param source defines the source bone
  80009. * @param rangeName defines the range name to copy
  80010. * @param frameOffset defines the frame offset
  80011. * @param rescaleAsRequired defines if rescaling must be applied if required
  80012. * @param skelDimensionsRatio defines the scaling ratio
  80013. * @returns true if operation was successful
  80014. */
  80015. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  80016. }
  80017. }
  80018. declare module BABYLON {
  80019. /**
  80020. * Class used to override all child animations of a given target
  80021. */
  80022. export class AnimationPropertiesOverride {
  80023. /**
  80024. * Gets or sets a value indicating if animation blending must be used
  80025. */
  80026. enableBlending: boolean;
  80027. /**
  80028. * Gets or sets the blending speed to use when enableBlending is true
  80029. */
  80030. blendingSpeed: number;
  80031. /**
  80032. * Gets or sets the default loop mode to use
  80033. */
  80034. loopMode: number;
  80035. }
  80036. }
  80037. declare module BABYLON {
  80038. /**
  80039. * Class used to handle skinning animations
  80040. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80041. */
  80042. export class Skeleton implements IAnimatable {
  80043. /** defines the skeleton name */
  80044. name: string;
  80045. /** defines the skeleton Id */
  80046. id: string;
  80047. /**
  80048. * Defines the list of child bones
  80049. */
  80050. bones: Bone[];
  80051. /**
  80052. * Defines an estimate of the dimension of the skeleton at rest
  80053. */
  80054. dimensionsAtRest: Vector3;
  80055. /**
  80056. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  80057. */
  80058. needInitialSkinMatrix: boolean;
  80059. /**
  80060. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  80061. */
  80062. overrideMesh: Nullable<AbstractMesh>;
  80063. /**
  80064. * Gets the list of animations attached to this skeleton
  80065. */
  80066. animations: Array<Animation>;
  80067. private _scene;
  80068. private _isDirty;
  80069. private _transformMatrices;
  80070. private _transformMatrixTexture;
  80071. private _meshesWithPoseMatrix;
  80072. private _animatables;
  80073. private _identity;
  80074. private _synchronizedWithMesh;
  80075. private _ranges;
  80076. private _lastAbsoluteTransformsUpdateId;
  80077. private _canUseTextureForBones;
  80078. private _uniqueId;
  80079. /** @hidden */
  80080. _numBonesWithLinkedTransformNode: number;
  80081. /** @hidden */
  80082. _hasWaitingData: Nullable<boolean>;
  80083. /**
  80084. * Specifies if the skeleton should be serialized
  80085. */
  80086. doNotSerialize: boolean;
  80087. private _useTextureToStoreBoneMatrices;
  80088. /**
  80089. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  80090. * Please note that this option is not available if the hardware does not support it
  80091. */
  80092. useTextureToStoreBoneMatrices: boolean;
  80093. private _animationPropertiesOverride;
  80094. /**
  80095. * Gets or sets the animation properties override
  80096. */
  80097. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80098. /**
  80099. * List of inspectable custom properties (used by the Inspector)
  80100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  80101. */
  80102. inspectableCustomProperties: IInspectable[];
  80103. /**
  80104. * An observable triggered before computing the skeleton's matrices
  80105. */
  80106. onBeforeComputeObservable: Observable<Skeleton>;
  80107. /**
  80108. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  80109. */
  80110. readonly isUsingTextureForMatrices: boolean;
  80111. /**
  80112. * Gets the unique ID of this skeleton
  80113. */
  80114. readonly uniqueId: number;
  80115. /**
  80116. * Creates a new skeleton
  80117. * @param name defines the skeleton name
  80118. * @param id defines the skeleton Id
  80119. * @param scene defines the hosting scene
  80120. */
  80121. constructor(
  80122. /** defines the skeleton name */
  80123. name: string,
  80124. /** defines the skeleton Id */
  80125. id: string, scene: Scene);
  80126. /**
  80127. * Gets the current object class name.
  80128. * @return the class name
  80129. */
  80130. getClassName(): string;
  80131. /**
  80132. * Returns an array containing the root bones
  80133. * @returns an array containing the root bones
  80134. */
  80135. getChildren(): Array<Bone>;
  80136. /**
  80137. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  80138. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80139. * @returns a Float32Array containing matrices data
  80140. */
  80141. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  80142. /**
  80143. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  80144. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  80145. * @returns a raw texture containing the data
  80146. */
  80147. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  80148. /**
  80149. * Gets the current hosting scene
  80150. * @returns a scene object
  80151. */
  80152. getScene(): Scene;
  80153. /**
  80154. * Gets a string representing the current skeleton data
  80155. * @param fullDetails defines a boolean indicating if we want a verbose version
  80156. * @returns a string representing the current skeleton data
  80157. */
  80158. toString(fullDetails?: boolean): string;
  80159. /**
  80160. * Get bone's index searching by name
  80161. * @param name defines bone's name to search for
  80162. * @return the indice of the bone. Returns -1 if not found
  80163. */
  80164. getBoneIndexByName(name: string): number;
  80165. /**
  80166. * Creater a new animation range
  80167. * @param name defines the name of the range
  80168. * @param from defines the start key
  80169. * @param to defines the end key
  80170. */
  80171. createAnimationRange(name: string, from: number, to: number): void;
  80172. /**
  80173. * Delete a specific animation range
  80174. * @param name defines the name of the range
  80175. * @param deleteFrames defines if frames must be removed as well
  80176. */
  80177. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  80178. /**
  80179. * Gets a specific animation range
  80180. * @param name defines the name of the range to look for
  80181. * @returns the requested animation range or null if not found
  80182. */
  80183. getAnimationRange(name: string): Nullable<AnimationRange>;
  80184. /**
  80185. * Gets the list of all animation ranges defined on this skeleton
  80186. * @returns an array
  80187. */
  80188. getAnimationRanges(): Nullable<AnimationRange>[];
  80189. /**
  80190. * Copy animation range from a source skeleton.
  80191. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  80192. * @param source defines the source skeleton
  80193. * @param name defines the name of the range to copy
  80194. * @param rescaleAsRequired defines if rescaling must be applied if required
  80195. * @returns true if operation was successful
  80196. */
  80197. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  80198. /**
  80199. * Forces the skeleton to go to rest pose
  80200. */
  80201. returnToRest(): void;
  80202. private _getHighestAnimationFrame;
  80203. /**
  80204. * Begin a specific animation range
  80205. * @param name defines the name of the range to start
  80206. * @param loop defines if looping must be turned on (false by default)
  80207. * @param speedRatio defines the speed ratio to apply (1 by default)
  80208. * @param onAnimationEnd defines a callback which will be called when animation will end
  80209. * @returns a new animatable
  80210. */
  80211. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  80212. /** @hidden */
  80213. _markAsDirty(): void;
  80214. /** @hidden */
  80215. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80216. /** @hidden */
  80217. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  80218. private _computeTransformMatrices;
  80219. /**
  80220. * Build all resources required to render a skeleton
  80221. */
  80222. prepare(): void;
  80223. /**
  80224. * Gets the list of animatables currently running for this skeleton
  80225. * @returns an array of animatables
  80226. */
  80227. getAnimatables(): IAnimatable[];
  80228. /**
  80229. * Clone the current skeleton
  80230. * @param name defines the name of the new skeleton
  80231. * @param id defines the id of the new skeleton
  80232. * @returns the new skeleton
  80233. */
  80234. clone(name: string, id: string): Skeleton;
  80235. /**
  80236. * Enable animation blending for this skeleton
  80237. * @param blendingSpeed defines the blending speed to apply
  80238. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  80239. */
  80240. enableBlending(blendingSpeed?: number): void;
  80241. /**
  80242. * Releases all resources associated with the current skeleton
  80243. */
  80244. dispose(): void;
  80245. /**
  80246. * Serialize the skeleton in a JSON object
  80247. * @returns a JSON object
  80248. */
  80249. serialize(): any;
  80250. /**
  80251. * Creates a new skeleton from serialized data
  80252. * @param parsedSkeleton defines the serialized data
  80253. * @param scene defines the hosting scene
  80254. * @returns a new skeleton
  80255. */
  80256. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  80257. /**
  80258. * Compute all node absolute transforms
  80259. * @param forceUpdate defines if computation must be done even if cache is up to date
  80260. */
  80261. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  80262. /**
  80263. * Gets the root pose matrix
  80264. * @returns a matrix
  80265. */
  80266. getPoseMatrix(): Nullable<Matrix>;
  80267. /**
  80268. * Sorts bones per internal index
  80269. */
  80270. sortBones(): void;
  80271. private _sortBones;
  80272. }
  80273. }
  80274. declare module BABYLON {
  80275. /**
  80276. * Class used to store bone information
  80277. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  80278. */
  80279. export class Bone extends Node {
  80280. /**
  80281. * defines the bone name
  80282. */
  80283. name: string;
  80284. private static _tmpVecs;
  80285. private static _tmpQuat;
  80286. private static _tmpMats;
  80287. /**
  80288. * Gets the list of child bones
  80289. */
  80290. children: Bone[];
  80291. /** Gets the animations associated with this bone */
  80292. animations: Animation[];
  80293. /**
  80294. * Gets or sets bone length
  80295. */
  80296. length: number;
  80297. /**
  80298. * @hidden Internal only
  80299. * Set this value to map this bone to a different index in the transform matrices
  80300. * Set this value to -1 to exclude the bone from the transform matrices
  80301. */
  80302. _index: Nullable<number>;
  80303. private _skeleton;
  80304. private _localMatrix;
  80305. private _restPose;
  80306. private _baseMatrix;
  80307. private _absoluteTransform;
  80308. private _invertedAbsoluteTransform;
  80309. private _parent;
  80310. private _scalingDeterminant;
  80311. private _worldTransform;
  80312. private _localScaling;
  80313. private _localRotation;
  80314. private _localPosition;
  80315. private _needToDecompose;
  80316. private _needToCompose;
  80317. /** @hidden */
  80318. _linkedTransformNode: Nullable<TransformNode>;
  80319. /** @hidden */
  80320. _waitingTransformNodeId: Nullable<string>;
  80321. /** @hidden */
  80322. /** @hidden */
  80323. _matrix: Matrix;
  80324. /**
  80325. * Create a new bone
  80326. * @param name defines the bone name
  80327. * @param skeleton defines the parent skeleton
  80328. * @param parentBone defines the parent (can be null if the bone is the root)
  80329. * @param localMatrix defines the local matrix
  80330. * @param restPose defines the rest pose matrix
  80331. * @param baseMatrix defines the base matrix
  80332. * @param index defines index of the bone in the hiearchy
  80333. */
  80334. constructor(
  80335. /**
  80336. * defines the bone name
  80337. */
  80338. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  80339. /**
  80340. * Gets the current object class name.
  80341. * @return the class name
  80342. */
  80343. getClassName(): string;
  80344. /**
  80345. * Gets the parent skeleton
  80346. * @returns a skeleton
  80347. */
  80348. getSkeleton(): Skeleton;
  80349. /**
  80350. * Gets parent bone
  80351. * @returns a bone or null if the bone is the root of the bone hierarchy
  80352. */
  80353. getParent(): Nullable<Bone>;
  80354. /**
  80355. * Returns an array containing the root bones
  80356. * @returns an array containing the root bones
  80357. */
  80358. getChildren(): Array<Bone>;
  80359. /**
  80360. * Sets the parent bone
  80361. * @param parent defines the parent (can be null if the bone is the root)
  80362. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80363. */
  80364. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  80365. /**
  80366. * Gets the local matrix
  80367. * @returns a matrix
  80368. */
  80369. getLocalMatrix(): Matrix;
  80370. /**
  80371. * Gets the base matrix (initial matrix which remains unchanged)
  80372. * @returns a matrix
  80373. */
  80374. getBaseMatrix(): Matrix;
  80375. /**
  80376. * Gets the rest pose matrix
  80377. * @returns a matrix
  80378. */
  80379. getRestPose(): Matrix;
  80380. /**
  80381. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  80382. */
  80383. getWorldMatrix(): Matrix;
  80384. /**
  80385. * Sets the local matrix to rest pose matrix
  80386. */
  80387. returnToRest(): void;
  80388. /**
  80389. * Gets the inverse of the absolute transform matrix.
  80390. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  80391. * @returns a matrix
  80392. */
  80393. getInvertedAbsoluteTransform(): Matrix;
  80394. /**
  80395. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  80396. * @returns a matrix
  80397. */
  80398. getAbsoluteTransform(): Matrix;
  80399. /**
  80400. * Links with the given transform node.
  80401. * The local matrix of this bone is copied from the transform node every frame.
  80402. * @param transformNode defines the transform node to link to
  80403. */
  80404. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  80405. /**
  80406. * Gets the node used to drive the bone's transformation
  80407. * @returns a transform node or null
  80408. */
  80409. getTransformNode(): Nullable<TransformNode>;
  80410. /** Gets or sets current position (in local space) */
  80411. position: Vector3;
  80412. /** Gets or sets current rotation (in local space) */
  80413. rotation: Vector3;
  80414. /** Gets or sets current rotation quaternion (in local space) */
  80415. rotationQuaternion: Quaternion;
  80416. /** Gets or sets current scaling (in local space) */
  80417. scaling: Vector3;
  80418. /**
  80419. * Gets the animation properties override
  80420. */
  80421. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  80422. private _decompose;
  80423. private _compose;
  80424. /**
  80425. * Update the base and local matrices
  80426. * @param matrix defines the new base or local matrix
  80427. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  80428. * @param updateLocalMatrix defines if the local matrix should be updated
  80429. */
  80430. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  80431. /** @hidden */
  80432. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  80433. /**
  80434. * Flag the bone as dirty (Forcing it to update everything)
  80435. */
  80436. markAsDirty(): void;
  80437. /** @hidden */
  80438. _markAsDirtyAndCompose(): void;
  80439. private _markAsDirtyAndDecompose;
  80440. /**
  80441. * Translate the bone in local or world space
  80442. * @param vec The amount to translate the bone
  80443. * @param space The space that the translation is in
  80444. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80445. */
  80446. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80447. /**
  80448. * Set the postion of the bone in local or world space
  80449. * @param position The position to set the bone
  80450. * @param space The space that the position is in
  80451. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80452. */
  80453. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80454. /**
  80455. * Set the absolute position of the bone (world space)
  80456. * @param position The position to set the bone
  80457. * @param mesh The mesh that this bone is attached to
  80458. */
  80459. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  80460. /**
  80461. * Scale the bone on the x, y and z axes (in local space)
  80462. * @param x The amount to scale the bone on the x axis
  80463. * @param y The amount to scale the bone on the y axis
  80464. * @param z The amount to scale the bone on the z axis
  80465. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  80466. */
  80467. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  80468. /**
  80469. * Set the bone scaling in local space
  80470. * @param scale defines the scaling vector
  80471. */
  80472. setScale(scale: Vector3): void;
  80473. /**
  80474. * Gets the current scaling in local space
  80475. * @returns the current scaling vector
  80476. */
  80477. getScale(): Vector3;
  80478. /**
  80479. * Gets the current scaling in local space and stores it in a target vector
  80480. * @param result defines the target vector
  80481. */
  80482. getScaleToRef(result: Vector3): void;
  80483. /**
  80484. * Set the yaw, pitch, and roll of the bone in local or world space
  80485. * @param yaw The rotation of the bone on the y axis
  80486. * @param pitch The rotation of the bone on the x axis
  80487. * @param roll The rotation of the bone on the z axis
  80488. * @param space The space that the axes of rotation are in
  80489. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80490. */
  80491. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  80492. /**
  80493. * Add a rotation to the bone on an axis in local or world space
  80494. * @param axis The axis to rotate the bone on
  80495. * @param amount The amount to rotate the bone
  80496. * @param space The space that the axis is in
  80497. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80498. */
  80499. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  80500. /**
  80501. * Set the rotation of the bone to a particular axis angle in local or world space
  80502. * @param axis The axis to rotate the bone on
  80503. * @param angle The angle that the bone should be rotated to
  80504. * @param space The space that the axis is in
  80505. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80506. */
  80507. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  80508. /**
  80509. * Set the euler rotation of the bone in local of world space
  80510. * @param rotation The euler rotation that the bone should be set to
  80511. * @param space The space that the rotation is in
  80512. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80513. */
  80514. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  80515. /**
  80516. * Set the quaternion rotation of the bone in local of world space
  80517. * @param quat The quaternion rotation that the bone should be set to
  80518. * @param space The space that the rotation is in
  80519. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80520. */
  80521. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  80522. /**
  80523. * Set the rotation matrix of the bone in local of world space
  80524. * @param rotMat The rotation matrix that the bone should be set to
  80525. * @param space The space that the rotation is in
  80526. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80527. */
  80528. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  80529. private _rotateWithMatrix;
  80530. private _getNegativeRotationToRef;
  80531. /**
  80532. * Get the position of the bone in local or world space
  80533. * @param space The space that the returned position is in
  80534. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80535. * @returns The position of the bone
  80536. */
  80537. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80538. /**
  80539. * Copy the position of the bone to a vector3 in local or world space
  80540. * @param space The space that the returned position is in
  80541. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80542. * @param result The vector3 to copy the position to
  80543. */
  80544. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  80545. /**
  80546. * Get the absolute position of the bone (world space)
  80547. * @param mesh The mesh that this bone is attached to
  80548. * @returns The absolute position of the bone
  80549. */
  80550. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  80551. /**
  80552. * Copy the absolute position of the bone (world space) to the result param
  80553. * @param mesh The mesh that this bone is attached to
  80554. * @param result The vector3 to copy the absolute position to
  80555. */
  80556. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  80557. /**
  80558. * Compute the absolute transforms of this bone and its children
  80559. */
  80560. computeAbsoluteTransforms(): void;
  80561. /**
  80562. * Get the world direction from an axis that is in the local space of the bone
  80563. * @param localAxis The local direction that is used to compute the world direction
  80564. * @param mesh The mesh that this bone is attached to
  80565. * @returns The world direction
  80566. */
  80567. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80568. /**
  80569. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  80570. * @param localAxis The local direction that is used to compute the world direction
  80571. * @param mesh The mesh that this bone is attached to
  80572. * @param result The vector3 that the world direction will be copied to
  80573. */
  80574. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80575. /**
  80576. * Get the euler rotation of the bone in local or world space
  80577. * @param space The space that the rotation should be in
  80578. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80579. * @returns The euler rotation
  80580. */
  80581. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  80582. /**
  80583. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  80584. * @param space The space that the rotation should be in
  80585. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80586. * @param result The vector3 that the rotation should be copied to
  80587. */
  80588. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80589. /**
  80590. * Get the quaternion rotation of the bone in either local or world space
  80591. * @param space The space that the rotation should be in
  80592. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80593. * @returns The quaternion rotation
  80594. */
  80595. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  80596. /**
  80597. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  80598. * @param space The space that the rotation should be in
  80599. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80600. * @param result The quaternion that the rotation should be copied to
  80601. */
  80602. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  80603. /**
  80604. * Get the rotation matrix of the bone in local or world space
  80605. * @param space The space that the rotation should be in
  80606. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80607. * @returns The rotation matrix
  80608. */
  80609. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  80610. /**
  80611. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  80612. * @param space The space that the rotation should be in
  80613. * @param mesh The mesh that this bone is attached to. This is only used in world space
  80614. * @param result The quaternion that the rotation should be copied to
  80615. */
  80616. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  80617. /**
  80618. * Get the world position of a point that is in the local space of the bone
  80619. * @param position The local position
  80620. * @param mesh The mesh that this bone is attached to
  80621. * @returns The world position
  80622. */
  80623. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80624. /**
  80625. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  80626. * @param position The local position
  80627. * @param mesh The mesh that this bone is attached to
  80628. * @param result The vector3 that the world position should be copied to
  80629. */
  80630. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80631. /**
  80632. * Get the local position of a point that is in world space
  80633. * @param position The world position
  80634. * @param mesh The mesh that this bone is attached to
  80635. * @returns The local position
  80636. */
  80637. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  80638. /**
  80639. * Get the local position of a point that is in world space and copy it to the result param
  80640. * @param position The world position
  80641. * @param mesh The mesh that this bone is attached to
  80642. * @param result The vector3 that the local position should be copied to
  80643. */
  80644. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  80645. }
  80646. }
  80647. declare module BABYLON {
  80648. /**
  80649. * 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.
  80650. * @see https://doc.babylonjs.com/how_to/transformnode
  80651. */
  80652. export class TransformNode extends Node {
  80653. /**
  80654. * Object will not rotate to face the camera
  80655. */
  80656. static BILLBOARDMODE_NONE: number;
  80657. /**
  80658. * Object will rotate to face the camera but only on the x axis
  80659. */
  80660. static BILLBOARDMODE_X: number;
  80661. /**
  80662. * Object will rotate to face the camera but only on the y axis
  80663. */
  80664. static BILLBOARDMODE_Y: number;
  80665. /**
  80666. * Object will rotate to face the camera but only on the z axis
  80667. */
  80668. static BILLBOARDMODE_Z: number;
  80669. /**
  80670. * Object will rotate to face the camera
  80671. */
  80672. static BILLBOARDMODE_ALL: number;
  80673. /**
  80674. * Object will rotate to face the camera's position instead of orientation
  80675. */
  80676. static BILLBOARDMODE_USE_POSITION: number;
  80677. private _forward;
  80678. private _forwardInverted;
  80679. private _up;
  80680. private _right;
  80681. private _rightInverted;
  80682. private _position;
  80683. private _rotation;
  80684. private _rotationQuaternion;
  80685. protected _scaling: Vector3;
  80686. protected _isDirty: boolean;
  80687. private _transformToBoneReferal;
  80688. private _isAbsoluteSynced;
  80689. private _billboardMode;
  80690. /**
  80691. * Gets or sets the billboard mode. Default is 0.
  80692. *
  80693. * | Value | Type | Description |
  80694. * | --- | --- | --- |
  80695. * | 0 | BILLBOARDMODE_NONE | |
  80696. * | 1 | BILLBOARDMODE_X | |
  80697. * | 2 | BILLBOARDMODE_Y | |
  80698. * | 4 | BILLBOARDMODE_Z | |
  80699. * | 7 | BILLBOARDMODE_ALL | |
  80700. *
  80701. */
  80702. billboardMode: number;
  80703. private _preserveParentRotationForBillboard;
  80704. /**
  80705. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  80706. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  80707. */
  80708. preserveParentRotationForBillboard: boolean;
  80709. /**
  80710. * 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
  80711. */
  80712. scalingDeterminant: number;
  80713. private _infiniteDistance;
  80714. /**
  80715. * Gets or sets the distance of the object to max, often used by skybox
  80716. */
  80717. infiniteDistance: boolean;
  80718. /**
  80719. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  80720. * By default the system will update normals to compensate
  80721. */
  80722. ignoreNonUniformScaling: boolean;
  80723. /**
  80724. * 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
  80725. */
  80726. reIntegrateRotationIntoRotationQuaternion: boolean;
  80727. /** @hidden */
  80728. _poseMatrix: Nullable<Matrix>;
  80729. /** @hidden */
  80730. _localMatrix: Matrix;
  80731. private _usePivotMatrix;
  80732. private _absolutePosition;
  80733. private _absoluteScaling;
  80734. private _absoluteRotationQuaternion;
  80735. private _pivotMatrix;
  80736. private _pivotMatrixInverse;
  80737. protected _postMultiplyPivotMatrix: boolean;
  80738. protected _isWorldMatrixFrozen: boolean;
  80739. /** @hidden */
  80740. _indexInSceneTransformNodesArray: number;
  80741. /**
  80742. * An event triggered after the world matrix is updated
  80743. */
  80744. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  80745. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  80746. /**
  80747. * Gets a string identifying the name of the class
  80748. * @returns "TransformNode" string
  80749. */
  80750. getClassName(): string;
  80751. /**
  80752. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  80753. */
  80754. position: Vector3;
  80755. /**
  80756. * 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)).
  80757. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  80758. */
  80759. rotation: Vector3;
  80760. /**
  80761. * 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)).
  80762. */
  80763. scaling: Vector3;
  80764. /**
  80765. * 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).
  80766. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  80767. */
  80768. rotationQuaternion: Nullable<Quaternion>;
  80769. /**
  80770. * The forward direction of that transform in world space.
  80771. */
  80772. readonly forward: Vector3;
  80773. /**
  80774. * The up direction of that transform in world space.
  80775. */
  80776. readonly up: Vector3;
  80777. /**
  80778. * The right direction of that transform in world space.
  80779. */
  80780. readonly right: Vector3;
  80781. /**
  80782. * Copies the parameter passed Matrix into the mesh Pose matrix.
  80783. * @param matrix the matrix to copy the pose from
  80784. * @returns this TransformNode.
  80785. */
  80786. updatePoseMatrix(matrix: Matrix): TransformNode;
  80787. /**
  80788. * Returns the mesh Pose matrix.
  80789. * @returns the pose matrix
  80790. */
  80791. getPoseMatrix(): Matrix;
  80792. /** @hidden */
  80793. _isSynchronized(): boolean;
  80794. /** @hidden */
  80795. _initCache(): void;
  80796. /**
  80797. * Flag the transform node as dirty (Forcing it to update everything)
  80798. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  80799. * @returns this transform node
  80800. */
  80801. markAsDirty(property: string): TransformNode;
  80802. /**
  80803. * Returns the current mesh absolute position.
  80804. * Returns a Vector3.
  80805. */
  80806. readonly absolutePosition: Vector3;
  80807. /**
  80808. * Returns the current mesh absolute scaling.
  80809. * Returns a Vector3.
  80810. */
  80811. readonly absoluteScaling: Vector3;
  80812. /**
  80813. * Returns the current mesh absolute rotation.
  80814. * Returns a Quaternion.
  80815. */
  80816. readonly absoluteRotationQuaternion: Quaternion;
  80817. /**
  80818. * Sets a new matrix to apply before all other transformation
  80819. * @param matrix defines the transform matrix
  80820. * @returns the current TransformNode
  80821. */
  80822. setPreTransformMatrix(matrix: Matrix): TransformNode;
  80823. /**
  80824. * Sets a new pivot matrix to the current node
  80825. * @param matrix defines the new pivot matrix to use
  80826. * @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
  80827. * @returns the current TransformNode
  80828. */
  80829. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  80830. /**
  80831. * Returns the mesh pivot matrix.
  80832. * Default : Identity.
  80833. * @returns the matrix
  80834. */
  80835. getPivotMatrix(): Matrix;
  80836. /**
  80837. * Instantiate (when possible) or clone that node with its hierarchy
  80838. * @param newParent defines the new parent to use for the instance (or clone)
  80839. * @returns an instance (or a clone) of the current node with its hiearchy
  80840. */
  80841. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  80842. /**
  80843. * Prevents the World matrix to be computed any longer
  80844. * @param newWorldMatrix defines an optional matrix to use as world matrix
  80845. * @returns the TransformNode.
  80846. */
  80847. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  80848. /**
  80849. * Allows back the World matrix computation.
  80850. * @returns the TransformNode.
  80851. */
  80852. unfreezeWorldMatrix(): this;
  80853. /**
  80854. * True if the World matrix has been frozen.
  80855. */
  80856. readonly isWorldMatrixFrozen: boolean;
  80857. /**
  80858. * Retuns the mesh absolute position in the World.
  80859. * @returns a Vector3.
  80860. */
  80861. getAbsolutePosition(): Vector3;
  80862. /**
  80863. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  80864. * @param absolutePosition the absolute position to set
  80865. * @returns the TransformNode.
  80866. */
  80867. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  80868. /**
  80869. * Sets the mesh position in its local space.
  80870. * @param vector3 the position to set in localspace
  80871. * @returns the TransformNode.
  80872. */
  80873. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  80874. /**
  80875. * Returns the mesh position in the local space from the current World matrix values.
  80876. * @returns a new Vector3.
  80877. */
  80878. getPositionExpressedInLocalSpace(): Vector3;
  80879. /**
  80880. * Translates the mesh along the passed Vector3 in its local space.
  80881. * @param vector3 the distance to translate in localspace
  80882. * @returns the TransformNode.
  80883. */
  80884. locallyTranslate(vector3: Vector3): TransformNode;
  80885. private static _lookAtVectorCache;
  80886. /**
  80887. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  80888. * @param targetPoint the position (must be in same space as current mesh) to look at
  80889. * @param yawCor optional yaw (y-axis) correction in radians
  80890. * @param pitchCor optional pitch (x-axis) correction in radians
  80891. * @param rollCor optional roll (z-axis) correction in radians
  80892. * @param space the choosen space of the target
  80893. * @returns the TransformNode.
  80894. */
  80895. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  80896. /**
  80897. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80898. * This Vector3 is expressed in the World space.
  80899. * @param localAxis axis to rotate
  80900. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  80901. */
  80902. getDirection(localAxis: Vector3): Vector3;
  80903. /**
  80904. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  80905. * localAxis is expressed in the mesh local space.
  80906. * result is computed in the Wordl space from the mesh World matrix.
  80907. * @param localAxis axis to rotate
  80908. * @param result the resulting transformnode
  80909. * @returns this TransformNode.
  80910. */
  80911. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  80912. /**
  80913. * Sets this transform node rotation to the given local axis.
  80914. * @param localAxis the axis in local space
  80915. * @param yawCor optional yaw (y-axis) correction in radians
  80916. * @param pitchCor optional pitch (x-axis) correction in radians
  80917. * @param rollCor optional roll (z-axis) correction in radians
  80918. * @returns this TransformNode
  80919. */
  80920. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  80921. /**
  80922. * Sets a new pivot point to the current node
  80923. * @param point defines the new pivot point to use
  80924. * @param space defines if the point is in world or local space (local by default)
  80925. * @returns the current TransformNode
  80926. */
  80927. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  80928. /**
  80929. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  80930. * @returns the pivot point
  80931. */
  80932. getPivotPoint(): Vector3;
  80933. /**
  80934. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  80935. * @param result the vector3 to store the result
  80936. * @returns this TransformNode.
  80937. */
  80938. getPivotPointToRef(result: Vector3): TransformNode;
  80939. /**
  80940. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  80941. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  80942. */
  80943. getAbsolutePivotPoint(): Vector3;
  80944. /**
  80945. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  80946. * @param result vector3 to store the result
  80947. * @returns this TransformNode.
  80948. */
  80949. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  80950. /**
  80951. * Defines the passed node as the parent of the current node.
  80952. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  80953. * @see https://doc.babylonjs.com/how_to/parenting
  80954. * @param node the node ot set as the parent
  80955. * @returns this TransformNode.
  80956. */
  80957. setParent(node: Nullable<Node>): TransformNode;
  80958. private _nonUniformScaling;
  80959. /**
  80960. * True if the scaling property of this object is non uniform eg. (1,2,1)
  80961. */
  80962. readonly nonUniformScaling: boolean;
  80963. /** @hidden */
  80964. _updateNonUniformScalingState(value: boolean): boolean;
  80965. /**
  80966. * Attach the current TransformNode to another TransformNode associated with a bone
  80967. * @param bone Bone affecting the TransformNode
  80968. * @param affectedTransformNode TransformNode associated with the bone
  80969. * @returns this object
  80970. */
  80971. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  80972. /**
  80973. * Detach the transform node if its associated with a bone
  80974. * @returns this object
  80975. */
  80976. detachFromBone(): TransformNode;
  80977. private static _rotationAxisCache;
  80978. /**
  80979. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  80980. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  80981. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80982. * The passed axis is also normalized.
  80983. * @param axis the axis to rotate around
  80984. * @param amount the amount to rotate in radians
  80985. * @param space Space to rotate in (Default: local)
  80986. * @returns the TransformNode.
  80987. */
  80988. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  80989. /**
  80990. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  80991. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  80992. * The passed axis is also normalized. .
  80993. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  80994. * @param point the point to rotate around
  80995. * @param axis the axis to rotate around
  80996. * @param amount the amount to rotate in radians
  80997. * @returns the TransformNode
  80998. */
  80999. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  81000. /**
  81001. * Translates the mesh along the axis vector for the passed distance in the given space.
  81002. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  81003. * @param axis the axis to translate in
  81004. * @param distance the distance to translate
  81005. * @param space Space to rotate in (Default: local)
  81006. * @returns the TransformNode.
  81007. */
  81008. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  81009. /**
  81010. * Adds a rotation step to the mesh current rotation.
  81011. * x, y, z are Euler angles expressed in radians.
  81012. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  81013. * This means this rotation is made in the mesh local space only.
  81014. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  81015. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  81016. * ```javascript
  81017. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  81018. * ```
  81019. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  81020. * 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.
  81021. * @param x Rotation to add
  81022. * @param y Rotation to add
  81023. * @param z Rotation to add
  81024. * @returns the TransformNode.
  81025. */
  81026. addRotation(x: number, y: number, z: number): TransformNode;
  81027. /**
  81028. * @hidden
  81029. */
  81030. protected _getEffectiveParent(): Nullable<Node>;
  81031. /**
  81032. * Computes the world matrix of the node
  81033. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81034. * @returns the world matrix
  81035. */
  81036. computeWorldMatrix(force?: boolean): Matrix;
  81037. protected _afterComputeWorldMatrix(): void;
  81038. /**
  81039. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  81040. * @param func callback function to add
  81041. *
  81042. * @returns the TransformNode.
  81043. */
  81044. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81045. /**
  81046. * Removes a registered callback function.
  81047. * @param func callback function to remove
  81048. * @returns the TransformNode.
  81049. */
  81050. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  81051. /**
  81052. * Gets the position of the current mesh in camera space
  81053. * @param camera defines the camera to use
  81054. * @returns a position
  81055. */
  81056. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  81057. /**
  81058. * Returns the distance from the mesh to the active camera
  81059. * @param camera defines the camera to use
  81060. * @returns the distance
  81061. */
  81062. getDistanceToCamera(camera?: Nullable<Camera>): number;
  81063. /**
  81064. * Clone the current transform node
  81065. * @param name Name of the new clone
  81066. * @param newParent New parent for the clone
  81067. * @param doNotCloneChildren Do not clone children hierarchy
  81068. * @returns the new transform node
  81069. */
  81070. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  81071. /**
  81072. * Serializes the objects information.
  81073. * @param currentSerializationObject defines the object to serialize in
  81074. * @returns the serialized object
  81075. */
  81076. serialize(currentSerializationObject?: any): any;
  81077. /**
  81078. * Returns a new TransformNode object parsed from the source provided.
  81079. * @param parsedTransformNode is the source.
  81080. * @param scene the scne the object belongs to
  81081. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  81082. * @returns a new TransformNode object parsed from the source provided.
  81083. */
  81084. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  81085. /**
  81086. * Get all child-transformNodes of this node
  81087. * @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
  81088. * @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
  81089. * @returns an array of TransformNode
  81090. */
  81091. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  81092. /**
  81093. * Releases resources associated with this transform node.
  81094. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  81095. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  81096. */
  81097. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  81098. /**
  81099. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  81100. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  81101. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  81102. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  81103. * @returns the current mesh
  81104. */
  81105. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  81106. private _syncAbsoluteScalingAndRotation;
  81107. }
  81108. }
  81109. declare module BABYLON {
  81110. /**
  81111. * Defines the types of pose enabled controllers that are supported
  81112. */
  81113. export enum PoseEnabledControllerType {
  81114. /**
  81115. * HTC Vive
  81116. */
  81117. VIVE = 0,
  81118. /**
  81119. * Oculus Rift
  81120. */
  81121. OCULUS = 1,
  81122. /**
  81123. * Windows mixed reality
  81124. */
  81125. WINDOWS = 2,
  81126. /**
  81127. * Samsung gear VR
  81128. */
  81129. GEAR_VR = 3,
  81130. /**
  81131. * Google Daydream
  81132. */
  81133. DAYDREAM = 4,
  81134. /**
  81135. * Generic
  81136. */
  81137. GENERIC = 5
  81138. }
  81139. /**
  81140. * Defines the MutableGamepadButton interface for the state of a gamepad button
  81141. */
  81142. export interface MutableGamepadButton {
  81143. /**
  81144. * Value of the button/trigger
  81145. */
  81146. value: number;
  81147. /**
  81148. * If the button/trigger is currently touched
  81149. */
  81150. touched: boolean;
  81151. /**
  81152. * If the button/trigger is currently pressed
  81153. */
  81154. pressed: boolean;
  81155. }
  81156. /**
  81157. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  81158. * @hidden
  81159. */
  81160. export interface ExtendedGamepadButton extends GamepadButton {
  81161. /**
  81162. * If the button/trigger is currently pressed
  81163. */
  81164. readonly pressed: boolean;
  81165. /**
  81166. * If the button/trigger is currently touched
  81167. */
  81168. readonly touched: boolean;
  81169. /**
  81170. * Value of the button/trigger
  81171. */
  81172. readonly value: number;
  81173. }
  81174. /** @hidden */
  81175. export interface _GamePadFactory {
  81176. /**
  81177. * Returns wether or not the current gamepad can be created for this type of controller.
  81178. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81179. * @returns true if it can be created, otherwise false
  81180. */
  81181. canCreate(gamepadInfo: any): boolean;
  81182. /**
  81183. * Creates a new instance of the Gamepad.
  81184. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  81185. * @returns the new gamepad instance
  81186. */
  81187. create(gamepadInfo: any): Gamepad;
  81188. }
  81189. /**
  81190. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81191. */
  81192. export class PoseEnabledControllerHelper {
  81193. /** @hidden */
  81194. static _ControllerFactories: _GamePadFactory[];
  81195. /** @hidden */
  81196. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  81197. /**
  81198. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  81199. * @param vrGamepad the gamepad to initialized
  81200. * @returns a vr controller of the type the gamepad identified as
  81201. */
  81202. static InitiateController(vrGamepad: any): Gamepad;
  81203. }
  81204. /**
  81205. * Defines the PoseEnabledController object that contains state of a vr capable controller
  81206. */
  81207. export class PoseEnabledController extends Gamepad implements PoseControlled {
  81208. /**
  81209. * If the controller is used in a webXR session
  81210. */
  81211. isXR: boolean;
  81212. private _deviceRoomPosition;
  81213. private _deviceRoomRotationQuaternion;
  81214. /**
  81215. * The device position in babylon space
  81216. */
  81217. devicePosition: Vector3;
  81218. /**
  81219. * The device rotation in babylon space
  81220. */
  81221. deviceRotationQuaternion: Quaternion;
  81222. /**
  81223. * The scale factor of the device in babylon space
  81224. */
  81225. deviceScaleFactor: number;
  81226. /**
  81227. * (Likely devicePosition should be used instead) The device position in its room space
  81228. */
  81229. position: Vector3;
  81230. /**
  81231. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  81232. */
  81233. rotationQuaternion: Quaternion;
  81234. /**
  81235. * The type of controller (Eg. Windows mixed reality)
  81236. */
  81237. controllerType: PoseEnabledControllerType;
  81238. protected _calculatedPosition: Vector3;
  81239. private _calculatedRotation;
  81240. /**
  81241. * The raw pose from the device
  81242. */
  81243. rawPose: DevicePose;
  81244. private _trackPosition;
  81245. private _maxRotationDistFromHeadset;
  81246. private _draggedRoomRotation;
  81247. /**
  81248. * @hidden
  81249. */
  81250. _disableTrackPosition(fixedPosition: Vector3): void;
  81251. /**
  81252. * Internal, the mesh attached to the controller
  81253. * @hidden
  81254. */
  81255. _mesh: Nullable<AbstractMesh>;
  81256. private _poseControlledCamera;
  81257. private _leftHandSystemQuaternion;
  81258. /**
  81259. * Internal, matrix used to convert room space to babylon space
  81260. * @hidden
  81261. */
  81262. _deviceToWorld: Matrix;
  81263. /**
  81264. * Node to be used when casting a ray from the controller
  81265. * @hidden
  81266. */
  81267. _pointingPoseNode: Nullable<TransformNode>;
  81268. /**
  81269. * Name of the child mesh that can be used to cast a ray from the controller
  81270. */
  81271. static readonly POINTING_POSE: string;
  81272. /**
  81273. * Creates a new PoseEnabledController from a gamepad
  81274. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  81275. */
  81276. constructor(browserGamepad: any);
  81277. private _workingMatrix;
  81278. /**
  81279. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  81280. */
  81281. update(): void;
  81282. /**
  81283. * Updates only the pose device and mesh without doing any button event checking
  81284. */
  81285. protected _updatePoseAndMesh(): void;
  81286. /**
  81287. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  81288. * @param poseData raw pose fromthe device
  81289. */
  81290. updateFromDevice(poseData: DevicePose): void;
  81291. /**
  81292. * @hidden
  81293. */
  81294. _meshAttachedObservable: Observable<AbstractMesh>;
  81295. /**
  81296. * Attaches a mesh to the controller
  81297. * @param mesh the mesh to be attached
  81298. */
  81299. attachToMesh(mesh: AbstractMesh): void;
  81300. /**
  81301. * Attaches the controllers mesh to a camera
  81302. * @param camera the camera the mesh should be attached to
  81303. */
  81304. attachToPoseControlledCamera(camera: TargetCamera): void;
  81305. /**
  81306. * Disposes of the controller
  81307. */
  81308. dispose(): void;
  81309. /**
  81310. * The mesh that is attached to the controller
  81311. */
  81312. readonly mesh: Nullable<AbstractMesh>;
  81313. /**
  81314. * Gets the ray of the controller in the direction the controller is pointing
  81315. * @param length the length the resulting ray should be
  81316. * @returns a ray in the direction the controller is pointing
  81317. */
  81318. getForwardRay(length?: number): Ray;
  81319. }
  81320. }
  81321. declare module BABYLON {
  81322. /**
  81323. * Defines the WebVRController object that represents controllers tracked in 3D space
  81324. */
  81325. export abstract class WebVRController extends PoseEnabledController {
  81326. /**
  81327. * Internal, the default controller model for the controller
  81328. */
  81329. protected _defaultModel: Nullable<AbstractMesh>;
  81330. /**
  81331. * Fired when the trigger state has changed
  81332. */
  81333. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  81334. /**
  81335. * Fired when the main button state has changed
  81336. */
  81337. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81338. /**
  81339. * Fired when the secondary button state has changed
  81340. */
  81341. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  81342. /**
  81343. * Fired when the pad state has changed
  81344. */
  81345. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  81346. /**
  81347. * Fired when controllers stick values have changed
  81348. */
  81349. onPadValuesChangedObservable: Observable<StickValues>;
  81350. /**
  81351. * Array of button availible on the controller
  81352. */
  81353. protected _buttons: Array<MutableGamepadButton>;
  81354. private _onButtonStateChange;
  81355. /**
  81356. * Fired when a controller button's state has changed
  81357. * @param callback the callback containing the button that was modified
  81358. */
  81359. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  81360. /**
  81361. * X and Y axis corresponding to the controllers joystick
  81362. */
  81363. pad: StickValues;
  81364. /**
  81365. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  81366. */
  81367. hand: string;
  81368. /**
  81369. * The default controller model for the controller
  81370. */
  81371. readonly defaultModel: Nullable<AbstractMesh>;
  81372. /**
  81373. * Creates a new WebVRController from a gamepad
  81374. * @param vrGamepad the gamepad that the WebVRController should be created from
  81375. */
  81376. constructor(vrGamepad: any);
  81377. /**
  81378. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  81379. */
  81380. update(): void;
  81381. /**
  81382. * Function to be called when a button is modified
  81383. */
  81384. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  81385. /**
  81386. * Loads a mesh and attaches it to the controller
  81387. * @param scene the scene the mesh should be added to
  81388. * @param meshLoaded callback for when the mesh has been loaded
  81389. */
  81390. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  81391. private _setButtonValue;
  81392. private _changes;
  81393. private _checkChanges;
  81394. /**
  81395. * Disposes of th webVRCOntroller
  81396. */
  81397. dispose(): void;
  81398. }
  81399. }
  81400. declare module BABYLON {
  81401. /**
  81402. * The HemisphericLight simulates the ambient environment light,
  81403. * so the passed direction is the light reflection direction, not the incoming direction.
  81404. */
  81405. export class HemisphericLight extends Light {
  81406. /**
  81407. * The groundColor is the light in the opposite direction to the one specified during creation.
  81408. * 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.
  81409. */
  81410. groundColor: Color3;
  81411. /**
  81412. * The light reflection direction, not the incoming direction.
  81413. */
  81414. direction: Vector3;
  81415. /**
  81416. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  81417. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  81418. * The HemisphericLight can't cast shadows.
  81419. * Documentation : https://doc.babylonjs.com/babylon101/lights
  81420. * @param name The friendly name of the light
  81421. * @param direction The direction of the light reflection
  81422. * @param scene The scene the light belongs to
  81423. */
  81424. constructor(name: string, direction: Vector3, scene: Scene);
  81425. protected _buildUniformLayout(): void;
  81426. /**
  81427. * Returns the string "HemisphericLight".
  81428. * @return The class name
  81429. */
  81430. getClassName(): string;
  81431. /**
  81432. * Sets the HemisphericLight direction towards the passed target (Vector3).
  81433. * Returns the updated direction.
  81434. * @param target The target the direction should point to
  81435. * @return The computed direction
  81436. */
  81437. setDirectionToTarget(target: Vector3): Vector3;
  81438. /**
  81439. * Returns the shadow generator associated to the light.
  81440. * @returns Always null for hemispheric lights because it does not support shadows.
  81441. */
  81442. getShadowGenerator(): Nullable<IShadowGenerator>;
  81443. /**
  81444. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  81445. * @param effect The effect to update
  81446. * @param lightIndex The index of the light in the effect to update
  81447. * @returns The hemispheric light
  81448. */
  81449. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  81450. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  81451. /**
  81452. * Computes the world matrix of the node
  81453. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  81454. * @param useWasUpdatedFlag defines a reserved property
  81455. * @returns the world matrix
  81456. */
  81457. computeWorldMatrix(): Matrix;
  81458. /**
  81459. * Returns the integer 3.
  81460. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  81461. */
  81462. getTypeID(): number;
  81463. /**
  81464. * Prepares the list of defines specific to the light type.
  81465. * @param defines the list of defines
  81466. * @param lightIndex defines the index of the light for the effect
  81467. */
  81468. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  81469. }
  81470. }
  81471. declare module BABYLON {
  81472. /** @hidden */
  81473. export var vrMultiviewToSingleviewPixelShader: {
  81474. name: string;
  81475. shader: string;
  81476. };
  81477. }
  81478. declare module BABYLON {
  81479. /**
  81480. * Renders to multiple views with a single draw call
  81481. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  81482. */
  81483. export class MultiviewRenderTarget extends RenderTargetTexture {
  81484. /**
  81485. * Creates a multiview render target
  81486. * @param scene scene used with the render target
  81487. * @param size the size of the render target (used for each view)
  81488. */
  81489. constructor(scene: Scene, size?: number | {
  81490. width: number;
  81491. height: number;
  81492. } | {
  81493. ratio: number;
  81494. });
  81495. /**
  81496. * @hidden
  81497. * @param faceIndex the face index, if its a cube texture
  81498. */
  81499. _bindFrameBuffer(faceIndex?: number): void;
  81500. /**
  81501. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  81502. * @returns the view count
  81503. */
  81504. getViewCount(): number;
  81505. }
  81506. }
  81507. declare module BABYLON {
  81508. /**
  81509. * Represents a camera frustum
  81510. */
  81511. export class Frustum {
  81512. /**
  81513. * Gets the planes representing the frustum
  81514. * @param transform matrix to be applied to the returned planes
  81515. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  81516. */
  81517. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  81518. /**
  81519. * Gets the near frustum plane transformed by the transform matrix
  81520. * @param transform transformation matrix to be applied to the resulting frustum plane
  81521. * @param frustumPlane the resuling frustum plane
  81522. */
  81523. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81524. /**
  81525. * Gets the far frustum plane transformed by the transform matrix
  81526. * @param transform transformation matrix to be applied to the resulting frustum plane
  81527. * @param frustumPlane the resuling frustum plane
  81528. */
  81529. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81530. /**
  81531. * Gets the left frustum plane transformed by the transform matrix
  81532. * @param transform transformation matrix to be applied to the resulting frustum plane
  81533. * @param frustumPlane the resuling frustum plane
  81534. */
  81535. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81536. /**
  81537. * Gets the right frustum plane transformed by the transform matrix
  81538. * @param transform transformation matrix to be applied to the resulting frustum plane
  81539. * @param frustumPlane the resuling frustum plane
  81540. */
  81541. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81542. /**
  81543. * Gets the top frustum plane transformed by the transform matrix
  81544. * @param transform transformation matrix to be applied to the resulting frustum plane
  81545. * @param frustumPlane the resuling frustum plane
  81546. */
  81547. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81548. /**
  81549. * Gets the bottom frustum plane transformed by the transform matrix
  81550. * @param transform transformation matrix to be applied to the resulting frustum plane
  81551. * @param frustumPlane the resuling frustum plane
  81552. */
  81553. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  81554. /**
  81555. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  81556. * @param transform transformation matrix to be applied to the resulting frustum planes
  81557. * @param frustumPlanes the resuling frustum planes
  81558. */
  81559. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  81560. }
  81561. }
  81562. declare module BABYLON {
  81563. interface Engine {
  81564. /**
  81565. * Creates a new multiview render target
  81566. * @param width defines the width of the texture
  81567. * @param height defines the height of the texture
  81568. * @returns the created multiview texture
  81569. */
  81570. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  81571. /**
  81572. * Binds a multiview framebuffer to be drawn to
  81573. * @param multiviewTexture texture to bind
  81574. */
  81575. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  81576. }
  81577. interface Camera {
  81578. /**
  81579. * @hidden
  81580. * 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)
  81581. */
  81582. _useMultiviewToSingleView: boolean;
  81583. /**
  81584. * @hidden
  81585. * 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)
  81586. */
  81587. _multiviewTexture: Nullable<RenderTargetTexture>;
  81588. /**
  81589. * @hidden
  81590. * ensures the multiview texture of the camera exists and has the specified width/height
  81591. * @param width height to set on the multiview texture
  81592. * @param height width to set on the multiview texture
  81593. */
  81594. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  81595. }
  81596. interface Scene {
  81597. /** @hidden */
  81598. _transformMatrixR: Matrix;
  81599. /** @hidden */
  81600. _multiviewSceneUbo: Nullable<UniformBuffer>;
  81601. /** @hidden */
  81602. _createMultiviewUbo(): void;
  81603. /** @hidden */
  81604. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  81605. /** @hidden */
  81606. _renderMultiviewToSingleView(camera: Camera): void;
  81607. }
  81608. }
  81609. declare module BABYLON {
  81610. /**
  81611. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  81612. * This will not be used for webXR as it supports displaying texture arrays directly
  81613. */
  81614. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  81615. /**
  81616. * Initializes a VRMultiviewToSingleview
  81617. * @param name name of the post process
  81618. * @param camera camera to be applied to
  81619. * @param scaleFactor scaling factor to the size of the output texture
  81620. */
  81621. constructor(name: string, camera: Camera, scaleFactor: number);
  81622. }
  81623. }
  81624. declare module BABYLON {
  81625. interface Engine {
  81626. /** @hidden */
  81627. _vrDisplay: any;
  81628. /** @hidden */
  81629. _vrSupported: boolean;
  81630. /** @hidden */
  81631. _oldSize: Size;
  81632. /** @hidden */
  81633. _oldHardwareScaleFactor: number;
  81634. /** @hidden */
  81635. _vrExclusivePointerMode: boolean;
  81636. /** @hidden */
  81637. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  81638. /** @hidden */
  81639. _onVRDisplayPointerRestricted: () => void;
  81640. /** @hidden */
  81641. _onVRDisplayPointerUnrestricted: () => void;
  81642. /** @hidden */
  81643. _onVrDisplayConnect: Nullable<(display: any) => void>;
  81644. /** @hidden */
  81645. _onVrDisplayDisconnect: Nullable<() => void>;
  81646. /** @hidden */
  81647. _onVrDisplayPresentChange: Nullable<() => void>;
  81648. /**
  81649. * Observable signaled when VR display mode changes
  81650. */
  81651. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  81652. /**
  81653. * Observable signaled when VR request present is complete
  81654. */
  81655. onVRRequestPresentComplete: Observable<boolean>;
  81656. /**
  81657. * Observable signaled when VR request present starts
  81658. */
  81659. onVRRequestPresentStart: Observable<Engine>;
  81660. /**
  81661. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  81662. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  81663. */
  81664. isInVRExclusivePointerMode: boolean;
  81665. /**
  81666. * Gets a boolean indicating if a webVR device was detected
  81667. * @returns true if a webVR device was detected
  81668. */
  81669. isVRDevicePresent(): boolean;
  81670. /**
  81671. * Gets the current webVR device
  81672. * @returns the current webVR device (or null)
  81673. */
  81674. getVRDevice(): any;
  81675. /**
  81676. * Initializes a webVR display and starts listening to display change events
  81677. * The onVRDisplayChangedObservable will be notified upon these changes
  81678. * @returns A promise containing a VRDisplay and if vr is supported
  81679. */
  81680. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  81681. /** @hidden */
  81682. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  81683. /**
  81684. * Call this function to switch to webVR mode
  81685. * Will do nothing if webVR is not supported or if there is no webVR device
  81686. * @see http://doc.babylonjs.com/how_to/webvr_camera
  81687. */
  81688. enableVR(): void;
  81689. /** @hidden */
  81690. _onVRFullScreenTriggered(): void;
  81691. }
  81692. }
  81693. declare module BABYLON {
  81694. /**
  81695. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  81696. * IMPORTANT!! The data is right-hand data.
  81697. * @export
  81698. * @interface DevicePose
  81699. */
  81700. export interface DevicePose {
  81701. /**
  81702. * The position of the device, values in array are [x,y,z].
  81703. */
  81704. readonly position: Nullable<Float32Array>;
  81705. /**
  81706. * The linearVelocity of the device, values in array are [x,y,z].
  81707. */
  81708. readonly linearVelocity: Nullable<Float32Array>;
  81709. /**
  81710. * The linearAcceleration of the device, values in array are [x,y,z].
  81711. */
  81712. readonly linearAcceleration: Nullable<Float32Array>;
  81713. /**
  81714. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  81715. */
  81716. readonly orientation: Nullable<Float32Array>;
  81717. /**
  81718. * The angularVelocity of the device, values in array are [x,y,z].
  81719. */
  81720. readonly angularVelocity: Nullable<Float32Array>;
  81721. /**
  81722. * The angularAcceleration of the device, values in array are [x,y,z].
  81723. */
  81724. readonly angularAcceleration: Nullable<Float32Array>;
  81725. }
  81726. /**
  81727. * Interface representing a pose controlled object in Babylon.
  81728. * A pose controlled object has both regular pose values as well as pose values
  81729. * from an external device such as a VR head mounted display
  81730. */
  81731. export interface PoseControlled {
  81732. /**
  81733. * The position of the object in babylon space.
  81734. */
  81735. position: Vector3;
  81736. /**
  81737. * The rotation quaternion of the object in babylon space.
  81738. */
  81739. rotationQuaternion: Quaternion;
  81740. /**
  81741. * The position of the device in babylon space.
  81742. */
  81743. devicePosition?: Vector3;
  81744. /**
  81745. * The rotation quaternion of the device in babylon space.
  81746. */
  81747. deviceRotationQuaternion: Quaternion;
  81748. /**
  81749. * The raw pose coming from the device.
  81750. */
  81751. rawPose: Nullable<DevicePose>;
  81752. /**
  81753. * The scale of the device to be used when translating from device space to babylon space.
  81754. */
  81755. deviceScaleFactor: number;
  81756. /**
  81757. * Updates the poseControlled values based on the input device pose.
  81758. * @param poseData the pose data to update the object with
  81759. */
  81760. updateFromDevice(poseData: DevicePose): void;
  81761. }
  81762. /**
  81763. * Set of options to customize the webVRCamera
  81764. */
  81765. export interface WebVROptions {
  81766. /**
  81767. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  81768. */
  81769. trackPosition?: boolean;
  81770. /**
  81771. * Sets the scale of the vrDevice in babylon space. (default: 1)
  81772. */
  81773. positionScale?: number;
  81774. /**
  81775. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  81776. */
  81777. displayName?: string;
  81778. /**
  81779. * Should the native controller meshes be initialized. (default: true)
  81780. */
  81781. controllerMeshes?: boolean;
  81782. /**
  81783. * Creating a default HemiLight only on controllers. (default: true)
  81784. */
  81785. defaultLightingOnControllers?: boolean;
  81786. /**
  81787. * If you don't want to use the default VR button of the helper. (default: false)
  81788. */
  81789. useCustomVRButton?: boolean;
  81790. /**
  81791. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  81792. */
  81793. customVRButton?: HTMLButtonElement;
  81794. /**
  81795. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  81796. */
  81797. rayLength?: number;
  81798. /**
  81799. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  81800. */
  81801. defaultHeight?: number;
  81802. /**
  81803. * If multiview should be used if availible (default: false)
  81804. */
  81805. useMultiview?: boolean;
  81806. }
  81807. /**
  81808. * This represents a WebVR camera.
  81809. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  81810. * @example http://doc.babylonjs.com/how_to/webvr_camera
  81811. */
  81812. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  81813. private webVROptions;
  81814. /**
  81815. * @hidden
  81816. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  81817. */
  81818. _vrDevice: any;
  81819. /**
  81820. * The rawPose of the vrDevice.
  81821. */
  81822. rawPose: Nullable<DevicePose>;
  81823. private _onVREnabled;
  81824. private _specsVersion;
  81825. private _attached;
  81826. private _frameData;
  81827. protected _descendants: Array<Node>;
  81828. private _deviceRoomPosition;
  81829. /** @hidden */
  81830. _deviceRoomRotationQuaternion: Quaternion;
  81831. private _standingMatrix;
  81832. /**
  81833. * Represents device position in babylon space.
  81834. */
  81835. devicePosition: Vector3;
  81836. /**
  81837. * Represents device rotation in babylon space.
  81838. */
  81839. deviceRotationQuaternion: Quaternion;
  81840. /**
  81841. * The scale of the device to be used when translating from device space to babylon space.
  81842. */
  81843. deviceScaleFactor: number;
  81844. private _deviceToWorld;
  81845. private _worldToDevice;
  81846. /**
  81847. * References to the webVR controllers for the vrDevice.
  81848. */
  81849. controllers: Array<WebVRController>;
  81850. /**
  81851. * Emits an event when a controller is attached.
  81852. */
  81853. onControllersAttachedObservable: Observable<WebVRController[]>;
  81854. /**
  81855. * Emits an event when a controller's mesh has been loaded;
  81856. */
  81857. onControllerMeshLoadedObservable: Observable<WebVRController>;
  81858. /**
  81859. * Emits an event when the HMD's pose has been updated.
  81860. */
  81861. onPoseUpdatedFromDeviceObservable: Observable<any>;
  81862. private _poseSet;
  81863. /**
  81864. * If the rig cameras be used as parent instead of this camera.
  81865. */
  81866. rigParenting: boolean;
  81867. private _lightOnControllers;
  81868. private _defaultHeight?;
  81869. /**
  81870. * Instantiates a WebVRFreeCamera.
  81871. * @param name The name of the WebVRFreeCamera
  81872. * @param position The starting anchor position for the camera
  81873. * @param scene The scene the camera belongs to
  81874. * @param webVROptions a set of customizable options for the webVRCamera
  81875. */
  81876. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  81877. /**
  81878. * Gets the device distance from the ground in meters.
  81879. * @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.
  81880. */
  81881. deviceDistanceToRoomGround(): number;
  81882. /**
  81883. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81884. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  81885. */
  81886. useStandingMatrix(callback?: (bool: boolean) => void): void;
  81887. /**
  81888. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  81889. * @returns A promise with a boolean set to if the standing matrix is supported.
  81890. */
  81891. useStandingMatrixAsync(): Promise<boolean>;
  81892. /**
  81893. * Disposes the camera
  81894. */
  81895. dispose(): void;
  81896. /**
  81897. * Gets a vrController by name.
  81898. * @param name The name of the controller to retreive
  81899. * @returns the controller matching the name specified or null if not found
  81900. */
  81901. getControllerByName(name: string): Nullable<WebVRController>;
  81902. private _leftController;
  81903. /**
  81904. * The controller corresponding to the users left hand.
  81905. */
  81906. readonly leftController: Nullable<WebVRController>;
  81907. private _rightController;
  81908. /**
  81909. * The controller corresponding to the users right hand.
  81910. */
  81911. readonly rightController: Nullable<WebVRController>;
  81912. /**
  81913. * Casts a ray forward from the vrCamera's gaze.
  81914. * @param length Length of the ray (default: 100)
  81915. * @returns the ray corresponding to the gaze
  81916. */
  81917. getForwardRay(length?: number): Ray;
  81918. /**
  81919. * @hidden
  81920. * Updates the camera based on device's frame data
  81921. */
  81922. _checkInputs(): void;
  81923. /**
  81924. * Updates the poseControlled values based on the input device pose.
  81925. * @param poseData Pose coming from the device
  81926. */
  81927. updateFromDevice(poseData: DevicePose): void;
  81928. private _htmlElementAttached;
  81929. private _detachIfAttached;
  81930. /**
  81931. * WebVR's attach control will start broadcasting frames to the device.
  81932. * Note that in certain browsers (chrome for example) this function must be called
  81933. * within a user-interaction callback. Example:
  81934. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  81935. *
  81936. * @param element html element to attach the vrDevice to
  81937. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  81938. */
  81939. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  81940. /**
  81941. * Detaches the camera from the html element and disables VR
  81942. *
  81943. * @param element html element to detach from
  81944. */
  81945. detachControl(element: HTMLElement): void;
  81946. /**
  81947. * @returns the name of this class
  81948. */
  81949. getClassName(): string;
  81950. /**
  81951. * Calls resetPose on the vrDisplay
  81952. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  81953. */
  81954. resetToCurrentRotation(): void;
  81955. /**
  81956. * @hidden
  81957. * Updates the rig cameras (left and right eye)
  81958. */
  81959. _updateRigCameras(): void;
  81960. private _workingVector;
  81961. private _oneVector;
  81962. private _workingMatrix;
  81963. private updateCacheCalled;
  81964. private _correctPositionIfNotTrackPosition;
  81965. /**
  81966. * @hidden
  81967. * Updates the cached values of the camera
  81968. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  81969. */
  81970. _updateCache(ignoreParentClass?: boolean): void;
  81971. /**
  81972. * @hidden
  81973. * Get current device position in babylon world
  81974. */
  81975. _computeDevicePosition(): void;
  81976. /**
  81977. * Updates the current device position and rotation in the babylon world
  81978. */
  81979. update(): void;
  81980. /**
  81981. * @hidden
  81982. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  81983. * @returns an identity matrix
  81984. */
  81985. _getViewMatrix(): Matrix;
  81986. private _tmpMatrix;
  81987. /**
  81988. * This function is called by the two RIG cameras.
  81989. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  81990. * @hidden
  81991. */
  81992. _getWebVRViewMatrix(): Matrix;
  81993. /** @hidden */
  81994. _getWebVRProjectionMatrix(): Matrix;
  81995. private _onGamepadConnectedObserver;
  81996. private _onGamepadDisconnectedObserver;
  81997. private _updateCacheWhenTrackingDisabledObserver;
  81998. /**
  81999. * Initializes the controllers and their meshes
  82000. */
  82001. initControllers(): void;
  82002. }
  82003. }
  82004. declare module BABYLON {
  82005. /**
  82006. * Size options for a post process
  82007. */
  82008. export type PostProcessOptions = {
  82009. width: number;
  82010. height: number;
  82011. };
  82012. /**
  82013. * PostProcess can be used to apply a shader to a texture after it has been rendered
  82014. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82015. */
  82016. export class PostProcess {
  82017. /** Name of the PostProcess. */
  82018. name: string;
  82019. /**
  82020. * Gets or sets the unique id of the post process
  82021. */
  82022. uniqueId: number;
  82023. /**
  82024. * Width of the texture to apply the post process on
  82025. */
  82026. width: number;
  82027. /**
  82028. * Height of the texture to apply the post process on
  82029. */
  82030. height: number;
  82031. /**
  82032. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  82033. * @hidden
  82034. */
  82035. _outputTexture: Nullable<InternalTexture>;
  82036. /**
  82037. * Sampling mode used by the shader
  82038. * See https://doc.babylonjs.com/classes/3.1/texture
  82039. */
  82040. renderTargetSamplingMode: number;
  82041. /**
  82042. * Clear color to use when screen clearing
  82043. */
  82044. clearColor: Color4;
  82045. /**
  82046. * If the buffer needs to be cleared before applying the post process. (default: true)
  82047. * Should be set to false if shader will overwrite all previous pixels.
  82048. */
  82049. autoClear: boolean;
  82050. /**
  82051. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  82052. */
  82053. alphaMode: number;
  82054. /**
  82055. * Sets the setAlphaBlendConstants of the babylon engine
  82056. */
  82057. alphaConstants: Color4;
  82058. /**
  82059. * Animations to be used for the post processing
  82060. */
  82061. animations: Animation[];
  82062. /**
  82063. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  82064. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  82065. */
  82066. enablePixelPerfectMode: boolean;
  82067. /**
  82068. * Force the postprocess to be applied without taking in account viewport
  82069. */
  82070. forceFullscreenViewport: boolean;
  82071. /**
  82072. * List of inspectable custom properties (used by the Inspector)
  82073. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82074. */
  82075. inspectableCustomProperties: IInspectable[];
  82076. /**
  82077. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  82078. *
  82079. * | Value | Type | Description |
  82080. * | ----- | ----------------------------------- | ----------- |
  82081. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  82082. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  82083. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  82084. *
  82085. */
  82086. scaleMode: number;
  82087. /**
  82088. * Force textures to be a power of two (default: false)
  82089. */
  82090. alwaysForcePOT: boolean;
  82091. private _samples;
  82092. /**
  82093. * Number of sample textures (default: 1)
  82094. */
  82095. samples: number;
  82096. /**
  82097. * Modify the scale of the post process to be the same as the viewport (default: false)
  82098. */
  82099. adaptScaleToCurrentViewport: boolean;
  82100. private _camera;
  82101. private _scene;
  82102. private _engine;
  82103. private _options;
  82104. private _reusable;
  82105. private _textureType;
  82106. /**
  82107. * Smart array of input and output textures for the post process.
  82108. * @hidden
  82109. */
  82110. _textures: SmartArray<InternalTexture>;
  82111. /**
  82112. * The index in _textures that corresponds to the output texture.
  82113. * @hidden
  82114. */
  82115. _currentRenderTextureInd: number;
  82116. private _effect;
  82117. private _samplers;
  82118. private _fragmentUrl;
  82119. private _vertexUrl;
  82120. private _parameters;
  82121. private _scaleRatio;
  82122. protected _indexParameters: any;
  82123. private _shareOutputWithPostProcess;
  82124. private _texelSize;
  82125. private _forcedOutputTexture;
  82126. /**
  82127. * Returns the fragment url or shader name used in the post process.
  82128. * @returns the fragment url or name in the shader store.
  82129. */
  82130. getEffectName(): string;
  82131. /**
  82132. * An event triggered when the postprocess is activated.
  82133. */
  82134. onActivateObservable: Observable<Camera>;
  82135. private _onActivateObserver;
  82136. /**
  82137. * A function that is added to the onActivateObservable
  82138. */
  82139. onActivate: Nullable<(camera: Camera) => void>;
  82140. /**
  82141. * An event triggered when the postprocess changes its size.
  82142. */
  82143. onSizeChangedObservable: Observable<PostProcess>;
  82144. private _onSizeChangedObserver;
  82145. /**
  82146. * A function that is added to the onSizeChangedObservable
  82147. */
  82148. onSizeChanged: (postProcess: PostProcess) => void;
  82149. /**
  82150. * An event triggered when the postprocess applies its effect.
  82151. */
  82152. onApplyObservable: Observable<Effect>;
  82153. private _onApplyObserver;
  82154. /**
  82155. * A function that is added to the onApplyObservable
  82156. */
  82157. onApply: (effect: Effect) => void;
  82158. /**
  82159. * An event triggered before rendering the postprocess
  82160. */
  82161. onBeforeRenderObservable: Observable<Effect>;
  82162. private _onBeforeRenderObserver;
  82163. /**
  82164. * A function that is added to the onBeforeRenderObservable
  82165. */
  82166. onBeforeRender: (effect: Effect) => void;
  82167. /**
  82168. * An event triggered after rendering the postprocess
  82169. */
  82170. onAfterRenderObservable: Observable<Effect>;
  82171. private _onAfterRenderObserver;
  82172. /**
  82173. * A function that is added to the onAfterRenderObservable
  82174. */
  82175. onAfterRender: (efect: Effect) => void;
  82176. /**
  82177. * 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
  82178. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  82179. */
  82180. inputTexture: InternalTexture;
  82181. /**
  82182. * Gets the camera which post process is applied to.
  82183. * @returns The camera the post process is applied to.
  82184. */
  82185. getCamera(): Camera;
  82186. /**
  82187. * Gets the texel size of the postprocess.
  82188. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  82189. */
  82190. readonly texelSize: Vector2;
  82191. /**
  82192. * Creates a new instance PostProcess
  82193. * @param name The name of the PostProcess.
  82194. * @param fragmentUrl The url of the fragment shader to be used.
  82195. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  82196. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  82197. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82198. * @param camera The camera to apply the render pass to.
  82199. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82200. * @param engine The engine which the post process will be applied. (default: current engine)
  82201. * @param reusable If the post process can be reused on the same frame. (default: false)
  82202. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  82203. * @param textureType Type of textures used when performing the post process. (default: 0)
  82204. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  82205. * @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
  82206. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  82207. */
  82208. constructor(
  82209. /** Name of the PostProcess. */
  82210. 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);
  82211. /**
  82212. * Gets a string idenfifying the name of the class
  82213. * @returns "PostProcess" string
  82214. */
  82215. getClassName(): string;
  82216. /**
  82217. * Gets the engine which this post process belongs to.
  82218. * @returns The engine the post process was enabled with.
  82219. */
  82220. getEngine(): Engine;
  82221. /**
  82222. * The effect that is created when initializing the post process.
  82223. * @returns The created effect corresponding the the postprocess.
  82224. */
  82225. getEffect(): Effect;
  82226. /**
  82227. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  82228. * @param postProcess The post process to share the output with.
  82229. * @returns This post process.
  82230. */
  82231. shareOutputWith(postProcess: PostProcess): PostProcess;
  82232. /**
  82233. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  82234. * This should be called if the post process that shares output with this post process is disabled/disposed.
  82235. */
  82236. useOwnOutput(): void;
  82237. /**
  82238. * Updates the effect with the current post process compile time values and recompiles the shader.
  82239. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82240. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82241. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82242. * @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
  82243. * @param onCompiled Called when the shader has been compiled.
  82244. * @param onError Called if there is an error when compiling a shader.
  82245. */
  82246. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82247. /**
  82248. * The post process is reusable if it can be used multiple times within one frame.
  82249. * @returns If the post process is reusable
  82250. */
  82251. isReusable(): boolean;
  82252. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  82253. markTextureDirty(): void;
  82254. /**
  82255. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  82256. * 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.
  82257. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  82258. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  82259. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  82260. * @returns The target texture that was bound to be written to.
  82261. */
  82262. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  82263. /**
  82264. * If the post process is supported.
  82265. */
  82266. readonly isSupported: boolean;
  82267. /**
  82268. * The aspect ratio of the output texture.
  82269. */
  82270. readonly aspectRatio: number;
  82271. /**
  82272. * Get a value indicating if the post-process is ready to be used
  82273. * @returns true if the post-process is ready (shader is compiled)
  82274. */
  82275. isReady(): boolean;
  82276. /**
  82277. * Binds all textures and uniforms to the shader, this will be run on every pass.
  82278. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  82279. */
  82280. apply(): Nullable<Effect>;
  82281. private _disposeTextures;
  82282. /**
  82283. * Disposes the post process.
  82284. * @param camera The camera to dispose the post process on.
  82285. */
  82286. dispose(camera?: Camera): void;
  82287. }
  82288. }
  82289. declare module BABYLON {
  82290. /** @hidden */
  82291. export var kernelBlurVaryingDeclaration: {
  82292. name: string;
  82293. shader: string;
  82294. };
  82295. }
  82296. declare module BABYLON {
  82297. /** @hidden */
  82298. export var kernelBlurFragment: {
  82299. name: string;
  82300. shader: string;
  82301. };
  82302. }
  82303. declare module BABYLON {
  82304. /** @hidden */
  82305. export var kernelBlurFragment2: {
  82306. name: string;
  82307. shader: string;
  82308. };
  82309. }
  82310. declare module BABYLON {
  82311. /** @hidden */
  82312. export var kernelBlurPixelShader: {
  82313. name: string;
  82314. shader: string;
  82315. };
  82316. }
  82317. declare module BABYLON {
  82318. /** @hidden */
  82319. export var kernelBlurVertex: {
  82320. name: string;
  82321. shader: string;
  82322. };
  82323. }
  82324. declare module BABYLON {
  82325. /** @hidden */
  82326. export var kernelBlurVertexShader: {
  82327. name: string;
  82328. shader: string;
  82329. };
  82330. }
  82331. declare module BABYLON {
  82332. /**
  82333. * The Blur Post Process which blurs an image based on a kernel and direction.
  82334. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  82335. */
  82336. export class BlurPostProcess extends PostProcess {
  82337. /** The direction in which to blur the image. */
  82338. direction: Vector2;
  82339. private blockCompilation;
  82340. protected _kernel: number;
  82341. protected _idealKernel: number;
  82342. protected _packedFloat: boolean;
  82343. private _staticDefines;
  82344. /**
  82345. * Sets the length in pixels of the blur sample region
  82346. */
  82347. /**
  82348. * Gets the length in pixels of the blur sample region
  82349. */
  82350. kernel: number;
  82351. /**
  82352. * Sets wether or not the blur needs to unpack/repack floats
  82353. */
  82354. /**
  82355. * Gets wether or not the blur is unpacking/repacking floats
  82356. */
  82357. packedFloat: boolean;
  82358. /**
  82359. * Creates a new instance BlurPostProcess
  82360. * @param name The name of the effect.
  82361. * @param direction The direction in which to blur the image.
  82362. * @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.
  82363. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  82364. * @param camera The camera to apply the render pass to.
  82365. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  82366. * @param engine The engine which the post process will be applied. (default: current engine)
  82367. * @param reusable If the post process can be reused on the same frame. (default: false)
  82368. * @param textureType Type of textures used when performing the post process. (default: 0)
  82369. * @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)
  82370. */
  82371. constructor(name: string,
  82372. /** The direction in which to blur the image. */
  82373. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  82374. /**
  82375. * Updates the effect with the current post process compile time values and recompiles the shader.
  82376. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  82377. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  82378. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  82379. * @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
  82380. * @param onCompiled Called when the shader has been compiled.
  82381. * @param onError Called if there is an error when compiling a shader.
  82382. */
  82383. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82384. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  82385. /**
  82386. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  82387. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  82388. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  82389. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  82390. * The gaps between physical kernels are compensated for in the weighting of the samples
  82391. * @param idealKernel Ideal blur kernel.
  82392. * @return Nearest best kernel.
  82393. */
  82394. protected _nearestBestKernel(idealKernel: number): number;
  82395. /**
  82396. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  82397. * @param x The point on the Gaussian distribution to sample.
  82398. * @return the value of the Gaussian function at x.
  82399. */
  82400. protected _gaussianWeight(x: number): number;
  82401. /**
  82402. * Generates a string that can be used as a floating point number in GLSL.
  82403. * @param x Value to print.
  82404. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  82405. * @return GLSL float string.
  82406. */
  82407. protected _glslFloat(x: number, decimalFigures?: number): string;
  82408. }
  82409. }
  82410. declare module BABYLON {
  82411. /**
  82412. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82413. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82414. * You can then easily use it as a reflectionTexture on a flat surface.
  82415. * In case the surface is not a plane, please consider relying on reflection probes.
  82416. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82417. */
  82418. export class MirrorTexture extends RenderTargetTexture {
  82419. private scene;
  82420. /**
  82421. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  82422. * 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.
  82423. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82424. */
  82425. mirrorPlane: Plane;
  82426. /**
  82427. * Define the blur ratio used to blur the reflection if needed.
  82428. */
  82429. blurRatio: number;
  82430. /**
  82431. * Define the adaptive blur kernel used to blur the reflection if needed.
  82432. * This will autocompute the closest best match for the `blurKernel`
  82433. */
  82434. adaptiveBlurKernel: number;
  82435. /**
  82436. * Define the blur kernel used to blur the reflection if needed.
  82437. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82438. */
  82439. blurKernel: number;
  82440. /**
  82441. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  82442. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82443. */
  82444. blurKernelX: number;
  82445. /**
  82446. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  82447. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  82448. */
  82449. blurKernelY: number;
  82450. private _autoComputeBlurKernel;
  82451. protected _onRatioRescale(): void;
  82452. private _updateGammaSpace;
  82453. private _imageProcessingConfigChangeObserver;
  82454. private _transformMatrix;
  82455. private _mirrorMatrix;
  82456. private _savedViewMatrix;
  82457. private _blurX;
  82458. private _blurY;
  82459. private _adaptiveBlurKernel;
  82460. private _blurKernelX;
  82461. private _blurKernelY;
  82462. private _blurRatio;
  82463. /**
  82464. * Instantiates a Mirror Texture.
  82465. * Mirror texture can be used to simulate the view from a mirror in a scene.
  82466. * It will dynamically be rendered every frame to adapt to the camera point of view.
  82467. * You can then easily use it as a reflectionTexture on a flat surface.
  82468. * In case the surface is not a plane, please consider relying on reflection probes.
  82469. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  82470. * @param name
  82471. * @param size
  82472. * @param scene
  82473. * @param generateMipMaps
  82474. * @param type
  82475. * @param samplingMode
  82476. * @param generateDepthBuffer
  82477. */
  82478. constructor(name: string, size: number | {
  82479. width: number;
  82480. height: number;
  82481. } | {
  82482. ratio: number;
  82483. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  82484. private _preparePostProcesses;
  82485. /**
  82486. * Clone the mirror texture.
  82487. * @returns the cloned texture
  82488. */
  82489. clone(): MirrorTexture;
  82490. /**
  82491. * Serialize the texture to a JSON representation you could use in Parse later on
  82492. * @returns the serialized JSON representation
  82493. */
  82494. serialize(): any;
  82495. /**
  82496. * Dispose the texture and release its associated resources.
  82497. */
  82498. dispose(): void;
  82499. }
  82500. }
  82501. declare module BABYLON {
  82502. /**
  82503. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82504. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82505. */
  82506. export class Texture extends BaseTexture {
  82507. /**
  82508. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  82509. */
  82510. static SerializeBuffers: boolean;
  82511. /** @hidden */
  82512. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  82513. /** @hidden */
  82514. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  82515. /** @hidden */
  82516. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  82517. /** nearest is mag = nearest and min = nearest and mip = linear */
  82518. static readonly NEAREST_SAMPLINGMODE: number;
  82519. /** nearest is mag = nearest and min = nearest and mip = linear */
  82520. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  82521. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82522. static readonly BILINEAR_SAMPLINGMODE: number;
  82523. /** Bilinear is mag = linear and min = linear and mip = nearest */
  82524. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  82525. /** Trilinear is mag = linear and min = linear and mip = linear */
  82526. static readonly TRILINEAR_SAMPLINGMODE: number;
  82527. /** Trilinear is mag = linear and min = linear and mip = linear */
  82528. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  82529. /** mag = nearest and min = nearest and mip = nearest */
  82530. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  82531. /** mag = nearest and min = linear and mip = nearest */
  82532. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  82533. /** mag = nearest and min = linear and mip = linear */
  82534. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  82535. /** mag = nearest and min = linear and mip = none */
  82536. static readonly NEAREST_LINEAR: number;
  82537. /** mag = nearest and min = nearest and mip = none */
  82538. static readonly NEAREST_NEAREST: number;
  82539. /** mag = linear and min = nearest and mip = nearest */
  82540. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  82541. /** mag = linear and min = nearest and mip = linear */
  82542. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  82543. /** mag = linear and min = linear and mip = none */
  82544. static readonly LINEAR_LINEAR: number;
  82545. /** mag = linear and min = nearest and mip = none */
  82546. static readonly LINEAR_NEAREST: number;
  82547. /** Explicit coordinates mode */
  82548. static readonly EXPLICIT_MODE: number;
  82549. /** Spherical coordinates mode */
  82550. static readonly SPHERICAL_MODE: number;
  82551. /** Planar coordinates mode */
  82552. static readonly PLANAR_MODE: number;
  82553. /** Cubic coordinates mode */
  82554. static readonly CUBIC_MODE: number;
  82555. /** Projection coordinates mode */
  82556. static readonly PROJECTION_MODE: number;
  82557. /** Inverse Cubic coordinates mode */
  82558. static readonly SKYBOX_MODE: number;
  82559. /** Inverse Cubic coordinates mode */
  82560. static readonly INVCUBIC_MODE: number;
  82561. /** Equirectangular coordinates mode */
  82562. static readonly EQUIRECTANGULAR_MODE: number;
  82563. /** Equirectangular Fixed coordinates mode */
  82564. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  82565. /** Equirectangular Fixed Mirrored coordinates mode */
  82566. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  82567. /** Texture is not repeating outside of 0..1 UVs */
  82568. static readonly CLAMP_ADDRESSMODE: number;
  82569. /** Texture is repeating outside of 0..1 UVs */
  82570. static readonly WRAP_ADDRESSMODE: number;
  82571. /** Texture is repeating and mirrored */
  82572. static readonly MIRROR_ADDRESSMODE: number;
  82573. /**
  82574. * 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
  82575. */
  82576. static UseSerializedUrlIfAny: boolean;
  82577. /**
  82578. * Define the url of the texture.
  82579. */
  82580. url: Nullable<string>;
  82581. /**
  82582. * Define an offset on the texture to offset the u coordinates of the UVs
  82583. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82584. */
  82585. uOffset: number;
  82586. /**
  82587. * Define an offset on the texture to offset the v coordinates of the UVs
  82588. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  82589. */
  82590. vOffset: number;
  82591. /**
  82592. * Define an offset on the texture to scale the u coordinates of the UVs
  82593. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82594. */
  82595. uScale: number;
  82596. /**
  82597. * Define an offset on the texture to scale the v coordinates of the UVs
  82598. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  82599. */
  82600. vScale: number;
  82601. /**
  82602. * Define an offset on the texture to rotate around the u coordinates of the UVs
  82603. * @see http://doc.babylonjs.com/how_to/more_materials
  82604. */
  82605. uAng: number;
  82606. /**
  82607. * Define an offset on the texture to rotate around the v coordinates of the UVs
  82608. * @see http://doc.babylonjs.com/how_to/more_materials
  82609. */
  82610. vAng: number;
  82611. /**
  82612. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  82613. * @see http://doc.babylonjs.com/how_to/more_materials
  82614. */
  82615. wAng: number;
  82616. /**
  82617. * Defines the center of rotation (U)
  82618. */
  82619. uRotationCenter: number;
  82620. /**
  82621. * Defines the center of rotation (V)
  82622. */
  82623. vRotationCenter: number;
  82624. /**
  82625. * Defines the center of rotation (W)
  82626. */
  82627. wRotationCenter: number;
  82628. /**
  82629. * Are mip maps generated for this texture or not.
  82630. */
  82631. readonly noMipmap: boolean;
  82632. /**
  82633. * List of inspectable custom properties (used by the Inspector)
  82634. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  82635. */
  82636. inspectableCustomProperties: Nullable<IInspectable[]>;
  82637. private _noMipmap;
  82638. /** @hidden */
  82639. _invertY: boolean;
  82640. private _rowGenerationMatrix;
  82641. private _cachedTextureMatrix;
  82642. private _projectionModeMatrix;
  82643. private _t0;
  82644. private _t1;
  82645. private _t2;
  82646. private _cachedUOffset;
  82647. private _cachedVOffset;
  82648. private _cachedUScale;
  82649. private _cachedVScale;
  82650. private _cachedUAng;
  82651. private _cachedVAng;
  82652. private _cachedWAng;
  82653. private _cachedProjectionMatrixId;
  82654. private _cachedCoordinatesMode;
  82655. /** @hidden */
  82656. protected _initialSamplingMode: number;
  82657. /** @hidden */
  82658. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  82659. private _deleteBuffer;
  82660. protected _format: Nullable<number>;
  82661. private _delayedOnLoad;
  82662. private _delayedOnError;
  82663. /**
  82664. * Observable triggered once the texture has been loaded.
  82665. */
  82666. onLoadObservable: Observable<Texture>;
  82667. protected _isBlocking: boolean;
  82668. /**
  82669. * Is the texture preventing material to render while loading.
  82670. * If false, a default texture will be used instead of the loading one during the preparation step.
  82671. */
  82672. isBlocking: boolean;
  82673. /**
  82674. * Get the current sampling mode associated with the texture.
  82675. */
  82676. readonly samplingMode: number;
  82677. /**
  82678. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  82679. */
  82680. readonly invertY: boolean;
  82681. /**
  82682. * Instantiates a new texture.
  82683. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  82684. * @see http://doc.babylonjs.com/babylon101/materials#texture
  82685. * @param url define the url of the picture to load as a texture
  82686. * @param scene define the scene or engine the texture will belong to
  82687. * @param noMipmap define if the texture will require mip maps or not
  82688. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82689. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82690. * @param onLoad define a callback triggered when the texture has been loaded
  82691. * @param onError define a callback triggered when an error occurred during the loading session
  82692. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82693. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82694. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82695. */
  82696. 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);
  82697. /**
  82698. * Update the url (and optional buffer) of this texture if url was null during construction.
  82699. * @param url the url of the texture
  82700. * @param buffer the buffer of the texture (defaults to null)
  82701. * @param onLoad callback called when the texture is loaded (defaults to null)
  82702. */
  82703. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  82704. /**
  82705. * Finish the loading sequence of a texture flagged as delayed load.
  82706. * @hidden
  82707. */
  82708. delayLoad(): void;
  82709. private _prepareRowForTextureGeneration;
  82710. /**
  82711. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  82712. * @returns the transform matrix of the texture.
  82713. */
  82714. getTextureMatrix(): Matrix;
  82715. /**
  82716. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  82717. * @returns The reflection texture transform
  82718. */
  82719. getReflectionTextureMatrix(): Matrix;
  82720. /**
  82721. * Clones the texture.
  82722. * @returns the cloned texture
  82723. */
  82724. clone(): Texture;
  82725. /**
  82726. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  82727. * @returns The JSON representation of the texture
  82728. */
  82729. serialize(): any;
  82730. /**
  82731. * Get the current class name of the texture useful for serialization or dynamic coding.
  82732. * @returns "Texture"
  82733. */
  82734. getClassName(): string;
  82735. /**
  82736. * Dispose the texture and release its associated resources.
  82737. */
  82738. dispose(): void;
  82739. /**
  82740. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  82741. * @param parsedTexture Define the JSON representation of the texture
  82742. * @param scene Define the scene the parsed texture should be instantiated in
  82743. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  82744. * @returns The parsed texture if successful
  82745. */
  82746. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  82747. /**
  82748. * Creates a texture from its base 64 representation.
  82749. * @param data Define the base64 payload without the data: prefix
  82750. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82751. * @param scene Define the scene the texture should belong to
  82752. * @param noMipmap Forces the texture to not create mip map information if true
  82753. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82754. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82755. * @param onLoad define a callback triggered when the texture has been loaded
  82756. * @param onError define a callback triggered when an error occurred during the loading session
  82757. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82758. * @returns the created texture
  82759. */
  82760. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  82761. /**
  82762. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  82763. * @param data Define the base64 payload without the data: prefix
  82764. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  82765. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  82766. * @param scene Define the scene the texture should belong to
  82767. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  82768. * @param noMipmap Forces the texture to not create mip map information if true
  82769. * @param invertY define if the texture needs to be inverted on the y axis during loading
  82770. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  82771. * @param onLoad define a callback triggered when the texture has been loaded
  82772. * @param onError define a callback triggered when an error occurred during the loading session
  82773. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  82774. * @returns the created texture
  82775. */
  82776. 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;
  82777. }
  82778. }
  82779. declare module BABYLON {
  82780. /**
  82781. * PostProcessManager is used to manage one or more post processes or post process pipelines
  82782. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  82783. */
  82784. export class PostProcessManager {
  82785. private _scene;
  82786. private _indexBuffer;
  82787. private _vertexBuffers;
  82788. /**
  82789. * Creates a new instance PostProcess
  82790. * @param scene The scene that the post process is associated with.
  82791. */
  82792. constructor(scene: Scene);
  82793. private _prepareBuffers;
  82794. private _buildIndexBuffer;
  82795. /**
  82796. * Rebuilds the vertex buffers of the manager.
  82797. * @hidden
  82798. */
  82799. _rebuild(): void;
  82800. /**
  82801. * Prepares a frame to be run through a post process.
  82802. * @param sourceTexture The input texture to the post procesess. (default: null)
  82803. * @param postProcesses An array of post processes to be run. (default: null)
  82804. * @returns True if the post processes were able to be run.
  82805. * @hidden
  82806. */
  82807. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  82808. /**
  82809. * Manually render a set of post processes to a texture.
  82810. * @param postProcesses An array of post processes to be run.
  82811. * @param targetTexture The target texture to render to.
  82812. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  82813. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  82814. * @param lodLevel defines which lod of the texture to render to
  82815. */
  82816. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  82817. /**
  82818. * Finalize the result of the output of the postprocesses.
  82819. * @param doNotPresent If true the result will not be displayed to the screen.
  82820. * @param targetTexture The target texture to render to.
  82821. * @param faceIndex The index of the face to bind the target texture to.
  82822. * @param postProcesses The array of post processes to render.
  82823. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  82824. * @hidden
  82825. */
  82826. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  82827. /**
  82828. * Disposes of the post process manager.
  82829. */
  82830. dispose(): void;
  82831. }
  82832. }
  82833. declare module BABYLON {
  82834. /** Interface used by value gradients (color, factor, ...) */
  82835. export interface IValueGradient {
  82836. /**
  82837. * Gets or sets the gradient value (between 0 and 1)
  82838. */
  82839. gradient: number;
  82840. }
  82841. /** Class used to store color4 gradient */
  82842. export class ColorGradient implements IValueGradient {
  82843. /**
  82844. * Gets or sets the gradient value (between 0 and 1)
  82845. */
  82846. gradient: number;
  82847. /**
  82848. * Gets or sets first associated color
  82849. */
  82850. color1: Color4;
  82851. /**
  82852. * Gets or sets second associated color
  82853. */
  82854. color2?: Color4;
  82855. /**
  82856. * Will get a color picked randomly between color1 and color2.
  82857. * If color2 is undefined then color1 will be used
  82858. * @param result defines the target Color4 to store the result in
  82859. */
  82860. getColorToRef(result: Color4): void;
  82861. }
  82862. /** Class used to store color 3 gradient */
  82863. export class Color3Gradient implements IValueGradient {
  82864. /**
  82865. * Gets or sets the gradient value (between 0 and 1)
  82866. */
  82867. gradient: number;
  82868. /**
  82869. * Gets or sets the associated color
  82870. */
  82871. color: Color3;
  82872. }
  82873. /** Class used to store factor gradient */
  82874. export class FactorGradient implements IValueGradient {
  82875. /**
  82876. * Gets or sets the gradient value (between 0 and 1)
  82877. */
  82878. gradient: number;
  82879. /**
  82880. * Gets or sets first associated factor
  82881. */
  82882. factor1: number;
  82883. /**
  82884. * Gets or sets second associated factor
  82885. */
  82886. factor2?: number;
  82887. /**
  82888. * Will get a number picked randomly between factor1 and factor2.
  82889. * If factor2 is undefined then factor1 will be used
  82890. * @returns the picked number
  82891. */
  82892. getFactor(): number;
  82893. }
  82894. /**
  82895. * Helper used to simplify some generic gradient tasks
  82896. */
  82897. export class GradientHelper {
  82898. /**
  82899. * Gets the current gradient from an array of IValueGradient
  82900. * @param ratio defines the current ratio to get
  82901. * @param gradients defines the array of IValueGradient
  82902. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  82903. */
  82904. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  82905. }
  82906. }
  82907. declare module BABYLON {
  82908. interface ThinEngine {
  82909. /**
  82910. * Creates a dynamic texture
  82911. * @param width defines the width of the texture
  82912. * @param height defines the height of the texture
  82913. * @param generateMipMaps defines if the engine should generate the mip levels
  82914. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  82915. * @returns the dynamic texture inside an InternalTexture
  82916. */
  82917. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  82918. /**
  82919. * Update the content of a dynamic texture
  82920. * @param texture defines the texture to update
  82921. * @param canvas defines the canvas containing the source
  82922. * @param invertY defines if data must be stored with Y axis inverted
  82923. * @param premulAlpha defines if alpha is stored as premultiplied
  82924. * @param format defines the format of the data
  82925. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  82926. */
  82927. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  82928. }
  82929. }
  82930. declare module BABYLON {
  82931. /**
  82932. * A class extending Texture allowing drawing on a texture
  82933. * @see http://doc.babylonjs.com/how_to/dynamictexture
  82934. */
  82935. export class DynamicTexture extends Texture {
  82936. private _generateMipMaps;
  82937. private _canvas;
  82938. private _context;
  82939. private _engine;
  82940. /**
  82941. * Creates a DynamicTexture
  82942. * @param name defines the name of the texture
  82943. * @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
  82944. * @param scene defines the scene where you want the texture
  82945. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  82946. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  82947. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  82948. */
  82949. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  82950. /**
  82951. * Get the current class name of the texture useful for serialization or dynamic coding.
  82952. * @returns "DynamicTexture"
  82953. */
  82954. getClassName(): string;
  82955. /**
  82956. * Gets the current state of canRescale
  82957. */
  82958. readonly canRescale: boolean;
  82959. private _recreate;
  82960. /**
  82961. * Scales the texture
  82962. * @param ratio the scale factor to apply to both width and height
  82963. */
  82964. scale(ratio: number): void;
  82965. /**
  82966. * Resizes the texture
  82967. * @param width the new width
  82968. * @param height the new height
  82969. */
  82970. scaleTo(width: number, height: number): void;
  82971. /**
  82972. * Gets the context of the canvas used by the texture
  82973. * @returns the canvas context of the dynamic texture
  82974. */
  82975. getContext(): CanvasRenderingContext2D;
  82976. /**
  82977. * Clears the texture
  82978. */
  82979. clear(): void;
  82980. /**
  82981. * Updates the texture
  82982. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82983. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  82984. */
  82985. update(invertY?: boolean, premulAlpha?: boolean): void;
  82986. /**
  82987. * Draws text onto the texture
  82988. * @param text defines the text to be drawn
  82989. * @param x defines the placement of the text from the left
  82990. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  82991. * @param font defines the font to be used with font-style, font-size, font-name
  82992. * @param color defines the color used for the text
  82993. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  82994. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  82995. * @param update defines whether texture is immediately update (default is true)
  82996. */
  82997. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  82998. /**
  82999. * Clones the texture
  83000. * @returns the clone of the texture.
  83001. */
  83002. clone(): DynamicTexture;
  83003. /**
  83004. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  83005. * @returns a serialized dynamic texture object
  83006. */
  83007. serialize(): any;
  83008. /** @hidden */
  83009. _rebuild(): void;
  83010. }
  83011. }
  83012. declare module BABYLON {
  83013. interface AbstractScene {
  83014. /**
  83015. * The list of procedural textures added to the scene
  83016. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83017. */
  83018. proceduralTextures: Array<ProceduralTexture>;
  83019. }
  83020. /**
  83021. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  83022. * in a given scene.
  83023. */
  83024. export class ProceduralTextureSceneComponent implements ISceneComponent {
  83025. /**
  83026. * The component name helpfull to identify the component in the list of scene components.
  83027. */
  83028. readonly name: string;
  83029. /**
  83030. * The scene the component belongs to.
  83031. */
  83032. scene: Scene;
  83033. /**
  83034. * Creates a new instance of the component for the given scene
  83035. * @param scene Defines the scene to register the component in
  83036. */
  83037. constructor(scene: Scene);
  83038. /**
  83039. * Registers the component in a given scene
  83040. */
  83041. register(): void;
  83042. /**
  83043. * Rebuilds the elements related to this component in case of
  83044. * context lost for instance.
  83045. */
  83046. rebuild(): void;
  83047. /**
  83048. * Disposes the component and the associated ressources.
  83049. */
  83050. dispose(): void;
  83051. private _beforeClear;
  83052. }
  83053. }
  83054. declare module BABYLON {
  83055. interface ThinEngine {
  83056. /**
  83057. * Creates a new render target cube texture
  83058. * @param size defines the size of the texture
  83059. * @param options defines the options used to create the texture
  83060. * @returns a new render target cube texture stored in an InternalTexture
  83061. */
  83062. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  83063. }
  83064. }
  83065. declare module BABYLON {
  83066. /** @hidden */
  83067. export var proceduralVertexShader: {
  83068. name: string;
  83069. shader: string;
  83070. };
  83071. }
  83072. declare module BABYLON {
  83073. /**
  83074. * 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.
  83075. * This is the base class of any Procedural texture and contains most of the shareable code.
  83076. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83077. */
  83078. export class ProceduralTexture extends Texture {
  83079. isCube: boolean;
  83080. /**
  83081. * Define if the texture is enabled or not (disabled texture will not render)
  83082. */
  83083. isEnabled: boolean;
  83084. /**
  83085. * Define if the texture must be cleared before rendering (default is true)
  83086. */
  83087. autoClear: boolean;
  83088. /**
  83089. * Callback called when the texture is generated
  83090. */
  83091. onGenerated: () => void;
  83092. /**
  83093. * Event raised when the texture is generated
  83094. */
  83095. onGeneratedObservable: Observable<ProceduralTexture>;
  83096. /** @hidden */
  83097. _generateMipMaps: boolean;
  83098. /** @hidden **/
  83099. _effect: Effect;
  83100. /** @hidden */
  83101. _textures: {
  83102. [key: string]: Texture;
  83103. };
  83104. private _size;
  83105. private _currentRefreshId;
  83106. private _refreshRate;
  83107. private _vertexBuffers;
  83108. private _indexBuffer;
  83109. private _uniforms;
  83110. private _samplers;
  83111. private _fragment;
  83112. private _floats;
  83113. private _ints;
  83114. private _floatsArrays;
  83115. private _colors3;
  83116. private _colors4;
  83117. private _vectors2;
  83118. private _vectors3;
  83119. private _matrices;
  83120. private _fallbackTexture;
  83121. private _fallbackTextureUsed;
  83122. private _engine;
  83123. private _cachedDefines;
  83124. private _contentUpdateId;
  83125. private _contentData;
  83126. /**
  83127. * Instantiates a new procedural texture.
  83128. * 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.
  83129. * This is the base class of any Procedural texture and contains most of the shareable code.
  83130. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  83131. * @param name Define the name of the texture
  83132. * @param size Define the size of the texture to create
  83133. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  83134. * @param scene Define the scene the texture belongs to
  83135. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  83136. * @param generateMipMaps Define if the texture should creates mip maps or not
  83137. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  83138. */
  83139. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  83140. /**
  83141. * The effect that is created when initializing the post process.
  83142. * @returns The created effect corresponding the the postprocess.
  83143. */
  83144. getEffect(): Effect;
  83145. /**
  83146. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  83147. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  83148. */
  83149. getContent(): Nullable<ArrayBufferView>;
  83150. private _createIndexBuffer;
  83151. /** @hidden */
  83152. _rebuild(): void;
  83153. /**
  83154. * Resets the texture in order to recreate its associated resources.
  83155. * This can be called in case of context loss
  83156. */
  83157. reset(): void;
  83158. protected _getDefines(): string;
  83159. /**
  83160. * Is the texture ready to be used ? (rendered at least once)
  83161. * @returns true if ready, otherwise, false.
  83162. */
  83163. isReady(): boolean;
  83164. /**
  83165. * Resets the refresh counter of the texture and start bak from scratch.
  83166. * Could be useful to regenerate the texture if it is setup to render only once.
  83167. */
  83168. resetRefreshCounter(): void;
  83169. /**
  83170. * Set the fragment shader to use in order to render the texture.
  83171. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  83172. */
  83173. setFragment(fragment: any): void;
  83174. /**
  83175. * Define the refresh rate of the texture or the rendering frequency.
  83176. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  83177. */
  83178. refreshRate: number;
  83179. /** @hidden */
  83180. _shouldRender(): boolean;
  83181. /**
  83182. * Get the size the texture is rendering at.
  83183. * @returns the size (texture is always squared)
  83184. */
  83185. getRenderSize(): number;
  83186. /**
  83187. * Resize the texture to new value.
  83188. * @param size Define the new size the texture should have
  83189. * @param generateMipMaps Define whether the new texture should create mip maps
  83190. */
  83191. resize(size: number, generateMipMaps: boolean): void;
  83192. private _checkUniform;
  83193. /**
  83194. * Set a texture in the shader program used to render.
  83195. * @param name Define the name of the uniform samplers as defined in the shader
  83196. * @param texture Define the texture to bind to this sampler
  83197. * @return the texture itself allowing "fluent" like uniform updates
  83198. */
  83199. setTexture(name: string, texture: Texture): ProceduralTexture;
  83200. /**
  83201. * Set a float in the shader.
  83202. * @param name Define the name of the uniform as defined in the shader
  83203. * @param value Define the value to give to the uniform
  83204. * @return the texture itself allowing "fluent" like uniform updates
  83205. */
  83206. setFloat(name: string, value: number): ProceduralTexture;
  83207. /**
  83208. * Set a int in the shader.
  83209. * @param name Define the name of the uniform as defined in the shader
  83210. * @param value Define the value to give to the uniform
  83211. * @return the texture itself allowing "fluent" like uniform updates
  83212. */
  83213. setInt(name: string, value: number): ProceduralTexture;
  83214. /**
  83215. * Set an array of floats in the shader.
  83216. * @param name Define the name of the uniform as defined in the shader
  83217. * @param value Define the value to give to the uniform
  83218. * @return the texture itself allowing "fluent" like uniform updates
  83219. */
  83220. setFloats(name: string, value: number[]): ProceduralTexture;
  83221. /**
  83222. * Set a vec3 in the shader from a Color3.
  83223. * @param name Define the name of the uniform as defined in the shader
  83224. * @param value Define the value to give to the uniform
  83225. * @return the texture itself allowing "fluent" like uniform updates
  83226. */
  83227. setColor3(name: string, value: Color3): ProceduralTexture;
  83228. /**
  83229. * Set a vec4 in the shader from a Color4.
  83230. * @param name Define the name of the uniform as defined in the shader
  83231. * @param value Define the value to give to the uniform
  83232. * @return the texture itself allowing "fluent" like uniform updates
  83233. */
  83234. setColor4(name: string, value: Color4): ProceduralTexture;
  83235. /**
  83236. * Set a vec2 in the shader from a Vector2.
  83237. * @param name Define the name of the uniform as defined in the shader
  83238. * @param value Define the value to give to the uniform
  83239. * @return the texture itself allowing "fluent" like uniform updates
  83240. */
  83241. setVector2(name: string, value: Vector2): ProceduralTexture;
  83242. /**
  83243. * Set a vec3 in the shader from a Vector3.
  83244. * @param name Define the name of the uniform as defined in the shader
  83245. * @param value Define the value to give to the uniform
  83246. * @return the texture itself allowing "fluent" like uniform updates
  83247. */
  83248. setVector3(name: string, value: Vector3): ProceduralTexture;
  83249. /**
  83250. * Set a mat4 in the shader from a MAtrix.
  83251. * @param name Define the name of the uniform as defined in the shader
  83252. * @param value Define the value to give to the uniform
  83253. * @return the texture itself allowing "fluent" like uniform updates
  83254. */
  83255. setMatrix(name: string, value: Matrix): ProceduralTexture;
  83256. /**
  83257. * Render the texture to its associated render target.
  83258. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  83259. */
  83260. render(useCameraPostProcess?: boolean): void;
  83261. /**
  83262. * Clone the texture.
  83263. * @returns the cloned texture
  83264. */
  83265. clone(): ProceduralTexture;
  83266. /**
  83267. * Dispose the texture and release its asoociated resources.
  83268. */
  83269. dispose(): void;
  83270. }
  83271. }
  83272. declare module BABYLON {
  83273. /**
  83274. * This represents the base class for particle system in Babylon.
  83275. * 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.
  83276. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83277. * @example https://doc.babylonjs.com/babylon101/particles
  83278. */
  83279. export class BaseParticleSystem {
  83280. /**
  83281. * Source color is added to the destination color without alpha affecting the result
  83282. */
  83283. static BLENDMODE_ONEONE: number;
  83284. /**
  83285. * Blend current color and particle color using particle’s alpha
  83286. */
  83287. static BLENDMODE_STANDARD: number;
  83288. /**
  83289. * Add current color and particle color multiplied by particle’s alpha
  83290. */
  83291. static BLENDMODE_ADD: number;
  83292. /**
  83293. * Multiply current color with particle color
  83294. */
  83295. static BLENDMODE_MULTIPLY: number;
  83296. /**
  83297. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  83298. */
  83299. static BLENDMODE_MULTIPLYADD: number;
  83300. /**
  83301. * List of animations used by the particle system.
  83302. */
  83303. animations: Animation[];
  83304. /**
  83305. * The id of the Particle system.
  83306. */
  83307. id: string;
  83308. /**
  83309. * The friendly name of the Particle system.
  83310. */
  83311. name: string;
  83312. /**
  83313. * The rendering group used by the Particle system to chose when to render.
  83314. */
  83315. renderingGroupId: number;
  83316. /**
  83317. * The emitter represents the Mesh or position we are attaching the particle system to.
  83318. */
  83319. emitter: Nullable<AbstractMesh | Vector3>;
  83320. /**
  83321. * The maximum number of particles to emit per frame
  83322. */
  83323. emitRate: number;
  83324. /**
  83325. * If you want to launch only a few particles at once, that can be done, as well.
  83326. */
  83327. manualEmitCount: number;
  83328. /**
  83329. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  83330. */
  83331. updateSpeed: number;
  83332. /**
  83333. * The amount of time the particle system is running (depends of the overall update speed).
  83334. */
  83335. targetStopDuration: number;
  83336. /**
  83337. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  83338. */
  83339. disposeOnStop: boolean;
  83340. /**
  83341. * Minimum power of emitting particles.
  83342. */
  83343. minEmitPower: number;
  83344. /**
  83345. * Maximum power of emitting particles.
  83346. */
  83347. maxEmitPower: number;
  83348. /**
  83349. * Minimum life time of emitting particles.
  83350. */
  83351. minLifeTime: number;
  83352. /**
  83353. * Maximum life time of emitting particles.
  83354. */
  83355. maxLifeTime: number;
  83356. /**
  83357. * Minimum Size of emitting particles.
  83358. */
  83359. minSize: number;
  83360. /**
  83361. * Maximum Size of emitting particles.
  83362. */
  83363. maxSize: number;
  83364. /**
  83365. * Minimum scale of emitting particles on X axis.
  83366. */
  83367. minScaleX: number;
  83368. /**
  83369. * Maximum scale of emitting particles on X axis.
  83370. */
  83371. maxScaleX: number;
  83372. /**
  83373. * Minimum scale of emitting particles on Y axis.
  83374. */
  83375. minScaleY: number;
  83376. /**
  83377. * Maximum scale of emitting particles on Y axis.
  83378. */
  83379. maxScaleY: number;
  83380. /**
  83381. * Gets or sets the minimal initial rotation in radians.
  83382. */
  83383. minInitialRotation: number;
  83384. /**
  83385. * Gets or sets the maximal initial rotation in radians.
  83386. */
  83387. maxInitialRotation: number;
  83388. /**
  83389. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  83390. */
  83391. minAngularSpeed: number;
  83392. /**
  83393. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  83394. */
  83395. maxAngularSpeed: number;
  83396. /**
  83397. * The texture used to render each particle. (this can be a spritesheet)
  83398. */
  83399. particleTexture: Nullable<Texture>;
  83400. /**
  83401. * The layer mask we are rendering the particles through.
  83402. */
  83403. layerMask: number;
  83404. /**
  83405. * This can help using your own shader to render the particle system.
  83406. * The according effect will be created
  83407. */
  83408. customShader: any;
  83409. /**
  83410. * By default particle system starts as soon as they are created. This prevents the
  83411. * automatic start to happen and let you decide when to start emitting particles.
  83412. */
  83413. preventAutoStart: boolean;
  83414. private _noiseTexture;
  83415. /**
  83416. * Gets or sets a texture used to add random noise to particle positions
  83417. */
  83418. noiseTexture: Nullable<ProceduralTexture>;
  83419. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  83420. noiseStrength: Vector3;
  83421. /**
  83422. * Callback triggered when the particle animation is ending.
  83423. */
  83424. onAnimationEnd: Nullable<() => void>;
  83425. /**
  83426. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  83427. */
  83428. blendMode: number;
  83429. /**
  83430. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  83431. * to override the particles.
  83432. */
  83433. forceDepthWrite: boolean;
  83434. /** 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 */
  83435. preWarmCycles: number;
  83436. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  83437. preWarmStepOffset: number;
  83438. /**
  83439. * 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)
  83440. */
  83441. spriteCellChangeSpeed: number;
  83442. /**
  83443. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  83444. */
  83445. startSpriteCellID: number;
  83446. /**
  83447. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  83448. */
  83449. endSpriteCellID: number;
  83450. /**
  83451. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  83452. */
  83453. spriteCellWidth: number;
  83454. /**
  83455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  83456. */
  83457. spriteCellHeight: number;
  83458. /**
  83459. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  83460. */
  83461. spriteRandomStartCell: boolean;
  83462. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  83463. translationPivot: Vector2;
  83464. /** @hidden */
  83465. protected _isAnimationSheetEnabled: boolean;
  83466. /**
  83467. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  83468. */
  83469. beginAnimationOnStart: boolean;
  83470. /**
  83471. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  83472. */
  83473. beginAnimationFrom: number;
  83474. /**
  83475. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  83476. */
  83477. beginAnimationTo: number;
  83478. /**
  83479. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  83480. */
  83481. beginAnimationLoop: boolean;
  83482. /**
  83483. * Gets or sets a world offset applied to all particles
  83484. */
  83485. worldOffset: Vector3;
  83486. /**
  83487. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  83488. */
  83489. isAnimationSheetEnabled: boolean;
  83490. /**
  83491. * Get hosting scene
  83492. * @returns the scene
  83493. */
  83494. getScene(): Scene;
  83495. /**
  83496. * You can use gravity if you want to give an orientation to your particles.
  83497. */
  83498. gravity: Vector3;
  83499. protected _colorGradients: Nullable<Array<ColorGradient>>;
  83500. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  83501. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  83502. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  83503. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  83504. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  83505. protected _dragGradients: Nullable<Array<FactorGradient>>;
  83506. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  83507. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  83508. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  83509. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  83510. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  83511. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  83512. /**
  83513. * Defines the delay in milliseconds before starting the system (0 by default)
  83514. */
  83515. startDelay: number;
  83516. /**
  83517. * Gets the current list of drag gradients.
  83518. * You must use addDragGradient and removeDragGradient to udpate this list
  83519. * @returns the list of drag gradients
  83520. */
  83521. getDragGradients(): Nullable<Array<FactorGradient>>;
  83522. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  83523. limitVelocityDamping: number;
  83524. /**
  83525. * Gets the current list of limit velocity gradients.
  83526. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  83527. * @returns the list of limit velocity gradients
  83528. */
  83529. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  83530. /**
  83531. * Gets the current list of color gradients.
  83532. * You must use addColorGradient and removeColorGradient to udpate this list
  83533. * @returns the list of color gradients
  83534. */
  83535. getColorGradients(): Nullable<Array<ColorGradient>>;
  83536. /**
  83537. * Gets the current list of size gradients.
  83538. * You must use addSizeGradient and removeSizeGradient to udpate this list
  83539. * @returns the list of size gradients
  83540. */
  83541. getSizeGradients(): Nullable<Array<FactorGradient>>;
  83542. /**
  83543. * Gets the current list of color remap gradients.
  83544. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  83545. * @returns the list of color remap gradients
  83546. */
  83547. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  83548. /**
  83549. * Gets the current list of alpha remap gradients.
  83550. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  83551. * @returns the list of alpha remap gradients
  83552. */
  83553. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  83554. /**
  83555. * Gets the current list of life time gradients.
  83556. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  83557. * @returns the list of life time gradients
  83558. */
  83559. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  83560. /**
  83561. * Gets the current list of angular speed gradients.
  83562. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  83563. * @returns the list of angular speed gradients
  83564. */
  83565. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  83566. /**
  83567. * Gets the current list of velocity gradients.
  83568. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  83569. * @returns the list of velocity gradients
  83570. */
  83571. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  83572. /**
  83573. * Gets the current list of start size gradients.
  83574. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  83575. * @returns the list of start size gradients
  83576. */
  83577. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  83578. /**
  83579. * Gets the current list of emit rate gradients.
  83580. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  83581. * @returns the list of emit rate gradients
  83582. */
  83583. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  83584. /**
  83585. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83586. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83587. */
  83588. direction1: Vector3;
  83589. /**
  83590. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  83591. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83592. */
  83593. direction2: Vector3;
  83594. /**
  83595. * 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.
  83596. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83597. */
  83598. minEmitBox: Vector3;
  83599. /**
  83600. * 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.
  83601. * This only works when particleEmitterTyps is a BoxParticleEmitter
  83602. */
  83603. maxEmitBox: Vector3;
  83604. /**
  83605. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83606. */
  83607. color1: Color4;
  83608. /**
  83609. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  83610. */
  83611. color2: Color4;
  83612. /**
  83613. * Color the particle will have at the end of its lifetime
  83614. */
  83615. colorDead: Color4;
  83616. /**
  83617. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  83618. */
  83619. textureMask: Color4;
  83620. /**
  83621. * The particle emitter type defines the emitter used by the particle system.
  83622. * It can be for example box, sphere, or cone...
  83623. */
  83624. particleEmitterType: IParticleEmitterType;
  83625. /** @hidden */
  83626. _isSubEmitter: boolean;
  83627. /**
  83628. * Gets or sets the billboard mode to use when isBillboardBased = true.
  83629. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  83630. */
  83631. billboardMode: number;
  83632. protected _isBillboardBased: boolean;
  83633. /**
  83634. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  83635. */
  83636. isBillboardBased: boolean;
  83637. /**
  83638. * The scene the particle system belongs to.
  83639. */
  83640. protected _scene: Scene;
  83641. /**
  83642. * Local cache of defines for image processing.
  83643. */
  83644. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  83645. /**
  83646. * Default configuration related to image processing available in the standard Material.
  83647. */
  83648. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  83649. /**
  83650. * Gets the image processing configuration used either in this material.
  83651. */
  83652. /**
  83653. * Sets the Default image processing configuration used either in the this material.
  83654. *
  83655. * If sets to null, the scene one is in use.
  83656. */
  83657. imageProcessingConfiguration: ImageProcessingConfiguration;
  83658. /**
  83659. * Attaches a new image processing configuration to the Standard Material.
  83660. * @param configuration
  83661. */
  83662. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  83663. /** @hidden */
  83664. protected _reset(): void;
  83665. /** @hidden */
  83666. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  83667. /**
  83668. * Instantiates a particle system.
  83669. * 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.
  83670. * @param name The name of the particle system
  83671. */
  83672. constructor(name: string);
  83673. /**
  83674. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  83675. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83676. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83677. * @returns the emitter
  83678. */
  83679. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  83680. /**
  83681. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  83682. * @param radius The radius of the hemisphere to emit from
  83683. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83684. * @returns the emitter
  83685. */
  83686. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  83687. /**
  83688. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  83689. * @param radius The radius of the sphere to emit from
  83690. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  83691. * @returns the emitter
  83692. */
  83693. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  83694. /**
  83695. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  83696. * @param radius The radius of the sphere to emit from
  83697. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  83698. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  83699. * @returns the emitter
  83700. */
  83701. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  83702. /**
  83703. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  83704. * @param radius The radius of the emission cylinder
  83705. * @param height The height of the emission cylinder
  83706. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  83707. * @param directionRandomizer How much to randomize the particle direction [0-1]
  83708. * @returns the emitter
  83709. */
  83710. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  83711. /**
  83712. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  83713. * @param radius The radius of the cylinder to emit from
  83714. * @param height The height of the emission cylinder
  83715. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  83716. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  83717. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  83718. * @returns the emitter
  83719. */
  83720. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  83721. /**
  83722. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  83723. * @param radius The radius of the cone to emit from
  83724. * @param angle The base angle of the cone
  83725. * @returns the emitter
  83726. */
  83727. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  83728. /**
  83729. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  83730. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  83731. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  83732. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83733. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  83734. * @returns the emitter
  83735. */
  83736. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  83737. }
  83738. }
  83739. declare module BABYLON {
  83740. /**
  83741. * Type of sub emitter
  83742. */
  83743. export enum SubEmitterType {
  83744. /**
  83745. * Attached to the particle over it's lifetime
  83746. */
  83747. ATTACHED = 0,
  83748. /**
  83749. * Created when the particle dies
  83750. */
  83751. END = 1
  83752. }
  83753. /**
  83754. * Sub emitter class used to emit particles from an existing particle
  83755. */
  83756. export class SubEmitter {
  83757. /**
  83758. * the particle system to be used by the sub emitter
  83759. */
  83760. particleSystem: ParticleSystem;
  83761. /**
  83762. * Type of the submitter (Default: END)
  83763. */
  83764. type: SubEmitterType;
  83765. /**
  83766. * 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)
  83767. * Note: This only is supported when using an emitter of type Mesh
  83768. */
  83769. inheritDirection: boolean;
  83770. /**
  83771. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  83772. */
  83773. inheritedVelocityAmount: number;
  83774. /**
  83775. * Creates a sub emitter
  83776. * @param particleSystem the particle system to be used by the sub emitter
  83777. */
  83778. constructor(
  83779. /**
  83780. * the particle system to be used by the sub emitter
  83781. */
  83782. particleSystem: ParticleSystem);
  83783. /**
  83784. * Clones the sub emitter
  83785. * @returns the cloned sub emitter
  83786. */
  83787. clone(): SubEmitter;
  83788. /**
  83789. * Serialize current object to a JSON object
  83790. * @returns the serialized object
  83791. */
  83792. serialize(): any;
  83793. /** @hidden */
  83794. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  83795. /**
  83796. * Creates a new SubEmitter from a serialized JSON version
  83797. * @param serializationObject defines the JSON object to read from
  83798. * @param scene defines the hosting scene
  83799. * @param rootUrl defines the rootUrl for data loading
  83800. * @returns a new SubEmitter
  83801. */
  83802. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  83803. /** Release associated resources */
  83804. dispose(): void;
  83805. }
  83806. }
  83807. declare module BABYLON {
  83808. /** @hidden */
  83809. export var clipPlaneFragmentDeclaration: {
  83810. name: string;
  83811. shader: string;
  83812. };
  83813. }
  83814. declare module BABYLON {
  83815. /** @hidden */
  83816. export var imageProcessingDeclaration: {
  83817. name: string;
  83818. shader: string;
  83819. };
  83820. }
  83821. declare module BABYLON {
  83822. /** @hidden */
  83823. export var imageProcessingFunctions: {
  83824. name: string;
  83825. shader: string;
  83826. };
  83827. }
  83828. declare module BABYLON {
  83829. /** @hidden */
  83830. export var clipPlaneFragment: {
  83831. name: string;
  83832. shader: string;
  83833. };
  83834. }
  83835. declare module BABYLON {
  83836. /** @hidden */
  83837. export var particlesPixelShader: {
  83838. name: string;
  83839. shader: string;
  83840. };
  83841. }
  83842. declare module BABYLON {
  83843. /** @hidden */
  83844. export var clipPlaneVertexDeclaration: {
  83845. name: string;
  83846. shader: string;
  83847. };
  83848. }
  83849. declare module BABYLON {
  83850. /** @hidden */
  83851. export var clipPlaneVertex: {
  83852. name: string;
  83853. shader: string;
  83854. };
  83855. }
  83856. declare module BABYLON {
  83857. /** @hidden */
  83858. export var particlesVertexShader: {
  83859. name: string;
  83860. shader: string;
  83861. };
  83862. }
  83863. declare module BABYLON {
  83864. /**
  83865. * This represents a particle system in Babylon.
  83866. * 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.
  83867. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  83868. * @example https://doc.babylonjs.com/babylon101/particles
  83869. */
  83870. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  83871. /**
  83872. * Billboard mode will only apply to Y axis
  83873. */
  83874. static readonly BILLBOARDMODE_Y: number;
  83875. /**
  83876. * Billboard mode will apply to all axes
  83877. */
  83878. static readonly BILLBOARDMODE_ALL: number;
  83879. /**
  83880. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  83881. */
  83882. static readonly BILLBOARDMODE_STRETCHED: number;
  83883. /**
  83884. * This function can be defined to provide custom update for active particles.
  83885. * This function will be called instead of regular update (age, position, color, etc.).
  83886. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  83887. */
  83888. updateFunction: (particles: Particle[]) => void;
  83889. private _emitterWorldMatrix;
  83890. /**
  83891. * This function can be defined to specify initial direction for every new particle.
  83892. * It by default use the emitterType defined function
  83893. */
  83894. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  83895. /**
  83896. * This function can be defined to specify initial position for every new particle.
  83897. * It by default use the emitterType defined function
  83898. */
  83899. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  83900. /**
  83901. * @hidden
  83902. */
  83903. _inheritedVelocityOffset: Vector3;
  83904. /**
  83905. * An event triggered when the system is disposed
  83906. */
  83907. onDisposeObservable: Observable<ParticleSystem>;
  83908. private _onDisposeObserver;
  83909. /**
  83910. * Sets a callback that will be triggered when the system is disposed
  83911. */
  83912. onDispose: () => void;
  83913. private _particles;
  83914. private _epsilon;
  83915. private _capacity;
  83916. private _stockParticles;
  83917. private _newPartsExcess;
  83918. private _vertexData;
  83919. private _vertexBuffer;
  83920. private _vertexBuffers;
  83921. private _spriteBuffer;
  83922. private _indexBuffer;
  83923. private _effect;
  83924. private _customEffect;
  83925. private _cachedDefines;
  83926. private _scaledColorStep;
  83927. private _colorDiff;
  83928. private _scaledDirection;
  83929. private _scaledGravity;
  83930. private _currentRenderId;
  83931. private _alive;
  83932. private _useInstancing;
  83933. private _started;
  83934. private _stopped;
  83935. private _actualFrame;
  83936. private _scaledUpdateSpeed;
  83937. private _vertexBufferSize;
  83938. /** @hidden */
  83939. _currentEmitRateGradient: Nullable<FactorGradient>;
  83940. /** @hidden */
  83941. _currentEmitRate1: number;
  83942. /** @hidden */
  83943. _currentEmitRate2: number;
  83944. /** @hidden */
  83945. _currentStartSizeGradient: Nullable<FactorGradient>;
  83946. /** @hidden */
  83947. _currentStartSize1: number;
  83948. /** @hidden */
  83949. _currentStartSize2: number;
  83950. private readonly _rawTextureWidth;
  83951. private _rampGradientsTexture;
  83952. private _useRampGradients;
  83953. /** Gets or sets a boolean indicating that ramp gradients must be used
  83954. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  83955. */
  83956. useRampGradients: boolean;
  83957. /**
  83958. * 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.
  83959. * 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: [])
  83960. */
  83961. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  83962. private _subEmitters;
  83963. /**
  83964. * @hidden
  83965. * If the particle systems emitter should be disposed when the particle system is disposed
  83966. */
  83967. _disposeEmitterOnDispose: boolean;
  83968. /**
  83969. * The current active Sub-systems, this property is used by the root particle system only.
  83970. */
  83971. activeSubSystems: Array<ParticleSystem>;
  83972. private _rootParticleSystem;
  83973. /**
  83974. * Gets the current list of active particles
  83975. */
  83976. readonly particles: Particle[];
  83977. /**
  83978. * Returns the string "ParticleSystem"
  83979. * @returns a string containing the class name
  83980. */
  83981. getClassName(): string;
  83982. /**
  83983. * Instantiates a particle system.
  83984. * 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.
  83985. * @param name The name of the particle system
  83986. * @param capacity The max number of particles alive at the same time
  83987. * @param scene The scene the particle system belongs to
  83988. * @param customEffect a custom effect used to change the way particles are rendered by default
  83989. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  83990. * @param epsilon Offset used to render the particles
  83991. */
  83992. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  83993. private _addFactorGradient;
  83994. private _removeFactorGradient;
  83995. /**
  83996. * Adds a new life time gradient
  83997. * @param gradient defines the gradient to use (between 0 and 1)
  83998. * @param factor defines the life time factor to affect to the specified gradient
  83999. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84000. * @returns the current particle system
  84001. */
  84002. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84003. /**
  84004. * Remove a specific life time gradient
  84005. * @param gradient defines the gradient to remove
  84006. * @returns the current particle system
  84007. */
  84008. removeLifeTimeGradient(gradient: number): IParticleSystem;
  84009. /**
  84010. * Adds a new size gradient
  84011. * @param gradient defines the gradient to use (between 0 and 1)
  84012. * @param factor defines the size factor to affect to the specified gradient
  84013. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84014. * @returns the current particle system
  84015. */
  84016. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84017. /**
  84018. * Remove a specific size gradient
  84019. * @param gradient defines the gradient to remove
  84020. * @returns the current particle system
  84021. */
  84022. removeSizeGradient(gradient: number): IParticleSystem;
  84023. /**
  84024. * Adds a new color remap gradient
  84025. * @param gradient defines the gradient to use (between 0 and 1)
  84026. * @param min defines the color remap minimal range
  84027. * @param max defines the color remap maximal range
  84028. * @returns the current particle system
  84029. */
  84030. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84031. /**
  84032. * Remove a specific color remap gradient
  84033. * @param gradient defines the gradient to remove
  84034. * @returns the current particle system
  84035. */
  84036. removeColorRemapGradient(gradient: number): IParticleSystem;
  84037. /**
  84038. * Adds a new alpha remap gradient
  84039. * @param gradient defines the gradient to use (between 0 and 1)
  84040. * @param min defines the alpha remap minimal range
  84041. * @param max defines the alpha remap maximal range
  84042. * @returns the current particle system
  84043. */
  84044. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  84045. /**
  84046. * Remove a specific alpha remap gradient
  84047. * @param gradient defines the gradient to remove
  84048. * @returns the current particle system
  84049. */
  84050. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  84051. /**
  84052. * Adds a new angular speed gradient
  84053. * @param gradient defines the gradient to use (between 0 and 1)
  84054. * @param factor defines the angular speed to affect to the specified gradient
  84055. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84056. * @returns the current particle system
  84057. */
  84058. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84059. /**
  84060. * Remove a specific angular speed gradient
  84061. * @param gradient defines the gradient to remove
  84062. * @returns the current particle system
  84063. */
  84064. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  84065. /**
  84066. * Adds a new velocity gradient
  84067. * @param gradient defines the gradient to use (between 0 and 1)
  84068. * @param factor defines the velocity to affect to the specified gradient
  84069. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84070. * @returns the current particle system
  84071. */
  84072. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84073. /**
  84074. * Remove a specific velocity gradient
  84075. * @param gradient defines the gradient to remove
  84076. * @returns the current particle system
  84077. */
  84078. removeVelocityGradient(gradient: number): IParticleSystem;
  84079. /**
  84080. * Adds a new limit velocity gradient
  84081. * @param gradient defines the gradient to use (between 0 and 1)
  84082. * @param factor defines the limit velocity value to affect to the specified gradient
  84083. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84084. * @returns the current particle system
  84085. */
  84086. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84087. /**
  84088. * Remove a specific limit velocity gradient
  84089. * @param gradient defines the gradient to remove
  84090. * @returns the current particle system
  84091. */
  84092. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  84093. /**
  84094. * Adds a new drag gradient
  84095. * @param gradient defines the gradient to use (between 0 and 1)
  84096. * @param factor defines the drag value to affect to the specified gradient
  84097. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84098. * @returns the current particle system
  84099. */
  84100. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84101. /**
  84102. * Remove a specific drag gradient
  84103. * @param gradient defines the gradient to remove
  84104. * @returns the current particle system
  84105. */
  84106. removeDragGradient(gradient: number): IParticleSystem;
  84107. /**
  84108. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  84109. * @param gradient defines the gradient to use (between 0 and 1)
  84110. * @param factor defines the emit rate value to affect to the specified gradient
  84111. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84112. * @returns the current particle system
  84113. */
  84114. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84115. /**
  84116. * Remove a specific emit rate gradient
  84117. * @param gradient defines the gradient to remove
  84118. * @returns the current particle system
  84119. */
  84120. removeEmitRateGradient(gradient: number): IParticleSystem;
  84121. /**
  84122. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  84123. * @param gradient defines the gradient to use (between 0 and 1)
  84124. * @param factor defines the start size value to affect to the specified gradient
  84125. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  84126. * @returns the current particle system
  84127. */
  84128. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  84129. /**
  84130. * Remove a specific start size gradient
  84131. * @param gradient defines the gradient to remove
  84132. * @returns the current particle system
  84133. */
  84134. removeStartSizeGradient(gradient: number): IParticleSystem;
  84135. private _createRampGradientTexture;
  84136. /**
  84137. * Gets the current list of ramp gradients.
  84138. * You must use addRampGradient and removeRampGradient to udpate this list
  84139. * @returns the list of ramp gradients
  84140. */
  84141. getRampGradients(): Nullable<Array<Color3Gradient>>;
  84142. /**
  84143. * Adds a new ramp gradient used to remap particle colors
  84144. * @param gradient defines the gradient to use (between 0 and 1)
  84145. * @param color defines the color to affect to the specified gradient
  84146. * @returns the current particle system
  84147. */
  84148. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  84149. /**
  84150. * Remove a specific ramp gradient
  84151. * @param gradient defines the gradient to remove
  84152. * @returns the current particle system
  84153. */
  84154. removeRampGradient(gradient: number): ParticleSystem;
  84155. /**
  84156. * Adds a new color gradient
  84157. * @param gradient defines the gradient to use (between 0 and 1)
  84158. * @param color1 defines the color to affect to the specified gradient
  84159. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  84160. * @returns this particle system
  84161. */
  84162. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  84163. /**
  84164. * Remove a specific color gradient
  84165. * @param gradient defines the gradient to remove
  84166. * @returns this particle system
  84167. */
  84168. removeColorGradient(gradient: number): IParticleSystem;
  84169. private _fetchR;
  84170. protected _reset(): void;
  84171. private _resetEffect;
  84172. private _createVertexBuffers;
  84173. private _createIndexBuffer;
  84174. /**
  84175. * Gets the maximum number of particles active at the same time.
  84176. * @returns The max number of active particles.
  84177. */
  84178. getCapacity(): number;
  84179. /**
  84180. * Gets whether there are still active particles in the system.
  84181. * @returns True if it is alive, otherwise false.
  84182. */
  84183. isAlive(): boolean;
  84184. /**
  84185. * Gets if the system has been started. (Note: this will still be true after stop is called)
  84186. * @returns True if it has been started, otherwise false.
  84187. */
  84188. isStarted(): boolean;
  84189. private _prepareSubEmitterInternalArray;
  84190. /**
  84191. * Starts the particle system and begins to emit
  84192. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  84193. */
  84194. start(delay?: number): void;
  84195. /**
  84196. * Stops the particle system.
  84197. * @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.
  84198. */
  84199. stop(stopSubEmitters?: boolean): void;
  84200. /**
  84201. * Remove all active particles
  84202. */
  84203. reset(): void;
  84204. /**
  84205. * @hidden (for internal use only)
  84206. */
  84207. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  84208. /**
  84209. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  84210. * Its lifetime will start back at 0.
  84211. */
  84212. recycleParticle: (particle: Particle) => void;
  84213. private _stopSubEmitters;
  84214. private _createParticle;
  84215. private _removeFromRoot;
  84216. private _emitFromParticle;
  84217. private _update;
  84218. /** @hidden */
  84219. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  84220. /** @hidden */
  84221. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  84222. /** @hidden */
  84223. private _getEffect;
  84224. /**
  84225. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  84226. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  84227. */
  84228. animate(preWarmOnly?: boolean): void;
  84229. private _appendParticleVertices;
  84230. /**
  84231. * Rebuilds the particle system.
  84232. */
  84233. rebuild(): void;
  84234. /**
  84235. * Is this system ready to be used/rendered
  84236. * @return true if the system is ready
  84237. */
  84238. isReady(): boolean;
  84239. private _render;
  84240. /**
  84241. * Renders the particle system in its current state.
  84242. * @returns the current number of particles
  84243. */
  84244. render(): number;
  84245. /**
  84246. * Disposes the particle system and free the associated resources
  84247. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  84248. */
  84249. dispose(disposeTexture?: boolean): void;
  84250. /**
  84251. * Clones the particle system.
  84252. * @param name The name of the cloned object
  84253. * @param newEmitter The new emitter to use
  84254. * @returns the cloned particle system
  84255. */
  84256. clone(name: string, newEmitter: any): ParticleSystem;
  84257. /**
  84258. * Serializes the particle system to a JSON object.
  84259. * @returns the JSON object
  84260. */
  84261. serialize(): any;
  84262. /** @hidden */
  84263. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  84264. /** @hidden */
  84265. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  84266. /**
  84267. * Parses a JSON object to create a particle system.
  84268. * @param parsedParticleSystem The JSON object to parse
  84269. * @param scene The scene to create the particle system in
  84270. * @param rootUrl The root url to use to load external dependencies like texture
  84271. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  84272. * @returns the Parsed particle system
  84273. */
  84274. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  84275. }
  84276. }
  84277. declare module BABYLON {
  84278. /**
  84279. * A particle represents one of the element emitted by a particle system.
  84280. * This is mainly define by its coordinates, direction, velocity and age.
  84281. */
  84282. export class Particle {
  84283. /**
  84284. * The particle system the particle belongs to.
  84285. */
  84286. particleSystem: ParticleSystem;
  84287. private static _Count;
  84288. /**
  84289. * Unique ID of the particle
  84290. */
  84291. id: number;
  84292. /**
  84293. * The world position of the particle in the scene.
  84294. */
  84295. position: Vector3;
  84296. /**
  84297. * The world direction of the particle in the scene.
  84298. */
  84299. direction: Vector3;
  84300. /**
  84301. * The color of the particle.
  84302. */
  84303. color: Color4;
  84304. /**
  84305. * The color change of the particle per step.
  84306. */
  84307. colorStep: Color4;
  84308. /**
  84309. * Defines how long will the life of the particle be.
  84310. */
  84311. lifeTime: number;
  84312. /**
  84313. * The current age of the particle.
  84314. */
  84315. age: number;
  84316. /**
  84317. * The current size of the particle.
  84318. */
  84319. size: number;
  84320. /**
  84321. * The current scale of the particle.
  84322. */
  84323. scale: Vector2;
  84324. /**
  84325. * The current angle of the particle.
  84326. */
  84327. angle: number;
  84328. /**
  84329. * Defines how fast is the angle changing.
  84330. */
  84331. angularSpeed: number;
  84332. /**
  84333. * Defines the cell index used by the particle to be rendered from a sprite.
  84334. */
  84335. cellIndex: number;
  84336. /**
  84337. * The information required to support color remapping
  84338. */
  84339. remapData: Vector4;
  84340. /** @hidden */
  84341. _randomCellOffset?: number;
  84342. /** @hidden */
  84343. _initialDirection: Nullable<Vector3>;
  84344. /** @hidden */
  84345. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  84346. /** @hidden */
  84347. _initialStartSpriteCellID: number;
  84348. /** @hidden */
  84349. _initialEndSpriteCellID: number;
  84350. /** @hidden */
  84351. _currentColorGradient: Nullable<ColorGradient>;
  84352. /** @hidden */
  84353. _currentColor1: Color4;
  84354. /** @hidden */
  84355. _currentColor2: Color4;
  84356. /** @hidden */
  84357. _currentSizeGradient: Nullable<FactorGradient>;
  84358. /** @hidden */
  84359. _currentSize1: number;
  84360. /** @hidden */
  84361. _currentSize2: number;
  84362. /** @hidden */
  84363. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  84364. /** @hidden */
  84365. _currentAngularSpeed1: number;
  84366. /** @hidden */
  84367. _currentAngularSpeed2: number;
  84368. /** @hidden */
  84369. _currentVelocityGradient: Nullable<FactorGradient>;
  84370. /** @hidden */
  84371. _currentVelocity1: number;
  84372. /** @hidden */
  84373. _currentVelocity2: number;
  84374. /** @hidden */
  84375. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  84376. /** @hidden */
  84377. _currentLimitVelocity1: number;
  84378. /** @hidden */
  84379. _currentLimitVelocity2: number;
  84380. /** @hidden */
  84381. _currentDragGradient: Nullable<FactorGradient>;
  84382. /** @hidden */
  84383. _currentDrag1: number;
  84384. /** @hidden */
  84385. _currentDrag2: number;
  84386. /** @hidden */
  84387. _randomNoiseCoordinates1: Vector3;
  84388. /** @hidden */
  84389. _randomNoiseCoordinates2: Vector3;
  84390. /**
  84391. * Creates a new instance Particle
  84392. * @param particleSystem the particle system the particle belongs to
  84393. */
  84394. constructor(
  84395. /**
  84396. * The particle system the particle belongs to.
  84397. */
  84398. particleSystem: ParticleSystem);
  84399. private updateCellInfoFromSystem;
  84400. /**
  84401. * Defines how the sprite cell index is updated for the particle
  84402. */
  84403. updateCellIndex(): void;
  84404. /** @hidden */
  84405. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  84406. /** @hidden */
  84407. _inheritParticleInfoToSubEmitters(): void;
  84408. /** @hidden */
  84409. _reset(): void;
  84410. /**
  84411. * Copy the properties of particle to another one.
  84412. * @param other the particle to copy the information to.
  84413. */
  84414. copyTo(other: Particle): void;
  84415. }
  84416. }
  84417. declare module BABYLON {
  84418. /**
  84419. * Particle emitter represents a volume emitting particles.
  84420. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  84421. */
  84422. export interface IParticleEmitterType {
  84423. /**
  84424. * Called by the particle System when the direction is computed for the created particle.
  84425. * @param worldMatrix is the world matrix of the particle system
  84426. * @param directionToUpdate is the direction vector to update with the result
  84427. * @param particle is the particle we are computed the direction for
  84428. */
  84429. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84430. /**
  84431. * Called by the particle System when the position is computed for the created particle.
  84432. * @param worldMatrix is the world matrix of the particle system
  84433. * @param positionToUpdate is the position vector to update with the result
  84434. * @param particle is the particle we are computed the position for
  84435. */
  84436. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84437. /**
  84438. * Clones the current emitter and returns a copy of it
  84439. * @returns the new emitter
  84440. */
  84441. clone(): IParticleEmitterType;
  84442. /**
  84443. * Called by the GPUParticleSystem to setup the update shader
  84444. * @param effect defines the update shader
  84445. */
  84446. applyToShader(effect: Effect): void;
  84447. /**
  84448. * Returns a string to use to update the GPU particles update shader
  84449. * @returns the effect defines string
  84450. */
  84451. getEffectDefines(): string;
  84452. /**
  84453. * Returns a string representing the class name
  84454. * @returns a string containing the class name
  84455. */
  84456. getClassName(): string;
  84457. /**
  84458. * Serializes the particle system to a JSON object.
  84459. * @returns the JSON object
  84460. */
  84461. serialize(): any;
  84462. /**
  84463. * Parse properties from a JSON object
  84464. * @param serializationObject defines the JSON object
  84465. */
  84466. parse(serializationObject: any): void;
  84467. }
  84468. }
  84469. declare module BABYLON {
  84470. /**
  84471. * Particle emitter emitting particles from the inside of a box.
  84472. * It emits the particles randomly between 2 given directions.
  84473. */
  84474. export class BoxParticleEmitter implements IParticleEmitterType {
  84475. /**
  84476. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84477. */
  84478. direction1: Vector3;
  84479. /**
  84480. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84481. */
  84482. direction2: Vector3;
  84483. /**
  84484. * 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.
  84485. */
  84486. minEmitBox: Vector3;
  84487. /**
  84488. * 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.
  84489. */
  84490. maxEmitBox: Vector3;
  84491. /**
  84492. * Creates a new instance BoxParticleEmitter
  84493. */
  84494. constructor();
  84495. /**
  84496. * Called by the particle System when the direction is computed for the created particle.
  84497. * @param worldMatrix is the world matrix of the particle system
  84498. * @param directionToUpdate is the direction vector to update with the result
  84499. * @param particle is the particle we are computed the direction for
  84500. */
  84501. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84502. /**
  84503. * Called by the particle System when the position is computed for the created particle.
  84504. * @param worldMatrix is the world matrix of the particle system
  84505. * @param positionToUpdate is the position vector to update with the result
  84506. * @param particle is the particle we are computed the position for
  84507. */
  84508. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84509. /**
  84510. * Clones the current emitter and returns a copy of it
  84511. * @returns the new emitter
  84512. */
  84513. clone(): BoxParticleEmitter;
  84514. /**
  84515. * Called by the GPUParticleSystem to setup the update shader
  84516. * @param effect defines the update shader
  84517. */
  84518. applyToShader(effect: Effect): void;
  84519. /**
  84520. * Returns a string to use to update the GPU particles update shader
  84521. * @returns a string containng the defines string
  84522. */
  84523. getEffectDefines(): string;
  84524. /**
  84525. * Returns the string "BoxParticleEmitter"
  84526. * @returns a string containing the class name
  84527. */
  84528. getClassName(): string;
  84529. /**
  84530. * Serializes the particle system to a JSON object.
  84531. * @returns the JSON object
  84532. */
  84533. serialize(): any;
  84534. /**
  84535. * Parse properties from a JSON object
  84536. * @param serializationObject defines the JSON object
  84537. */
  84538. parse(serializationObject: any): void;
  84539. }
  84540. }
  84541. declare module BABYLON {
  84542. /**
  84543. * Particle emitter emitting particles from the inside of a cone.
  84544. * It emits the particles alongside the cone volume from the base to the particle.
  84545. * The emission direction might be randomized.
  84546. */
  84547. export class ConeParticleEmitter implements IParticleEmitterType {
  84548. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84549. directionRandomizer: number;
  84550. private _radius;
  84551. private _angle;
  84552. private _height;
  84553. /**
  84554. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  84555. */
  84556. radiusRange: number;
  84557. /**
  84558. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  84559. */
  84560. heightRange: number;
  84561. /**
  84562. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  84563. */
  84564. emitFromSpawnPointOnly: boolean;
  84565. /**
  84566. * Gets or sets the radius of the emission cone
  84567. */
  84568. radius: number;
  84569. /**
  84570. * Gets or sets the angle of the emission cone
  84571. */
  84572. angle: number;
  84573. private _buildHeight;
  84574. /**
  84575. * Creates a new instance ConeParticleEmitter
  84576. * @param radius the radius of the emission cone (1 by default)
  84577. * @param angle the cone base angle (PI by default)
  84578. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  84579. */
  84580. constructor(radius?: number, angle?: number,
  84581. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  84582. directionRandomizer?: number);
  84583. /**
  84584. * Called by the particle System when the direction is computed for the created particle.
  84585. * @param worldMatrix is the world matrix of the particle system
  84586. * @param directionToUpdate is the direction vector to update with the result
  84587. * @param particle is the particle we are computed the direction for
  84588. */
  84589. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84590. /**
  84591. * Called by the particle System when the position is computed for the created particle.
  84592. * @param worldMatrix is the world matrix of the particle system
  84593. * @param positionToUpdate is the position vector to update with the result
  84594. * @param particle is the particle we are computed the position for
  84595. */
  84596. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84597. /**
  84598. * Clones the current emitter and returns a copy of it
  84599. * @returns the new emitter
  84600. */
  84601. clone(): ConeParticleEmitter;
  84602. /**
  84603. * Called by the GPUParticleSystem to setup the update shader
  84604. * @param effect defines the update shader
  84605. */
  84606. applyToShader(effect: Effect): void;
  84607. /**
  84608. * Returns a string to use to update the GPU particles update shader
  84609. * @returns a string containng the defines string
  84610. */
  84611. getEffectDefines(): string;
  84612. /**
  84613. * Returns the string "ConeParticleEmitter"
  84614. * @returns a string containing the class name
  84615. */
  84616. getClassName(): string;
  84617. /**
  84618. * Serializes the particle system to a JSON object.
  84619. * @returns the JSON object
  84620. */
  84621. serialize(): any;
  84622. /**
  84623. * Parse properties from a JSON object
  84624. * @param serializationObject defines the JSON object
  84625. */
  84626. parse(serializationObject: any): void;
  84627. }
  84628. }
  84629. declare module BABYLON {
  84630. /**
  84631. * Particle emitter emitting particles from the inside of a cylinder.
  84632. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  84633. */
  84634. export class CylinderParticleEmitter implements IParticleEmitterType {
  84635. /**
  84636. * The radius of the emission cylinder.
  84637. */
  84638. radius: number;
  84639. /**
  84640. * The height of the emission cylinder.
  84641. */
  84642. height: number;
  84643. /**
  84644. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84645. */
  84646. radiusRange: number;
  84647. /**
  84648. * How much to randomize the particle direction [0-1].
  84649. */
  84650. directionRandomizer: number;
  84651. /**
  84652. * Creates a new instance CylinderParticleEmitter
  84653. * @param radius the radius of the emission cylinder (1 by default)
  84654. * @param height the height of the emission cylinder (1 by default)
  84655. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84656. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84657. */
  84658. constructor(
  84659. /**
  84660. * The radius of the emission cylinder.
  84661. */
  84662. radius?: number,
  84663. /**
  84664. * The height of the emission cylinder.
  84665. */
  84666. height?: number,
  84667. /**
  84668. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84669. */
  84670. radiusRange?: number,
  84671. /**
  84672. * How much to randomize the particle direction [0-1].
  84673. */
  84674. directionRandomizer?: number);
  84675. /**
  84676. * Called by the particle System when the direction is computed for the created particle.
  84677. * @param worldMatrix is the world matrix of the particle system
  84678. * @param directionToUpdate is the direction vector to update with the result
  84679. * @param particle is the particle we are computed the direction for
  84680. */
  84681. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84682. /**
  84683. * Called by the particle System when the position is computed for the created particle.
  84684. * @param worldMatrix is the world matrix of the particle system
  84685. * @param positionToUpdate is the position vector to update with the result
  84686. * @param particle is the particle we are computed the position for
  84687. */
  84688. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84689. /**
  84690. * Clones the current emitter and returns a copy of it
  84691. * @returns the new emitter
  84692. */
  84693. clone(): CylinderParticleEmitter;
  84694. /**
  84695. * Called by the GPUParticleSystem to setup the update shader
  84696. * @param effect defines the update shader
  84697. */
  84698. applyToShader(effect: Effect): void;
  84699. /**
  84700. * Returns a string to use to update the GPU particles update shader
  84701. * @returns a string containng the defines string
  84702. */
  84703. getEffectDefines(): string;
  84704. /**
  84705. * Returns the string "CylinderParticleEmitter"
  84706. * @returns a string containing the class name
  84707. */
  84708. getClassName(): string;
  84709. /**
  84710. * Serializes the particle system to a JSON object.
  84711. * @returns the JSON object
  84712. */
  84713. serialize(): any;
  84714. /**
  84715. * Parse properties from a JSON object
  84716. * @param serializationObject defines the JSON object
  84717. */
  84718. parse(serializationObject: any): void;
  84719. }
  84720. /**
  84721. * Particle emitter emitting particles from the inside of a cylinder.
  84722. * It emits the particles randomly between two vectors.
  84723. */
  84724. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  84725. /**
  84726. * The min limit of the emission direction.
  84727. */
  84728. direction1: Vector3;
  84729. /**
  84730. * The max limit of the emission direction.
  84731. */
  84732. direction2: Vector3;
  84733. /**
  84734. * Creates a new instance CylinderDirectedParticleEmitter
  84735. * @param radius the radius of the emission cylinder (1 by default)
  84736. * @param height the height of the emission cylinder (1 by default)
  84737. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84738. * @param direction1 the min limit of the emission direction (up vector by default)
  84739. * @param direction2 the max limit of the emission direction (up vector by default)
  84740. */
  84741. constructor(radius?: number, height?: number, radiusRange?: number,
  84742. /**
  84743. * The min limit of the emission direction.
  84744. */
  84745. direction1?: Vector3,
  84746. /**
  84747. * The max limit of the emission direction.
  84748. */
  84749. direction2?: Vector3);
  84750. /**
  84751. * Called by the particle System when the direction is computed for the created particle.
  84752. * @param worldMatrix is the world matrix of the particle system
  84753. * @param directionToUpdate is the direction vector to update with the result
  84754. * @param particle is the particle we are computed the direction for
  84755. */
  84756. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84757. /**
  84758. * Clones the current emitter and returns a copy of it
  84759. * @returns the new emitter
  84760. */
  84761. clone(): CylinderDirectedParticleEmitter;
  84762. /**
  84763. * Called by the GPUParticleSystem to setup the update shader
  84764. * @param effect defines the update shader
  84765. */
  84766. applyToShader(effect: Effect): void;
  84767. /**
  84768. * Returns a string to use to update the GPU particles update shader
  84769. * @returns a string containng the defines string
  84770. */
  84771. getEffectDefines(): string;
  84772. /**
  84773. * Returns the string "CylinderDirectedParticleEmitter"
  84774. * @returns a string containing the class name
  84775. */
  84776. getClassName(): string;
  84777. /**
  84778. * Serializes the particle system to a JSON object.
  84779. * @returns the JSON object
  84780. */
  84781. serialize(): any;
  84782. /**
  84783. * Parse properties from a JSON object
  84784. * @param serializationObject defines the JSON object
  84785. */
  84786. parse(serializationObject: any): void;
  84787. }
  84788. }
  84789. declare module BABYLON {
  84790. /**
  84791. * Particle emitter emitting particles from the inside of a hemisphere.
  84792. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  84793. */
  84794. export class HemisphericParticleEmitter implements IParticleEmitterType {
  84795. /**
  84796. * The radius of the emission hemisphere.
  84797. */
  84798. radius: number;
  84799. /**
  84800. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84801. */
  84802. radiusRange: number;
  84803. /**
  84804. * How much to randomize the particle direction [0-1].
  84805. */
  84806. directionRandomizer: number;
  84807. /**
  84808. * Creates a new instance HemisphericParticleEmitter
  84809. * @param radius the radius of the emission hemisphere (1 by default)
  84810. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84811. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84812. */
  84813. constructor(
  84814. /**
  84815. * The radius of the emission hemisphere.
  84816. */
  84817. radius?: number,
  84818. /**
  84819. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84820. */
  84821. radiusRange?: number,
  84822. /**
  84823. * How much to randomize the particle direction [0-1].
  84824. */
  84825. directionRandomizer?: number);
  84826. /**
  84827. * Called by the particle System when the direction is computed for the created particle.
  84828. * @param worldMatrix is the world matrix of the particle system
  84829. * @param directionToUpdate is the direction vector to update with the result
  84830. * @param particle is the particle we are computed the direction for
  84831. */
  84832. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84833. /**
  84834. * Called by the particle System when the position is computed for the created particle.
  84835. * @param worldMatrix is the world matrix of the particle system
  84836. * @param positionToUpdate is the position vector to update with the result
  84837. * @param particle is the particle we are computed the position for
  84838. */
  84839. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84840. /**
  84841. * Clones the current emitter and returns a copy of it
  84842. * @returns the new emitter
  84843. */
  84844. clone(): HemisphericParticleEmitter;
  84845. /**
  84846. * Called by the GPUParticleSystem to setup the update shader
  84847. * @param effect defines the update shader
  84848. */
  84849. applyToShader(effect: Effect): void;
  84850. /**
  84851. * Returns a string to use to update the GPU particles update shader
  84852. * @returns a string containng the defines string
  84853. */
  84854. getEffectDefines(): string;
  84855. /**
  84856. * Returns the string "HemisphericParticleEmitter"
  84857. * @returns a string containing the class name
  84858. */
  84859. getClassName(): string;
  84860. /**
  84861. * Serializes the particle system to a JSON object.
  84862. * @returns the JSON object
  84863. */
  84864. serialize(): any;
  84865. /**
  84866. * Parse properties from a JSON object
  84867. * @param serializationObject defines the JSON object
  84868. */
  84869. parse(serializationObject: any): void;
  84870. }
  84871. }
  84872. declare module BABYLON {
  84873. /**
  84874. * Particle emitter emitting particles from a point.
  84875. * It emits the particles randomly between 2 given directions.
  84876. */
  84877. export class PointParticleEmitter implements IParticleEmitterType {
  84878. /**
  84879. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84880. */
  84881. direction1: Vector3;
  84882. /**
  84883. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  84884. */
  84885. direction2: Vector3;
  84886. /**
  84887. * Creates a new instance PointParticleEmitter
  84888. */
  84889. constructor();
  84890. /**
  84891. * Called by the particle System when the direction is computed for the created particle.
  84892. * @param worldMatrix is the world matrix of the particle system
  84893. * @param directionToUpdate is the direction vector to update with the result
  84894. * @param particle is the particle we are computed the direction for
  84895. */
  84896. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84897. /**
  84898. * Called by the particle System when the position is computed for the created particle.
  84899. * @param worldMatrix is the world matrix of the particle system
  84900. * @param positionToUpdate is the position vector to update with the result
  84901. * @param particle is the particle we are computed the position for
  84902. */
  84903. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84904. /**
  84905. * Clones the current emitter and returns a copy of it
  84906. * @returns the new emitter
  84907. */
  84908. clone(): PointParticleEmitter;
  84909. /**
  84910. * Called by the GPUParticleSystem to setup the update shader
  84911. * @param effect defines the update shader
  84912. */
  84913. applyToShader(effect: Effect): void;
  84914. /**
  84915. * Returns a string to use to update the GPU particles update shader
  84916. * @returns a string containng the defines string
  84917. */
  84918. getEffectDefines(): string;
  84919. /**
  84920. * Returns the string "PointParticleEmitter"
  84921. * @returns a string containing the class name
  84922. */
  84923. getClassName(): string;
  84924. /**
  84925. * Serializes the particle system to a JSON object.
  84926. * @returns the JSON object
  84927. */
  84928. serialize(): any;
  84929. /**
  84930. * Parse properties from a JSON object
  84931. * @param serializationObject defines the JSON object
  84932. */
  84933. parse(serializationObject: any): void;
  84934. }
  84935. }
  84936. declare module BABYLON {
  84937. /**
  84938. * Particle emitter emitting particles from the inside of a sphere.
  84939. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  84940. */
  84941. export class SphereParticleEmitter implements IParticleEmitterType {
  84942. /**
  84943. * The radius of the emission sphere.
  84944. */
  84945. radius: number;
  84946. /**
  84947. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84948. */
  84949. radiusRange: number;
  84950. /**
  84951. * How much to randomize the particle direction [0-1].
  84952. */
  84953. directionRandomizer: number;
  84954. /**
  84955. * Creates a new instance SphereParticleEmitter
  84956. * @param radius the radius of the emission sphere (1 by default)
  84957. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  84958. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  84959. */
  84960. constructor(
  84961. /**
  84962. * The radius of the emission sphere.
  84963. */
  84964. radius?: number,
  84965. /**
  84966. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  84967. */
  84968. radiusRange?: number,
  84969. /**
  84970. * How much to randomize the particle direction [0-1].
  84971. */
  84972. directionRandomizer?: number);
  84973. /**
  84974. * Called by the particle System when the direction is computed for the created particle.
  84975. * @param worldMatrix is the world matrix of the particle system
  84976. * @param directionToUpdate is the direction vector to update with the result
  84977. * @param particle is the particle we are computed the direction for
  84978. */
  84979. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  84980. /**
  84981. * Called by the particle System when the position is computed for the created particle.
  84982. * @param worldMatrix is the world matrix of the particle system
  84983. * @param positionToUpdate is the position vector to update with the result
  84984. * @param particle is the particle we are computed the position for
  84985. */
  84986. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  84987. /**
  84988. * Clones the current emitter and returns a copy of it
  84989. * @returns the new emitter
  84990. */
  84991. clone(): SphereParticleEmitter;
  84992. /**
  84993. * Called by the GPUParticleSystem to setup the update shader
  84994. * @param effect defines the update shader
  84995. */
  84996. applyToShader(effect: Effect): void;
  84997. /**
  84998. * Returns a string to use to update the GPU particles update shader
  84999. * @returns a string containng the defines string
  85000. */
  85001. getEffectDefines(): string;
  85002. /**
  85003. * Returns the string "SphereParticleEmitter"
  85004. * @returns a string containing the class name
  85005. */
  85006. getClassName(): string;
  85007. /**
  85008. * Serializes the particle system to a JSON object.
  85009. * @returns the JSON object
  85010. */
  85011. serialize(): any;
  85012. /**
  85013. * Parse properties from a JSON object
  85014. * @param serializationObject defines the JSON object
  85015. */
  85016. parse(serializationObject: any): void;
  85017. }
  85018. /**
  85019. * Particle emitter emitting particles from the inside of a sphere.
  85020. * It emits the particles randomly between two vectors.
  85021. */
  85022. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  85023. /**
  85024. * The min limit of the emission direction.
  85025. */
  85026. direction1: Vector3;
  85027. /**
  85028. * The max limit of the emission direction.
  85029. */
  85030. direction2: Vector3;
  85031. /**
  85032. * Creates a new instance SphereDirectedParticleEmitter
  85033. * @param radius the radius of the emission sphere (1 by default)
  85034. * @param direction1 the min limit of the emission direction (up vector by default)
  85035. * @param direction2 the max limit of the emission direction (up vector by default)
  85036. */
  85037. constructor(radius?: number,
  85038. /**
  85039. * The min limit of the emission direction.
  85040. */
  85041. direction1?: Vector3,
  85042. /**
  85043. * The max limit of the emission direction.
  85044. */
  85045. direction2?: Vector3);
  85046. /**
  85047. * Called by the particle System when the direction is computed for the created particle.
  85048. * @param worldMatrix is the world matrix of the particle system
  85049. * @param directionToUpdate is the direction vector to update with the result
  85050. * @param particle is the particle we are computed the direction for
  85051. */
  85052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  85053. /**
  85054. * Clones the current emitter and returns a copy of it
  85055. * @returns the new emitter
  85056. */
  85057. clone(): SphereDirectedParticleEmitter;
  85058. /**
  85059. * Called by the GPUParticleSystem to setup the update shader
  85060. * @param effect defines the update shader
  85061. */
  85062. applyToShader(effect: Effect): void;
  85063. /**
  85064. * Returns a string to use to update the GPU particles update shader
  85065. * @returns a string containng the defines string
  85066. */
  85067. getEffectDefines(): string;
  85068. /**
  85069. * Returns the string "SphereDirectedParticleEmitter"
  85070. * @returns a string containing the class name
  85071. */
  85072. getClassName(): string;
  85073. /**
  85074. * Serializes the particle system to a JSON object.
  85075. * @returns the JSON object
  85076. */
  85077. serialize(): any;
  85078. /**
  85079. * Parse properties from a JSON object
  85080. * @param serializationObject defines the JSON object
  85081. */
  85082. parse(serializationObject: any): void;
  85083. }
  85084. }
  85085. declare module BABYLON {
  85086. /**
  85087. * Interface representing a particle system in Babylon.js.
  85088. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  85089. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  85090. */
  85091. export interface IParticleSystem {
  85092. /**
  85093. * List of animations used by the particle system.
  85094. */
  85095. animations: Animation[];
  85096. /**
  85097. * The id of the Particle system.
  85098. */
  85099. id: string;
  85100. /**
  85101. * The name of the Particle system.
  85102. */
  85103. name: string;
  85104. /**
  85105. * The emitter represents the Mesh or position we are attaching the particle system to.
  85106. */
  85107. emitter: Nullable<AbstractMesh | Vector3>;
  85108. /**
  85109. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85110. */
  85111. isBillboardBased: boolean;
  85112. /**
  85113. * The rendering group used by the Particle system to chose when to render.
  85114. */
  85115. renderingGroupId: number;
  85116. /**
  85117. * The layer mask we are rendering the particles through.
  85118. */
  85119. layerMask: number;
  85120. /**
  85121. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85122. */
  85123. updateSpeed: number;
  85124. /**
  85125. * The amount of time the particle system is running (depends of the overall update speed).
  85126. */
  85127. targetStopDuration: number;
  85128. /**
  85129. * The texture used to render each particle. (this can be a spritesheet)
  85130. */
  85131. particleTexture: Nullable<Texture>;
  85132. /**
  85133. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  85134. */
  85135. blendMode: number;
  85136. /**
  85137. * Minimum life time of emitting particles.
  85138. */
  85139. minLifeTime: number;
  85140. /**
  85141. * Maximum life time of emitting particles.
  85142. */
  85143. maxLifeTime: number;
  85144. /**
  85145. * Minimum Size of emitting particles.
  85146. */
  85147. minSize: number;
  85148. /**
  85149. * Maximum Size of emitting particles.
  85150. */
  85151. maxSize: number;
  85152. /**
  85153. * Minimum scale of emitting particles on X axis.
  85154. */
  85155. minScaleX: number;
  85156. /**
  85157. * Maximum scale of emitting particles on X axis.
  85158. */
  85159. maxScaleX: number;
  85160. /**
  85161. * Minimum scale of emitting particles on Y axis.
  85162. */
  85163. minScaleY: number;
  85164. /**
  85165. * Maximum scale of emitting particles on Y axis.
  85166. */
  85167. maxScaleY: number;
  85168. /**
  85169. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85170. */
  85171. color1: Color4;
  85172. /**
  85173. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  85174. */
  85175. color2: Color4;
  85176. /**
  85177. * Color the particle will have at the end of its lifetime.
  85178. */
  85179. colorDead: Color4;
  85180. /**
  85181. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  85182. */
  85183. emitRate: number;
  85184. /**
  85185. * You can use gravity if you want to give an orientation to your particles.
  85186. */
  85187. gravity: Vector3;
  85188. /**
  85189. * Minimum power of emitting particles.
  85190. */
  85191. minEmitPower: number;
  85192. /**
  85193. * Maximum power of emitting particles.
  85194. */
  85195. maxEmitPower: number;
  85196. /**
  85197. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85198. */
  85199. minAngularSpeed: number;
  85200. /**
  85201. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85202. */
  85203. maxAngularSpeed: number;
  85204. /**
  85205. * Gets or sets the minimal initial rotation in radians.
  85206. */
  85207. minInitialRotation: number;
  85208. /**
  85209. * Gets or sets the maximal initial rotation in radians.
  85210. */
  85211. maxInitialRotation: number;
  85212. /**
  85213. * The particle emitter type defines the emitter used by the particle system.
  85214. * It can be for example box, sphere, or cone...
  85215. */
  85216. particleEmitterType: Nullable<IParticleEmitterType>;
  85217. /**
  85218. * Defines the delay in milliseconds before starting the system (0 by default)
  85219. */
  85220. startDelay: number;
  85221. /**
  85222. * 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
  85223. */
  85224. preWarmCycles: number;
  85225. /**
  85226. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  85227. */
  85228. preWarmStepOffset: number;
  85229. /**
  85230. * 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)
  85231. */
  85232. spriteCellChangeSpeed: number;
  85233. /**
  85234. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85235. */
  85236. startSpriteCellID: number;
  85237. /**
  85238. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85239. */
  85240. endSpriteCellID: number;
  85241. /**
  85242. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85243. */
  85244. spriteCellWidth: number;
  85245. /**
  85246. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85247. */
  85248. spriteCellHeight: number;
  85249. /**
  85250. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85251. */
  85252. spriteRandomStartCell: boolean;
  85253. /**
  85254. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  85255. */
  85256. isAnimationSheetEnabled: boolean;
  85257. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85258. translationPivot: Vector2;
  85259. /**
  85260. * Gets or sets a texture used to add random noise to particle positions
  85261. */
  85262. noiseTexture: Nullable<BaseTexture>;
  85263. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85264. noiseStrength: Vector3;
  85265. /**
  85266. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85267. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85268. */
  85269. billboardMode: number;
  85270. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85271. limitVelocityDamping: number;
  85272. /**
  85273. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85274. */
  85275. beginAnimationOnStart: boolean;
  85276. /**
  85277. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85278. */
  85279. beginAnimationFrom: number;
  85280. /**
  85281. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85282. */
  85283. beginAnimationTo: number;
  85284. /**
  85285. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85286. */
  85287. beginAnimationLoop: boolean;
  85288. /**
  85289. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85290. */
  85291. disposeOnStop: boolean;
  85292. /**
  85293. * Gets the maximum number of particles active at the same time.
  85294. * @returns The max number of active particles.
  85295. */
  85296. getCapacity(): number;
  85297. /**
  85298. * Gets if the system has been started. (Note: this will still be true after stop is called)
  85299. * @returns True if it has been started, otherwise false.
  85300. */
  85301. isStarted(): boolean;
  85302. /**
  85303. * Animates the particle system for this frame.
  85304. */
  85305. animate(): void;
  85306. /**
  85307. * Renders the particle system in its current state.
  85308. * @returns the current number of particles
  85309. */
  85310. render(): number;
  85311. /**
  85312. * Dispose the particle system and frees its associated resources.
  85313. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  85314. */
  85315. dispose(disposeTexture?: boolean): void;
  85316. /**
  85317. * Clones the particle system.
  85318. * @param name The name of the cloned object
  85319. * @param newEmitter The new emitter to use
  85320. * @returns the cloned particle system
  85321. */
  85322. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  85323. /**
  85324. * Serializes the particle system to a JSON object.
  85325. * @returns the JSON object
  85326. */
  85327. serialize(): any;
  85328. /**
  85329. * Rebuild the particle system
  85330. */
  85331. rebuild(): void;
  85332. /**
  85333. * Starts the particle system and begins to emit
  85334. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  85335. */
  85336. start(delay?: number): void;
  85337. /**
  85338. * Stops the particle system.
  85339. */
  85340. stop(): void;
  85341. /**
  85342. * Remove all active particles
  85343. */
  85344. reset(): void;
  85345. /**
  85346. * Is this system ready to be used/rendered
  85347. * @return true if the system is ready
  85348. */
  85349. isReady(): boolean;
  85350. /**
  85351. * Adds a new color gradient
  85352. * @param gradient defines the gradient to use (between 0 and 1)
  85353. * @param color1 defines the color to affect to the specified gradient
  85354. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  85355. * @returns the current particle system
  85356. */
  85357. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  85358. /**
  85359. * Remove a specific color gradient
  85360. * @param gradient defines the gradient to remove
  85361. * @returns the current particle system
  85362. */
  85363. removeColorGradient(gradient: number): IParticleSystem;
  85364. /**
  85365. * Adds a new size gradient
  85366. * @param gradient defines the gradient to use (between 0 and 1)
  85367. * @param factor defines the size factor to affect to the specified gradient
  85368. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85369. * @returns the current particle system
  85370. */
  85371. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85372. /**
  85373. * Remove a specific size gradient
  85374. * @param gradient defines the gradient to remove
  85375. * @returns the current particle system
  85376. */
  85377. removeSizeGradient(gradient: number): IParticleSystem;
  85378. /**
  85379. * Gets the current list of color gradients.
  85380. * You must use addColorGradient and removeColorGradient to udpate this list
  85381. * @returns the list of color gradients
  85382. */
  85383. getColorGradients(): Nullable<Array<ColorGradient>>;
  85384. /**
  85385. * Gets the current list of size gradients.
  85386. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85387. * @returns the list of size gradients
  85388. */
  85389. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85390. /**
  85391. * Gets the current list of angular speed gradients.
  85392. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85393. * @returns the list of angular speed gradients
  85394. */
  85395. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85396. /**
  85397. * Adds a new angular speed gradient
  85398. * @param gradient defines the gradient to use (between 0 and 1)
  85399. * @param factor defines the angular speed to affect to the specified gradient
  85400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85401. * @returns the current particle system
  85402. */
  85403. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85404. /**
  85405. * Remove a specific angular speed gradient
  85406. * @param gradient defines the gradient to remove
  85407. * @returns the current particle system
  85408. */
  85409. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  85410. /**
  85411. * Gets the current list of velocity gradients.
  85412. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85413. * @returns the list of velocity gradients
  85414. */
  85415. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85416. /**
  85417. * Adds a new velocity gradient
  85418. * @param gradient defines the gradient to use (between 0 and 1)
  85419. * @param factor defines the velocity to affect to the specified gradient
  85420. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85421. * @returns the current particle system
  85422. */
  85423. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85424. /**
  85425. * Remove a specific velocity gradient
  85426. * @param gradient defines the gradient to remove
  85427. * @returns the current particle system
  85428. */
  85429. removeVelocityGradient(gradient: number): IParticleSystem;
  85430. /**
  85431. * Gets the current list of limit velocity gradients.
  85432. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85433. * @returns the list of limit velocity gradients
  85434. */
  85435. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85436. /**
  85437. * Adds a new limit velocity gradient
  85438. * @param gradient defines the gradient to use (between 0 and 1)
  85439. * @param factor defines the limit velocity to affect to the specified gradient
  85440. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85441. * @returns the current particle system
  85442. */
  85443. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85444. /**
  85445. * Remove a specific limit velocity gradient
  85446. * @param gradient defines the gradient to remove
  85447. * @returns the current particle system
  85448. */
  85449. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  85450. /**
  85451. * Adds a new drag gradient
  85452. * @param gradient defines the gradient to use (between 0 and 1)
  85453. * @param factor defines the drag to affect to the specified gradient
  85454. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85455. * @returns the current particle system
  85456. */
  85457. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85458. /**
  85459. * Remove a specific drag gradient
  85460. * @param gradient defines the gradient to remove
  85461. * @returns the current particle system
  85462. */
  85463. removeDragGradient(gradient: number): IParticleSystem;
  85464. /**
  85465. * Gets the current list of drag gradients.
  85466. * You must use addDragGradient and removeDragGradient to udpate this list
  85467. * @returns the list of drag gradients
  85468. */
  85469. getDragGradients(): Nullable<Array<FactorGradient>>;
  85470. /**
  85471. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  85472. * @param gradient defines the gradient to use (between 0 and 1)
  85473. * @param factor defines the emit rate to affect to the specified gradient
  85474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85475. * @returns the current particle system
  85476. */
  85477. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85478. /**
  85479. * Remove a specific emit rate gradient
  85480. * @param gradient defines the gradient to remove
  85481. * @returns the current particle system
  85482. */
  85483. removeEmitRateGradient(gradient: number): IParticleSystem;
  85484. /**
  85485. * Gets the current list of emit rate gradients.
  85486. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85487. * @returns the list of emit rate gradients
  85488. */
  85489. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85490. /**
  85491. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  85492. * @param gradient defines the gradient to use (between 0 and 1)
  85493. * @param factor defines the start size to affect to the specified gradient
  85494. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85495. * @returns the current particle system
  85496. */
  85497. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85498. /**
  85499. * Remove a specific start size gradient
  85500. * @param gradient defines the gradient to remove
  85501. * @returns the current particle system
  85502. */
  85503. removeStartSizeGradient(gradient: number): IParticleSystem;
  85504. /**
  85505. * Gets the current list of start size gradients.
  85506. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85507. * @returns the list of start size gradients
  85508. */
  85509. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85510. /**
  85511. * Adds a new life time gradient
  85512. * @param gradient defines the gradient to use (between 0 and 1)
  85513. * @param factor defines the life time factor to affect to the specified gradient
  85514. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  85515. * @returns the current particle system
  85516. */
  85517. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  85518. /**
  85519. * Remove a specific life time gradient
  85520. * @param gradient defines the gradient to remove
  85521. * @returns the current particle system
  85522. */
  85523. removeLifeTimeGradient(gradient: number): IParticleSystem;
  85524. /**
  85525. * Gets the current list of life time gradients.
  85526. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85527. * @returns the list of life time gradients
  85528. */
  85529. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85530. /**
  85531. * Gets the current list of color gradients.
  85532. * You must use addColorGradient and removeColorGradient to udpate this list
  85533. * @returns the list of color gradients
  85534. */
  85535. getColorGradients(): Nullable<Array<ColorGradient>>;
  85536. /**
  85537. * Adds a new ramp gradient used to remap particle colors
  85538. * @param gradient defines the gradient to use (between 0 and 1)
  85539. * @param color defines the color to affect to the specified gradient
  85540. * @returns the current particle system
  85541. */
  85542. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  85543. /**
  85544. * Gets the current list of ramp gradients.
  85545. * You must use addRampGradient and removeRampGradient to udpate this list
  85546. * @returns the list of ramp gradients
  85547. */
  85548. getRampGradients(): Nullable<Array<Color3Gradient>>;
  85549. /** Gets or sets a boolean indicating that ramp gradients must be used
  85550. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85551. */
  85552. useRampGradients: boolean;
  85553. /**
  85554. * Adds a new color remap gradient
  85555. * @param gradient defines the gradient to use (between 0 and 1)
  85556. * @param min defines the color remap minimal range
  85557. * @param max defines the color remap maximal range
  85558. * @returns the current particle system
  85559. */
  85560. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85561. /**
  85562. * Gets the current list of color remap gradients.
  85563. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85564. * @returns the list of color remap gradients
  85565. */
  85566. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85567. /**
  85568. * Adds a new alpha remap gradient
  85569. * @param gradient defines the gradient to use (between 0 and 1)
  85570. * @param min defines the alpha remap minimal range
  85571. * @param max defines the alpha remap maximal range
  85572. * @returns the current particle system
  85573. */
  85574. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  85575. /**
  85576. * Gets the current list of alpha remap gradients.
  85577. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85578. * @returns the list of alpha remap gradients
  85579. */
  85580. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85581. /**
  85582. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85583. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85584. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85585. * @returns the emitter
  85586. */
  85587. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85588. /**
  85589. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85590. * @param radius The radius of the hemisphere to emit from
  85591. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85592. * @returns the emitter
  85593. */
  85594. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  85595. /**
  85596. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85597. * @param radius The radius of the sphere to emit from
  85598. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85599. * @returns the emitter
  85600. */
  85601. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  85602. /**
  85603. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85604. * @param radius The radius of the sphere to emit from
  85605. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85606. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85607. * @returns the emitter
  85608. */
  85609. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85610. /**
  85611. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85612. * @param radius The radius of the emission cylinder
  85613. * @param height The height of the emission cylinder
  85614. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85615. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85616. * @returns the emitter
  85617. */
  85618. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  85619. /**
  85620. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85621. * @param radius The radius of the cylinder to emit from
  85622. * @param height The height of the emission cylinder
  85623. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85624. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85625. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85626. * @returns the emitter
  85627. */
  85628. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  85629. /**
  85630. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85631. * @param radius The radius of the cone to emit from
  85632. * @param angle The base angle of the cone
  85633. * @returns the emitter
  85634. */
  85635. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  85636. /**
  85637. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85640. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85641. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85642. * @returns the emitter
  85643. */
  85644. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85645. /**
  85646. * Get hosting scene
  85647. * @returns the scene
  85648. */
  85649. getScene(): Scene;
  85650. }
  85651. }
  85652. declare module BABYLON {
  85653. /**
  85654. * Creates an instance based on a source mesh.
  85655. */
  85656. export class InstancedMesh extends AbstractMesh {
  85657. private _sourceMesh;
  85658. private _currentLOD;
  85659. /** @hidden */
  85660. _indexInSourceMeshInstanceArray: number;
  85661. constructor(name: string, source: Mesh);
  85662. /**
  85663. * Returns the string "InstancedMesh".
  85664. */
  85665. getClassName(): string;
  85666. /** Gets the list of lights affecting that mesh */
  85667. readonly lightSources: Light[];
  85668. _resyncLightSources(): void;
  85669. _resyncLighSource(light: Light): void;
  85670. _removeLightSource(light: Light, dispose: boolean): void;
  85671. /**
  85672. * If the source mesh receives shadows
  85673. */
  85674. readonly receiveShadows: boolean;
  85675. /**
  85676. * The material of the source mesh
  85677. */
  85678. readonly material: Nullable<Material>;
  85679. /**
  85680. * Visibility of the source mesh
  85681. */
  85682. readonly visibility: number;
  85683. /**
  85684. * Skeleton of the source mesh
  85685. */
  85686. readonly skeleton: Nullable<Skeleton>;
  85687. /**
  85688. * Rendering ground id of the source mesh
  85689. */
  85690. renderingGroupId: number;
  85691. /**
  85692. * Returns the total number of vertices (integer).
  85693. */
  85694. getTotalVertices(): number;
  85695. /**
  85696. * Returns a positive integer : the total number of indices in this mesh geometry.
  85697. * @returns the numner of indices or zero if the mesh has no geometry.
  85698. */
  85699. getTotalIndices(): number;
  85700. /**
  85701. * The source mesh of the instance
  85702. */
  85703. readonly sourceMesh: Mesh;
  85704. /**
  85705. * Is this node ready to be used/rendered
  85706. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  85707. * @return {boolean} is it ready
  85708. */
  85709. isReady(completeCheck?: boolean): boolean;
  85710. /**
  85711. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  85712. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  85713. * @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.
  85714. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  85715. */
  85716. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  85717. /**
  85718. * Sets the vertex data of the mesh geometry for the requested `kind`.
  85719. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  85720. * The `data` are either a numeric array either a Float32Array.
  85721. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  85722. * 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).
  85723. * Note that a new underlying VertexBuffer object is created each call.
  85724. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  85725. *
  85726. * Possible `kind` values :
  85727. * - VertexBuffer.PositionKind
  85728. * - VertexBuffer.UVKind
  85729. * - VertexBuffer.UV2Kind
  85730. * - VertexBuffer.UV3Kind
  85731. * - VertexBuffer.UV4Kind
  85732. * - VertexBuffer.UV5Kind
  85733. * - VertexBuffer.UV6Kind
  85734. * - VertexBuffer.ColorKind
  85735. * - VertexBuffer.MatricesIndicesKind
  85736. * - VertexBuffer.MatricesIndicesExtraKind
  85737. * - VertexBuffer.MatricesWeightsKind
  85738. * - VertexBuffer.MatricesWeightsExtraKind
  85739. *
  85740. * Returns the Mesh.
  85741. */
  85742. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  85743. /**
  85744. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  85745. * If the mesh has no geometry, it is simply returned as it is.
  85746. * The `data` are either a numeric array either a Float32Array.
  85747. * No new underlying VertexBuffer object is created.
  85748. * 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.
  85749. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  85750. *
  85751. * Possible `kind` values :
  85752. * - VertexBuffer.PositionKind
  85753. * - VertexBuffer.UVKind
  85754. * - VertexBuffer.UV2Kind
  85755. * - VertexBuffer.UV3Kind
  85756. * - VertexBuffer.UV4Kind
  85757. * - VertexBuffer.UV5Kind
  85758. * - VertexBuffer.UV6Kind
  85759. * - VertexBuffer.ColorKind
  85760. * - VertexBuffer.MatricesIndicesKind
  85761. * - VertexBuffer.MatricesIndicesExtraKind
  85762. * - VertexBuffer.MatricesWeightsKind
  85763. * - VertexBuffer.MatricesWeightsExtraKind
  85764. *
  85765. * Returns the Mesh.
  85766. */
  85767. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  85768. /**
  85769. * Sets the mesh indices.
  85770. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  85771. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  85772. * This method creates a new index buffer each call.
  85773. * Returns the Mesh.
  85774. */
  85775. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  85776. /**
  85777. * Boolean : True if the mesh owns the requested kind of data.
  85778. */
  85779. isVerticesDataPresent(kind: string): boolean;
  85780. /**
  85781. * Returns an array of indices (IndicesArray).
  85782. */
  85783. getIndices(): Nullable<IndicesArray>;
  85784. readonly _positions: Nullable<Vector3[]>;
  85785. /**
  85786. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  85787. * This means the mesh underlying bounding box and sphere are recomputed.
  85788. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  85789. * @returns the current mesh
  85790. */
  85791. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  85792. /** @hidden */
  85793. _preActivate(): InstancedMesh;
  85794. /** @hidden */
  85795. _activate(renderId: number, intermediateRendering: boolean): boolean;
  85796. /** @hidden */
  85797. _postActivate(): void;
  85798. getWorldMatrix(): Matrix;
  85799. readonly isAnInstance: boolean;
  85800. /**
  85801. * Returns the current associated LOD AbstractMesh.
  85802. */
  85803. getLOD(camera: Camera): AbstractMesh;
  85804. /** @hidden */
  85805. _syncSubMeshes(): InstancedMesh;
  85806. /** @hidden */
  85807. _generatePointsArray(): boolean;
  85808. /**
  85809. * Creates a new InstancedMesh from the current mesh.
  85810. * - name (string) : the cloned mesh name
  85811. * - newParent (optional Node) : the optional Node to parent the clone to.
  85812. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  85813. *
  85814. * Returns the clone.
  85815. */
  85816. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  85817. /**
  85818. * Disposes the InstancedMesh.
  85819. * Returns nothing.
  85820. */
  85821. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  85822. }
  85823. }
  85824. declare module BABYLON {
  85825. /**
  85826. * Defines the options associated with the creation of a shader material.
  85827. */
  85828. export interface IShaderMaterialOptions {
  85829. /**
  85830. * Does the material work in alpha blend mode
  85831. */
  85832. needAlphaBlending: boolean;
  85833. /**
  85834. * Does the material work in alpha test mode
  85835. */
  85836. needAlphaTesting: boolean;
  85837. /**
  85838. * The list of attribute names used in the shader
  85839. */
  85840. attributes: string[];
  85841. /**
  85842. * The list of unifrom names used in the shader
  85843. */
  85844. uniforms: string[];
  85845. /**
  85846. * The list of UBO names used in the shader
  85847. */
  85848. uniformBuffers: string[];
  85849. /**
  85850. * The list of sampler names used in the shader
  85851. */
  85852. samplers: string[];
  85853. /**
  85854. * The list of defines used in the shader
  85855. */
  85856. defines: string[];
  85857. }
  85858. /**
  85859. * 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.
  85860. *
  85861. * This returned material effects how the mesh will look based on the code in the shaders.
  85862. *
  85863. * @see http://doc.babylonjs.com/how_to/shader_material
  85864. */
  85865. export class ShaderMaterial extends Material {
  85866. private _shaderPath;
  85867. private _options;
  85868. private _textures;
  85869. private _textureArrays;
  85870. private _floats;
  85871. private _ints;
  85872. private _floatsArrays;
  85873. private _colors3;
  85874. private _colors3Arrays;
  85875. private _colors4;
  85876. private _colors4Arrays;
  85877. private _vectors2;
  85878. private _vectors3;
  85879. private _vectors4;
  85880. private _matrices;
  85881. private _matrices3x3;
  85882. private _matrices2x2;
  85883. private _vectors2Arrays;
  85884. private _vectors3Arrays;
  85885. private _vectors4Arrays;
  85886. private _cachedWorldViewMatrix;
  85887. private _cachedWorldViewProjectionMatrix;
  85888. private _renderId;
  85889. /**
  85890. * Instantiate a new shader material.
  85891. * 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.
  85892. * This returned material effects how the mesh will look based on the code in the shaders.
  85893. * @see http://doc.babylonjs.com/how_to/shader_material
  85894. * @param name Define the name of the material in the scene
  85895. * @param scene Define the scene the material belongs to
  85896. * @param shaderPath Defines the route to the shader code in one of three ways:
  85897. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  85898. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  85899. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  85900. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  85901. * @param options Define the options used to create the shader
  85902. */
  85903. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  85904. /**
  85905. * Gets the options used to compile the shader.
  85906. * They can be modified to trigger a new compilation
  85907. */
  85908. readonly options: IShaderMaterialOptions;
  85909. /**
  85910. * Gets the current class name of the material e.g. "ShaderMaterial"
  85911. * Mainly use in serialization.
  85912. * @returns the class name
  85913. */
  85914. getClassName(): string;
  85915. /**
  85916. * Specifies if the material will require alpha blending
  85917. * @returns a boolean specifying if alpha blending is needed
  85918. */
  85919. needAlphaBlending(): boolean;
  85920. /**
  85921. * Specifies if this material should be rendered in alpha test mode
  85922. * @returns a boolean specifying if an alpha test is needed.
  85923. */
  85924. needAlphaTesting(): boolean;
  85925. private _checkUniform;
  85926. /**
  85927. * Set a texture in the shader.
  85928. * @param name Define the name of the uniform samplers as defined in the shader
  85929. * @param texture Define the texture to bind to this sampler
  85930. * @return the material itself allowing "fluent" like uniform updates
  85931. */
  85932. setTexture(name: string, texture: Texture): ShaderMaterial;
  85933. /**
  85934. * Set a texture array in the shader.
  85935. * @param name Define the name of the uniform sampler array as defined in the shader
  85936. * @param textures Define the list of textures to bind to this sampler
  85937. * @return the material itself allowing "fluent" like uniform updates
  85938. */
  85939. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  85940. /**
  85941. * Set a float in the shader.
  85942. * @param name Define the name of the uniform as defined in the shader
  85943. * @param value Define the value to give to the uniform
  85944. * @return the material itself allowing "fluent" like uniform updates
  85945. */
  85946. setFloat(name: string, value: number): ShaderMaterial;
  85947. /**
  85948. * Set a int in the shader.
  85949. * @param name Define the name of the uniform as defined in the shader
  85950. * @param value Define the value to give to the uniform
  85951. * @return the material itself allowing "fluent" like uniform updates
  85952. */
  85953. setInt(name: string, value: number): ShaderMaterial;
  85954. /**
  85955. * Set an array of floats in the shader.
  85956. * @param name Define the name of the uniform as defined in the shader
  85957. * @param value Define the value to give to the uniform
  85958. * @return the material itself allowing "fluent" like uniform updates
  85959. */
  85960. setFloats(name: string, value: number[]): ShaderMaterial;
  85961. /**
  85962. * Set a vec3 in the shader from a Color3.
  85963. * @param name Define the name of the uniform as defined in the shader
  85964. * @param value Define the value to give to the uniform
  85965. * @return the material itself allowing "fluent" like uniform updates
  85966. */
  85967. setColor3(name: string, value: Color3): ShaderMaterial;
  85968. /**
  85969. * Set a vec3 array in the shader from a Color3 array.
  85970. * @param name Define the name of the uniform as defined in the shader
  85971. * @param value Define the value to give to the uniform
  85972. * @return the material itself allowing "fluent" like uniform updates
  85973. */
  85974. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  85975. /**
  85976. * Set a vec4 in the shader from a Color4.
  85977. * @param name Define the name of the uniform as defined in the shader
  85978. * @param value Define the value to give to the uniform
  85979. * @return the material itself allowing "fluent" like uniform updates
  85980. */
  85981. setColor4(name: string, value: Color4): ShaderMaterial;
  85982. /**
  85983. * Set a vec4 array in the shader from a Color4 array.
  85984. * @param name Define the name of the uniform as defined in the shader
  85985. * @param value Define the value to give to the uniform
  85986. * @return the material itself allowing "fluent" like uniform updates
  85987. */
  85988. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  85989. /**
  85990. * Set a vec2 in the shader from a Vector2.
  85991. * @param name Define the name of the uniform as defined in the shader
  85992. * @param value Define the value to give to the uniform
  85993. * @return the material itself allowing "fluent" like uniform updates
  85994. */
  85995. setVector2(name: string, value: Vector2): ShaderMaterial;
  85996. /**
  85997. * Set a vec3 in the shader from a Vector3.
  85998. * @param name Define the name of the uniform as defined in the shader
  85999. * @param value Define the value to give to the uniform
  86000. * @return the material itself allowing "fluent" like uniform updates
  86001. */
  86002. setVector3(name: string, value: Vector3): ShaderMaterial;
  86003. /**
  86004. * Set a vec4 in the shader from a Vector4.
  86005. * @param name Define the name of the uniform as defined in the shader
  86006. * @param value Define the value to give to the uniform
  86007. * @return the material itself allowing "fluent" like uniform updates
  86008. */
  86009. setVector4(name: string, value: Vector4): ShaderMaterial;
  86010. /**
  86011. * Set a mat4 in the shader from a Matrix.
  86012. * @param name Define the name of the uniform as defined in the shader
  86013. * @param value Define the value to give to the uniform
  86014. * @return the material itself allowing "fluent" like uniform updates
  86015. */
  86016. setMatrix(name: string, value: Matrix): ShaderMaterial;
  86017. /**
  86018. * Set a mat3 in the shader from a Float32Array.
  86019. * @param name Define the name of the uniform as defined in the shader
  86020. * @param value Define the value to give to the uniform
  86021. * @return the material itself allowing "fluent" like uniform updates
  86022. */
  86023. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  86024. /**
  86025. * Set a mat2 in the shader from a Float32Array.
  86026. * @param name Define the name of the uniform as defined in the shader
  86027. * @param value Define the value to give to the uniform
  86028. * @return the material itself allowing "fluent" like uniform updates
  86029. */
  86030. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  86031. /**
  86032. * Set a vec2 array in the shader from a number array.
  86033. * @param name Define the name of the uniform as defined in the shader
  86034. * @param value Define the value to give to the uniform
  86035. * @return the material itself allowing "fluent" like uniform updates
  86036. */
  86037. setArray2(name: string, value: number[]): ShaderMaterial;
  86038. /**
  86039. * Set a vec3 array in the shader from a number array.
  86040. * @param name Define the name of the uniform as defined in the shader
  86041. * @param value Define the value to give to the uniform
  86042. * @return the material itself allowing "fluent" like uniform updates
  86043. */
  86044. setArray3(name: string, value: number[]): ShaderMaterial;
  86045. /**
  86046. * Set a vec4 array in the shader from a number array.
  86047. * @param name Define the name of the uniform as defined in the shader
  86048. * @param value Define the value to give to the uniform
  86049. * @return the material itself allowing "fluent" like uniform updates
  86050. */
  86051. setArray4(name: string, value: number[]): ShaderMaterial;
  86052. private _checkCache;
  86053. /**
  86054. * Specifies that the submesh is ready to be used
  86055. * @param mesh defines the mesh to check
  86056. * @param subMesh defines which submesh to check
  86057. * @param useInstances specifies that instances should be used
  86058. * @returns a boolean indicating that the submesh is ready or not
  86059. */
  86060. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  86061. /**
  86062. * Checks if the material is ready to render the requested mesh
  86063. * @param mesh Define the mesh to render
  86064. * @param useInstances Define whether or not the material is used with instances
  86065. * @returns true if ready, otherwise false
  86066. */
  86067. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  86068. /**
  86069. * Binds the world matrix to the material
  86070. * @param world defines the world transformation matrix
  86071. */
  86072. bindOnlyWorldMatrix(world: Matrix): void;
  86073. /**
  86074. * Binds the material to the mesh
  86075. * @param world defines the world transformation matrix
  86076. * @param mesh defines the mesh to bind the material to
  86077. */
  86078. bind(world: Matrix, mesh?: Mesh): void;
  86079. /**
  86080. * Gets the active textures from the material
  86081. * @returns an array of textures
  86082. */
  86083. getActiveTextures(): BaseTexture[];
  86084. /**
  86085. * Specifies if the material uses a texture
  86086. * @param texture defines the texture to check against the material
  86087. * @returns a boolean specifying if the material uses the texture
  86088. */
  86089. hasTexture(texture: BaseTexture): boolean;
  86090. /**
  86091. * Makes a duplicate of the material, and gives it a new name
  86092. * @param name defines the new name for the duplicated material
  86093. * @returns the cloned material
  86094. */
  86095. clone(name: string): ShaderMaterial;
  86096. /**
  86097. * Disposes the material
  86098. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  86099. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  86100. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  86101. */
  86102. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  86103. /**
  86104. * Serializes this material in a JSON representation
  86105. * @returns the serialized material object
  86106. */
  86107. serialize(): any;
  86108. /**
  86109. * Creates a shader material from parsed shader material data
  86110. * @param source defines the JSON represnetation of the material
  86111. * @param scene defines the hosting scene
  86112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  86113. * @returns a new material
  86114. */
  86115. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  86116. }
  86117. }
  86118. declare module BABYLON {
  86119. /** @hidden */
  86120. export var colorPixelShader: {
  86121. name: string;
  86122. shader: string;
  86123. };
  86124. }
  86125. declare module BABYLON {
  86126. /** @hidden */
  86127. export var colorVertexShader: {
  86128. name: string;
  86129. shader: string;
  86130. };
  86131. }
  86132. declare module BABYLON {
  86133. /**
  86134. * Line mesh
  86135. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  86136. */
  86137. export class LinesMesh extends Mesh {
  86138. /**
  86139. * If vertex color should be applied to the mesh
  86140. */
  86141. readonly useVertexColor?: boolean | undefined;
  86142. /**
  86143. * If vertex alpha should be applied to the mesh
  86144. */
  86145. readonly useVertexAlpha?: boolean | undefined;
  86146. /**
  86147. * Color of the line (Default: White)
  86148. */
  86149. color: Color3;
  86150. /**
  86151. * Alpha of the line (Default: 1)
  86152. */
  86153. alpha: number;
  86154. /**
  86155. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86156. * This margin is expressed in world space coordinates, so its value may vary.
  86157. * Default value is 0.1
  86158. */
  86159. intersectionThreshold: number;
  86160. private _colorShader;
  86161. private color4;
  86162. /**
  86163. * Creates a new LinesMesh
  86164. * @param name defines the name
  86165. * @param scene defines the hosting scene
  86166. * @param parent defines the parent mesh if any
  86167. * @param source defines the optional source LinesMesh used to clone data from
  86168. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  86169. * When false, achieved by calling a clone(), also passing False.
  86170. * This will make creation of children, recursive.
  86171. * @param useVertexColor defines if this LinesMesh supports vertex color
  86172. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  86173. */
  86174. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  86175. /**
  86176. * If vertex color should be applied to the mesh
  86177. */
  86178. useVertexColor?: boolean | undefined,
  86179. /**
  86180. * If vertex alpha should be applied to the mesh
  86181. */
  86182. useVertexAlpha?: boolean | undefined);
  86183. private _addClipPlaneDefine;
  86184. private _removeClipPlaneDefine;
  86185. isReady(): boolean;
  86186. /**
  86187. * Returns the string "LineMesh"
  86188. */
  86189. getClassName(): string;
  86190. /**
  86191. * @hidden
  86192. */
  86193. /**
  86194. * @hidden
  86195. */
  86196. material: Material;
  86197. /**
  86198. * @hidden
  86199. */
  86200. readonly checkCollisions: boolean;
  86201. /** @hidden */
  86202. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  86203. /** @hidden */
  86204. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  86205. /**
  86206. * Disposes of the line mesh
  86207. * @param doNotRecurse If children should be disposed
  86208. */
  86209. dispose(doNotRecurse?: boolean): void;
  86210. /**
  86211. * Returns a new LineMesh object cloned from the current one.
  86212. */
  86213. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  86214. /**
  86215. * Creates a new InstancedLinesMesh object from the mesh model.
  86216. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86217. * @param name defines the name of the new instance
  86218. * @returns a new InstancedLinesMesh
  86219. */
  86220. createInstance(name: string): InstancedLinesMesh;
  86221. }
  86222. /**
  86223. * Creates an instance based on a source LinesMesh
  86224. */
  86225. export class InstancedLinesMesh extends InstancedMesh {
  86226. /**
  86227. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  86228. * This margin is expressed in world space coordinates, so its value may vary.
  86229. * Initilized with the intersectionThreshold value of the source LinesMesh
  86230. */
  86231. intersectionThreshold: number;
  86232. constructor(name: string, source: LinesMesh);
  86233. /**
  86234. * Returns the string "InstancedLinesMesh".
  86235. */
  86236. getClassName(): string;
  86237. }
  86238. }
  86239. declare module BABYLON {
  86240. /** @hidden */
  86241. export var linePixelShader: {
  86242. name: string;
  86243. shader: string;
  86244. };
  86245. }
  86246. declare module BABYLON {
  86247. /** @hidden */
  86248. export var lineVertexShader: {
  86249. name: string;
  86250. shader: string;
  86251. };
  86252. }
  86253. declare module BABYLON {
  86254. interface AbstractMesh {
  86255. /**
  86256. * Gets the edgesRenderer associated with the mesh
  86257. */
  86258. edgesRenderer: Nullable<EdgesRenderer>;
  86259. }
  86260. interface LinesMesh {
  86261. /**
  86262. * Enables the edge rendering mode on the mesh.
  86263. * This mode makes the mesh edges visible
  86264. * @param epsilon defines the maximal distance between two angles to detect a face
  86265. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86266. * @returns the currentAbstractMesh
  86267. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86268. */
  86269. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  86270. }
  86271. interface InstancedLinesMesh {
  86272. /**
  86273. * Enables the edge rendering mode on the mesh.
  86274. * This mode makes the mesh edges visible
  86275. * @param epsilon defines the maximal distance between two angles to detect a face
  86276. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  86277. * @returns the current InstancedLinesMesh
  86278. * @see https://www.babylonjs-playground.com/#19O9TU#0
  86279. */
  86280. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  86281. }
  86282. /**
  86283. * Defines the minimum contract an Edges renderer should follow.
  86284. */
  86285. export interface IEdgesRenderer extends IDisposable {
  86286. /**
  86287. * Gets or sets a boolean indicating if the edgesRenderer is active
  86288. */
  86289. isEnabled: boolean;
  86290. /**
  86291. * Renders the edges of the attached mesh,
  86292. */
  86293. render(): void;
  86294. /**
  86295. * Checks wether or not the edges renderer is ready to render.
  86296. * @return true if ready, otherwise false.
  86297. */
  86298. isReady(): boolean;
  86299. }
  86300. /**
  86301. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  86302. */
  86303. export class EdgesRenderer implements IEdgesRenderer {
  86304. /**
  86305. * Define the size of the edges with an orthographic camera
  86306. */
  86307. edgesWidthScalerForOrthographic: number;
  86308. /**
  86309. * Define the size of the edges with a perspective camera
  86310. */
  86311. edgesWidthScalerForPerspective: number;
  86312. protected _source: AbstractMesh;
  86313. protected _linesPositions: number[];
  86314. protected _linesNormals: number[];
  86315. protected _linesIndices: number[];
  86316. protected _epsilon: number;
  86317. protected _indicesCount: number;
  86318. protected _lineShader: ShaderMaterial;
  86319. protected _ib: DataBuffer;
  86320. protected _buffers: {
  86321. [key: string]: Nullable<VertexBuffer>;
  86322. };
  86323. protected _checkVerticesInsteadOfIndices: boolean;
  86324. private _meshRebuildObserver;
  86325. private _meshDisposeObserver;
  86326. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  86327. isEnabled: boolean;
  86328. /**
  86329. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  86330. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  86331. * @param source Mesh used to create edges
  86332. * @param epsilon sum of angles in adjacency to check for edge
  86333. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  86334. * @param generateEdgesLines - should generate Lines or only prepare resources.
  86335. */
  86336. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  86337. protected _prepareRessources(): void;
  86338. /** @hidden */
  86339. _rebuild(): void;
  86340. /**
  86341. * Releases the required resources for the edges renderer
  86342. */
  86343. dispose(): void;
  86344. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  86345. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  86346. /**
  86347. * Checks if the pair of p0 and p1 is en edge
  86348. * @param faceIndex
  86349. * @param edge
  86350. * @param faceNormals
  86351. * @param p0
  86352. * @param p1
  86353. * @private
  86354. */
  86355. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  86356. /**
  86357. * push line into the position, normal and index buffer
  86358. * @protected
  86359. */
  86360. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  86361. /**
  86362. * Generates lines edges from adjacencjes
  86363. * @private
  86364. */
  86365. _generateEdgesLines(): void;
  86366. /**
  86367. * Checks wether or not the edges renderer is ready to render.
  86368. * @return true if ready, otherwise false.
  86369. */
  86370. isReady(): boolean;
  86371. /**
  86372. * Renders the edges of the attached mesh,
  86373. */
  86374. render(): void;
  86375. }
  86376. /**
  86377. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  86378. */
  86379. export class LineEdgesRenderer extends EdgesRenderer {
  86380. /**
  86381. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  86382. * @param source LineMesh used to generate edges
  86383. * @param epsilon not important (specified angle for edge detection)
  86384. * @param checkVerticesInsteadOfIndices not important for LineMesh
  86385. */
  86386. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  86387. /**
  86388. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  86389. */
  86390. _generateEdgesLines(): void;
  86391. }
  86392. }
  86393. declare module BABYLON {
  86394. /**
  86395. * This represents the object necessary to create a rendering group.
  86396. * This is exclusively used and created by the rendering manager.
  86397. * To modify the behavior, you use the available helpers in your scene or meshes.
  86398. * @hidden
  86399. */
  86400. export class RenderingGroup {
  86401. index: number;
  86402. private static _zeroVector;
  86403. private _scene;
  86404. private _opaqueSubMeshes;
  86405. private _transparentSubMeshes;
  86406. private _alphaTestSubMeshes;
  86407. private _depthOnlySubMeshes;
  86408. private _particleSystems;
  86409. private _spriteManagers;
  86410. private _opaqueSortCompareFn;
  86411. private _alphaTestSortCompareFn;
  86412. private _transparentSortCompareFn;
  86413. private _renderOpaque;
  86414. private _renderAlphaTest;
  86415. private _renderTransparent;
  86416. /** @hidden */
  86417. _edgesRenderers: SmartArray<IEdgesRenderer>;
  86418. onBeforeTransparentRendering: () => void;
  86419. /**
  86420. * Set the opaque sort comparison function.
  86421. * If null the sub meshes will be render in the order they were created
  86422. */
  86423. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86424. /**
  86425. * Set the alpha test sort comparison function.
  86426. * If null the sub meshes will be render in the order they were created
  86427. */
  86428. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86429. /**
  86430. * Set the transparent sort comparison function.
  86431. * If null the sub meshes will be render in the order they were created
  86432. */
  86433. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  86434. /**
  86435. * Creates a new rendering group.
  86436. * @param index The rendering group index
  86437. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  86438. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  86439. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  86440. */
  86441. 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>);
  86442. /**
  86443. * Render all the sub meshes contained in the group.
  86444. * @param customRenderFunction Used to override the default render behaviour of the group.
  86445. * @returns true if rendered some submeshes.
  86446. */
  86447. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  86448. /**
  86449. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  86450. * @param subMeshes The submeshes to render
  86451. */
  86452. private renderOpaqueSorted;
  86453. /**
  86454. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  86455. * @param subMeshes The submeshes to render
  86456. */
  86457. private renderAlphaTestSorted;
  86458. /**
  86459. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  86460. * @param subMeshes The submeshes to render
  86461. */
  86462. private renderTransparentSorted;
  86463. /**
  86464. * Renders the submeshes in a specified order.
  86465. * @param subMeshes The submeshes to sort before render
  86466. * @param sortCompareFn The comparison function use to sort
  86467. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  86468. * @param transparent Specifies to activate blending if true
  86469. */
  86470. private static renderSorted;
  86471. /**
  86472. * Renders the submeshes in the order they were dispatched (no sort applied).
  86473. * @param subMeshes The submeshes to render
  86474. */
  86475. private static renderUnsorted;
  86476. /**
  86477. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86478. * are rendered back to front if in the same alpha index.
  86479. *
  86480. * @param a The first submesh
  86481. * @param b The second submesh
  86482. * @returns The result of the comparison
  86483. */
  86484. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  86485. /**
  86486. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86487. * are rendered back to front.
  86488. *
  86489. * @param a The first submesh
  86490. * @param b The second submesh
  86491. * @returns The result of the comparison
  86492. */
  86493. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  86494. /**
  86495. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  86496. * are rendered front to back (prevent overdraw).
  86497. *
  86498. * @param a The first submesh
  86499. * @param b The second submesh
  86500. * @returns The result of the comparison
  86501. */
  86502. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  86503. /**
  86504. * Resets the different lists of submeshes to prepare a new frame.
  86505. */
  86506. prepare(): void;
  86507. dispose(): void;
  86508. /**
  86509. * Inserts the submesh in its correct queue depending on its material.
  86510. * @param subMesh The submesh to dispatch
  86511. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86512. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86513. */
  86514. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86515. dispatchSprites(spriteManager: ISpriteManager): void;
  86516. dispatchParticles(particleSystem: IParticleSystem): void;
  86517. private _renderParticles;
  86518. private _renderSprites;
  86519. }
  86520. }
  86521. declare module BABYLON {
  86522. /**
  86523. * Interface describing the different options available in the rendering manager
  86524. * regarding Auto Clear between groups.
  86525. */
  86526. export interface IRenderingManagerAutoClearSetup {
  86527. /**
  86528. * Defines whether or not autoclear is enable.
  86529. */
  86530. autoClear: boolean;
  86531. /**
  86532. * Defines whether or not to autoclear the depth buffer.
  86533. */
  86534. depth: boolean;
  86535. /**
  86536. * Defines whether or not to autoclear the stencil buffer.
  86537. */
  86538. stencil: boolean;
  86539. }
  86540. /**
  86541. * This class is used by the onRenderingGroupObservable
  86542. */
  86543. export class RenderingGroupInfo {
  86544. /**
  86545. * The Scene that being rendered
  86546. */
  86547. scene: Scene;
  86548. /**
  86549. * The camera currently used for the rendering pass
  86550. */
  86551. camera: Nullable<Camera>;
  86552. /**
  86553. * The ID of the renderingGroup being processed
  86554. */
  86555. renderingGroupId: number;
  86556. }
  86557. /**
  86558. * This is the manager responsible of all the rendering for meshes sprites and particles.
  86559. * It is enable to manage the different groups as well as the different necessary sort functions.
  86560. * This should not be used directly aside of the few static configurations
  86561. */
  86562. export class RenderingManager {
  86563. /**
  86564. * The max id used for rendering groups (not included)
  86565. */
  86566. static MAX_RENDERINGGROUPS: number;
  86567. /**
  86568. * The min id used for rendering groups (included)
  86569. */
  86570. static MIN_RENDERINGGROUPS: number;
  86571. /**
  86572. * Used to globally prevent autoclearing scenes.
  86573. */
  86574. static AUTOCLEAR: boolean;
  86575. /**
  86576. * @hidden
  86577. */
  86578. _useSceneAutoClearSetup: boolean;
  86579. private _scene;
  86580. private _renderingGroups;
  86581. private _depthStencilBufferAlreadyCleaned;
  86582. private _autoClearDepthStencil;
  86583. private _customOpaqueSortCompareFn;
  86584. private _customAlphaTestSortCompareFn;
  86585. private _customTransparentSortCompareFn;
  86586. private _renderingGroupInfo;
  86587. /**
  86588. * Instantiates a new rendering group for a particular scene
  86589. * @param scene Defines the scene the groups belongs to
  86590. */
  86591. constructor(scene: Scene);
  86592. private _clearDepthStencilBuffer;
  86593. /**
  86594. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  86595. * @hidden
  86596. */
  86597. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  86598. /**
  86599. * Resets the different information of the group to prepare a new frame
  86600. * @hidden
  86601. */
  86602. reset(): void;
  86603. /**
  86604. * Dispose and release the group and its associated resources.
  86605. * @hidden
  86606. */
  86607. dispose(): void;
  86608. /**
  86609. * Clear the info related to rendering groups preventing retention points during dispose.
  86610. */
  86611. freeRenderingGroups(): void;
  86612. private _prepareRenderingGroup;
  86613. /**
  86614. * Add a sprite manager to the rendering manager in order to render it this frame.
  86615. * @param spriteManager Define the sprite manager to render
  86616. */
  86617. dispatchSprites(spriteManager: ISpriteManager): void;
  86618. /**
  86619. * Add a particle system to the rendering manager in order to render it this frame.
  86620. * @param particleSystem Define the particle system to render
  86621. */
  86622. dispatchParticles(particleSystem: IParticleSystem): void;
  86623. /**
  86624. * Add a submesh to the manager in order to render it this frame
  86625. * @param subMesh The submesh to dispatch
  86626. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  86627. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  86628. */
  86629. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  86630. /**
  86631. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86632. * This allowed control for front to back rendering or reversly depending of the special needs.
  86633. *
  86634. * @param renderingGroupId The rendering group id corresponding to its index
  86635. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86636. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86637. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86638. */
  86639. 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;
  86640. /**
  86641. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86642. *
  86643. * @param renderingGroupId The rendering group id corresponding to its index
  86644. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86645. * @param depth Automatically clears depth between groups if true and autoClear is true.
  86646. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  86647. */
  86648. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  86649. /**
  86650. * Gets the current auto clear configuration for one rendering group of the rendering
  86651. * manager.
  86652. * @param index the rendering group index to get the information for
  86653. * @returns The auto clear setup for the requested rendering group
  86654. */
  86655. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  86656. }
  86657. }
  86658. declare module BABYLON {
  86659. /**
  86660. * This Helps creating a texture that will be created from a camera in your scene.
  86661. * It is basically a dynamic texture that could be used to create special effects for instance.
  86662. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  86663. */
  86664. export class RenderTargetTexture extends Texture {
  86665. isCube: boolean;
  86666. /**
  86667. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  86668. */
  86669. static readonly REFRESHRATE_RENDER_ONCE: number;
  86670. /**
  86671. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  86672. */
  86673. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  86674. /**
  86675. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  86676. * the central point of your effect and can save a lot of performances.
  86677. */
  86678. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  86679. /**
  86680. * Use this predicate to dynamically define the list of mesh you want to render.
  86681. * If set, the renderList property will be overwritten.
  86682. */
  86683. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  86684. private _renderList;
  86685. /**
  86686. * Use this list to define the list of mesh you want to render.
  86687. */
  86688. renderList: Nullable<Array<AbstractMesh>>;
  86689. private _hookArray;
  86690. /**
  86691. * Define if particles should be rendered in your texture.
  86692. */
  86693. renderParticles: boolean;
  86694. /**
  86695. * Define if sprites should be rendered in your texture.
  86696. */
  86697. renderSprites: boolean;
  86698. /**
  86699. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  86700. */
  86701. coordinatesMode: number;
  86702. /**
  86703. * Define the camera used to render the texture.
  86704. */
  86705. activeCamera: Nullable<Camera>;
  86706. /**
  86707. * Override the render function of the texture with your own one.
  86708. */
  86709. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  86710. /**
  86711. * Define if camera post processes should be use while rendering the texture.
  86712. */
  86713. useCameraPostProcesses: boolean;
  86714. /**
  86715. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  86716. */
  86717. ignoreCameraViewport: boolean;
  86718. private _postProcessManager;
  86719. private _postProcesses;
  86720. private _resizeObserver;
  86721. /**
  86722. * An event triggered when the texture is unbind.
  86723. */
  86724. onBeforeBindObservable: Observable<RenderTargetTexture>;
  86725. /**
  86726. * An event triggered when the texture is unbind.
  86727. */
  86728. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  86729. private _onAfterUnbindObserver;
  86730. /**
  86731. * Set a after unbind callback in the texture.
  86732. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  86733. */
  86734. onAfterUnbind: () => void;
  86735. /**
  86736. * An event triggered before rendering the texture
  86737. */
  86738. onBeforeRenderObservable: Observable<number>;
  86739. private _onBeforeRenderObserver;
  86740. /**
  86741. * Set a before render callback in the texture.
  86742. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  86743. */
  86744. onBeforeRender: (faceIndex: number) => void;
  86745. /**
  86746. * An event triggered after rendering the texture
  86747. */
  86748. onAfterRenderObservable: Observable<number>;
  86749. private _onAfterRenderObserver;
  86750. /**
  86751. * Set a after render callback in the texture.
  86752. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  86753. */
  86754. onAfterRender: (faceIndex: number) => void;
  86755. /**
  86756. * An event triggered after the texture clear
  86757. */
  86758. onClearObservable: Observable<Engine>;
  86759. private _onClearObserver;
  86760. /**
  86761. * Set a clear callback in the texture.
  86762. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  86763. */
  86764. onClear: (Engine: Engine) => void;
  86765. /**
  86766. * An event triggered when the texture is resized.
  86767. */
  86768. onResizeObservable: Observable<RenderTargetTexture>;
  86769. /**
  86770. * Define the clear color of the Render Target if it should be different from the scene.
  86771. */
  86772. clearColor: Color4;
  86773. protected _size: number | {
  86774. width: number;
  86775. height: number;
  86776. };
  86777. protected _initialSizeParameter: number | {
  86778. width: number;
  86779. height: number;
  86780. } | {
  86781. ratio: number;
  86782. };
  86783. protected _sizeRatio: Nullable<number>;
  86784. /** @hidden */
  86785. _generateMipMaps: boolean;
  86786. protected _renderingManager: RenderingManager;
  86787. /** @hidden */
  86788. _waitingRenderList: string[];
  86789. protected _doNotChangeAspectRatio: boolean;
  86790. protected _currentRefreshId: number;
  86791. protected _refreshRate: number;
  86792. protected _textureMatrix: Matrix;
  86793. protected _samples: number;
  86794. protected _renderTargetOptions: RenderTargetCreationOptions;
  86795. /**
  86796. * Gets render target creation options that were used.
  86797. */
  86798. readonly renderTargetOptions: RenderTargetCreationOptions;
  86799. protected _engine: Engine;
  86800. protected _onRatioRescale(): void;
  86801. /**
  86802. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  86803. * It must define where the camera used to render the texture is set
  86804. */
  86805. boundingBoxPosition: Vector3;
  86806. private _boundingBoxSize;
  86807. /**
  86808. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  86809. * When defined, the cubemap will switch to local mode
  86810. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  86811. * @example https://www.babylonjs-playground.com/#RNASML
  86812. */
  86813. boundingBoxSize: Vector3;
  86814. /**
  86815. * In case the RTT has been created with a depth texture, get the associated
  86816. * depth texture.
  86817. * Otherwise, return null.
  86818. */
  86819. depthStencilTexture: Nullable<InternalTexture>;
  86820. /**
  86821. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  86822. * or used a shadow, depth texture...
  86823. * @param name The friendly name of the texture
  86824. * @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)
  86825. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  86826. * @param generateMipMaps True if mip maps need to be generated after render.
  86827. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  86828. * @param type The type of the buffer in the RTT (int, half float, float...)
  86829. * @param isCube True if a cube texture needs to be created
  86830. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  86831. * @param generateDepthBuffer True to generate a depth buffer
  86832. * @param generateStencilBuffer True to generate a stencil buffer
  86833. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  86834. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  86835. * @param delayAllocation if the texture allocation should be delayed (default: false)
  86836. */
  86837. constructor(name: string, size: number | {
  86838. width: number;
  86839. height: number;
  86840. } | {
  86841. ratio: number;
  86842. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  86843. /**
  86844. * Creates a depth stencil texture.
  86845. * This is only available in WebGL 2 or with the depth texture extension available.
  86846. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  86847. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  86848. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  86849. */
  86850. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  86851. private _processSizeParameter;
  86852. /**
  86853. * Define the number of samples to use in case of MSAA.
  86854. * It defaults to one meaning no MSAA has been enabled.
  86855. */
  86856. samples: number;
  86857. /**
  86858. * Resets the refresh counter of the texture and start bak from scratch.
  86859. * Could be useful to regenerate the texture if it is setup to render only once.
  86860. */
  86861. resetRefreshCounter(): void;
  86862. /**
  86863. * Define the refresh rate of the texture or the rendering frequency.
  86864. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  86865. */
  86866. refreshRate: number;
  86867. /**
  86868. * Adds a post process to the render target rendering passes.
  86869. * @param postProcess define the post process to add
  86870. */
  86871. addPostProcess(postProcess: PostProcess): void;
  86872. /**
  86873. * Clear all the post processes attached to the render target
  86874. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  86875. */
  86876. clearPostProcesses(dispose?: boolean): void;
  86877. /**
  86878. * Remove one of the post process from the list of attached post processes to the texture
  86879. * @param postProcess define the post process to remove from the list
  86880. */
  86881. removePostProcess(postProcess: PostProcess): void;
  86882. /** @hidden */
  86883. _shouldRender(): boolean;
  86884. /**
  86885. * Gets the actual render size of the texture.
  86886. * @returns the width of the render size
  86887. */
  86888. getRenderSize(): number;
  86889. /**
  86890. * Gets the actual render width of the texture.
  86891. * @returns the width of the render size
  86892. */
  86893. getRenderWidth(): number;
  86894. /**
  86895. * Gets the actual render height of the texture.
  86896. * @returns the height of the render size
  86897. */
  86898. getRenderHeight(): number;
  86899. /**
  86900. * Get if the texture can be rescaled or not.
  86901. */
  86902. readonly canRescale: boolean;
  86903. /**
  86904. * Resize the texture using a ratio.
  86905. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  86906. */
  86907. scale(ratio: number): void;
  86908. /**
  86909. * Get the texture reflection matrix used to rotate/transform the reflection.
  86910. * @returns the reflection matrix
  86911. */
  86912. getReflectionTextureMatrix(): Matrix;
  86913. /**
  86914. * Resize the texture to a new desired size.
  86915. * Be carrefull as it will recreate all the data in the new texture.
  86916. * @param size Define the new size. It can be:
  86917. * - a number for squared texture,
  86918. * - an object containing { width: number, height: number }
  86919. * - or an object containing a ratio { ratio: number }
  86920. */
  86921. resize(size: number | {
  86922. width: number;
  86923. height: number;
  86924. } | {
  86925. ratio: number;
  86926. }): void;
  86927. /**
  86928. * Renders all the objects from the render list into the texture.
  86929. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  86930. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  86931. */
  86932. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  86933. private _bestReflectionRenderTargetDimension;
  86934. /**
  86935. * @hidden
  86936. * @param faceIndex face index to bind to if this is a cubetexture
  86937. */
  86938. _bindFrameBuffer(faceIndex?: number): void;
  86939. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  86940. private renderToTarget;
  86941. /**
  86942. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  86943. * This allowed control for front to back rendering or reversly depending of the special needs.
  86944. *
  86945. * @param renderingGroupId The rendering group id corresponding to its index
  86946. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  86947. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  86948. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  86949. */
  86950. 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;
  86951. /**
  86952. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  86953. *
  86954. * @param renderingGroupId The rendering group id corresponding to its index
  86955. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  86956. */
  86957. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  86958. /**
  86959. * Clones the texture.
  86960. * @returns the cloned texture
  86961. */
  86962. clone(): RenderTargetTexture;
  86963. /**
  86964. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  86965. * @returns The JSON representation of the texture
  86966. */
  86967. serialize(): any;
  86968. /**
  86969. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  86970. */
  86971. disposeFramebufferObjects(): void;
  86972. /**
  86973. * Dispose the texture and release its associated resources.
  86974. */
  86975. dispose(): void;
  86976. /** @hidden */
  86977. _rebuild(): void;
  86978. /**
  86979. * Clear the info related to rendering groups preventing retention point in material dispose.
  86980. */
  86981. freeRenderingGroups(): void;
  86982. /**
  86983. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  86984. * @returns the view count
  86985. */
  86986. getViewCount(): number;
  86987. }
  86988. }
  86989. declare module BABYLON {
  86990. /**
  86991. * Base class for the main features of a material in Babylon.js
  86992. */
  86993. export class Material implements IAnimatable {
  86994. /**
  86995. * Returns the triangle fill mode
  86996. */
  86997. static readonly TriangleFillMode: number;
  86998. /**
  86999. * Returns the wireframe mode
  87000. */
  87001. static readonly WireFrameFillMode: number;
  87002. /**
  87003. * Returns the point fill mode
  87004. */
  87005. static readonly PointFillMode: number;
  87006. /**
  87007. * Returns the point list draw mode
  87008. */
  87009. static readonly PointListDrawMode: number;
  87010. /**
  87011. * Returns the line list draw mode
  87012. */
  87013. static readonly LineListDrawMode: number;
  87014. /**
  87015. * Returns the line loop draw mode
  87016. */
  87017. static readonly LineLoopDrawMode: number;
  87018. /**
  87019. * Returns the line strip draw mode
  87020. */
  87021. static readonly LineStripDrawMode: number;
  87022. /**
  87023. * Returns the triangle strip draw mode
  87024. */
  87025. static readonly TriangleStripDrawMode: number;
  87026. /**
  87027. * Returns the triangle fan draw mode
  87028. */
  87029. static readonly TriangleFanDrawMode: number;
  87030. /**
  87031. * Stores the clock-wise side orientation
  87032. */
  87033. static readonly ClockWiseSideOrientation: number;
  87034. /**
  87035. * Stores the counter clock-wise side orientation
  87036. */
  87037. static readonly CounterClockWiseSideOrientation: number;
  87038. /**
  87039. * The dirty texture flag value
  87040. */
  87041. static readonly TextureDirtyFlag: number;
  87042. /**
  87043. * The dirty light flag value
  87044. */
  87045. static readonly LightDirtyFlag: number;
  87046. /**
  87047. * The dirty fresnel flag value
  87048. */
  87049. static readonly FresnelDirtyFlag: number;
  87050. /**
  87051. * The dirty attribute flag value
  87052. */
  87053. static readonly AttributesDirtyFlag: number;
  87054. /**
  87055. * The dirty misc flag value
  87056. */
  87057. static readonly MiscDirtyFlag: number;
  87058. /**
  87059. * The all dirty flag value
  87060. */
  87061. static readonly AllDirtyFlag: number;
  87062. /**
  87063. * The ID of the material
  87064. */
  87065. id: string;
  87066. /**
  87067. * Gets or sets the unique id of the material
  87068. */
  87069. uniqueId: number;
  87070. /**
  87071. * The name of the material
  87072. */
  87073. name: string;
  87074. /**
  87075. * Gets or sets user defined metadata
  87076. */
  87077. metadata: any;
  87078. /**
  87079. * For internal use only. Please do not use.
  87080. */
  87081. reservedDataStore: any;
  87082. /**
  87083. * Specifies if the ready state should be checked on each call
  87084. */
  87085. checkReadyOnEveryCall: boolean;
  87086. /**
  87087. * Specifies if the ready state should be checked once
  87088. */
  87089. checkReadyOnlyOnce: boolean;
  87090. /**
  87091. * The state of the material
  87092. */
  87093. state: string;
  87094. /**
  87095. * The alpha value of the material
  87096. */
  87097. protected _alpha: number;
  87098. /**
  87099. * List of inspectable custom properties (used by the Inspector)
  87100. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  87101. */
  87102. inspectableCustomProperties: IInspectable[];
  87103. /**
  87104. * Sets the alpha value of the material
  87105. */
  87106. /**
  87107. * Gets the alpha value of the material
  87108. */
  87109. alpha: number;
  87110. /**
  87111. * Specifies if back face culling is enabled
  87112. */
  87113. protected _backFaceCulling: boolean;
  87114. /**
  87115. * Sets the back-face culling state
  87116. */
  87117. /**
  87118. * Gets the back-face culling state
  87119. */
  87120. backFaceCulling: boolean;
  87121. /**
  87122. * Stores the value for side orientation
  87123. */
  87124. sideOrientation: number;
  87125. /**
  87126. * Callback triggered when the material is compiled
  87127. */
  87128. onCompiled: Nullable<(effect: Effect) => void>;
  87129. /**
  87130. * Callback triggered when an error occurs
  87131. */
  87132. onError: Nullable<(effect: Effect, errors: string) => void>;
  87133. /**
  87134. * Callback triggered to get the render target textures
  87135. */
  87136. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  87137. /**
  87138. * Gets a boolean indicating that current material needs to register RTT
  87139. */
  87140. readonly hasRenderTargetTextures: boolean;
  87141. /**
  87142. * Specifies if the material should be serialized
  87143. */
  87144. doNotSerialize: boolean;
  87145. /**
  87146. * @hidden
  87147. */
  87148. _storeEffectOnSubMeshes: boolean;
  87149. /**
  87150. * Stores the animations for the material
  87151. */
  87152. animations: Nullable<Array<Animation>>;
  87153. /**
  87154. * An event triggered when the material is disposed
  87155. */
  87156. onDisposeObservable: Observable<Material>;
  87157. /**
  87158. * An observer which watches for dispose events
  87159. */
  87160. private _onDisposeObserver;
  87161. private _onUnBindObservable;
  87162. /**
  87163. * Called during a dispose event
  87164. */
  87165. onDispose: () => void;
  87166. private _onBindObservable;
  87167. /**
  87168. * An event triggered when the material is bound
  87169. */
  87170. readonly onBindObservable: Observable<AbstractMesh>;
  87171. /**
  87172. * An observer which watches for bind events
  87173. */
  87174. private _onBindObserver;
  87175. /**
  87176. * Called during a bind event
  87177. */
  87178. onBind: (Mesh: AbstractMesh) => void;
  87179. /**
  87180. * An event triggered when the material is unbound
  87181. */
  87182. readonly onUnBindObservable: Observable<Material>;
  87183. /**
  87184. * Stores the value of the alpha mode
  87185. */
  87186. private _alphaMode;
  87187. /**
  87188. * Sets the value of the alpha mode.
  87189. *
  87190. * | Value | Type | Description |
  87191. * | --- | --- | --- |
  87192. * | 0 | ALPHA_DISABLE | |
  87193. * | 1 | ALPHA_ADD | |
  87194. * | 2 | ALPHA_COMBINE | |
  87195. * | 3 | ALPHA_SUBTRACT | |
  87196. * | 4 | ALPHA_MULTIPLY | |
  87197. * | 5 | ALPHA_MAXIMIZED | |
  87198. * | 6 | ALPHA_ONEONE | |
  87199. * | 7 | ALPHA_PREMULTIPLIED | |
  87200. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  87201. * | 9 | ALPHA_INTERPOLATE | |
  87202. * | 10 | ALPHA_SCREENMODE | |
  87203. *
  87204. */
  87205. /**
  87206. * Gets the value of the alpha mode
  87207. */
  87208. alphaMode: number;
  87209. /**
  87210. * Stores the state of the need depth pre-pass value
  87211. */
  87212. private _needDepthPrePass;
  87213. /**
  87214. * Sets the need depth pre-pass value
  87215. */
  87216. /**
  87217. * Gets the depth pre-pass value
  87218. */
  87219. needDepthPrePass: boolean;
  87220. /**
  87221. * Specifies if depth writing should be disabled
  87222. */
  87223. disableDepthWrite: boolean;
  87224. /**
  87225. * Specifies if depth writing should be forced
  87226. */
  87227. forceDepthWrite: boolean;
  87228. /**
  87229. * Specifies if there should be a separate pass for culling
  87230. */
  87231. separateCullingPass: boolean;
  87232. /**
  87233. * Stores the state specifing if fog should be enabled
  87234. */
  87235. private _fogEnabled;
  87236. /**
  87237. * Sets the state for enabling fog
  87238. */
  87239. /**
  87240. * Gets the value of the fog enabled state
  87241. */
  87242. fogEnabled: boolean;
  87243. /**
  87244. * Stores the size of points
  87245. */
  87246. pointSize: number;
  87247. /**
  87248. * Stores the z offset value
  87249. */
  87250. zOffset: number;
  87251. /**
  87252. * Gets a value specifying if wireframe mode is enabled
  87253. */
  87254. /**
  87255. * Sets the state of wireframe mode
  87256. */
  87257. wireframe: boolean;
  87258. /**
  87259. * Gets the value specifying if point clouds are enabled
  87260. */
  87261. /**
  87262. * Sets the state of point cloud mode
  87263. */
  87264. pointsCloud: boolean;
  87265. /**
  87266. * Gets the material fill mode
  87267. */
  87268. /**
  87269. * Sets the material fill mode
  87270. */
  87271. fillMode: number;
  87272. /**
  87273. * @hidden
  87274. * Stores the effects for the material
  87275. */
  87276. _effect: Nullable<Effect>;
  87277. /**
  87278. * @hidden
  87279. * Specifies if the material was previously ready
  87280. */
  87281. _wasPreviouslyReady: boolean;
  87282. /**
  87283. * Specifies if uniform buffers should be used
  87284. */
  87285. private _useUBO;
  87286. /**
  87287. * Stores a reference to the scene
  87288. */
  87289. private _scene;
  87290. /**
  87291. * Stores the fill mode state
  87292. */
  87293. private _fillMode;
  87294. /**
  87295. * Specifies if the depth write state should be cached
  87296. */
  87297. private _cachedDepthWriteState;
  87298. /**
  87299. * Stores the uniform buffer
  87300. */
  87301. protected _uniformBuffer: UniformBuffer;
  87302. /** @hidden */
  87303. _indexInSceneMaterialArray: number;
  87304. /** @hidden */
  87305. meshMap: Nullable<{
  87306. [id: string]: AbstractMesh | undefined;
  87307. }>;
  87308. /**
  87309. * Creates a material instance
  87310. * @param name defines the name of the material
  87311. * @param scene defines the scene to reference
  87312. * @param doNotAdd specifies if the material should be added to the scene
  87313. */
  87314. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  87315. /**
  87316. * Returns a string representation of the current material
  87317. * @param fullDetails defines a boolean indicating which levels of logging is desired
  87318. * @returns a string with material information
  87319. */
  87320. toString(fullDetails?: boolean): string;
  87321. /**
  87322. * Gets the class name of the material
  87323. * @returns a string with the class name of the material
  87324. */
  87325. getClassName(): string;
  87326. /**
  87327. * Specifies if updates for the material been locked
  87328. */
  87329. readonly isFrozen: boolean;
  87330. /**
  87331. * Locks updates for the material
  87332. */
  87333. freeze(): void;
  87334. /**
  87335. * Unlocks updates for the material
  87336. */
  87337. unfreeze(): void;
  87338. /**
  87339. * Specifies if the material is ready to be used
  87340. * @param mesh defines the mesh to check
  87341. * @param useInstances specifies if instances should be used
  87342. * @returns a boolean indicating if the material is ready to be used
  87343. */
  87344. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  87345. /**
  87346. * Specifies that the submesh is ready to be used
  87347. * @param mesh defines the mesh to check
  87348. * @param subMesh defines which submesh to check
  87349. * @param useInstances specifies that instances should be used
  87350. * @returns a boolean indicating that the submesh is ready or not
  87351. */
  87352. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87353. /**
  87354. * Returns the material effect
  87355. * @returns the effect associated with the material
  87356. */
  87357. getEffect(): Nullable<Effect>;
  87358. /**
  87359. * Returns the current scene
  87360. * @returns a Scene
  87361. */
  87362. getScene(): Scene;
  87363. /**
  87364. * Specifies if the material will require alpha blending
  87365. * @returns a boolean specifying if alpha blending is needed
  87366. */
  87367. needAlphaBlending(): boolean;
  87368. /**
  87369. * Specifies if the mesh will require alpha blending
  87370. * @param mesh defines the mesh to check
  87371. * @returns a boolean specifying if alpha blending is needed for the mesh
  87372. */
  87373. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  87374. /**
  87375. * Specifies if this material should be rendered in alpha test mode
  87376. * @returns a boolean specifying if an alpha test is needed.
  87377. */
  87378. needAlphaTesting(): boolean;
  87379. /**
  87380. * Gets the texture used for the alpha test
  87381. * @returns the texture to use for alpha testing
  87382. */
  87383. getAlphaTestTexture(): Nullable<BaseTexture>;
  87384. /**
  87385. * Marks the material to indicate that it needs to be re-calculated
  87386. */
  87387. markDirty(): void;
  87388. /** @hidden */
  87389. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  87390. /**
  87391. * Binds the material to the mesh
  87392. * @param world defines the world transformation matrix
  87393. * @param mesh defines the mesh to bind the material to
  87394. */
  87395. bind(world: Matrix, mesh?: Mesh): void;
  87396. /**
  87397. * Binds the submesh to the material
  87398. * @param world defines the world transformation matrix
  87399. * @param mesh defines the mesh containing the submesh
  87400. * @param subMesh defines the submesh to bind the material to
  87401. */
  87402. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  87403. /**
  87404. * Binds the world matrix to the material
  87405. * @param world defines the world transformation matrix
  87406. */
  87407. bindOnlyWorldMatrix(world: Matrix): void;
  87408. /**
  87409. * Binds the scene's uniform buffer to the effect.
  87410. * @param effect defines the effect to bind to the scene uniform buffer
  87411. * @param sceneUbo defines the uniform buffer storing scene data
  87412. */
  87413. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  87414. /**
  87415. * Binds the view matrix to the effect
  87416. * @param effect defines the effect to bind the view matrix to
  87417. */
  87418. bindView(effect: Effect): void;
  87419. /**
  87420. * Binds the view projection matrix to the effect
  87421. * @param effect defines the effect to bind the view projection matrix to
  87422. */
  87423. bindViewProjection(effect: Effect): void;
  87424. /**
  87425. * Specifies if material alpha testing should be turned on for the mesh
  87426. * @param mesh defines the mesh to check
  87427. */
  87428. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  87429. /**
  87430. * Processes to execute after binding the material to a mesh
  87431. * @param mesh defines the rendered mesh
  87432. */
  87433. protected _afterBind(mesh?: Mesh): void;
  87434. /**
  87435. * Unbinds the material from the mesh
  87436. */
  87437. unbind(): void;
  87438. /**
  87439. * Gets the active textures from the material
  87440. * @returns an array of textures
  87441. */
  87442. getActiveTextures(): BaseTexture[];
  87443. /**
  87444. * Specifies if the material uses a texture
  87445. * @param texture defines the texture to check against the material
  87446. * @returns a boolean specifying if the material uses the texture
  87447. */
  87448. hasTexture(texture: BaseTexture): boolean;
  87449. /**
  87450. * Makes a duplicate of the material, and gives it a new name
  87451. * @param name defines the new name for the duplicated material
  87452. * @returns the cloned material
  87453. */
  87454. clone(name: string): Nullable<Material>;
  87455. /**
  87456. * Gets the meshes bound to the material
  87457. * @returns an array of meshes bound to the material
  87458. */
  87459. getBindedMeshes(): AbstractMesh[];
  87460. /**
  87461. * Force shader compilation
  87462. * @param mesh defines the mesh associated with this material
  87463. * @param onCompiled defines a function to execute once the material is compiled
  87464. * @param options defines the options to configure the compilation
  87465. */
  87466. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  87467. clipPlane: boolean;
  87468. }>): void;
  87469. /**
  87470. * Force shader compilation
  87471. * @param mesh defines the mesh that will use this material
  87472. * @param options defines additional options for compiling the shaders
  87473. * @returns a promise that resolves when the compilation completes
  87474. */
  87475. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  87476. clipPlane: boolean;
  87477. }>): Promise<void>;
  87478. private static readonly _AllDirtyCallBack;
  87479. private static readonly _ImageProcessingDirtyCallBack;
  87480. private static readonly _TextureDirtyCallBack;
  87481. private static readonly _FresnelDirtyCallBack;
  87482. private static readonly _MiscDirtyCallBack;
  87483. private static readonly _LightsDirtyCallBack;
  87484. private static readonly _AttributeDirtyCallBack;
  87485. private static _FresnelAndMiscDirtyCallBack;
  87486. private static _TextureAndMiscDirtyCallBack;
  87487. private static readonly _DirtyCallbackArray;
  87488. private static readonly _RunDirtyCallBacks;
  87489. /**
  87490. * Marks a define in the material to indicate that it needs to be re-computed
  87491. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  87492. */
  87493. markAsDirty(flag: number): void;
  87494. /**
  87495. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  87496. * @param func defines a function which checks material defines against the submeshes
  87497. */
  87498. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  87499. /**
  87500. * Indicates that we need to re-calculated for all submeshes
  87501. */
  87502. protected _markAllSubMeshesAsAllDirty(): void;
  87503. /**
  87504. * Indicates that image processing needs to be re-calculated for all submeshes
  87505. */
  87506. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  87507. /**
  87508. * Indicates that textures need to be re-calculated for all submeshes
  87509. */
  87510. protected _markAllSubMeshesAsTexturesDirty(): void;
  87511. /**
  87512. * Indicates that fresnel needs to be re-calculated for all submeshes
  87513. */
  87514. protected _markAllSubMeshesAsFresnelDirty(): void;
  87515. /**
  87516. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  87517. */
  87518. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  87519. /**
  87520. * Indicates that lights need to be re-calculated for all submeshes
  87521. */
  87522. protected _markAllSubMeshesAsLightsDirty(): void;
  87523. /**
  87524. * Indicates that attributes need to be re-calculated for all submeshes
  87525. */
  87526. protected _markAllSubMeshesAsAttributesDirty(): void;
  87527. /**
  87528. * Indicates that misc needs to be re-calculated for all submeshes
  87529. */
  87530. protected _markAllSubMeshesAsMiscDirty(): void;
  87531. /**
  87532. * Indicates that textures and misc need to be re-calculated for all submeshes
  87533. */
  87534. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  87535. /**
  87536. * Disposes the material
  87537. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  87538. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  87539. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  87540. */
  87541. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  87542. /** @hidden */
  87543. private releaseVertexArrayObject;
  87544. /**
  87545. * Serializes this material
  87546. * @returns the serialized material object
  87547. */
  87548. serialize(): any;
  87549. /**
  87550. * Creates a material from parsed material data
  87551. * @param parsedMaterial defines parsed material data
  87552. * @param scene defines the hosting scene
  87553. * @param rootUrl defines the root URL to use to load textures
  87554. * @returns a new material
  87555. */
  87556. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  87557. }
  87558. }
  87559. declare module BABYLON {
  87560. /**
  87561. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87562. * separate meshes. This can be use to improve performances.
  87563. * @see http://doc.babylonjs.com/how_to/multi_materials
  87564. */
  87565. export class MultiMaterial extends Material {
  87566. private _subMaterials;
  87567. /**
  87568. * Gets or Sets the list of Materials used within the multi material.
  87569. * They need to be ordered according to the submeshes order in the associated mesh
  87570. */
  87571. subMaterials: Nullable<Material>[];
  87572. /**
  87573. * Function used to align with Node.getChildren()
  87574. * @returns the list of Materials used within the multi material
  87575. */
  87576. getChildren(): Nullable<Material>[];
  87577. /**
  87578. * Instantiates a new Multi Material
  87579. * A multi-material is used to apply different materials to different parts of the same object without the need of
  87580. * separate meshes. This can be use to improve performances.
  87581. * @see http://doc.babylonjs.com/how_to/multi_materials
  87582. * @param name Define the name in the scene
  87583. * @param scene Define the scene the material belongs to
  87584. */
  87585. constructor(name: string, scene: Scene);
  87586. private _hookArray;
  87587. /**
  87588. * Get one of the submaterial by its index in the submaterials array
  87589. * @param index The index to look the sub material at
  87590. * @returns The Material if the index has been defined
  87591. */
  87592. getSubMaterial(index: number): Nullable<Material>;
  87593. /**
  87594. * Get the list of active textures for the whole sub materials list.
  87595. * @returns All the textures that will be used during the rendering
  87596. */
  87597. getActiveTextures(): BaseTexture[];
  87598. /**
  87599. * Gets the current class name of the material e.g. "MultiMaterial"
  87600. * Mainly use in serialization.
  87601. * @returns the class name
  87602. */
  87603. getClassName(): string;
  87604. /**
  87605. * Checks if the material is ready to render the requested sub mesh
  87606. * @param mesh Define the mesh the submesh belongs to
  87607. * @param subMesh Define the sub mesh to look readyness for
  87608. * @param useInstances Define whether or not the material is used with instances
  87609. * @returns true if ready, otherwise false
  87610. */
  87611. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  87612. /**
  87613. * Clones the current material and its related sub materials
  87614. * @param name Define the name of the newly cloned material
  87615. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  87616. * @returns the cloned material
  87617. */
  87618. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  87619. /**
  87620. * Serializes the materials into a JSON representation.
  87621. * @returns the JSON representation
  87622. */
  87623. serialize(): any;
  87624. /**
  87625. * Dispose the material and release its associated resources
  87626. * @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)
  87627. * @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)
  87628. * @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)
  87629. */
  87630. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  87631. /**
  87632. * Creates a MultiMaterial from parsed MultiMaterial data.
  87633. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  87634. * @param scene defines the hosting scene
  87635. * @returns a new MultiMaterial
  87636. */
  87637. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  87638. }
  87639. }
  87640. declare module BABYLON {
  87641. /**
  87642. * Base class for submeshes
  87643. */
  87644. export class BaseSubMesh {
  87645. /** @hidden */
  87646. _materialDefines: Nullable<MaterialDefines>;
  87647. /** @hidden */
  87648. _materialEffect: Nullable<Effect>;
  87649. /**
  87650. * Gets associated effect
  87651. */
  87652. readonly effect: Nullable<Effect>;
  87653. /**
  87654. * Sets associated effect (effect used to render this submesh)
  87655. * @param effect defines the effect to associate with
  87656. * @param defines defines the set of defines used to compile this effect
  87657. */
  87658. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  87659. }
  87660. /**
  87661. * Defines a subdivision inside a mesh
  87662. */
  87663. export class SubMesh extends BaseSubMesh implements ICullable {
  87664. /** the material index to use */
  87665. materialIndex: number;
  87666. /** vertex index start */
  87667. verticesStart: number;
  87668. /** vertices count */
  87669. verticesCount: number;
  87670. /** index start */
  87671. indexStart: number;
  87672. /** indices count */
  87673. indexCount: number;
  87674. /** @hidden */
  87675. _linesIndexCount: number;
  87676. private _mesh;
  87677. private _renderingMesh;
  87678. private _boundingInfo;
  87679. private _linesIndexBuffer;
  87680. /** @hidden */
  87681. _lastColliderWorldVertices: Nullable<Vector3[]>;
  87682. /** @hidden */
  87683. _trianglePlanes: Plane[];
  87684. /** @hidden */
  87685. _lastColliderTransformMatrix: Nullable<Matrix>;
  87686. /** @hidden */
  87687. _renderId: number;
  87688. /** @hidden */
  87689. _alphaIndex: number;
  87690. /** @hidden */
  87691. _distanceToCamera: number;
  87692. /** @hidden */
  87693. _id: number;
  87694. private _currentMaterial;
  87695. /**
  87696. * Add a new submesh to a mesh
  87697. * @param materialIndex defines the material index to use
  87698. * @param verticesStart defines vertex index start
  87699. * @param verticesCount defines vertices count
  87700. * @param indexStart defines index start
  87701. * @param indexCount defines indices count
  87702. * @param mesh defines the parent mesh
  87703. * @param renderingMesh defines an optional rendering mesh
  87704. * @param createBoundingBox defines if bounding box should be created for this submesh
  87705. * @returns the new submesh
  87706. */
  87707. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  87708. /**
  87709. * Creates a new submesh
  87710. * @param materialIndex defines the material index to use
  87711. * @param verticesStart defines vertex index start
  87712. * @param verticesCount defines vertices count
  87713. * @param indexStart defines index start
  87714. * @param indexCount defines indices count
  87715. * @param mesh defines the parent mesh
  87716. * @param renderingMesh defines an optional rendering mesh
  87717. * @param createBoundingBox defines if bounding box should be created for this submesh
  87718. */
  87719. constructor(
  87720. /** the material index to use */
  87721. materialIndex: number,
  87722. /** vertex index start */
  87723. verticesStart: number,
  87724. /** vertices count */
  87725. verticesCount: number,
  87726. /** index start */
  87727. indexStart: number,
  87728. /** indices count */
  87729. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  87730. /**
  87731. * Returns true if this submesh covers the entire parent mesh
  87732. * @ignorenaming
  87733. */
  87734. readonly IsGlobal: boolean;
  87735. /**
  87736. * Returns the submesh BoudingInfo object
  87737. * @returns current bounding info (or mesh's one if the submesh is global)
  87738. */
  87739. getBoundingInfo(): BoundingInfo;
  87740. /**
  87741. * Sets the submesh BoundingInfo
  87742. * @param boundingInfo defines the new bounding info to use
  87743. * @returns the SubMesh
  87744. */
  87745. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  87746. /**
  87747. * Returns the mesh of the current submesh
  87748. * @return the parent mesh
  87749. */
  87750. getMesh(): AbstractMesh;
  87751. /**
  87752. * Returns the rendering mesh of the submesh
  87753. * @returns the rendering mesh (could be different from parent mesh)
  87754. */
  87755. getRenderingMesh(): Mesh;
  87756. /**
  87757. * Returns the submesh material
  87758. * @returns null or the current material
  87759. */
  87760. getMaterial(): Nullable<Material>;
  87761. /**
  87762. * Sets a new updated BoundingInfo object to the submesh
  87763. * @param data defines an optional position array to use to determine the bounding info
  87764. * @returns the SubMesh
  87765. */
  87766. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  87767. /** @hidden */
  87768. _checkCollision(collider: Collider): boolean;
  87769. /**
  87770. * Updates the submesh BoundingInfo
  87771. * @param world defines the world matrix to use to update the bounding info
  87772. * @returns the submesh
  87773. */
  87774. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  87775. /**
  87776. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  87777. * @param frustumPlanes defines the frustum planes
  87778. * @returns true if the submesh is intersecting with the frustum
  87779. */
  87780. isInFrustum(frustumPlanes: Plane[]): boolean;
  87781. /**
  87782. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  87783. * @param frustumPlanes defines the frustum planes
  87784. * @returns true if the submesh is inside the frustum
  87785. */
  87786. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87787. /**
  87788. * Renders the submesh
  87789. * @param enableAlphaMode defines if alpha needs to be used
  87790. * @returns the submesh
  87791. */
  87792. render(enableAlphaMode: boolean): SubMesh;
  87793. /**
  87794. * @hidden
  87795. */
  87796. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  87797. /**
  87798. * Checks if the submesh intersects with a ray
  87799. * @param ray defines the ray to test
  87800. * @returns true is the passed ray intersects the submesh bounding box
  87801. */
  87802. canIntersects(ray: Ray): boolean;
  87803. /**
  87804. * Intersects current submesh with a ray
  87805. * @param ray defines the ray to test
  87806. * @param positions defines mesh's positions array
  87807. * @param indices defines mesh's indices array
  87808. * @param fastCheck defines if only bounding info should be used
  87809. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  87810. * @returns intersection info or null if no intersection
  87811. */
  87812. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  87813. /** @hidden */
  87814. private _intersectLines;
  87815. /** @hidden */
  87816. private _intersectUnIndexedLines;
  87817. /** @hidden */
  87818. private _intersectTriangles;
  87819. /** @hidden */
  87820. private _intersectUnIndexedTriangles;
  87821. /** @hidden */
  87822. _rebuild(): void;
  87823. /**
  87824. * Creates a new submesh from the passed mesh
  87825. * @param newMesh defines the new hosting mesh
  87826. * @param newRenderingMesh defines an optional rendering mesh
  87827. * @returns the new submesh
  87828. */
  87829. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  87830. /**
  87831. * Release associated resources
  87832. */
  87833. dispose(): void;
  87834. /**
  87835. * Gets the class name
  87836. * @returns the string "SubMesh".
  87837. */
  87838. getClassName(): string;
  87839. /**
  87840. * Creates a new submesh from indices data
  87841. * @param materialIndex the index of the main mesh material
  87842. * @param startIndex the index where to start the copy in the mesh indices array
  87843. * @param indexCount the number of indices to copy then from the startIndex
  87844. * @param mesh the main mesh to create the submesh from
  87845. * @param renderingMesh the optional rendering mesh
  87846. * @returns a new submesh
  87847. */
  87848. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  87849. }
  87850. }
  87851. declare module BABYLON {
  87852. /**
  87853. * Class used to represent data loading progression
  87854. */
  87855. export class SceneLoaderFlags {
  87856. private static _ForceFullSceneLoadingForIncremental;
  87857. private static _ShowLoadingScreen;
  87858. private static _CleanBoneMatrixWeights;
  87859. private static _loggingLevel;
  87860. /**
  87861. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  87862. */
  87863. static ForceFullSceneLoadingForIncremental: boolean;
  87864. /**
  87865. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  87866. */
  87867. static ShowLoadingScreen: boolean;
  87868. /**
  87869. * Defines the current logging level (while loading the scene)
  87870. * @ignorenaming
  87871. */
  87872. static loggingLevel: number;
  87873. /**
  87874. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  87875. */
  87876. static CleanBoneMatrixWeights: boolean;
  87877. }
  87878. }
  87879. declare module BABYLON {
  87880. /**
  87881. * Class used to store geometry data (vertex buffers + index buffer)
  87882. */
  87883. export class Geometry implements IGetSetVerticesData {
  87884. /**
  87885. * Gets or sets the ID of the geometry
  87886. */
  87887. id: string;
  87888. /**
  87889. * Gets or sets the unique ID of the geometry
  87890. */
  87891. uniqueId: number;
  87892. /**
  87893. * Gets the delay loading state of the geometry (none by default which means not delayed)
  87894. */
  87895. delayLoadState: number;
  87896. /**
  87897. * Gets the file containing the data to load when running in delay load state
  87898. */
  87899. delayLoadingFile: Nullable<string>;
  87900. /**
  87901. * Callback called when the geometry is updated
  87902. */
  87903. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  87904. private _scene;
  87905. private _engine;
  87906. private _meshes;
  87907. private _totalVertices;
  87908. /** @hidden */
  87909. _indices: IndicesArray;
  87910. /** @hidden */
  87911. _vertexBuffers: {
  87912. [key: string]: VertexBuffer;
  87913. };
  87914. private _isDisposed;
  87915. private _extend;
  87916. private _boundingBias;
  87917. /** @hidden */
  87918. _delayInfo: Array<string>;
  87919. private _indexBuffer;
  87920. private _indexBufferIsUpdatable;
  87921. /** @hidden */
  87922. _boundingInfo: Nullable<BoundingInfo>;
  87923. /** @hidden */
  87924. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  87925. /** @hidden */
  87926. _softwareSkinningFrameId: number;
  87927. private _vertexArrayObjects;
  87928. private _updatable;
  87929. /** @hidden */
  87930. _positions: Nullable<Vector3[]>;
  87931. /**
  87932. * 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
  87933. */
  87934. /**
  87935. * 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
  87936. */
  87937. boundingBias: Vector2;
  87938. /**
  87939. * Static function used to attach a new empty geometry to a mesh
  87940. * @param mesh defines the mesh to attach the geometry to
  87941. * @returns the new Geometry
  87942. */
  87943. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  87944. /**
  87945. * Creates a new geometry
  87946. * @param id defines the unique ID
  87947. * @param scene defines the hosting scene
  87948. * @param vertexData defines the VertexData used to get geometry data
  87949. * @param updatable defines if geometry must be updatable (false by default)
  87950. * @param mesh defines the mesh that will be associated with the geometry
  87951. */
  87952. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  87953. /**
  87954. * Gets the current extend of the geometry
  87955. */
  87956. readonly extend: {
  87957. minimum: Vector3;
  87958. maximum: Vector3;
  87959. };
  87960. /**
  87961. * Gets the hosting scene
  87962. * @returns the hosting Scene
  87963. */
  87964. getScene(): Scene;
  87965. /**
  87966. * Gets the hosting engine
  87967. * @returns the hosting Engine
  87968. */
  87969. getEngine(): Engine;
  87970. /**
  87971. * Defines if the geometry is ready to use
  87972. * @returns true if the geometry is ready to be used
  87973. */
  87974. isReady(): boolean;
  87975. /**
  87976. * Gets a value indicating that the geometry should not be serialized
  87977. */
  87978. readonly doNotSerialize: boolean;
  87979. /** @hidden */
  87980. _rebuild(): void;
  87981. /**
  87982. * Affects all geometry data in one call
  87983. * @param vertexData defines the geometry data
  87984. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  87985. */
  87986. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  87987. /**
  87988. * Set specific vertex data
  87989. * @param kind defines the data kind (Position, normal, etc...)
  87990. * @param data defines the vertex data to use
  87991. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  87992. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  87993. */
  87994. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  87995. /**
  87996. * Removes a specific vertex data
  87997. * @param kind defines the data kind (Position, normal, etc...)
  87998. */
  87999. removeVerticesData(kind: string): void;
  88000. /**
  88001. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  88002. * @param buffer defines the vertex buffer to use
  88003. * @param totalVertices defines the total number of vertices for position kind (could be null)
  88004. */
  88005. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  88006. /**
  88007. * Update a specific vertex buffer
  88008. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  88009. * It will do nothing if the buffer is not updatable
  88010. * @param kind defines the data kind (Position, normal, etc...)
  88011. * @param data defines the data to use
  88012. * @param offset defines the offset in the target buffer where to store the data
  88013. * @param useBytes set to true if the offset is in bytes
  88014. */
  88015. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  88016. /**
  88017. * Update a specific vertex buffer
  88018. * This function will create a new buffer if the current one is not updatable
  88019. * @param kind defines the data kind (Position, normal, etc...)
  88020. * @param data defines the data to use
  88021. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  88022. */
  88023. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  88024. private _updateBoundingInfo;
  88025. /** @hidden */
  88026. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  88027. /**
  88028. * Gets total number of vertices
  88029. * @returns the total number of vertices
  88030. */
  88031. getTotalVertices(): number;
  88032. /**
  88033. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88034. * @param kind defines the data kind (Position, normal, etc...)
  88035. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88036. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88037. * @returns a float array containing vertex data
  88038. */
  88039. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88040. /**
  88041. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  88042. * @param kind defines the data kind (Position, normal, etc...)
  88043. * @returns true if the vertex buffer with the specified kind is updatable
  88044. */
  88045. isVertexBufferUpdatable(kind: string): boolean;
  88046. /**
  88047. * Gets a specific vertex buffer
  88048. * @param kind defines the data kind (Position, normal, etc...)
  88049. * @returns a VertexBuffer
  88050. */
  88051. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  88052. /**
  88053. * Returns all vertex buffers
  88054. * @return an object holding all vertex buffers indexed by kind
  88055. */
  88056. getVertexBuffers(): Nullable<{
  88057. [key: string]: VertexBuffer;
  88058. }>;
  88059. /**
  88060. * Gets a boolean indicating if specific vertex buffer is present
  88061. * @param kind defines the data kind (Position, normal, etc...)
  88062. * @returns true if data is present
  88063. */
  88064. isVerticesDataPresent(kind: string): boolean;
  88065. /**
  88066. * Gets a list of all attached data kinds (Position, normal, etc...)
  88067. * @returns a list of string containing all kinds
  88068. */
  88069. getVerticesDataKinds(): string[];
  88070. /**
  88071. * Update index buffer
  88072. * @param indices defines the indices to store in the index buffer
  88073. * @param offset defines the offset in the target buffer where to store the data
  88074. * @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)
  88075. */
  88076. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  88077. /**
  88078. * Creates a new index buffer
  88079. * @param indices defines the indices to store in the index buffer
  88080. * @param totalVertices defines the total number of vertices (could be null)
  88081. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88082. */
  88083. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  88084. /**
  88085. * Return the total number of indices
  88086. * @returns the total number of indices
  88087. */
  88088. getTotalIndices(): number;
  88089. /**
  88090. * Gets the index buffer array
  88091. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88092. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88093. * @returns the index buffer array
  88094. */
  88095. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88096. /**
  88097. * Gets the index buffer
  88098. * @return the index buffer
  88099. */
  88100. getIndexBuffer(): Nullable<DataBuffer>;
  88101. /** @hidden */
  88102. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  88103. /**
  88104. * Release the associated resources for a specific mesh
  88105. * @param mesh defines the source mesh
  88106. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  88107. */
  88108. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  88109. /**
  88110. * Apply current geometry to a given mesh
  88111. * @param mesh defines the mesh to apply geometry to
  88112. */
  88113. applyToMesh(mesh: Mesh): void;
  88114. private _updateExtend;
  88115. private _applyToMesh;
  88116. private notifyUpdate;
  88117. /**
  88118. * Load the geometry if it was flagged as delay loaded
  88119. * @param scene defines the hosting scene
  88120. * @param onLoaded defines a callback called when the geometry is loaded
  88121. */
  88122. load(scene: Scene, onLoaded?: () => void): void;
  88123. private _queueLoad;
  88124. /**
  88125. * Invert the geometry to move from a right handed system to a left handed one.
  88126. */
  88127. toLeftHanded(): void;
  88128. /** @hidden */
  88129. _resetPointsArrayCache(): void;
  88130. /** @hidden */
  88131. _generatePointsArray(): boolean;
  88132. /**
  88133. * Gets a value indicating if the geometry is disposed
  88134. * @returns true if the geometry was disposed
  88135. */
  88136. isDisposed(): boolean;
  88137. private _disposeVertexArrayObjects;
  88138. /**
  88139. * Free all associated resources
  88140. */
  88141. dispose(): void;
  88142. /**
  88143. * Clone the current geometry into a new geometry
  88144. * @param id defines the unique ID of the new geometry
  88145. * @returns a new geometry object
  88146. */
  88147. copy(id: string): Geometry;
  88148. /**
  88149. * Serialize the current geometry info (and not the vertices data) into a JSON object
  88150. * @return a JSON representation of the current geometry data (without the vertices data)
  88151. */
  88152. serialize(): any;
  88153. private toNumberArray;
  88154. /**
  88155. * Serialize all vertices data into a JSON oject
  88156. * @returns a JSON representation of the current geometry data
  88157. */
  88158. serializeVerticeData(): any;
  88159. /**
  88160. * Extracts a clone of a mesh geometry
  88161. * @param mesh defines the source mesh
  88162. * @param id defines the unique ID of the new geometry object
  88163. * @returns the new geometry object
  88164. */
  88165. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  88166. /**
  88167. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  88168. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  88169. * Be aware Math.random() could cause collisions, but:
  88170. * "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"
  88171. * @returns a string containing a new GUID
  88172. */
  88173. static RandomId(): string;
  88174. /** @hidden */
  88175. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  88176. private static _CleanMatricesWeights;
  88177. /**
  88178. * Create a new geometry from persisted data (Using .babylon file format)
  88179. * @param parsedVertexData defines the persisted data
  88180. * @param scene defines the hosting scene
  88181. * @param rootUrl defines the root url to use to load assets (like delayed data)
  88182. * @returns the new geometry object
  88183. */
  88184. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  88185. }
  88186. }
  88187. declare module BABYLON {
  88188. /**
  88189. * Define an interface for all classes that will get and set the data on vertices
  88190. */
  88191. export interface IGetSetVerticesData {
  88192. /**
  88193. * Gets a boolean indicating if specific vertex data is present
  88194. * @param kind defines the vertex data kind to use
  88195. * @returns true is data kind is present
  88196. */
  88197. isVerticesDataPresent(kind: string): boolean;
  88198. /**
  88199. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  88200. * @param kind defines the data kind (Position, normal, etc...)
  88201. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  88202. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88203. * @returns a float array containing vertex data
  88204. */
  88205. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  88206. /**
  88207. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  88208. * @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.
  88209. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  88210. * @returns the indices array or an empty array if the mesh has no geometry
  88211. */
  88212. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  88213. /**
  88214. * Set specific vertex data
  88215. * @param kind defines the data kind (Position, normal, etc...)
  88216. * @param data defines the vertex data to use
  88217. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  88218. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  88219. */
  88220. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  88221. /**
  88222. * Update a specific associated vertex buffer
  88223. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  88224. * - VertexBuffer.PositionKind
  88225. * - VertexBuffer.UVKind
  88226. * - VertexBuffer.UV2Kind
  88227. * - VertexBuffer.UV3Kind
  88228. * - VertexBuffer.UV4Kind
  88229. * - VertexBuffer.UV5Kind
  88230. * - VertexBuffer.UV6Kind
  88231. * - VertexBuffer.ColorKind
  88232. * - VertexBuffer.MatricesIndicesKind
  88233. * - VertexBuffer.MatricesIndicesExtraKind
  88234. * - VertexBuffer.MatricesWeightsKind
  88235. * - VertexBuffer.MatricesWeightsExtraKind
  88236. * @param data defines the data source
  88237. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  88238. * @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)
  88239. */
  88240. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  88241. /**
  88242. * Creates a new index buffer
  88243. * @param indices defines the indices to store in the index buffer
  88244. * @param totalVertices defines the total number of vertices (could be null)
  88245. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  88246. */
  88247. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  88248. }
  88249. /**
  88250. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  88251. */
  88252. export class VertexData {
  88253. /**
  88254. * Mesh side orientation : usually the external or front surface
  88255. */
  88256. static readonly FRONTSIDE: number;
  88257. /**
  88258. * Mesh side orientation : usually the internal or back surface
  88259. */
  88260. static readonly BACKSIDE: number;
  88261. /**
  88262. * Mesh side orientation : both internal and external or front and back surfaces
  88263. */
  88264. static readonly DOUBLESIDE: number;
  88265. /**
  88266. * Mesh side orientation : by default, `FRONTSIDE`
  88267. */
  88268. static readonly DEFAULTSIDE: number;
  88269. /**
  88270. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  88271. */
  88272. positions: Nullable<FloatArray>;
  88273. /**
  88274. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  88275. */
  88276. normals: Nullable<FloatArray>;
  88277. /**
  88278. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  88279. */
  88280. tangents: Nullable<FloatArray>;
  88281. /**
  88282. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88283. */
  88284. uvs: Nullable<FloatArray>;
  88285. /**
  88286. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88287. */
  88288. uvs2: Nullable<FloatArray>;
  88289. /**
  88290. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88291. */
  88292. uvs3: Nullable<FloatArray>;
  88293. /**
  88294. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88295. */
  88296. uvs4: Nullable<FloatArray>;
  88297. /**
  88298. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88299. */
  88300. uvs5: Nullable<FloatArray>;
  88301. /**
  88302. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  88303. */
  88304. uvs6: Nullable<FloatArray>;
  88305. /**
  88306. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  88307. */
  88308. colors: Nullable<FloatArray>;
  88309. /**
  88310. * 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).
  88311. */
  88312. matricesIndices: Nullable<FloatArray>;
  88313. /**
  88314. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  88315. */
  88316. matricesWeights: Nullable<FloatArray>;
  88317. /**
  88318. * An array extending the number of possible indices
  88319. */
  88320. matricesIndicesExtra: Nullable<FloatArray>;
  88321. /**
  88322. * An array extending the number of possible weights when the number of indices is extended
  88323. */
  88324. matricesWeightsExtra: Nullable<FloatArray>;
  88325. /**
  88326. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  88327. */
  88328. indices: Nullable<IndicesArray>;
  88329. /**
  88330. * Uses the passed data array to set the set the values for the specified kind of data
  88331. * @param data a linear array of floating numbers
  88332. * @param kind the type of data that is being set, eg positions, colors etc
  88333. */
  88334. set(data: FloatArray, kind: string): void;
  88335. /**
  88336. * Associates the vertexData to the passed Mesh.
  88337. * Sets it as updatable or not (default `false`)
  88338. * @param mesh the mesh the vertexData is applied to
  88339. * @param updatable when used and having the value true allows new data to update the vertexData
  88340. * @returns the VertexData
  88341. */
  88342. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  88343. /**
  88344. * Associates the vertexData to the passed Geometry.
  88345. * Sets it as updatable or not (default `false`)
  88346. * @param geometry the geometry the vertexData is applied to
  88347. * @param updatable when used and having the value true allows new data to update the vertexData
  88348. * @returns VertexData
  88349. */
  88350. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  88351. /**
  88352. * Updates the associated mesh
  88353. * @param mesh the mesh to be updated
  88354. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88355. * @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
  88356. * @returns VertexData
  88357. */
  88358. updateMesh(mesh: Mesh): VertexData;
  88359. /**
  88360. * Updates the associated geometry
  88361. * @param geometry the geometry to be updated
  88362. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  88363. * @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
  88364. * @returns VertexData.
  88365. */
  88366. updateGeometry(geometry: Geometry): VertexData;
  88367. private _applyTo;
  88368. private _update;
  88369. /**
  88370. * Transforms each position and each normal of the vertexData according to the passed Matrix
  88371. * @param matrix the transforming matrix
  88372. * @returns the VertexData
  88373. */
  88374. transform(matrix: Matrix): VertexData;
  88375. /**
  88376. * Merges the passed VertexData into the current one
  88377. * @param other the VertexData to be merged into the current one
  88378. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  88379. * @returns the modified VertexData
  88380. */
  88381. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  88382. private _mergeElement;
  88383. private _validate;
  88384. /**
  88385. * Serializes the VertexData
  88386. * @returns a serialized object
  88387. */
  88388. serialize(): any;
  88389. /**
  88390. * Extracts the vertexData from a mesh
  88391. * @param mesh the mesh from which to extract the VertexData
  88392. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  88393. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88394. * @returns the object VertexData associated to the passed mesh
  88395. */
  88396. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88397. /**
  88398. * Extracts the vertexData from the geometry
  88399. * @param geometry the geometry from which to extract the VertexData
  88400. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  88401. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  88402. * @returns the object VertexData associated to the passed mesh
  88403. */
  88404. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  88405. private static _ExtractFrom;
  88406. /**
  88407. * Creates the VertexData for a Ribbon
  88408. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  88409. * * pathArray array of paths, each of which an array of successive Vector3
  88410. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  88411. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  88412. * * 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
  88413. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88414. * * 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)
  88415. * * 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)
  88416. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  88417. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  88418. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  88419. * @returns the VertexData of the ribbon
  88420. */
  88421. static CreateRibbon(options: {
  88422. pathArray: Vector3[][];
  88423. closeArray?: boolean;
  88424. closePath?: boolean;
  88425. offset?: number;
  88426. sideOrientation?: number;
  88427. frontUVs?: Vector4;
  88428. backUVs?: Vector4;
  88429. invertUV?: boolean;
  88430. uvs?: Vector2[];
  88431. colors?: Color4[];
  88432. }): VertexData;
  88433. /**
  88434. * Creates the VertexData for a box
  88435. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88436. * * size sets the width, height and depth of the box to the value of size, optional default 1
  88437. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  88438. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  88439. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  88440. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88441. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88442. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88443. * * 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)
  88444. * * 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)
  88445. * @returns the VertexData of the box
  88446. */
  88447. static CreateBox(options: {
  88448. size?: number;
  88449. width?: number;
  88450. height?: number;
  88451. depth?: number;
  88452. faceUV?: Vector4[];
  88453. faceColors?: Color4[];
  88454. sideOrientation?: number;
  88455. frontUVs?: Vector4;
  88456. backUVs?: Vector4;
  88457. }): VertexData;
  88458. /**
  88459. * Creates the VertexData for a tiled box
  88460. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88461. * * faceTiles sets the pattern, tile size and number of tiles for a face
  88462. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  88463. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  88464. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88465. * @returns the VertexData of the box
  88466. */
  88467. static CreateTiledBox(options: {
  88468. pattern?: number;
  88469. width?: number;
  88470. height?: number;
  88471. depth?: number;
  88472. tileSize?: number;
  88473. tileWidth?: number;
  88474. tileHeight?: number;
  88475. alignHorizontal?: number;
  88476. alignVertical?: number;
  88477. faceUV?: Vector4[];
  88478. faceColors?: Color4[];
  88479. sideOrientation?: number;
  88480. }): VertexData;
  88481. /**
  88482. * Creates the VertexData for a tiled plane
  88483. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88484. * * pattern a limited pattern arrangement depending on the number
  88485. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  88486. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  88487. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  88488. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88489. * * 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)
  88490. * * 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)
  88491. * @returns the VertexData of the tiled plane
  88492. */
  88493. static CreateTiledPlane(options: {
  88494. pattern?: number;
  88495. tileSize?: number;
  88496. tileWidth?: number;
  88497. tileHeight?: number;
  88498. size?: number;
  88499. width?: number;
  88500. height?: number;
  88501. alignHorizontal?: number;
  88502. alignVertical?: number;
  88503. sideOrientation?: number;
  88504. frontUVs?: Vector4;
  88505. backUVs?: Vector4;
  88506. }): VertexData;
  88507. /**
  88508. * Creates the VertexData for an ellipsoid, defaults to a sphere
  88509. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88510. * * segments sets the number of horizontal strips optional, default 32
  88511. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  88512. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88513. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88514. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88515. * * 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
  88516. * * 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
  88517. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88518. * * 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)
  88519. * * 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)
  88520. * @returns the VertexData of the ellipsoid
  88521. */
  88522. static CreateSphere(options: {
  88523. segments?: number;
  88524. diameter?: number;
  88525. diameterX?: number;
  88526. diameterY?: number;
  88527. diameterZ?: number;
  88528. arc?: number;
  88529. slice?: number;
  88530. sideOrientation?: number;
  88531. frontUVs?: Vector4;
  88532. backUVs?: Vector4;
  88533. }): VertexData;
  88534. /**
  88535. * Creates the VertexData for a cylinder, cone or prism
  88536. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88537. * * height sets the height (y direction) of the cylinder, optional, default 2
  88538. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88539. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88540. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88541. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88542. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88543. * * 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
  88544. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88545. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88546. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88547. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88548. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88549. * * 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)
  88550. * * 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)
  88551. * @returns the VertexData of the cylinder, cone or prism
  88552. */
  88553. static CreateCylinder(options: {
  88554. height?: number;
  88555. diameterTop?: number;
  88556. diameterBottom?: number;
  88557. diameter?: number;
  88558. tessellation?: number;
  88559. subdivisions?: number;
  88560. arc?: number;
  88561. faceColors?: Color4[];
  88562. faceUV?: Vector4[];
  88563. hasRings?: boolean;
  88564. enclose?: boolean;
  88565. sideOrientation?: number;
  88566. frontUVs?: Vector4;
  88567. backUVs?: Vector4;
  88568. }): VertexData;
  88569. /**
  88570. * Creates the VertexData for a torus
  88571. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88572. * * diameter the diameter of the torus, optional default 1
  88573. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88574. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88575. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88576. * * 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)
  88577. * * 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)
  88578. * @returns the VertexData of the torus
  88579. */
  88580. static CreateTorus(options: {
  88581. diameter?: number;
  88582. thickness?: number;
  88583. tessellation?: number;
  88584. sideOrientation?: number;
  88585. frontUVs?: Vector4;
  88586. backUVs?: Vector4;
  88587. }): VertexData;
  88588. /**
  88589. * Creates the VertexData of the LineSystem
  88590. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88591. * - lines an array of lines, each line being an array of successive Vector3
  88592. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88593. * @returns the VertexData of the LineSystem
  88594. */
  88595. static CreateLineSystem(options: {
  88596. lines: Vector3[][];
  88597. colors?: Nullable<Color4[][]>;
  88598. }): VertexData;
  88599. /**
  88600. * Create the VertexData for a DashedLines
  88601. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88602. * - points an array successive Vector3
  88603. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88604. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88605. * - dashNb the intended total number of dashes, optional, default 200
  88606. * @returns the VertexData for the DashedLines
  88607. */
  88608. static CreateDashedLines(options: {
  88609. points: Vector3[];
  88610. dashSize?: number;
  88611. gapSize?: number;
  88612. dashNb?: number;
  88613. }): VertexData;
  88614. /**
  88615. * Creates the VertexData for a Ground
  88616. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88617. * - width the width (x direction) of the ground, optional, default 1
  88618. * - height the height (z direction) of the ground, optional, default 1
  88619. * - subdivisions the number of subdivisions per side, optional, default 1
  88620. * @returns the VertexData of the Ground
  88621. */
  88622. static CreateGround(options: {
  88623. width?: number;
  88624. height?: number;
  88625. subdivisions?: number;
  88626. subdivisionsX?: number;
  88627. subdivisionsY?: number;
  88628. }): VertexData;
  88629. /**
  88630. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88631. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88632. * * xmin the ground minimum X coordinate, optional, default -1
  88633. * * zmin the ground minimum Z coordinate, optional, default -1
  88634. * * xmax the ground maximum X coordinate, optional, default 1
  88635. * * zmax the ground maximum Z coordinate, optional, default 1
  88636. * * 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}
  88637. * * 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}
  88638. * @returns the VertexData of the TiledGround
  88639. */
  88640. static CreateTiledGround(options: {
  88641. xmin: number;
  88642. zmin: number;
  88643. xmax: number;
  88644. zmax: number;
  88645. subdivisions?: {
  88646. w: number;
  88647. h: number;
  88648. };
  88649. precision?: {
  88650. w: number;
  88651. h: number;
  88652. };
  88653. }): VertexData;
  88654. /**
  88655. * Creates the VertexData of the Ground designed from a heightmap
  88656. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88657. * * width the width (x direction) of the ground
  88658. * * height the height (z direction) of the ground
  88659. * * subdivisions the number of subdivisions per side
  88660. * * minHeight the minimum altitude on the ground, optional, default 0
  88661. * * maxHeight the maximum altitude on the ground, optional default 1
  88662. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88663. * * buffer the array holding the image color data
  88664. * * bufferWidth the width of image
  88665. * * bufferHeight the height of image
  88666. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88667. * @returns the VertexData of the Ground designed from a heightmap
  88668. */
  88669. static CreateGroundFromHeightMap(options: {
  88670. width: number;
  88671. height: number;
  88672. subdivisions: number;
  88673. minHeight: number;
  88674. maxHeight: number;
  88675. colorFilter: Color3;
  88676. buffer: Uint8Array;
  88677. bufferWidth: number;
  88678. bufferHeight: number;
  88679. alphaFilter: number;
  88680. }): VertexData;
  88681. /**
  88682. * Creates the VertexData for a Plane
  88683. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88684. * * size sets the width and height of the plane to the value of size, optional default 1
  88685. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88686. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88687. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88688. * * 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)
  88689. * * 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)
  88690. * @returns the VertexData of the box
  88691. */
  88692. static CreatePlane(options: {
  88693. size?: number;
  88694. width?: number;
  88695. height?: number;
  88696. sideOrientation?: number;
  88697. frontUVs?: Vector4;
  88698. backUVs?: Vector4;
  88699. }): VertexData;
  88700. /**
  88701. * Creates the VertexData of the Disc or regular Polygon
  88702. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88703. * * radius the radius of the disc, optional default 0.5
  88704. * * tessellation the number of polygon sides, optional, default 64
  88705. * * 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
  88706. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88707. * * 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)
  88708. * * 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)
  88709. * @returns the VertexData of the box
  88710. */
  88711. static CreateDisc(options: {
  88712. radius?: number;
  88713. tessellation?: number;
  88714. arc?: number;
  88715. sideOrientation?: number;
  88716. frontUVs?: Vector4;
  88717. backUVs?: Vector4;
  88718. }): VertexData;
  88719. /**
  88720. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88721. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88722. * @param polygon a mesh built from polygonTriangulation.build()
  88723. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88724. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88725. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88726. * @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)
  88727. * @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)
  88728. * @returns the VertexData of the Polygon
  88729. */
  88730. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  88731. /**
  88732. * Creates the VertexData of the IcoSphere
  88733. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88734. * * radius the radius of the IcoSphere, optional default 1
  88735. * * radiusX allows stretching in the x direction, optional, default radius
  88736. * * radiusY allows stretching in the y direction, optional, default radius
  88737. * * radiusZ allows stretching in the z direction, optional, default radius
  88738. * * flat when true creates a flat shaded mesh, optional, default true
  88739. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88740. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88741. * * 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)
  88742. * * 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)
  88743. * @returns the VertexData of the IcoSphere
  88744. */
  88745. static CreateIcoSphere(options: {
  88746. radius?: number;
  88747. radiusX?: number;
  88748. radiusY?: number;
  88749. radiusZ?: number;
  88750. flat?: boolean;
  88751. subdivisions?: number;
  88752. sideOrientation?: number;
  88753. frontUVs?: Vector4;
  88754. backUVs?: Vector4;
  88755. }): VertexData;
  88756. /**
  88757. * Creates the VertexData for a Polyhedron
  88758. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88759. * * type provided types are:
  88760. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88761. * * 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)
  88762. * * size the size of the IcoSphere, optional default 1
  88763. * * sizeX allows stretching in the x direction, optional, default size
  88764. * * sizeY allows stretching in the y direction, optional, default size
  88765. * * sizeZ allows stretching in the z direction, optional, default size
  88766. * * 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
  88767. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88768. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88769. * * flat when true creates a flat shaded mesh, optional, default true
  88770. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88771. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88772. * * 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)
  88773. * * 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)
  88774. * @returns the VertexData of the Polyhedron
  88775. */
  88776. static CreatePolyhedron(options: {
  88777. type?: number;
  88778. size?: number;
  88779. sizeX?: number;
  88780. sizeY?: number;
  88781. sizeZ?: number;
  88782. custom?: any;
  88783. faceUV?: Vector4[];
  88784. faceColors?: Color4[];
  88785. flat?: boolean;
  88786. sideOrientation?: number;
  88787. frontUVs?: Vector4;
  88788. backUVs?: Vector4;
  88789. }): VertexData;
  88790. /**
  88791. * Creates the VertexData for a TorusKnot
  88792. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88793. * * radius the radius of the torus knot, optional, default 2
  88794. * * tube the thickness of the tube, optional, default 0.5
  88795. * * radialSegments the number of sides on each tube segments, optional, default 32
  88796. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88797. * * p the number of windings around the z axis, optional, default 2
  88798. * * q the number of windings around the x axis, optional, default 3
  88799. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88800. * * 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)
  88801. * * 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)
  88802. * @returns the VertexData of the Torus Knot
  88803. */
  88804. static CreateTorusKnot(options: {
  88805. radius?: number;
  88806. tube?: number;
  88807. radialSegments?: number;
  88808. tubularSegments?: number;
  88809. p?: number;
  88810. q?: number;
  88811. sideOrientation?: number;
  88812. frontUVs?: Vector4;
  88813. backUVs?: Vector4;
  88814. }): VertexData;
  88815. /**
  88816. * Compute normals for given positions and indices
  88817. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88818. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88819. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88820. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88821. * * facetNormals : optional array of facet normals (vector3)
  88822. * * facetPositions : optional array of facet positions (vector3)
  88823. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88824. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88825. * * bInfo : optional bounding info, required for facetPartitioning computation
  88826. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88827. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88828. * * useRightHandedSystem: optional boolean to for right handed system computation
  88829. * * depthSort : optional boolean to enable the facet depth sort computation
  88830. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88831. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88832. */
  88833. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  88834. facetNormals?: any;
  88835. facetPositions?: any;
  88836. facetPartitioning?: any;
  88837. ratio?: number;
  88838. bInfo?: any;
  88839. bbSize?: Vector3;
  88840. subDiv?: any;
  88841. useRightHandedSystem?: boolean;
  88842. depthSort?: boolean;
  88843. distanceTo?: Vector3;
  88844. depthSortedFacets?: any;
  88845. }): void;
  88846. /** @hidden */
  88847. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  88848. /**
  88849. * Applies VertexData created from the imported parameters to the geometry
  88850. * @param parsedVertexData the parsed data from an imported file
  88851. * @param geometry the geometry to apply the VertexData to
  88852. */
  88853. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  88854. }
  88855. }
  88856. declare module BABYLON {
  88857. /**
  88858. * Defines a target to use with MorphTargetManager
  88859. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88860. */
  88861. export class MorphTarget implements IAnimatable {
  88862. /** defines the name of the target */
  88863. name: string;
  88864. /**
  88865. * Gets or sets the list of animations
  88866. */
  88867. animations: Animation[];
  88868. private _scene;
  88869. private _positions;
  88870. private _normals;
  88871. private _tangents;
  88872. private _uvs;
  88873. private _influence;
  88874. /**
  88875. * Observable raised when the influence changes
  88876. */
  88877. onInfluenceChanged: Observable<boolean>;
  88878. /** @hidden */
  88879. _onDataLayoutChanged: Observable<void>;
  88880. /**
  88881. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  88882. */
  88883. influence: number;
  88884. /**
  88885. * Gets or sets the id of the morph Target
  88886. */
  88887. id: string;
  88888. private _animationPropertiesOverride;
  88889. /**
  88890. * Gets or sets the animation properties override
  88891. */
  88892. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  88893. /**
  88894. * Creates a new MorphTarget
  88895. * @param name defines the name of the target
  88896. * @param influence defines the influence to use
  88897. * @param scene defines the scene the morphtarget belongs to
  88898. */
  88899. constructor(
  88900. /** defines the name of the target */
  88901. name: string, influence?: number, scene?: Nullable<Scene>);
  88902. /**
  88903. * Gets a boolean defining if the target contains position data
  88904. */
  88905. readonly hasPositions: boolean;
  88906. /**
  88907. * Gets a boolean defining if the target contains normal data
  88908. */
  88909. readonly hasNormals: boolean;
  88910. /**
  88911. * Gets a boolean defining if the target contains tangent data
  88912. */
  88913. readonly hasTangents: boolean;
  88914. /**
  88915. * Gets a boolean defining if the target contains texture coordinates data
  88916. */
  88917. readonly hasUVs: boolean;
  88918. /**
  88919. * Affects position data to this target
  88920. * @param data defines the position data to use
  88921. */
  88922. setPositions(data: Nullable<FloatArray>): void;
  88923. /**
  88924. * Gets the position data stored in this target
  88925. * @returns a FloatArray containing the position data (or null if not present)
  88926. */
  88927. getPositions(): Nullable<FloatArray>;
  88928. /**
  88929. * Affects normal data to this target
  88930. * @param data defines the normal data to use
  88931. */
  88932. setNormals(data: Nullable<FloatArray>): void;
  88933. /**
  88934. * Gets the normal data stored in this target
  88935. * @returns a FloatArray containing the normal data (or null if not present)
  88936. */
  88937. getNormals(): Nullable<FloatArray>;
  88938. /**
  88939. * Affects tangent data to this target
  88940. * @param data defines the tangent data to use
  88941. */
  88942. setTangents(data: Nullable<FloatArray>): void;
  88943. /**
  88944. * Gets the tangent data stored in this target
  88945. * @returns a FloatArray containing the tangent data (or null if not present)
  88946. */
  88947. getTangents(): Nullable<FloatArray>;
  88948. /**
  88949. * Affects texture coordinates data to this target
  88950. * @param data defines the texture coordinates data to use
  88951. */
  88952. setUVs(data: Nullable<FloatArray>): void;
  88953. /**
  88954. * Gets the texture coordinates data stored in this target
  88955. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  88956. */
  88957. getUVs(): Nullable<FloatArray>;
  88958. /**
  88959. * Serializes the current target into a Serialization object
  88960. * @returns the serialized object
  88961. */
  88962. serialize(): any;
  88963. /**
  88964. * Returns the string "MorphTarget"
  88965. * @returns "MorphTarget"
  88966. */
  88967. getClassName(): string;
  88968. /**
  88969. * Creates a new target from serialized data
  88970. * @param serializationObject defines the serialized data to use
  88971. * @returns a new MorphTarget
  88972. */
  88973. static Parse(serializationObject: any): MorphTarget;
  88974. /**
  88975. * Creates a MorphTarget from mesh data
  88976. * @param mesh defines the source mesh
  88977. * @param name defines the name to use for the new target
  88978. * @param influence defines the influence to attach to the target
  88979. * @returns a new MorphTarget
  88980. */
  88981. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  88982. }
  88983. }
  88984. declare module BABYLON {
  88985. /**
  88986. * This class is used to deform meshes using morphing between different targets
  88987. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  88988. */
  88989. export class MorphTargetManager {
  88990. private _targets;
  88991. private _targetInfluenceChangedObservers;
  88992. private _targetDataLayoutChangedObservers;
  88993. private _activeTargets;
  88994. private _scene;
  88995. private _influences;
  88996. private _supportsNormals;
  88997. private _supportsTangents;
  88998. private _supportsUVs;
  88999. private _vertexCount;
  89000. private _uniqueId;
  89001. private _tempInfluences;
  89002. /**
  89003. * Gets or sets a boolean indicating if normals must be morphed
  89004. */
  89005. enableNormalMorphing: boolean;
  89006. /**
  89007. * Gets or sets a boolean indicating if tangents must be morphed
  89008. */
  89009. enableTangentMorphing: boolean;
  89010. /**
  89011. * Gets or sets a boolean indicating if UV must be morphed
  89012. */
  89013. enableUVMorphing: boolean;
  89014. /**
  89015. * Creates a new MorphTargetManager
  89016. * @param scene defines the current scene
  89017. */
  89018. constructor(scene?: Nullable<Scene>);
  89019. /**
  89020. * Gets the unique ID of this manager
  89021. */
  89022. readonly uniqueId: number;
  89023. /**
  89024. * Gets the number of vertices handled by this manager
  89025. */
  89026. readonly vertexCount: number;
  89027. /**
  89028. * Gets a boolean indicating if this manager supports morphing of normals
  89029. */
  89030. readonly supportsNormals: boolean;
  89031. /**
  89032. * Gets a boolean indicating if this manager supports morphing of tangents
  89033. */
  89034. readonly supportsTangents: boolean;
  89035. /**
  89036. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  89037. */
  89038. readonly supportsUVs: boolean;
  89039. /**
  89040. * Gets the number of targets stored in this manager
  89041. */
  89042. readonly numTargets: number;
  89043. /**
  89044. * Gets the number of influencers (ie. the number of targets with influences > 0)
  89045. */
  89046. readonly numInfluencers: number;
  89047. /**
  89048. * Gets the list of influences (one per target)
  89049. */
  89050. readonly influences: Float32Array;
  89051. /**
  89052. * Gets the active target at specified index. An active target is a target with an influence > 0
  89053. * @param index defines the index to check
  89054. * @returns the requested target
  89055. */
  89056. getActiveTarget(index: number): MorphTarget;
  89057. /**
  89058. * Gets the target at specified index
  89059. * @param index defines the index to check
  89060. * @returns the requested target
  89061. */
  89062. getTarget(index: number): MorphTarget;
  89063. /**
  89064. * Add a new target to this manager
  89065. * @param target defines the target to add
  89066. */
  89067. addTarget(target: MorphTarget): void;
  89068. /**
  89069. * Removes a target from the manager
  89070. * @param target defines the target to remove
  89071. */
  89072. removeTarget(target: MorphTarget): void;
  89073. /**
  89074. * Serializes the current manager into a Serialization object
  89075. * @returns the serialized object
  89076. */
  89077. serialize(): any;
  89078. private _syncActiveTargets;
  89079. /**
  89080. * Syncrhonize the targets with all the meshes using this morph target manager
  89081. */
  89082. synchronize(): void;
  89083. /**
  89084. * Creates a new MorphTargetManager from serialized data
  89085. * @param serializationObject defines the serialized data
  89086. * @param scene defines the hosting scene
  89087. * @returns the new MorphTargetManager
  89088. */
  89089. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  89090. }
  89091. }
  89092. declare module BABYLON {
  89093. /**
  89094. * Class used to represent a specific level of detail of a mesh
  89095. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  89096. */
  89097. export class MeshLODLevel {
  89098. /** Defines the distance where this level should start being displayed */
  89099. distance: number;
  89100. /** Defines the mesh to use to render this level */
  89101. mesh: Nullable<Mesh>;
  89102. /**
  89103. * Creates a new LOD level
  89104. * @param distance defines the distance where this level should star being displayed
  89105. * @param mesh defines the mesh to use to render this level
  89106. */
  89107. constructor(
  89108. /** Defines the distance where this level should start being displayed */
  89109. distance: number,
  89110. /** Defines the mesh to use to render this level */
  89111. mesh: Nullable<Mesh>);
  89112. }
  89113. }
  89114. declare module BABYLON {
  89115. /**
  89116. * Mesh representing the gorund
  89117. */
  89118. export class GroundMesh extends Mesh {
  89119. /** If octree should be generated */
  89120. generateOctree: boolean;
  89121. private _heightQuads;
  89122. /** @hidden */
  89123. _subdivisionsX: number;
  89124. /** @hidden */
  89125. _subdivisionsY: number;
  89126. /** @hidden */
  89127. _width: number;
  89128. /** @hidden */
  89129. _height: number;
  89130. /** @hidden */
  89131. _minX: number;
  89132. /** @hidden */
  89133. _maxX: number;
  89134. /** @hidden */
  89135. _minZ: number;
  89136. /** @hidden */
  89137. _maxZ: number;
  89138. constructor(name: string, scene: Scene);
  89139. /**
  89140. * "GroundMesh"
  89141. * @returns "GroundMesh"
  89142. */
  89143. getClassName(): string;
  89144. /**
  89145. * The minimum of x and y subdivisions
  89146. */
  89147. readonly subdivisions: number;
  89148. /**
  89149. * X subdivisions
  89150. */
  89151. readonly subdivisionsX: number;
  89152. /**
  89153. * Y subdivisions
  89154. */
  89155. readonly subdivisionsY: number;
  89156. /**
  89157. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  89158. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  89159. * @param chunksCount the number of subdivisions for x and y
  89160. * @param octreeBlocksSize (Default: 32)
  89161. */
  89162. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  89163. /**
  89164. * Returns a height (y) value in the Worl system :
  89165. * the ground altitude at the coordinates (x, z) expressed in the World system.
  89166. * @param x x coordinate
  89167. * @param z z coordinate
  89168. * @returns the ground y position if (x, z) are outside the ground surface.
  89169. */
  89170. getHeightAtCoordinates(x: number, z: number): number;
  89171. /**
  89172. * Returns a normalized vector (Vector3) orthogonal to the ground
  89173. * at the ground coordinates (x, z) expressed in the World system.
  89174. * @param x x coordinate
  89175. * @param z z coordinate
  89176. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  89177. */
  89178. getNormalAtCoordinates(x: number, z: number): Vector3;
  89179. /**
  89180. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  89181. * at the ground coordinates (x, z) expressed in the World system.
  89182. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  89183. * @param x x coordinate
  89184. * @param z z coordinate
  89185. * @param ref vector to store the result
  89186. * @returns the GroundMesh.
  89187. */
  89188. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  89189. /**
  89190. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  89191. * if the ground has been updated.
  89192. * This can be used in the render loop.
  89193. * @returns the GroundMesh.
  89194. */
  89195. updateCoordinateHeights(): GroundMesh;
  89196. private _getFacetAt;
  89197. private _initHeightQuads;
  89198. private _computeHeightQuads;
  89199. /**
  89200. * Serializes this ground mesh
  89201. * @param serializationObject object to write serialization to
  89202. */
  89203. serialize(serializationObject: any): void;
  89204. /**
  89205. * Parses a serialized ground mesh
  89206. * @param parsedMesh the serialized mesh
  89207. * @param scene the scene to create the ground mesh in
  89208. * @returns the created ground mesh
  89209. */
  89210. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  89211. }
  89212. }
  89213. declare module BABYLON {
  89214. /**
  89215. * Interface for Physics-Joint data
  89216. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89217. */
  89218. export interface PhysicsJointData {
  89219. /**
  89220. * The main pivot of the joint
  89221. */
  89222. mainPivot?: Vector3;
  89223. /**
  89224. * The connected pivot of the joint
  89225. */
  89226. connectedPivot?: Vector3;
  89227. /**
  89228. * The main axis of the joint
  89229. */
  89230. mainAxis?: Vector3;
  89231. /**
  89232. * The connected axis of the joint
  89233. */
  89234. connectedAxis?: Vector3;
  89235. /**
  89236. * The collision of the joint
  89237. */
  89238. collision?: boolean;
  89239. /**
  89240. * Native Oimo/Cannon/Energy data
  89241. */
  89242. nativeParams?: any;
  89243. }
  89244. /**
  89245. * This is a holder class for the physics joint created by the physics plugin
  89246. * It holds a set of functions to control the underlying joint
  89247. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89248. */
  89249. export class PhysicsJoint {
  89250. /**
  89251. * The type of the physics joint
  89252. */
  89253. type: number;
  89254. /**
  89255. * The data for the physics joint
  89256. */
  89257. jointData: PhysicsJointData;
  89258. private _physicsJoint;
  89259. protected _physicsPlugin: IPhysicsEnginePlugin;
  89260. /**
  89261. * Initializes the physics joint
  89262. * @param type The type of the physics joint
  89263. * @param jointData The data for the physics joint
  89264. */
  89265. constructor(
  89266. /**
  89267. * The type of the physics joint
  89268. */
  89269. type: number,
  89270. /**
  89271. * The data for the physics joint
  89272. */
  89273. jointData: PhysicsJointData);
  89274. /**
  89275. * Gets the physics joint
  89276. */
  89277. /**
  89278. * Sets the physics joint
  89279. */
  89280. physicsJoint: any;
  89281. /**
  89282. * Sets the physics plugin
  89283. */
  89284. physicsPlugin: IPhysicsEnginePlugin;
  89285. /**
  89286. * Execute a function that is physics-plugin specific.
  89287. * @param {Function} func the function that will be executed.
  89288. * It accepts two parameters: the physics world and the physics joint
  89289. */
  89290. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  89291. /**
  89292. * Distance-Joint type
  89293. */
  89294. static DistanceJoint: number;
  89295. /**
  89296. * Hinge-Joint type
  89297. */
  89298. static HingeJoint: number;
  89299. /**
  89300. * Ball-and-Socket joint type
  89301. */
  89302. static BallAndSocketJoint: number;
  89303. /**
  89304. * Wheel-Joint type
  89305. */
  89306. static WheelJoint: number;
  89307. /**
  89308. * Slider-Joint type
  89309. */
  89310. static SliderJoint: number;
  89311. /**
  89312. * Prismatic-Joint type
  89313. */
  89314. static PrismaticJoint: number;
  89315. /**
  89316. * Universal-Joint type
  89317. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  89318. */
  89319. static UniversalJoint: number;
  89320. /**
  89321. * Hinge-Joint 2 type
  89322. */
  89323. static Hinge2Joint: number;
  89324. /**
  89325. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  89326. */
  89327. static PointToPointJoint: number;
  89328. /**
  89329. * Spring-Joint type
  89330. */
  89331. static SpringJoint: number;
  89332. /**
  89333. * Lock-Joint type
  89334. */
  89335. static LockJoint: number;
  89336. }
  89337. /**
  89338. * A class representing a physics distance joint
  89339. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89340. */
  89341. export class DistanceJoint extends PhysicsJoint {
  89342. /**
  89343. *
  89344. * @param jointData The data for the Distance-Joint
  89345. */
  89346. constructor(jointData: DistanceJointData);
  89347. /**
  89348. * Update the predefined distance.
  89349. * @param maxDistance The maximum preferred distance
  89350. * @param minDistance The minimum preferred distance
  89351. */
  89352. updateDistance(maxDistance: number, minDistance?: number): void;
  89353. }
  89354. /**
  89355. * Represents a Motor-Enabled Joint
  89356. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89357. */
  89358. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  89359. /**
  89360. * Initializes the Motor-Enabled Joint
  89361. * @param type The type of the joint
  89362. * @param jointData The physica joint data for the joint
  89363. */
  89364. constructor(type: number, jointData: PhysicsJointData);
  89365. /**
  89366. * Set the motor values.
  89367. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89368. * @param force the force to apply
  89369. * @param maxForce max force for this motor.
  89370. */
  89371. setMotor(force?: number, maxForce?: number): void;
  89372. /**
  89373. * Set the motor's limits.
  89374. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89375. * @param upperLimit The upper limit of the motor
  89376. * @param lowerLimit The lower limit of the motor
  89377. */
  89378. setLimit(upperLimit: number, lowerLimit?: number): void;
  89379. }
  89380. /**
  89381. * This class represents a single physics Hinge-Joint
  89382. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89383. */
  89384. export class HingeJoint extends MotorEnabledJoint {
  89385. /**
  89386. * Initializes the Hinge-Joint
  89387. * @param jointData The joint data for the Hinge-Joint
  89388. */
  89389. constructor(jointData: PhysicsJointData);
  89390. /**
  89391. * Set the motor values.
  89392. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89393. * @param {number} force the force to apply
  89394. * @param {number} maxForce max force for this motor.
  89395. */
  89396. setMotor(force?: number, maxForce?: number): void;
  89397. /**
  89398. * Set the motor's limits.
  89399. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89400. * @param upperLimit The upper limit of the motor
  89401. * @param lowerLimit The lower limit of the motor
  89402. */
  89403. setLimit(upperLimit: number, lowerLimit?: number): void;
  89404. }
  89405. /**
  89406. * This class represents a dual hinge physics joint (same as wheel joint)
  89407. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89408. */
  89409. export class Hinge2Joint extends MotorEnabledJoint {
  89410. /**
  89411. * Initializes the Hinge2-Joint
  89412. * @param jointData The joint data for the Hinge2-Joint
  89413. */
  89414. constructor(jointData: PhysicsJointData);
  89415. /**
  89416. * Set the motor values.
  89417. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89418. * @param {number} targetSpeed the speed the motor is to reach
  89419. * @param {number} maxForce max force for this motor.
  89420. * @param {motorIndex} the motor's index, 0 or 1.
  89421. */
  89422. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  89423. /**
  89424. * Set the motor limits.
  89425. * Attention, this function is plugin specific. Engines won't react 100% the same.
  89426. * @param {number} upperLimit the upper limit
  89427. * @param {number} lowerLimit lower limit
  89428. * @param {motorIndex} the motor's index, 0 or 1.
  89429. */
  89430. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89431. }
  89432. /**
  89433. * Interface for a motor enabled joint
  89434. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89435. */
  89436. export interface IMotorEnabledJoint {
  89437. /**
  89438. * Physics joint
  89439. */
  89440. physicsJoint: any;
  89441. /**
  89442. * Sets the motor of the motor-enabled joint
  89443. * @param force The force of the motor
  89444. * @param maxForce The maximum force of the motor
  89445. * @param motorIndex The index of the motor
  89446. */
  89447. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  89448. /**
  89449. * Sets the limit of the motor
  89450. * @param upperLimit The upper limit of the motor
  89451. * @param lowerLimit The lower limit of the motor
  89452. * @param motorIndex The index of the motor
  89453. */
  89454. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89455. }
  89456. /**
  89457. * Joint data for a Distance-Joint
  89458. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89459. */
  89460. export interface DistanceJointData extends PhysicsJointData {
  89461. /**
  89462. * Max distance the 2 joint objects can be apart
  89463. */
  89464. maxDistance: number;
  89465. }
  89466. /**
  89467. * Joint data from a spring joint
  89468. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89469. */
  89470. export interface SpringJointData extends PhysicsJointData {
  89471. /**
  89472. * Length of the spring
  89473. */
  89474. length: number;
  89475. /**
  89476. * Stiffness of the spring
  89477. */
  89478. stiffness: number;
  89479. /**
  89480. * Damping of the spring
  89481. */
  89482. damping: number;
  89483. /** this callback will be called when applying the force to the impostors. */
  89484. forceApplicationCallback: () => void;
  89485. }
  89486. }
  89487. declare module BABYLON {
  89488. /**
  89489. * Holds the data for the raycast result
  89490. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89491. */
  89492. export class PhysicsRaycastResult {
  89493. private _hasHit;
  89494. private _hitDistance;
  89495. private _hitNormalWorld;
  89496. private _hitPointWorld;
  89497. private _rayFromWorld;
  89498. private _rayToWorld;
  89499. /**
  89500. * Gets if there was a hit
  89501. */
  89502. readonly hasHit: boolean;
  89503. /**
  89504. * Gets the distance from the hit
  89505. */
  89506. readonly hitDistance: number;
  89507. /**
  89508. * Gets the hit normal/direction in the world
  89509. */
  89510. readonly hitNormalWorld: Vector3;
  89511. /**
  89512. * Gets the hit point in the world
  89513. */
  89514. readonly hitPointWorld: Vector3;
  89515. /**
  89516. * Gets the ray "start point" of the ray in the world
  89517. */
  89518. readonly rayFromWorld: Vector3;
  89519. /**
  89520. * Gets the ray "end point" of the ray in the world
  89521. */
  89522. readonly rayToWorld: Vector3;
  89523. /**
  89524. * Sets the hit data (normal & point in world space)
  89525. * @param hitNormalWorld defines the normal in world space
  89526. * @param hitPointWorld defines the point in world space
  89527. */
  89528. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  89529. /**
  89530. * Sets the distance from the start point to the hit point
  89531. * @param distance
  89532. */
  89533. setHitDistance(distance: number): void;
  89534. /**
  89535. * Calculates the distance manually
  89536. */
  89537. calculateHitDistance(): void;
  89538. /**
  89539. * Resets all the values to default
  89540. * @param from The from point on world space
  89541. * @param to The to point on world space
  89542. */
  89543. reset(from?: Vector3, to?: Vector3): void;
  89544. }
  89545. /**
  89546. * Interface for the size containing width and height
  89547. */
  89548. interface IXYZ {
  89549. /**
  89550. * X
  89551. */
  89552. x: number;
  89553. /**
  89554. * Y
  89555. */
  89556. y: number;
  89557. /**
  89558. * Z
  89559. */
  89560. z: number;
  89561. }
  89562. }
  89563. declare module BABYLON {
  89564. /**
  89565. * Interface used to describe a physics joint
  89566. */
  89567. export interface PhysicsImpostorJoint {
  89568. /** Defines the main impostor to which the joint is linked */
  89569. mainImpostor: PhysicsImpostor;
  89570. /** Defines the impostor that is connected to the main impostor using this joint */
  89571. connectedImpostor: PhysicsImpostor;
  89572. /** Defines the joint itself */
  89573. joint: PhysicsJoint;
  89574. }
  89575. /** @hidden */
  89576. export interface IPhysicsEnginePlugin {
  89577. world: any;
  89578. name: string;
  89579. setGravity(gravity: Vector3): void;
  89580. setTimeStep(timeStep: number): void;
  89581. getTimeStep(): number;
  89582. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  89583. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89584. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  89585. generatePhysicsBody(impostor: PhysicsImpostor): void;
  89586. removePhysicsBody(impostor: PhysicsImpostor): void;
  89587. generateJoint(joint: PhysicsImpostorJoint): void;
  89588. removeJoint(joint: PhysicsImpostorJoint): void;
  89589. isSupported(): boolean;
  89590. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  89591. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  89592. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89593. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  89594. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89595. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  89596. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  89597. getBodyMass(impostor: PhysicsImpostor): number;
  89598. getBodyFriction(impostor: PhysicsImpostor): number;
  89599. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  89600. getBodyRestitution(impostor: PhysicsImpostor): number;
  89601. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  89602. getBodyPressure?(impostor: PhysicsImpostor): number;
  89603. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  89604. getBodyStiffness?(impostor: PhysicsImpostor): number;
  89605. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  89606. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  89607. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  89608. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  89609. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  89610. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89611. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  89612. sleepBody(impostor: PhysicsImpostor): void;
  89613. wakeUpBody(impostor: PhysicsImpostor): void;
  89614. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89615. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  89616. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  89617. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  89618. getRadius(impostor: PhysicsImpostor): number;
  89619. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  89620. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  89621. dispose(): void;
  89622. }
  89623. /**
  89624. * Interface used to define a physics engine
  89625. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  89626. */
  89627. export interface IPhysicsEngine {
  89628. /**
  89629. * Gets the gravity vector used by the simulation
  89630. */
  89631. gravity: Vector3;
  89632. /**
  89633. * Sets the gravity vector used by the simulation
  89634. * @param gravity defines the gravity vector to use
  89635. */
  89636. setGravity(gravity: Vector3): void;
  89637. /**
  89638. * Set the time step of the physics engine.
  89639. * Default is 1/60.
  89640. * To slow it down, enter 1/600 for example.
  89641. * To speed it up, 1/30
  89642. * @param newTimeStep the new timestep to apply to this world.
  89643. */
  89644. setTimeStep(newTimeStep: number): void;
  89645. /**
  89646. * Get the time step of the physics engine.
  89647. * @returns the current time step
  89648. */
  89649. getTimeStep(): number;
  89650. /**
  89651. * Release all resources
  89652. */
  89653. dispose(): void;
  89654. /**
  89655. * Gets the name of the current physics plugin
  89656. * @returns the name of the plugin
  89657. */
  89658. getPhysicsPluginName(): string;
  89659. /**
  89660. * Adding a new impostor for the impostor tracking.
  89661. * This will be done by the impostor itself.
  89662. * @param impostor the impostor to add
  89663. */
  89664. addImpostor(impostor: PhysicsImpostor): void;
  89665. /**
  89666. * Remove an impostor from the engine.
  89667. * This impostor and its mesh will not longer be updated by the physics engine.
  89668. * @param impostor the impostor to remove
  89669. */
  89670. removeImpostor(impostor: PhysicsImpostor): void;
  89671. /**
  89672. * Add a joint to the physics engine
  89673. * @param mainImpostor defines the main impostor to which the joint is added.
  89674. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  89675. * @param joint defines the joint that will connect both impostors.
  89676. */
  89677. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89678. /**
  89679. * Removes a joint from the simulation
  89680. * @param mainImpostor defines the impostor used with the joint
  89681. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  89682. * @param joint defines the joint to remove
  89683. */
  89684. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  89685. /**
  89686. * Gets the current plugin used to run the simulation
  89687. * @returns current plugin
  89688. */
  89689. getPhysicsPlugin(): IPhysicsEnginePlugin;
  89690. /**
  89691. * Gets the list of physic impostors
  89692. * @returns an array of PhysicsImpostor
  89693. */
  89694. getImpostors(): Array<PhysicsImpostor>;
  89695. /**
  89696. * Gets the impostor for a physics enabled object
  89697. * @param object defines the object impersonated by the impostor
  89698. * @returns the PhysicsImpostor or null if not found
  89699. */
  89700. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  89701. /**
  89702. * Gets the impostor for a physics body object
  89703. * @param body defines physics body used by the impostor
  89704. * @returns the PhysicsImpostor or null if not found
  89705. */
  89706. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  89707. /**
  89708. * Does a raycast in the physics world
  89709. * @param from when should the ray start?
  89710. * @param to when should the ray end?
  89711. * @returns PhysicsRaycastResult
  89712. */
  89713. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  89714. /**
  89715. * Called by the scene. No need to call it.
  89716. * @param delta defines the timespam between frames
  89717. */
  89718. _step(delta: number): void;
  89719. }
  89720. }
  89721. declare module BABYLON {
  89722. /**
  89723. * The interface for the physics imposter parameters
  89724. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89725. */
  89726. export interface PhysicsImpostorParameters {
  89727. /**
  89728. * The mass of the physics imposter
  89729. */
  89730. mass: number;
  89731. /**
  89732. * The friction of the physics imposter
  89733. */
  89734. friction?: number;
  89735. /**
  89736. * The coefficient of restitution of the physics imposter
  89737. */
  89738. restitution?: number;
  89739. /**
  89740. * The native options of the physics imposter
  89741. */
  89742. nativeOptions?: any;
  89743. /**
  89744. * Specifies if the parent should be ignored
  89745. */
  89746. ignoreParent?: boolean;
  89747. /**
  89748. * Specifies if bi-directional transformations should be disabled
  89749. */
  89750. disableBidirectionalTransformation?: boolean;
  89751. /**
  89752. * The pressure inside the physics imposter, soft object only
  89753. */
  89754. pressure?: number;
  89755. /**
  89756. * The stiffness the physics imposter, soft object only
  89757. */
  89758. stiffness?: number;
  89759. /**
  89760. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  89761. */
  89762. velocityIterations?: number;
  89763. /**
  89764. * The number of iterations used in maintaining consistent vertex positions, soft object only
  89765. */
  89766. positionIterations?: number;
  89767. /**
  89768. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  89769. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  89770. * Add to fix multiple points
  89771. */
  89772. fixedPoints?: number;
  89773. /**
  89774. * The collision margin around a soft object
  89775. */
  89776. margin?: number;
  89777. /**
  89778. * The collision margin around a soft object
  89779. */
  89780. damping?: number;
  89781. /**
  89782. * The path for a rope based on an extrusion
  89783. */
  89784. path?: any;
  89785. /**
  89786. * The shape of an extrusion used for a rope based on an extrusion
  89787. */
  89788. shape?: any;
  89789. }
  89790. /**
  89791. * Interface for a physics-enabled object
  89792. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89793. */
  89794. export interface IPhysicsEnabledObject {
  89795. /**
  89796. * The position of the physics-enabled object
  89797. */
  89798. position: Vector3;
  89799. /**
  89800. * The rotation of the physics-enabled object
  89801. */
  89802. rotationQuaternion: Nullable<Quaternion>;
  89803. /**
  89804. * The scale of the physics-enabled object
  89805. */
  89806. scaling: Vector3;
  89807. /**
  89808. * The rotation of the physics-enabled object
  89809. */
  89810. rotation?: Vector3;
  89811. /**
  89812. * The parent of the physics-enabled object
  89813. */
  89814. parent?: any;
  89815. /**
  89816. * The bounding info of the physics-enabled object
  89817. * @returns The bounding info of the physics-enabled object
  89818. */
  89819. getBoundingInfo(): BoundingInfo;
  89820. /**
  89821. * Computes the world matrix
  89822. * @param force Specifies if the world matrix should be computed by force
  89823. * @returns A world matrix
  89824. */
  89825. computeWorldMatrix(force: boolean): Matrix;
  89826. /**
  89827. * Gets the world matrix
  89828. * @returns A world matrix
  89829. */
  89830. getWorldMatrix?(): Matrix;
  89831. /**
  89832. * Gets the child meshes
  89833. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  89834. * @returns An array of abstract meshes
  89835. */
  89836. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  89837. /**
  89838. * Gets the vertex data
  89839. * @param kind The type of vertex data
  89840. * @returns A nullable array of numbers, or a float32 array
  89841. */
  89842. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  89843. /**
  89844. * Gets the indices from the mesh
  89845. * @returns A nullable array of index arrays
  89846. */
  89847. getIndices?(): Nullable<IndicesArray>;
  89848. /**
  89849. * Gets the scene from the mesh
  89850. * @returns the indices array or null
  89851. */
  89852. getScene?(): Scene;
  89853. /**
  89854. * Gets the absolute position from the mesh
  89855. * @returns the absolute position
  89856. */
  89857. getAbsolutePosition(): Vector3;
  89858. /**
  89859. * Gets the absolute pivot point from the mesh
  89860. * @returns the absolute pivot point
  89861. */
  89862. getAbsolutePivotPoint(): Vector3;
  89863. /**
  89864. * Rotates the mesh
  89865. * @param axis The axis of rotation
  89866. * @param amount The amount of rotation
  89867. * @param space The space of the rotation
  89868. * @returns The rotation transform node
  89869. */
  89870. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  89871. /**
  89872. * Translates the mesh
  89873. * @param axis The axis of translation
  89874. * @param distance The distance of translation
  89875. * @param space The space of the translation
  89876. * @returns The transform node
  89877. */
  89878. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  89879. /**
  89880. * Sets the absolute position of the mesh
  89881. * @param absolutePosition The absolute position of the mesh
  89882. * @returns The transform node
  89883. */
  89884. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  89885. /**
  89886. * Gets the class name of the mesh
  89887. * @returns The class name
  89888. */
  89889. getClassName(): string;
  89890. }
  89891. /**
  89892. * Represents a physics imposter
  89893. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  89894. */
  89895. export class PhysicsImpostor {
  89896. /**
  89897. * The physics-enabled object used as the physics imposter
  89898. */
  89899. object: IPhysicsEnabledObject;
  89900. /**
  89901. * The type of the physics imposter
  89902. */
  89903. type: number;
  89904. private _options;
  89905. private _scene?;
  89906. /**
  89907. * The default object size of the imposter
  89908. */
  89909. static DEFAULT_OBJECT_SIZE: Vector3;
  89910. /**
  89911. * The identity quaternion of the imposter
  89912. */
  89913. static IDENTITY_QUATERNION: Quaternion;
  89914. /** @hidden */
  89915. _pluginData: any;
  89916. private _physicsEngine;
  89917. private _physicsBody;
  89918. private _bodyUpdateRequired;
  89919. private _onBeforePhysicsStepCallbacks;
  89920. private _onAfterPhysicsStepCallbacks;
  89921. /** @hidden */
  89922. _onPhysicsCollideCallbacks: Array<{
  89923. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  89924. otherImpostors: Array<PhysicsImpostor>;
  89925. }>;
  89926. private _deltaPosition;
  89927. private _deltaRotation;
  89928. private _deltaRotationConjugated;
  89929. /** @hidden */
  89930. _isFromLine: boolean;
  89931. private _parent;
  89932. private _isDisposed;
  89933. private static _tmpVecs;
  89934. private static _tmpQuat;
  89935. /**
  89936. * Specifies if the physics imposter is disposed
  89937. */
  89938. readonly isDisposed: boolean;
  89939. /**
  89940. * Gets the mass of the physics imposter
  89941. */
  89942. mass: number;
  89943. /**
  89944. * Gets the coefficient of friction
  89945. */
  89946. /**
  89947. * Sets the coefficient of friction
  89948. */
  89949. friction: number;
  89950. /**
  89951. * Gets the coefficient of restitution
  89952. */
  89953. /**
  89954. * Sets the coefficient of restitution
  89955. */
  89956. restitution: number;
  89957. /**
  89958. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  89959. */
  89960. /**
  89961. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  89962. */
  89963. pressure: number;
  89964. /**
  89965. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89966. */
  89967. /**
  89968. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  89969. */
  89970. stiffness: number;
  89971. /**
  89972. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89973. */
  89974. /**
  89975. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  89976. */
  89977. velocityIterations: number;
  89978. /**
  89979. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89980. */
  89981. /**
  89982. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  89983. */
  89984. positionIterations: number;
  89985. /**
  89986. * The unique id of the physics imposter
  89987. * set by the physics engine when adding this impostor to the array
  89988. */
  89989. uniqueId: number;
  89990. /**
  89991. * @hidden
  89992. */
  89993. soft: boolean;
  89994. /**
  89995. * @hidden
  89996. */
  89997. segments: number;
  89998. private _joints;
  89999. /**
  90000. * Initializes the physics imposter
  90001. * @param object The physics-enabled object used as the physics imposter
  90002. * @param type The type of the physics imposter
  90003. * @param _options The options for the physics imposter
  90004. * @param _scene The Babylon scene
  90005. */
  90006. constructor(
  90007. /**
  90008. * The physics-enabled object used as the physics imposter
  90009. */
  90010. object: IPhysicsEnabledObject,
  90011. /**
  90012. * The type of the physics imposter
  90013. */
  90014. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  90015. /**
  90016. * This function will completly initialize this impostor.
  90017. * It will create a new body - but only if this mesh has no parent.
  90018. * If it has, this impostor will not be used other than to define the impostor
  90019. * of the child mesh.
  90020. * @hidden
  90021. */
  90022. _init(): void;
  90023. private _getPhysicsParent;
  90024. /**
  90025. * Should a new body be generated.
  90026. * @returns boolean specifying if body initialization is required
  90027. */
  90028. isBodyInitRequired(): boolean;
  90029. /**
  90030. * Sets the updated scaling
  90031. * @param updated Specifies if the scaling is updated
  90032. */
  90033. setScalingUpdated(): void;
  90034. /**
  90035. * Force a regeneration of this or the parent's impostor's body.
  90036. * Use under cautious - This will remove all joints already implemented.
  90037. */
  90038. forceUpdate(): void;
  90039. /**
  90040. * Gets the body that holds this impostor. Either its own, or its parent.
  90041. */
  90042. /**
  90043. * Set the physics body. Used mainly by the physics engine/plugin
  90044. */
  90045. physicsBody: any;
  90046. /**
  90047. * Get the parent of the physics imposter
  90048. * @returns Physics imposter or null
  90049. */
  90050. /**
  90051. * Sets the parent of the physics imposter
  90052. */
  90053. parent: Nullable<PhysicsImpostor>;
  90054. /**
  90055. * Resets the update flags
  90056. */
  90057. resetUpdateFlags(): void;
  90058. /**
  90059. * Gets the object extend size
  90060. * @returns the object extend size
  90061. */
  90062. getObjectExtendSize(): Vector3;
  90063. /**
  90064. * Gets the object center
  90065. * @returns The object center
  90066. */
  90067. getObjectCenter(): Vector3;
  90068. /**
  90069. * Get a specific parametes from the options parameter
  90070. * @param paramName The object parameter name
  90071. * @returns The object parameter
  90072. */
  90073. getParam(paramName: string): any;
  90074. /**
  90075. * Sets a specific parameter in the options given to the physics plugin
  90076. * @param paramName The parameter name
  90077. * @param value The value of the parameter
  90078. */
  90079. setParam(paramName: string, value: number): void;
  90080. /**
  90081. * Specifically change the body's mass option. Won't recreate the physics body object
  90082. * @param mass The mass of the physics imposter
  90083. */
  90084. setMass(mass: number): void;
  90085. /**
  90086. * Gets the linear velocity
  90087. * @returns linear velocity or null
  90088. */
  90089. getLinearVelocity(): Nullable<Vector3>;
  90090. /**
  90091. * Sets the linear velocity
  90092. * @param velocity linear velocity or null
  90093. */
  90094. setLinearVelocity(velocity: Nullable<Vector3>): void;
  90095. /**
  90096. * Gets the angular velocity
  90097. * @returns angular velocity or null
  90098. */
  90099. getAngularVelocity(): Nullable<Vector3>;
  90100. /**
  90101. * Sets the angular velocity
  90102. * @param velocity The velocity or null
  90103. */
  90104. setAngularVelocity(velocity: Nullable<Vector3>): void;
  90105. /**
  90106. * Execute a function with the physics plugin native code
  90107. * Provide a function the will have two variables - the world object and the physics body object
  90108. * @param func The function to execute with the physics plugin native code
  90109. */
  90110. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  90111. /**
  90112. * Register a function that will be executed before the physics world is stepping forward
  90113. * @param func The function to execute before the physics world is stepped forward
  90114. */
  90115. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90116. /**
  90117. * Unregister a function that will be executed before the physics world is stepping forward
  90118. * @param func The function to execute before the physics world is stepped forward
  90119. */
  90120. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90121. /**
  90122. * Register a function that will be executed after the physics step
  90123. * @param func The function to execute after physics step
  90124. */
  90125. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90126. /**
  90127. * Unregisters a function that will be executed after the physics step
  90128. * @param func The function to execute after physics step
  90129. */
  90130. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  90131. /**
  90132. * register a function that will be executed when this impostor collides against a different body
  90133. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  90134. * @param func Callback that is executed on collision
  90135. */
  90136. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  90137. /**
  90138. * Unregisters the physics imposter on contact
  90139. * @param collideAgainst The physics object to collide against
  90140. * @param func Callback to execute on collision
  90141. */
  90142. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  90143. private _tmpQuat;
  90144. private _tmpQuat2;
  90145. /**
  90146. * Get the parent rotation
  90147. * @returns The parent rotation
  90148. */
  90149. getParentsRotation(): Quaternion;
  90150. /**
  90151. * this function is executed by the physics engine.
  90152. */
  90153. beforeStep: () => void;
  90154. /**
  90155. * this function is executed by the physics engine
  90156. */
  90157. afterStep: () => void;
  90158. /**
  90159. * Legacy collision detection event support
  90160. */
  90161. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  90162. /**
  90163. * event and body object due to cannon's event-based architecture.
  90164. */
  90165. onCollide: (e: {
  90166. body: any;
  90167. }) => void;
  90168. /**
  90169. * Apply a force
  90170. * @param force The force to apply
  90171. * @param contactPoint The contact point for the force
  90172. * @returns The physics imposter
  90173. */
  90174. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90175. /**
  90176. * Apply an impulse
  90177. * @param force The impulse force
  90178. * @param contactPoint The contact point for the impulse force
  90179. * @returns The physics imposter
  90180. */
  90181. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  90182. /**
  90183. * A help function to create a joint
  90184. * @param otherImpostor A physics imposter used to create a joint
  90185. * @param jointType The type of joint
  90186. * @param jointData The data for the joint
  90187. * @returns The physics imposter
  90188. */
  90189. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  90190. /**
  90191. * Add a joint to this impostor with a different impostor
  90192. * @param otherImpostor A physics imposter used to add a joint
  90193. * @param joint The joint to add
  90194. * @returns The physics imposter
  90195. */
  90196. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  90197. /**
  90198. * Add an anchor to a cloth impostor
  90199. * @param otherImpostor rigid impostor to anchor to
  90200. * @param width ratio across width from 0 to 1
  90201. * @param height ratio up height from 0 to 1
  90202. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  90203. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  90204. * @returns impostor the soft imposter
  90205. */
  90206. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90207. /**
  90208. * Add a hook to a rope impostor
  90209. * @param otherImpostor rigid impostor to anchor to
  90210. * @param length ratio across rope from 0 to 1
  90211. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  90212. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  90213. * @returns impostor the rope imposter
  90214. */
  90215. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  90216. /**
  90217. * Will keep this body still, in a sleep mode.
  90218. * @returns the physics imposter
  90219. */
  90220. sleep(): PhysicsImpostor;
  90221. /**
  90222. * Wake the body up.
  90223. * @returns The physics imposter
  90224. */
  90225. wakeUp(): PhysicsImpostor;
  90226. /**
  90227. * Clones the physics imposter
  90228. * @param newObject The physics imposter clones to this physics-enabled object
  90229. * @returns A nullable physics imposter
  90230. */
  90231. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  90232. /**
  90233. * Disposes the physics imposter
  90234. */
  90235. dispose(): void;
  90236. /**
  90237. * Sets the delta position
  90238. * @param position The delta position amount
  90239. */
  90240. setDeltaPosition(position: Vector3): void;
  90241. /**
  90242. * Sets the delta rotation
  90243. * @param rotation The delta rotation amount
  90244. */
  90245. setDeltaRotation(rotation: Quaternion): void;
  90246. /**
  90247. * Gets the box size of the physics imposter and stores the result in the input parameter
  90248. * @param result Stores the box size
  90249. * @returns The physics imposter
  90250. */
  90251. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  90252. /**
  90253. * Gets the radius of the physics imposter
  90254. * @returns Radius of the physics imposter
  90255. */
  90256. getRadius(): number;
  90257. /**
  90258. * Sync a bone with this impostor
  90259. * @param bone The bone to sync to the impostor.
  90260. * @param boneMesh The mesh that the bone is influencing.
  90261. * @param jointPivot The pivot of the joint / bone in local space.
  90262. * @param distToJoint Optional distance from the impostor to the joint.
  90263. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90264. */
  90265. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  90266. /**
  90267. * Sync impostor to a bone
  90268. * @param bone The bone that the impostor will be synced to.
  90269. * @param boneMesh The mesh that the bone is influencing.
  90270. * @param jointPivot The pivot of the joint / bone in local space.
  90271. * @param distToJoint Optional distance from the impostor to the joint.
  90272. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  90273. * @param boneAxis Optional vector3 axis the bone is aligned with
  90274. */
  90275. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  90276. /**
  90277. * No-Imposter type
  90278. */
  90279. static NoImpostor: number;
  90280. /**
  90281. * Sphere-Imposter type
  90282. */
  90283. static SphereImpostor: number;
  90284. /**
  90285. * Box-Imposter type
  90286. */
  90287. static BoxImpostor: number;
  90288. /**
  90289. * Plane-Imposter type
  90290. */
  90291. static PlaneImpostor: number;
  90292. /**
  90293. * Mesh-imposter type
  90294. */
  90295. static MeshImpostor: number;
  90296. /**
  90297. * Capsule-Impostor type (Ammo.js plugin only)
  90298. */
  90299. static CapsuleImpostor: number;
  90300. /**
  90301. * Cylinder-Imposter type
  90302. */
  90303. static CylinderImpostor: number;
  90304. /**
  90305. * Particle-Imposter type
  90306. */
  90307. static ParticleImpostor: number;
  90308. /**
  90309. * Heightmap-Imposter type
  90310. */
  90311. static HeightmapImpostor: number;
  90312. /**
  90313. * ConvexHull-Impostor type (Ammo.js plugin only)
  90314. */
  90315. static ConvexHullImpostor: number;
  90316. /**
  90317. * Rope-Imposter type
  90318. */
  90319. static RopeImpostor: number;
  90320. /**
  90321. * Cloth-Imposter type
  90322. */
  90323. static ClothImpostor: number;
  90324. /**
  90325. * Softbody-Imposter type
  90326. */
  90327. static SoftbodyImpostor: number;
  90328. }
  90329. }
  90330. declare module BABYLON {
  90331. /**
  90332. * @hidden
  90333. **/
  90334. export class _CreationDataStorage {
  90335. closePath?: boolean;
  90336. closeArray?: boolean;
  90337. idx: number[];
  90338. dashSize: number;
  90339. gapSize: number;
  90340. path3D: Path3D;
  90341. pathArray: Vector3[][];
  90342. arc: number;
  90343. radius: number;
  90344. cap: number;
  90345. tessellation: number;
  90346. }
  90347. /**
  90348. * @hidden
  90349. **/
  90350. class _InstanceDataStorage {
  90351. visibleInstances: any;
  90352. batchCache: _InstancesBatch;
  90353. instancesBufferSize: number;
  90354. instancesBuffer: Nullable<Buffer>;
  90355. instancesData: Float32Array;
  90356. overridenInstanceCount: number;
  90357. isFrozen: boolean;
  90358. previousBatch: Nullable<_InstancesBatch>;
  90359. hardwareInstancedRendering: boolean;
  90360. sideOrientation: number;
  90361. }
  90362. /**
  90363. * @hidden
  90364. **/
  90365. export class _InstancesBatch {
  90366. mustReturn: boolean;
  90367. visibleInstances: Nullable<InstancedMesh[]>[];
  90368. renderSelf: boolean[];
  90369. hardwareInstancedRendering: boolean[];
  90370. }
  90371. /**
  90372. * Class used to represent renderable models
  90373. */
  90374. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  90375. /**
  90376. * Mesh side orientation : usually the external or front surface
  90377. */
  90378. static readonly FRONTSIDE: number;
  90379. /**
  90380. * Mesh side orientation : usually the internal or back surface
  90381. */
  90382. static readonly BACKSIDE: number;
  90383. /**
  90384. * Mesh side orientation : both internal and external or front and back surfaces
  90385. */
  90386. static readonly DOUBLESIDE: number;
  90387. /**
  90388. * Mesh side orientation : by default, `FRONTSIDE`
  90389. */
  90390. static readonly DEFAULTSIDE: number;
  90391. /**
  90392. * Mesh cap setting : no cap
  90393. */
  90394. static readonly NO_CAP: number;
  90395. /**
  90396. * Mesh cap setting : one cap at the beginning of the mesh
  90397. */
  90398. static readonly CAP_START: number;
  90399. /**
  90400. * Mesh cap setting : one cap at the end of the mesh
  90401. */
  90402. static readonly CAP_END: number;
  90403. /**
  90404. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  90405. */
  90406. static readonly CAP_ALL: number;
  90407. /**
  90408. * Mesh pattern setting : no flip or rotate
  90409. */
  90410. static readonly NO_FLIP: number;
  90411. /**
  90412. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  90413. */
  90414. static readonly FLIP_TILE: number;
  90415. /**
  90416. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  90417. */
  90418. static readonly ROTATE_TILE: number;
  90419. /**
  90420. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  90421. */
  90422. static readonly FLIP_ROW: number;
  90423. /**
  90424. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  90425. */
  90426. static readonly ROTATE_ROW: number;
  90427. /**
  90428. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  90429. */
  90430. static readonly FLIP_N_ROTATE_TILE: number;
  90431. /**
  90432. * Mesh pattern setting : rotate pattern and rotate
  90433. */
  90434. static readonly FLIP_N_ROTATE_ROW: number;
  90435. /**
  90436. * Mesh tile positioning : part tiles same on left/right or top/bottom
  90437. */
  90438. static readonly CENTER: number;
  90439. /**
  90440. * Mesh tile positioning : part tiles on left
  90441. */
  90442. static readonly LEFT: number;
  90443. /**
  90444. * Mesh tile positioning : part tiles on right
  90445. */
  90446. static readonly RIGHT: number;
  90447. /**
  90448. * Mesh tile positioning : part tiles on top
  90449. */
  90450. static readonly TOP: number;
  90451. /**
  90452. * Mesh tile positioning : part tiles on bottom
  90453. */
  90454. static readonly BOTTOM: number;
  90455. /**
  90456. * Gets the default side orientation.
  90457. * @param orientation the orientation to value to attempt to get
  90458. * @returns the default orientation
  90459. * @hidden
  90460. */
  90461. static _GetDefaultSideOrientation(orientation?: number): number;
  90462. private _internalMeshDataInfo;
  90463. /**
  90464. * An event triggered before rendering the mesh
  90465. */
  90466. readonly onBeforeRenderObservable: Observable<Mesh>;
  90467. /**
  90468. * An event triggered before binding the mesh
  90469. */
  90470. readonly onBeforeBindObservable: Observable<Mesh>;
  90471. /**
  90472. * An event triggered after rendering the mesh
  90473. */
  90474. readonly onAfterRenderObservable: Observable<Mesh>;
  90475. /**
  90476. * An event triggered before drawing the mesh
  90477. */
  90478. readonly onBeforeDrawObservable: Observable<Mesh>;
  90479. private _onBeforeDrawObserver;
  90480. /**
  90481. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  90482. */
  90483. onBeforeDraw: () => void;
  90484. readonly hasInstances: boolean;
  90485. /**
  90486. * Gets the delay loading state of the mesh (when delay loading is turned on)
  90487. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  90488. */
  90489. delayLoadState: number;
  90490. /**
  90491. * Gets the list of instances created from this mesh
  90492. * it is not supposed to be modified manually.
  90493. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  90494. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90495. */
  90496. instances: InstancedMesh[];
  90497. /**
  90498. * Gets the file containing delay loading data for this mesh
  90499. */
  90500. delayLoadingFile: string;
  90501. /** @hidden */
  90502. _binaryInfo: any;
  90503. /**
  90504. * User defined function used to change how LOD level selection is done
  90505. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  90506. */
  90507. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  90508. /**
  90509. * Gets or sets the morph target manager
  90510. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  90511. */
  90512. morphTargetManager: Nullable<MorphTargetManager>;
  90513. /** @hidden */
  90514. _creationDataStorage: Nullable<_CreationDataStorage>;
  90515. /** @hidden */
  90516. _geometry: Nullable<Geometry>;
  90517. /** @hidden */
  90518. _delayInfo: Array<string>;
  90519. /** @hidden */
  90520. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  90521. /** @hidden */
  90522. _instanceDataStorage: _InstanceDataStorage;
  90523. private _effectiveMaterial;
  90524. /** @hidden */
  90525. _shouldGenerateFlatShading: boolean;
  90526. /** @hidden */
  90527. _originalBuilderSideOrientation: number;
  90528. /**
  90529. * Use this property to change the original side orientation defined at construction time
  90530. */
  90531. overrideMaterialSideOrientation: Nullable<number>;
  90532. /**
  90533. * Gets the source mesh (the one used to clone this one from)
  90534. */
  90535. readonly source: Nullable<Mesh>;
  90536. /**
  90537. * Gets or sets a boolean indicating that this mesh does not use index buffer
  90538. */
  90539. isUnIndexed: boolean;
  90540. /**
  90541. * @constructor
  90542. * @param name The value used by scene.getMeshByName() to do a lookup.
  90543. * @param scene The scene to add this mesh to.
  90544. * @param parent The parent of this mesh, if it has one
  90545. * @param source An optional Mesh from which geometry is shared, cloned.
  90546. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90547. * When false, achieved by calling a clone(), also passing False.
  90548. * This will make creation of children, recursive.
  90549. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  90550. */
  90551. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  90552. instantiateHierarchy(newParent?: Nullable<TransformNode>): Nullable<TransformNode>;
  90553. /**
  90554. * Gets the class name
  90555. * @returns the string "Mesh".
  90556. */
  90557. getClassName(): string;
  90558. /** @hidden */
  90559. readonly _isMesh: boolean;
  90560. /**
  90561. * Returns a description of this mesh
  90562. * @param fullDetails define if full details about this mesh must be used
  90563. * @returns a descriptive string representing this mesh
  90564. */
  90565. toString(fullDetails?: boolean): string;
  90566. /** @hidden */
  90567. _unBindEffect(): void;
  90568. /**
  90569. * Gets a boolean indicating if this mesh has LOD
  90570. */
  90571. readonly hasLODLevels: boolean;
  90572. /**
  90573. * Gets the list of MeshLODLevel associated with the current mesh
  90574. * @returns an array of MeshLODLevel
  90575. */
  90576. getLODLevels(): MeshLODLevel[];
  90577. private _sortLODLevels;
  90578. /**
  90579. * Add a mesh as LOD level triggered at the given distance.
  90580. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90581. * @param distance The distance from the center of the object to show this level
  90582. * @param mesh The mesh to be added as LOD level (can be null)
  90583. * @return This mesh (for chaining)
  90584. */
  90585. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  90586. /**
  90587. * Returns the LOD level mesh at the passed distance or null if not found.
  90588. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90589. * @param distance The distance from the center of the object to show this level
  90590. * @returns a Mesh or `null`
  90591. */
  90592. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  90593. /**
  90594. * Remove a mesh from the LOD array
  90595. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90596. * @param mesh defines the mesh to be removed
  90597. * @return This mesh (for chaining)
  90598. */
  90599. removeLODLevel(mesh: Mesh): Mesh;
  90600. /**
  90601. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  90602. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  90603. * @param camera defines the camera to use to compute distance
  90604. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  90605. * @return This mesh (for chaining)
  90606. */
  90607. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  90608. /**
  90609. * Gets the mesh internal Geometry object
  90610. */
  90611. readonly geometry: Nullable<Geometry>;
  90612. /**
  90613. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  90614. * @returns the total number of vertices
  90615. */
  90616. getTotalVertices(): number;
  90617. /**
  90618. * Returns the content of an associated vertex buffer
  90619. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90620. * - VertexBuffer.PositionKind
  90621. * - VertexBuffer.UVKind
  90622. * - VertexBuffer.UV2Kind
  90623. * - VertexBuffer.UV3Kind
  90624. * - VertexBuffer.UV4Kind
  90625. * - VertexBuffer.UV5Kind
  90626. * - VertexBuffer.UV6Kind
  90627. * - VertexBuffer.ColorKind
  90628. * - VertexBuffer.MatricesIndicesKind
  90629. * - VertexBuffer.MatricesIndicesExtraKind
  90630. * - VertexBuffer.MatricesWeightsKind
  90631. * - VertexBuffer.MatricesWeightsExtraKind
  90632. * @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
  90633. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  90634. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  90635. */
  90636. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  90637. /**
  90638. * Returns the mesh VertexBuffer object from the requested `kind`
  90639. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90640. * - VertexBuffer.PositionKind
  90641. * - VertexBuffer.NormalKind
  90642. * - VertexBuffer.UVKind
  90643. * - VertexBuffer.UV2Kind
  90644. * - VertexBuffer.UV3Kind
  90645. * - VertexBuffer.UV4Kind
  90646. * - VertexBuffer.UV5Kind
  90647. * - VertexBuffer.UV6Kind
  90648. * - VertexBuffer.ColorKind
  90649. * - VertexBuffer.MatricesIndicesKind
  90650. * - VertexBuffer.MatricesIndicesExtraKind
  90651. * - VertexBuffer.MatricesWeightsKind
  90652. * - VertexBuffer.MatricesWeightsExtraKind
  90653. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  90654. */
  90655. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  90656. /**
  90657. * Tests if a specific vertex buffer is associated with this mesh
  90658. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90659. * - VertexBuffer.PositionKind
  90660. * - VertexBuffer.NormalKind
  90661. * - VertexBuffer.UVKind
  90662. * - VertexBuffer.UV2Kind
  90663. * - VertexBuffer.UV3Kind
  90664. * - VertexBuffer.UV4Kind
  90665. * - VertexBuffer.UV5Kind
  90666. * - VertexBuffer.UV6Kind
  90667. * - VertexBuffer.ColorKind
  90668. * - VertexBuffer.MatricesIndicesKind
  90669. * - VertexBuffer.MatricesIndicesExtraKind
  90670. * - VertexBuffer.MatricesWeightsKind
  90671. * - VertexBuffer.MatricesWeightsExtraKind
  90672. * @returns a boolean
  90673. */
  90674. isVerticesDataPresent(kind: string): boolean;
  90675. /**
  90676. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  90677. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  90678. * - VertexBuffer.PositionKind
  90679. * - VertexBuffer.UVKind
  90680. * - VertexBuffer.UV2Kind
  90681. * - VertexBuffer.UV3Kind
  90682. * - VertexBuffer.UV4Kind
  90683. * - VertexBuffer.UV5Kind
  90684. * - VertexBuffer.UV6Kind
  90685. * - VertexBuffer.ColorKind
  90686. * - VertexBuffer.MatricesIndicesKind
  90687. * - VertexBuffer.MatricesIndicesExtraKind
  90688. * - VertexBuffer.MatricesWeightsKind
  90689. * - VertexBuffer.MatricesWeightsExtraKind
  90690. * @returns a boolean
  90691. */
  90692. isVertexBufferUpdatable(kind: string): boolean;
  90693. /**
  90694. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  90695. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  90696. * - VertexBuffer.PositionKind
  90697. * - VertexBuffer.NormalKind
  90698. * - VertexBuffer.UVKind
  90699. * - VertexBuffer.UV2Kind
  90700. * - VertexBuffer.UV3Kind
  90701. * - VertexBuffer.UV4Kind
  90702. * - VertexBuffer.UV5Kind
  90703. * - VertexBuffer.UV6Kind
  90704. * - VertexBuffer.ColorKind
  90705. * - VertexBuffer.MatricesIndicesKind
  90706. * - VertexBuffer.MatricesIndicesExtraKind
  90707. * - VertexBuffer.MatricesWeightsKind
  90708. * - VertexBuffer.MatricesWeightsExtraKind
  90709. * @returns an array of strings
  90710. */
  90711. getVerticesDataKinds(): string[];
  90712. /**
  90713. * Returns a positive integer : the total number of indices in this mesh geometry.
  90714. * @returns the numner of indices or zero if the mesh has no geometry.
  90715. */
  90716. getTotalIndices(): number;
  90717. /**
  90718. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  90719. * @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.
  90720. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  90721. * @returns the indices array or an empty array if the mesh has no geometry
  90722. */
  90723. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  90724. readonly isBlocked: boolean;
  90725. /**
  90726. * Determine if the current mesh is ready to be rendered
  90727. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  90728. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  90729. * @returns true if all associated assets are ready (material, textures, shaders)
  90730. */
  90731. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  90732. /**
  90733. * 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.
  90734. */
  90735. readonly areNormalsFrozen: boolean;
  90736. /**
  90737. * 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.
  90738. * @returns the current mesh
  90739. */
  90740. freezeNormals(): Mesh;
  90741. /**
  90742. * 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
  90743. * @returns the current mesh
  90744. */
  90745. unfreezeNormals(): Mesh;
  90746. /**
  90747. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  90748. */
  90749. overridenInstanceCount: number;
  90750. /** @hidden */
  90751. _preActivate(): Mesh;
  90752. /** @hidden */
  90753. _preActivateForIntermediateRendering(renderId: number): Mesh;
  90754. /** @hidden */
  90755. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  90756. /**
  90757. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  90758. * This means the mesh underlying bounding box and sphere are recomputed.
  90759. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  90760. * @returns the current mesh
  90761. */
  90762. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  90763. /** @hidden */
  90764. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  90765. /**
  90766. * This function will subdivide the mesh into multiple submeshes
  90767. * @param count defines the expected number of submeshes
  90768. */
  90769. subdivide(count: number): void;
  90770. /**
  90771. * Copy a FloatArray into a specific associated vertex buffer
  90772. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90773. * - VertexBuffer.PositionKind
  90774. * - VertexBuffer.UVKind
  90775. * - VertexBuffer.UV2Kind
  90776. * - VertexBuffer.UV3Kind
  90777. * - VertexBuffer.UV4Kind
  90778. * - VertexBuffer.UV5Kind
  90779. * - VertexBuffer.UV6Kind
  90780. * - VertexBuffer.ColorKind
  90781. * - VertexBuffer.MatricesIndicesKind
  90782. * - VertexBuffer.MatricesIndicesExtraKind
  90783. * - VertexBuffer.MatricesWeightsKind
  90784. * - VertexBuffer.MatricesWeightsExtraKind
  90785. * @param data defines the data source
  90786. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90787. * @param stride defines the data stride size (can be null)
  90788. * @returns the current mesh
  90789. */
  90790. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  90791. /**
  90792. * Flags an associated vertex buffer as updatable
  90793. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  90794. * - VertexBuffer.PositionKind
  90795. * - VertexBuffer.UVKind
  90796. * - VertexBuffer.UV2Kind
  90797. * - VertexBuffer.UV3Kind
  90798. * - VertexBuffer.UV4Kind
  90799. * - VertexBuffer.UV5Kind
  90800. * - VertexBuffer.UV6Kind
  90801. * - VertexBuffer.ColorKind
  90802. * - VertexBuffer.MatricesIndicesKind
  90803. * - VertexBuffer.MatricesIndicesExtraKind
  90804. * - VertexBuffer.MatricesWeightsKind
  90805. * - VertexBuffer.MatricesWeightsExtraKind
  90806. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  90807. */
  90808. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  90809. /**
  90810. * Sets the mesh global Vertex Buffer
  90811. * @param buffer defines the buffer to use
  90812. * @returns the current mesh
  90813. */
  90814. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  90815. /**
  90816. * Update a specific associated vertex buffer
  90817. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  90818. * - VertexBuffer.PositionKind
  90819. * - VertexBuffer.UVKind
  90820. * - VertexBuffer.UV2Kind
  90821. * - VertexBuffer.UV3Kind
  90822. * - VertexBuffer.UV4Kind
  90823. * - VertexBuffer.UV5Kind
  90824. * - VertexBuffer.UV6Kind
  90825. * - VertexBuffer.ColorKind
  90826. * - VertexBuffer.MatricesIndicesKind
  90827. * - VertexBuffer.MatricesIndicesExtraKind
  90828. * - VertexBuffer.MatricesWeightsKind
  90829. * - VertexBuffer.MatricesWeightsExtraKind
  90830. * @param data defines the data source
  90831. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  90832. * @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)
  90833. * @returns the current mesh
  90834. */
  90835. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  90836. /**
  90837. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  90838. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  90839. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  90840. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  90841. * @returns the current mesh
  90842. */
  90843. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  90844. /**
  90845. * Creates a un-shared specific occurence of the geometry for the mesh.
  90846. * @returns the current mesh
  90847. */
  90848. makeGeometryUnique(): Mesh;
  90849. /**
  90850. * Set the index buffer of this mesh
  90851. * @param indices defines the source data
  90852. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  90853. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  90854. * @returns the current mesh
  90855. */
  90856. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  90857. /**
  90858. * Update the current index buffer
  90859. * @param indices defines the source data
  90860. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  90861. * @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)
  90862. * @returns the current mesh
  90863. */
  90864. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  90865. /**
  90866. * Invert the geometry to move from a right handed system to a left handed one.
  90867. * @returns the current mesh
  90868. */
  90869. toLeftHanded(): Mesh;
  90870. /** @hidden */
  90871. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90872. /** @hidden */
  90873. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90874. /**
  90875. * Registers for this mesh a javascript function called just before the rendering process
  90876. * @param func defines the function to call before rendering this mesh
  90877. * @returns the current mesh
  90878. */
  90879. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90880. /**
  90881. * Disposes a previously registered javascript function called before the rendering
  90882. * @param func defines the function to remove
  90883. * @returns the current mesh
  90884. */
  90885. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  90886. /**
  90887. * Registers for this mesh a javascript function called just after the rendering is complete
  90888. * @param func defines the function to call after rendering this mesh
  90889. * @returns the current mesh
  90890. */
  90891. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90892. /**
  90893. * Disposes a previously registered javascript function called after the rendering.
  90894. * @param func defines the function to remove
  90895. * @returns the current mesh
  90896. */
  90897. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  90898. /** @hidden */
  90899. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  90900. /** @hidden */
  90901. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  90902. /** @hidden */
  90903. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  90904. /** @hidden */
  90905. _rebuild(): void;
  90906. /** @hidden */
  90907. _freeze(): void;
  90908. /** @hidden */
  90909. _unFreeze(): void;
  90910. /**
  90911. * 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
  90912. * @param subMesh defines the subMesh to render
  90913. * @param enableAlphaMode defines if alpha mode can be changed
  90914. * @returns the current mesh
  90915. */
  90916. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  90917. private _onBeforeDraw;
  90918. /**
  90919. * Renormalize the mesh and patch it up if there are no weights
  90920. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  90921. * However in the case of zero weights then we set just a single influence to 1.
  90922. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  90923. */
  90924. cleanMatrixWeights(): void;
  90925. private normalizeSkinFourWeights;
  90926. private normalizeSkinWeightsAndExtra;
  90927. /**
  90928. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  90929. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  90930. * the user know there was an issue with importing the mesh
  90931. * @returns a validation object with skinned, valid and report string
  90932. */
  90933. validateSkinning(): {
  90934. skinned: boolean;
  90935. valid: boolean;
  90936. report: string;
  90937. };
  90938. /** @hidden */
  90939. _checkDelayState(): Mesh;
  90940. private _queueLoad;
  90941. /**
  90942. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  90943. * A mesh is in the frustum if its bounding box intersects the frustum
  90944. * @param frustumPlanes defines the frustum to test
  90945. * @returns true if the mesh is in the frustum planes
  90946. */
  90947. isInFrustum(frustumPlanes: Plane[]): boolean;
  90948. /**
  90949. * Sets the mesh material by the material or multiMaterial `id` property
  90950. * @param id is a string identifying the material or the multiMaterial
  90951. * @returns the current mesh
  90952. */
  90953. setMaterialByID(id: string): Mesh;
  90954. /**
  90955. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  90956. * @returns an array of IAnimatable
  90957. */
  90958. getAnimatables(): IAnimatable[];
  90959. /**
  90960. * Modifies the mesh geometry according to the passed transformation matrix.
  90961. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  90962. * The mesh normals are modified using the same transformation.
  90963. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90964. * @param transform defines the transform matrix to use
  90965. * @see http://doc.babylonjs.com/resources/baking_transformations
  90966. * @returns the current mesh
  90967. */
  90968. bakeTransformIntoVertices(transform: Matrix): Mesh;
  90969. /**
  90970. * Modifies the mesh geometry according to its own current World Matrix.
  90971. * The mesh World Matrix is then reset.
  90972. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  90973. * Note that, under the hood, this method sets a new VertexBuffer each call.
  90974. * @see http://doc.babylonjs.com/resources/baking_transformations
  90975. * @returns the current mesh
  90976. */
  90977. bakeCurrentTransformIntoVertices(): Mesh;
  90978. /** @hidden */
  90979. readonly _positions: Nullable<Vector3[]>;
  90980. /** @hidden */
  90981. _resetPointsArrayCache(): Mesh;
  90982. /** @hidden */
  90983. _generatePointsArray(): boolean;
  90984. /**
  90985. * Returns a new Mesh object generated from the current mesh properties.
  90986. * This method must not get confused with createInstance()
  90987. * @param name is a string, the name given to the new mesh
  90988. * @param newParent can be any Node object (default `null`)
  90989. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  90990. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  90991. * @returns a new mesh
  90992. */
  90993. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Nullable<AbstractMesh>;
  90994. /**
  90995. * Releases resources associated with this mesh.
  90996. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90997. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90998. */
  90999. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91000. /**
  91001. * Modifies the mesh geometry according to a displacement map.
  91002. * 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.
  91003. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91004. * @param url is a string, the URL from the image file is to be downloaded.
  91005. * @param minHeight is the lower limit of the displacement.
  91006. * @param maxHeight is the upper limit of the displacement.
  91007. * @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.
  91008. * @param uvOffset is an optional vector2 used to offset UV.
  91009. * @param uvScale is an optional vector2 used to scale UV.
  91010. * @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.
  91011. * @returns the Mesh.
  91012. */
  91013. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91014. /**
  91015. * Modifies the mesh geometry according to a displacementMap buffer.
  91016. * 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.
  91017. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  91018. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  91019. * @param heightMapWidth is the width of the buffer image.
  91020. * @param heightMapHeight is the height of the buffer image.
  91021. * @param minHeight is the lower limit of the displacement.
  91022. * @param maxHeight is the upper limit of the displacement.
  91023. * @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.
  91024. * @param uvOffset is an optional vector2 used to offset UV.
  91025. * @param uvScale is an optional vector2 used to scale UV.
  91026. * @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.
  91027. * @returns the Mesh.
  91028. */
  91029. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  91030. /**
  91031. * Modify the mesh to get a flat shading rendering.
  91032. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  91033. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  91034. * @returns current mesh
  91035. */
  91036. convertToFlatShadedMesh(): Mesh;
  91037. /**
  91038. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  91039. * In other words, more vertices, no more indices and a single bigger VBO.
  91040. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  91041. * @returns current mesh
  91042. */
  91043. convertToUnIndexedMesh(): Mesh;
  91044. /**
  91045. * Inverses facet orientations.
  91046. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91047. * @param flipNormals will also inverts the normals
  91048. * @returns current mesh
  91049. */
  91050. flipFaces(flipNormals?: boolean): Mesh;
  91051. /**
  91052. * Increase the number of facets and hence vertices in a mesh
  91053. * Vertex normals are interpolated from existing vertex normals
  91054. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91055. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  91056. */
  91057. increaseVertices(numberPerEdge: number): void;
  91058. /**
  91059. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  91060. * This will undo any application of covertToFlatShadedMesh
  91061. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  91062. */
  91063. forceSharedVertices(): void;
  91064. /** @hidden */
  91065. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  91066. /** @hidden */
  91067. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  91068. /**
  91069. * Creates a new InstancedMesh object from the mesh model.
  91070. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  91071. * @param name defines the name of the new instance
  91072. * @returns a new InstancedMesh
  91073. */
  91074. createInstance(name: string): InstancedMesh;
  91075. /**
  91076. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  91077. * After this call, all the mesh instances have the same submeshes than the current mesh.
  91078. * @returns the current mesh
  91079. */
  91080. synchronizeInstances(): Mesh;
  91081. /**
  91082. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  91083. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  91084. * This should be used together with the simplification to avoid disappearing triangles.
  91085. * @param successCallback an optional success callback to be called after the optimization finished.
  91086. * @returns the current mesh
  91087. */
  91088. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  91089. /**
  91090. * Serialize current mesh
  91091. * @param serializationObject defines the object which will receive the serialization data
  91092. */
  91093. serialize(serializationObject: any): void;
  91094. /** @hidden */
  91095. _syncGeometryWithMorphTargetManager(): void;
  91096. /** @hidden */
  91097. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  91098. /**
  91099. * Returns a new Mesh object parsed from the source provided.
  91100. * @param parsedMesh is the source
  91101. * @param scene defines the hosting scene
  91102. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  91103. * @returns a new Mesh
  91104. */
  91105. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  91106. /**
  91107. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  91108. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91109. * @param name defines the name of the mesh to create
  91110. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  91111. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  91112. * @param closePath creates a seam between the first and the last points of each path of the path array
  91113. * @param offset is taken in account only if the `pathArray` is containing a single path
  91114. * @param scene defines the hosting scene
  91115. * @param updatable defines if the mesh must be flagged as updatable
  91116. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91117. * @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)
  91118. * @returns a new Mesh
  91119. */
  91120. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91121. /**
  91122. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  91123. * @param name defines the name of the mesh to create
  91124. * @param radius sets the radius size (float) of the polygon (default 0.5)
  91125. * @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
  91126. * @param scene defines the hosting scene
  91127. * @param updatable defines if the mesh must be flagged as updatable
  91128. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91129. * @returns a new Mesh
  91130. */
  91131. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91132. /**
  91133. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  91134. * @param name defines the name of the mesh to create
  91135. * @param size sets the size (float) of each box side (default 1)
  91136. * @param scene defines the hosting scene
  91137. * @param updatable defines if the mesh must be flagged as updatable
  91138. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91139. * @returns a new Mesh
  91140. */
  91141. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  91142. /**
  91143. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  91144. * @param name defines the name of the mesh to create
  91145. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91146. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91147. * @param scene defines the hosting scene
  91148. * @param updatable defines if the mesh must be flagged as updatable
  91149. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91150. * @returns a new Mesh
  91151. */
  91152. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91153. /**
  91154. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  91155. * @param name defines the name of the mesh to create
  91156. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  91157. * @param diameter sets the diameter size (float) of the sphere (default 1)
  91158. * @param scene defines the hosting scene
  91159. * @returns a new Mesh
  91160. */
  91161. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  91162. /**
  91163. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  91164. * @param name defines the name of the mesh to create
  91165. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  91166. * @param diameterTop set the top cap diameter (floats, default 1)
  91167. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  91168. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  91169. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  91170. * @param scene defines the hosting scene
  91171. * @param updatable defines if the mesh must be flagged as updatable
  91172. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91173. * @returns a new Mesh
  91174. */
  91175. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  91176. /**
  91177. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  91178. * @param name defines the name of the mesh to create
  91179. * @param diameter sets the diameter size (float) of the torus (default 1)
  91180. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  91181. * @param tessellation sets the number of torus sides (postive integer, default 16)
  91182. * @param scene defines the hosting scene
  91183. * @param updatable defines if the mesh must be flagged as updatable
  91184. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91185. * @returns a new Mesh
  91186. */
  91187. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91188. /**
  91189. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  91190. * @param name defines the name of the mesh to create
  91191. * @param radius sets the global radius size (float) of the torus knot (default 2)
  91192. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  91193. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  91194. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  91195. * @param p the number of windings on X axis (positive integers, default 2)
  91196. * @param q the number of windings on Y axis (positive integers, default 3)
  91197. * @param scene defines the hosting scene
  91198. * @param updatable defines if the mesh must be flagged as updatable
  91199. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91200. * @returns a new Mesh
  91201. */
  91202. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91203. /**
  91204. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  91205. * @param name defines the name of the mesh to create
  91206. * @param points is an array successive Vector3
  91207. * @param scene defines the hosting scene
  91208. * @param updatable defines if the mesh must be flagged as updatable
  91209. * @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).
  91210. * @returns a new Mesh
  91211. */
  91212. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  91213. /**
  91214. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  91215. * @param name defines the name of the mesh to create
  91216. * @param points is an array successive Vector3
  91217. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  91218. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  91219. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  91220. * @param scene defines the hosting scene
  91221. * @param updatable defines if the mesh must be flagged as updatable
  91222. * @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)
  91223. * @returns a new Mesh
  91224. */
  91225. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  91226. /**
  91227. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  91228. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  91229. * 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.
  91230. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91231. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  91232. * Remember you can only change the shape positions, not their number when updating a polygon.
  91233. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  91234. * @param name defines the name of the mesh to create
  91235. * @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
  91236. * @param scene defines the hosting scene
  91237. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91238. * @param updatable defines if the mesh must be flagged as updatable
  91239. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91240. * @param earcutInjection can be used to inject your own earcut reference
  91241. * @returns a new Mesh
  91242. */
  91243. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91244. /**
  91245. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  91246. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  91247. * @param name defines the name of the mesh to create
  91248. * @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
  91249. * @param depth defines the height of extrusion
  91250. * @param scene defines the hosting scene
  91251. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  91252. * @param updatable defines if the mesh must be flagged as updatable
  91253. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91254. * @param earcutInjection can be used to inject your own earcut reference
  91255. * @returns a new Mesh
  91256. */
  91257. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  91258. /**
  91259. * Creates an extruded shape mesh.
  91260. * 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
  91261. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91262. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91263. * @param name defines the name of the mesh to create
  91264. * @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
  91265. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91266. * @param scale is the value to scale the shape
  91267. * @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
  91268. * @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
  91269. * @param scene defines the hosting scene
  91270. * @param updatable defines if the mesh must be flagged as updatable
  91271. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91272. * @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)
  91273. * @returns a new Mesh
  91274. */
  91275. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91276. /**
  91277. * Creates an custom extruded shape mesh.
  91278. * The custom extrusion is a parametric shape.
  91279. * It has no predefined shape. Its final shape will depend on the input parameters.
  91280. * Please consider using the same method from the MeshBuilder class instead
  91281. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  91282. * @param name defines the name of the mesh to create
  91283. * @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
  91284. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  91285. * @param scaleFunction is a custom Javascript function called on each path point
  91286. * @param rotationFunction is a custom Javascript function called on each path point
  91287. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  91288. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  91289. * @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
  91290. * @param scene defines the hosting scene
  91291. * @param updatable defines if the mesh must be flagged as updatable
  91292. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91293. * @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)
  91294. * @returns a new Mesh
  91295. */
  91296. 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;
  91297. /**
  91298. * Creates lathe mesh.
  91299. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  91300. * Please consider using the same method from the MeshBuilder class instead
  91301. * @param name defines the name of the mesh to create
  91302. * @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
  91303. * @param radius is the radius value of the lathe
  91304. * @param tessellation is the side number of the lathe.
  91305. * @param scene defines the hosting scene
  91306. * @param updatable defines if the mesh must be flagged as updatable
  91307. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91308. * @returns a new Mesh
  91309. */
  91310. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91311. /**
  91312. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  91313. * @param name defines the name of the mesh to create
  91314. * @param size sets the size (float) of both sides of the plane at once (default 1)
  91315. * @param scene defines the hosting scene
  91316. * @param updatable defines if the mesh must be flagged as updatable
  91317. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91318. * @returns a new Mesh
  91319. */
  91320. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  91321. /**
  91322. * Creates a ground mesh.
  91323. * Please consider using the same method from the MeshBuilder class instead
  91324. * @param name defines the name of the mesh to create
  91325. * @param width set the width of the ground
  91326. * @param height set the height of the ground
  91327. * @param subdivisions sets the number of subdivisions per side
  91328. * @param scene defines the hosting scene
  91329. * @param updatable defines if the mesh must be flagged as updatable
  91330. * @returns a new Mesh
  91331. */
  91332. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  91333. /**
  91334. * Creates a tiled ground mesh.
  91335. * Please consider using the same method from the MeshBuilder class instead
  91336. * @param name defines the name of the mesh to create
  91337. * @param xmin set the ground minimum X coordinate
  91338. * @param zmin set the ground minimum Y coordinate
  91339. * @param xmax set the ground maximum X coordinate
  91340. * @param zmax set the ground maximum Z coordinate
  91341. * @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
  91342. * @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
  91343. * @param scene defines the hosting scene
  91344. * @param updatable defines if the mesh must be flagged as updatable
  91345. * @returns a new Mesh
  91346. */
  91347. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  91348. w: number;
  91349. h: number;
  91350. }, precision: {
  91351. w: number;
  91352. h: number;
  91353. }, scene: Scene, updatable?: boolean): Mesh;
  91354. /**
  91355. * Creates a ground mesh from a height map.
  91356. * Please consider using the same method from the MeshBuilder class instead
  91357. * @see http://doc.babylonjs.com/babylon101/height_map
  91358. * @param name defines the name of the mesh to create
  91359. * @param url sets the URL of the height map image resource
  91360. * @param width set the ground width size
  91361. * @param height set the ground height size
  91362. * @param subdivisions sets the number of subdivision per side
  91363. * @param minHeight is the minimum altitude on the ground
  91364. * @param maxHeight is the maximum altitude on the ground
  91365. * @param scene defines the hosting scene
  91366. * @param updatable defines if the mesh must be flagged as updatable
  91367. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  91368. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  91369. * @returns a new Mesh
  91370. */
  91371. 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;
  91372. /**
  91373. * Creates a tube mesh.
  91374. * The tube is a parametric shape.
  91375. * It has no predefined shape. Its final shape will depend on the input parameters.
  91376. * Please consider using the same method from the MeshBuilder class instead
  91377. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  91378. * @param name defines the name of the mesh to create
  91379. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  91380. * @param radius sets the tube radius size
  91381. * @param tessellation is the number of sides on the tubular surface
  91382. * @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
  91383. * @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
  91384. * @param scene defines the hosting scene
  91385. * @param updatable defines if the mesh must be flagged as updatable
  91386. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  91387. * @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)
  91388. * @returns a new Mesh
  91389. */
  91390. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  91391. (i: number, distance: number): number;
  91392. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  91393. /**
  91394. * Creates a polyhedron mesh.
  91395. * Please consider using the same method from the MeshBuilder class instead.
  91396. * * 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
  91397. * * The parameter `size` (positive float, default 1) sets the polygon size
  91398. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  91399. * * 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`
  91400. * * 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
  91401. * * 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)`)
  91402. * * 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
  91403. * * 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
  91404. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91405. * * If you create a double-sided mesh, you can choose what parts of 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
  91406. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91407. * @param name defines the name of the mesh to create
  91408. * @param options defines the options used to create the mesh
  91409. * @param scene defines the hosting scene
  91410. * @returns a new Mesh
  91411. */
  91412. static CreatePolyhedron(name: string, options: {
  91413. type?: number;
  91414. size?: number;
  91415. sizeX?: number;
  91416. sizeY?: number;
  91417. sizeZ?: number;
  91418. custom?: any;
  91419. faceUV?: Vector4[];
  91420. faceColors?: Color4[];
  91421. updatable?: boolean;
  91422. sideOrientation?: number;
  91423. }, scene: Scene): Mesh;
  91424. /**
  91425. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  91426. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  91427. * * 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`)
  91428. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  91429. * * 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
  91430. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  91431. * * If you create a double-sided mesh, you can choose what parts of 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
  91432. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  91433. * @param name defines the name of the mesh
  91434. * @param options defines the options used to create the mesh
  91435. * @param scene defines the hosting scene
  91436. * @returns a new Mesh
  91437. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  91438. */
  91439. static CreateIcoSphere(name: string, options: {
  91440. radius?: number;
  91441. flat?: boolean;
  91442. subdivisions?: number;
  91443. sideOrientation?: number;
  91444. updatable?: boolean;
  91445. }, scene: Scene): Mesh;
  91446. /**
  91447. * Creates a decal mesh.
  91448. * Please consider using the same method from the MeshBuilder class instead.
  91449. * A decal is a mesh usually applied as a model onto the surface of another mesh
  91450. * @param name defines the name of the mesh
  91451. * @param sourceMesh defines the mesh receiving the decal
  91452. * @param position sets the position of the decal in world coordinates
  91453. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  91454. * @param size sets the decal scaling
  91455. * @param angle sets the angle to rotate the decal
  91456. * @returns a new Mesh
  91457. */
  91458. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  91459. /**
  91460. * Prepare internal position array for software CPU skinning
  91461. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  91462. */
  91463. setPositionsForCPUSkinning(): Float32Array;
  91464. /**
  91465. * Prepare internal normal array for software CPU skinning
  91466. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  91467. */
  91468. setNormalsForCPUSkinning(): Float32Array;
  91469. /**
  91470. * Updates the vertex buffer by applying transformation from the bones
  91471. * @param skeleton defines the skeleton to apply to current mesh
  91472. * @returns the current mesh
  91473. */
  91474. applySkeleton(skeleton: Skeleton): Mesh;
  91475. /**
  91476. * 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
  91477. * @param meshes defines the list of meshes to scan
  91478. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  91479. */
  91480. static MinMax(meshes: AbstractMesh[]): {
  91481. min: Vector3;
  91482. max: Vector3;
  91483. };
  91484. /**
  91485. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  91486. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  91487. * @returns a vector3
  91488. */
  91489. static Center(meshesOrMinMaxVector: {
  91490. min: Vector3;
  91491. max: Vector3;
  91492. } | AbstractMesh[]): Vector3;
  91493. /**
  91494. * Merge the array of meshes into a single mesh for performance reasons.
  91495. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  91496. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  91497. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  91498. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  91499. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  91500. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  91501. * @returns a new mesh
  91502. */
  91503. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  91504. /** @hidden */
  91505. addInstance(instance: InstancedMesh): void;
  91506. /** @hidden */
  91507. removeInstance(instance: InstancedMesh): void;
  91508. }
  91509. }
  91510. declare module BABYLON {
  91511. /**
  91512. * This is the base class of all the camera used in the application.
  91513. * @see http://doc.babylonjs.com/features/cameras
  91514. */
  91515. export class Camera extends Node {
  91516. /** @hidden */
  91517. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  91518. /**
  91519. * This is the default projection mode used by the cameras.
  91520. * It helps recreating a feeling of perspective and better appreciate depth.
  91521. * This is the best way to simulate real life cameras.
  91522. */
  91523. static readonly PERSPECTIVE_CAMERA: number;
  91524. /**
  91525. * This helps creating camera with an orthographic mode.
  91526. * 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.
  91527. */
  91528. static readonly ORTHOGRAPHIC_CAMERA: number;
  91529. /**
  91530. * This is the default FOV mode for perspective cameras.
  91531. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  91532. */
  91533. static readonly FOVMODE_VERTICAL_FIXED: number;
  91534. /**
  91535. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  91536. */
  91537. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  91538. /**
  91539. * This specifies ther is no need for a camera rig.
  91540. * Basically only one eye is rendered corresponding to the camera.
  91541. */
  91542. static readonly RIG_MODE_NONE: number;
  91543. /**
  91544. * Simulates a camera Rig with one blue eye and one red eye.
  91545. * This can be use with 3d blue and red glasses.
  91546. */
  91547. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  91548. /**
  91549. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  91550. */
  91551. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  91552. /**
  91553. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  91554. */
  91555. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  91556. /**
  91557. * Defines that both eyes of the camera will be rendered over under each other.
  91558. */
  91559. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  91560. /**
  91561. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  91562. */
  91563. static readonly RIG_MODE_VR: number;
  91564. /**
  91565. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  91566. */
  91567. static readonly RIG_MODE_WEBVR: number;
  91568. /**
  91569. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  91570. */
  91571. static readonly RIG_MODE_CUSTOM: number;
  91572. /**
  91573. * Defines if by default attaching controls should prevent the default javascript event to continue.
  91574. */
  91575. static ForceAttachControlToAlwaysPreventDefault: boolean;
  91576. /**
  91577. * Define the input manager associated with the camera.
  91578. */
  91579. inputs: CameraInputsManager<Camera>;
  91580. /** @hidden */
  91581. _position: Vector3;
  91582. /**
  91583. * Define the current local position of the camera in the scene
  91584. */
  91585. position: Vector3;
  91586. /**
  91587. * The vector the camera should consider as up.
  91588. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  91589. */
  91590. upVector: Vector3;
  91591. /**
  91592. * Define the current limit on the left side for an orthographic camera
  91593. * In scene unit
  91594. */
  91595. orthoLeft: Nullable<number>;
  91596. /**
  91597. * Define the current limit on the right side for an orthographic camera
  91598. * In scene unit
  91599. */
  91600. orthoRight: Nullable<number>;
  91601. /**
  91602. * Define the current limit on the bottom side for an orthographic camera
  91603. * In scene unit
  91604. */
  91605. orthoBottom: Nullable<number>;
  91606. /**
  91607. * Define the current limit on the top side for an orthographic camera
  91608. * In scene unit
  91609. */
  91610. orthoTop: Nullable<number>;
  91611. /**
  91612. * Field Of View is set in Radians. (default is 0.8)
  91613. */
  91614. fov: number;
  91615. /**
  91616. * Define the minimum distance the camera can see from.
  91617. * This is important to note that the depth buffer are not infinite and the closer it starts
  91618. * the more your scene might encounter depth fighting issue.
  91619. */
  91620. minZ: number;
  91621. /**
  91622. * Define the maximum distance the camera can see to.
  91623. * This is important to note that the depth buffer are not infinite and the further it end
  91624. * the more your scene might encounter depth fighting issue.
  91625. */
  91626. maxZ: number;
  91627. /**
  91628. * Define the default inertia of the camera.
  91629. * This helps giving a smooth feeling to the camera movement.
  91630. */
  91631. inertia: number;
  91632. /**
  91633. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  91634. */
  91635. mode: number;
  91636. /**
  91637. * Define wether the camera is intermediate.
  91638. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  91639. */
  91640. isIntermediate: boolean;
  91641. /**
  91642. * Define the viewport of the camera.
  91643. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  91644. */
  91645. viewport: Viewport;
  91646. /**
  91647. * Restricts the camera to viewing objects with the same layerMask.
  91648. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  91649. */
  91650. layerMask: number;
  91651. /**
  91652. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  91653. */
  91654. fovMode: number;
  91655. /**
  91656. * Rig mode of the camera.
  91657. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  91658. * This is normally controlled byt the camera themselves as internal use.
  91659. */
  91660. cameraRigMode: number;
  91661. /**
  91662. * Defines the distance between both "eyes" in case of a RIG
  91663. */
  91664. interaxialDistance: number;
  91665. /**
  91666. * Defines if stereoscopic rendering is done side by side or over under.
  91667. */
  91668. isStereoscopicSideBySide: boolean;
  91669. /**
  91670. * 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
  91671. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  91672. * else in the scene. (Eg. security camera)
  91673. *
  91674. * 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)
  91675. */
  91676. customRenderTargets: RenderTargetTexture[];
  91677. /**
  91678. * When set, the camera will render to this render target instead of the default canvas
  91679. *
  91680. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  91681. */
  91682. outputRenderTarget: Nullable<RenderTargetTexture>;
  91683. /**
  91684. * Observable triggered when the camera view matrix has changed.
  91685. */
  91686. onViewMatrixChangedObservable: Observable<Camera>;
  91687. /**
  91688. * Observable triggered when the camera Projection matrix has changed.
  91689. */
  91690. onProjectionMatrixChangedObservable: Observable<Camera>;
  91691. /**
  91692. * Observable triggered when the inputs have been processed.
  91693. */
  91694. onAfterCheckInputsObservable: Observable<Camera>;
  91695. /**
  91696. * Observable triggered when reset has been called and applied to the camera.
  91697. */
  91698. onRestoreStateObservable: Observable<Camera>;
  91699. /** @hidden */
  91700. _cameraRigParams: any;
  91701. /** @hidden */
  91702. _rigCameras: Camera[];
  91703. /** @hidden */
  91704. _rigPostProcess: Nullable<PostProcess>;
  91705. protected _webvrViewMatrix: Matrix;
  91706. /** @hidden */
  91707. _skipRendering: boolean;
  91708. /** @hidden */
  91709. _projectionMatrix: Matrix;
  91710. /** @hidden */
  91711. _postProcesses: Nullable<PostProcess>[];
  91712. /** @hidden */
  91713. _activeMeshes: SmartArray<AbstractMesh>;
  91714. protected _globalPosition: Vector3;
  91715. /** @hidden */
  91716. _computedViewMatrix: Matrix;
  91717. private _doNotComputeProjectionMatrix;
  91718. private _transformMatrix;
  91719. private _frustumPlanes;
  91720. private _refreshFrustumPlanes;
  91721. private _storedFov;
  91722. private _stateStored;
  91723. /**
  91724. * Instantiates a new camera object.
  91725. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  91726. * @see http://doc.babylonjs.com/features/cameras
  91727. * @param name Defines the name of the camera in the scene
  91728. * @param position Defines the position of the camera
  91729. * @param scene Defines the scene the camera belongs too
  91730. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  91731. */
  91732. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  91733. /**
  91734. * Store current camera state (fov, position, etc..)
  91735. * @returns the camera
  91736. */
  91737. storeState(): Camera;
  91738. /**
  91739. * Restores the camera state values if it has been stored. You must call storeState() first
  91740. */
  91741. protected _restoreStateValues(): boolean;
  91742. /**
  91743. * Restored camera state. You must call storeState() first.
  91744. * @returns true if restored and false otherwise
  91745. */
  91746. restoreState(): boolean;
  91747. /**
  91748. * Gets the class name of the camera.
  91749. * @returns the class name
  91750. */
  91751. getClassName(): string;
  91752. /** @hidden */
  91753. readonly _isCamera: boolean;
  91754. /**
  91755. * Gets a string representation of the camera useful for debug purpose.
  91756. * @param fullDetails Defines that a more verboe level of logging is required
  91757. * @returns the string representation
  91758. */
  91759. toString(fullDetails?: boolean): string;
  91760. /**
  91761. * Gets the current world space position of the camera.
  91762. */
  91763. readonly globalPosition: Vector3;
  91764. /**
  91765. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  91766. * @returns the active meshe list
  91767. */
  91768. getActiveMeshes(): SmartArray<AbstractMesh>;
  91769. /**
  91770. * Check wether a mesh is part of the current active mesh list of the camera
  91771. * @param mesh Defines the mesh to check
  91772. * @returns true if active, false otherwise
  91773. */
  91774. isActiveMesh(mesh: Mesh): boolean;
  91775. /**
  91776. * Is this camera ready to be used/rendered
  91777. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  91778. * @return true if the camera is ready
  91779. */
  91780. isReady(completeCheck?: boolean): boolean;
  91781. /** @hidden */
  91782. _initCache(): void;
  91783. /** @hidden */
  91784. _updateCache(ignoreParentClass?: boolean): void;
  91785. /** @hidden */
  91786. _isSynchronized(): boolean;
  91787. /** @hidden */
  91788. _isSynchronizedViewMatrix(): boolean;
  91789. /** @hidden */
  91790. _isSynchronizedProjectionMatrix(): boolean;
  91791. /**
  91792. * Attach the input controls to a specific dom element to get the input from.
  91793. * @param element Defines the element the controls should be listened from
  91794. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  91795. */
  91796. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  91797. /**
  91798. * Detach the current controls from the specified dom element.
  91799. * @param element Defines the element to stop listening the inputs from
  91800. */
  91801. detachControl(element: HTMLElement): void;
  91802. /**
  91803. * Update the camera state according to the different inputs gathered during the frame.
  91804. */
  91805. update(): void;
  91806. /** @hidden */
  91807. _checkInputs(): void;
  91808. /** @hidden */
  91809. readonly rigCameras: Camera[];
  91810. /**
  91811. * Gets the post process used by the rig cameras
  91812. */
  91813. readonly rigPostProcess: Nullable<PostProcess>;
  91814. /**
  91815. * Internal, gets the first post proces.
  91816. * @returns the first post process to be run on this camera.
  91817. */
  91818. _getFirstPostProcess(): Nullable<PostProcess>;
  91819. private _cascadePostProcessesToRigCams;
  91820. /**
  91821. * Attach a post process to the camera.
  91822. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91823. * @param postProcess The post process to attach to the camera
  91824. * @param insertAt The position of the post process in case several of them are in use in the scene
  91825. * @returns the position the post process has been inserted at
  91826. */
  91827. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  91828. /**
  91829. * Detach a post process to the camera.
  91830. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  91831. * @param postProcess The post process to detach from the camera
  91832. */
  91833. detachPostProcess(postProcess: PostProcess): void;
  91834. /**
  91835. * Gets the current world matrix of the camera
  91836. */
  91837. getWorldMatrix(): Matrix;
  91838. /** @hidden */
  91839. _getViewMatrix(): Matrix;
  91840. /**
  91841. * Gets the current view matrix of the camera.
  91842. * @param force forces the camera to recompute the matrix without looking at the cached state
  91843. * @returns the view matrix
  91844. */
  91845. getViewMatrix(force?: boolean): Matrix;
  91846. /**
  91847. * Freeze the projection matrix.
  91848. * It will prevent the cache check of the camera projection compute and can speed up perf
  91849. * if no parameter of the camera are meant to change
  91850. * @param projection Defines manually a projection if necessary
  91851. */
  91852. freezeProjectionMatrix(projection?: Matrix): void;
  91853. /**
  91854. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  91855. */
  91856. unfreezeProjectionMatrix(): void;
  91857. /**
  91858. * Gets the current projection matrix of the camera.
  91859. * @param force forces the camera to recompute the matrix without looking at the cached state
  91860. * @returns the projection matrix
  91861. */
  91862. getProjectionMatrix(force?: boolean): Matrix;
  91863. /**
  91864. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  91865. * @returns a Matrix
  91866. */
  91867. getTransformationMatrix(): Matrix;
  91868. private _updateFrustumPlanes;
  91869. /**
  91870. * Checks if a cullable object (mesh...) is in the camera frustum
  91871. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  91872. * @param target The object to check
  91873. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  91874. * @returns true if the object is in frustum otherwise false
  91875. */
  91876. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  91877. /**
  91878. * Checks if a cullable object (mesh...) is in the camera frustum
  91879. * Unlike isInFrustum this cheks the full bounding box
  91880. * @param target The object to check
  91881. * @returns true if the object is in frustum otherwise false
  91882. */
  91883. isCompletelyInFrustum(target: ICullable): boolean;
  91884. /**
  91885. * Gets a ray in the forward direction from the camera.
  91886. * @param length Defines the length of the ray to create
  91887. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  91888. * @param origin Defines the start point of the ray which defaults to the camera position
  91889. * @returns the forward ray
  91890. */
  91891. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  91892. /**
  91893. * Releases resources associated with this node.
  91894. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91895. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91896. */
  91897. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91898. /** @hidden */
  91899. _isLeftCamera: boolean;
  91900. /**
  91901. * Gets the left camera of a rig setup in case of Rigged Camera
  91902. */
  91903. readonly isLeftCamera: boolean;
  91904. /** @hidden */
  91905. _isRightCamera: boolean;
  91906. /**
  91907. * Gets the right camera of a rig setup in case of Rigged Camera
  91908. */
  91909. readonly isRightCamera: boolean;
  91910. /**
  91911. * Gets the left camera of a rig setup in case of Rigged Camera
  91912. */
  91913. readonly leftCamera: Nullable<FreeCamera>;
  91914. /**
  91915. * Gets the right camera of a rig setup in case of Rigged Camera
  91916. */
  91917. readonly rightCamera: Nullable<FreeCamera>;
  91918. /**
  91919. * Gets the left camera target of a rig setup in case of Rigged Camera
  91920. * @returns the target position
  91921. */
  91922. getLeftTarget(): Nullable<Vector3>;
  91923. /**
  91924. * Gets the right camera target of a rig setup in case of Rigged Camera
  91925. * @returns the target position
  91926. */
  91927. getRightTarget(): Nullable<Vector3>;
  91928. /**
  91929. * @hidden
  91930. */
  91931. setCameraRigMode(mode: number, rigParams: any): void;
  91932. /** @hidden */
  91933. static _setStereoscopicRigMode(camera: Camera): void;
  91934. /** @hidden */
  91935. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  91936. /** @hidden */
  91937. static _setVRRigMode(camera: Camera, rigParams: any): void;
  91938. /** @hidden */
  91939. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  91940. /** @hidden */
  91941. _getVRProjectionMatrix(): Matrix;
  91942. protected _updateCameraRotationMatrix(): void;
  91943. protected _updateWebVRCameraRotationMatrix(): void;
  91944. /**
  91945. * This function MUST be overwritten by the different WebVR cameras available.
  91946. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91947. * @hidden
  91948. */
  91949. _getWebVRProjectionMatrix(): Matrix;
  91950. /**
  91951. * This function MUST be overwritten by the different WebVR cameras available.
  91952. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  91953. * @hidden
  91954. */
  91955. _getWebVRViewMatrix(): Matrix;
  91956. /** @hidden */
  91957. setCameraRigParameter(name: string, value: any): void;
  91958. /**
  91959. * needs to be overridden by children so sub has required properties to be copied
  91960. * @hidden
  91961. */
  91962. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  91963. /**
  91964. * May need to be overridden by children
  91965. * @hidden
  91966. */
  91967. _updateRigCameras(): void;
  91968. /** @hidden */
  91969. _setupInputs(): void;
  91970. /**
  91971. * Serialiaze the camera setup to a json represention
  91972. * @returns the JSON representation
  91973. */
  91974. serialize(): any;
  91975. /**
  91976. * Clones the current camera.
  91977. * @param name The cloned camera name
  91978. * @returns the cloned camera
  91979. */
  91980. clone(name: string): Camera;
  91981. /**
  91982. * Gets the direction of the camera relative to a given local axis.
  91983. * @param localAxis Defines the reference axis to provide a relative direction.
  91984. * @return the direction
  91985. */
  91986. getDirection(localAxis: Vector3): Vector3;
  91987. /**
  91988. * Returns the current camera absolute rotation
  91989. */
  91990. readonly absoluteRotation: Quaternion;
  91991. /**
  91992. * Gets the direction of the camera relative to a given local axis into a passed vector.
  91993. * @param localAxis Defines the reference axis to provide a relative direction.
  91994. * @param result Defines the vector to store the result in
  91995. */
  91996. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  91997. /**
  91998. * Gets a camera constructor for a given camera type
  91999. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  92000. * @param name The name of the camera the result will be able to instantiate
  92001. * @param scene The scene the result will construct the camera in
  92002. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  92003. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  92004. * @returns a factory method to construc the camera
  92005. */
  92006. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  92007. /**
  92008. * Compute the world matrix of the camera.
  92009. * @returns the camera workd matrix
  92010. */
  92011. computeWorldMatrix(): Matrix;
  92012. /**
  92013. * Parse a JSON and creates the camera from the parsed information
  92014. * @param parsedCamera The JSON to parse
  92015. * @param scene The scene to instantiate the camera in
  92016. * @returns the newly constructed camera
  92017. */
  92018. static Parse(parsedCamera: any, scene: Scene): Camera;
  92019. }
  92020. }
  92021. declare module BABYLON {
  92022. /**
  92023. * Class containing static functions to help procedurally build meshes
  92024. */
  92025. export class DiscBuilder {
  92026. /**
  92027. * Creates a plane polygonal mesh. By default, this is a disc
  92028. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  92029. * * 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
  92030. * * 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
  92031. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  92032. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  92033. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  92034. * @param name defines the name of the mesh
  92035. * @param options defines the options used to create the mesh
  92036. * @param scene defines the hosting scene
  92037. * @returns the plane polygonal mesh
  92038. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  92039. */
  92040. static CreateDisc(name: string, options: {
  92041. radius?: number;
  92042. tessellation?: number;
  92043. arc?: number;
  92044. updatable?: boolean;
  92045. sideOrientation?: number;
  92046. frontUVs?: Vector4;
  92047. backUVs?: Vector4;
  92048. }, scene?: Nullable<Scene>): Mesh;
  92049. }
  92050. }
  92051. declare module BABYLON {
  92052. /**
  92053. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  92054. *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.
  92055. * The SPS is also a particle system. It provides some methods to manage the particles.
  92056. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  92057. *
  92058. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  92059. */
  92060. export class SolidParticleSystem implements IDisposable {
  92061. /**
  92062. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  92063. * Example : var p = SPS.particles[i];
  92064. */
  92065. particles: SolidParticle[];
  92066. /**
  92067. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  92068. */
  92069. nbParticles: number;
  92070. /**
  92071. * If the particles must ever face the camera (default false). Useful for planar particles.
  92072. */
  92073. billboard: boolean;
  92074. /**
  92075. * Recompute normals when adding a shape
  92076. */
  92077. recomputeNormals: boolean;
  92078. /**
  92079. * This a counter ofr your own usage. It's not set by any SPS functions.
  92080. */
  92081. counter: number;
  92082. /**
  92083. * The SPS name. This name is also given to the underlying mesh.
  92084. */
  92085. name: string;
  92086. /**
  92087. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  92088. */
  92089. mesh: Mesh;
  92090. /**
  92091. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  92092. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  92093. */
  92094. vars: any;
  92095. /**
  92096. * This array is populated when the SPS is set as 'pickable'.
  92097. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  92098. * Each element of this array is an object `{idx: int, faceId: int}`.
  92099. * `idx` is the picked particle index in the `SPS.particles` array
  92100. * `faceId` is the picked face index counted within this particle.
  92101. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  92102. */
  92103. pickedParticles: {
  92104. idx: number;
  92105. faceId: number;
  92106. }[];
  92107. /**
  92108. * This array is populated when `enableDepthSort` is set to true.
  92109. * Each element of this array is an instance of the class DepthSortedParticle.
  92110. */
  92111. depthSortedParticles: DepthSortedParticle[];
  92112. /**
  92113. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  92114. * @hidden
  92115. */
  92116. _bSphereOnly: boolean;
  92117. /**
  92118. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  92119. * @hidden
  92120. */
  92121. _bSphereRadiusFactor: number;
  92122. private _scene;
  92123. private _positions;
  92124. private _indices;
  92125. private _normals;
  92126. private _colors;
  92127. private _uvs;
  92128. private _indices32;
  92129. private _positions32;
  92130. private _normals32;
  92131. private _fixedNormal32;
  92132. private _colors32;
  92133. private _uvs32;
  92134. private _index;
  92135. private _updatable;
  92136. private _pickable;
  92137. private _isVisibilityBoxLocked;
  92138. private _alwaysVisible;
  92139. private _depthSort;
  92140. private _shapeCounter;
  92141. private _copy;
  92142. private _color;
  92143. private _computeParticleColor;
  92144. private _computeParticleTexture;
  92145. private _computeParticleRotation;
  92146. private _computeParticleVertex;
  92147. private _computeBoundingBox;
  92148. private _depthSortParticles;
  92149. private _camera;
  92150. private _mustUnrotateFixedNormals;
  92151. private _particlesIntersect;
  92152. private _needs32Bits;
  92153. /**
  92154. * Creates a SPS (Solid Particle System) object.
  92155. * @param name (String) is the SPS name, this will be the underlying mesh name.
  92156. * @param scene (Scene) is the scene in which the SPS is added.
  92157. * @param options defines the options of the sps e.g.
  92158. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  92159. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  92160. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  92161. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  92162. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  92163. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  92164. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  92165. */
  92166. constructor(name: string, scene: Scene, options?: {
  92167. updatable?: boolean;
  92168. isPickable?: boolean;
  92169. enableDepthSort?: boolean;
  92170. particleIntersection?: boolean;
  92171. boundingSphereOnly?: boolean;
  92172. bSphereRadiusFactor?: number;
  92173. });
  92174. /**
  92175. * Builds the SPS underlying mesh. Returns a standard Mesh.
  92176. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  92177. * @returns the created mesh
  92178. */
  92179. buildMesh(): Mesh;
  92180. /**
  92181. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  92182. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  92183. * Thus the particles generated from `digest()` have their property `position` set yet.
  92184. * @param mesh ( Mesh ) is the mesh to be digested
  92185. * @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
  92186. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  92187. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  92188. * @returns the current SPS
  92189. */
  92190. digest(mesh: Mesh, options?: {
  92191. facetNb?: number;
  92192. number?: number;
  92193. delta?: number;
  92194. }): SolidParticleSystem;
  92195. private _unrotateFixedNormals;
  92196. private _resetCopy;
  92197. private _meshBuilder;
  92198. private _posToShape;
  92199. private _uvsToShapeUV;
  92200. private _addParticle;
  92201. /**
  92202. * Adds some particles to the SPS from the model shape. Returns the shape id.
  92203. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  92204. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  92205. * @param nb (positive integer) the number of particles to be created from this model
  92206. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  92207. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  92208. * @returns the number of shapes in the system
  92209. */
  92210. addShape(mesh: Mesh, nb: number, options?: {
  92211. positionFunction?: any;
  92212. vertexFunction?: any;
  92213. }): number;
  92214. private _rebuildParticle;
  92215. /**
  92216. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  92217. * @returns the SPS.
  92218. */
  92219. rebuildMesh(): SolidParticleSystem;
  92220. /**
  92221. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  92222. * This method calls `updateParticle()` for each particle of the SPS.
  92223. * For an animated SPS, it is usually called within the render loop.
  92224. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  92225. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  92226. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  92227. * @returns the SPS.
  92228. */
  92229. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  92230. /**
  92231. * Disposes the SPS.
  92232. */
  92233. dispose(): void;
  92234. /**
  92235. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  92236. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92237. * @returns the SPS.
  92238. */
  92239. refreshVisibleSize(): SolidParticleSystem;
  92240. /**
  92241. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  92242. * @param size the size (float) of the visibility box
  92243. * note : this doesn't lock the SPS mesh bounding box.
  92244. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92245. */
  92246. setVisibilityBox(size: number): void;
  92247. /**
  92248. * Gets whether the SPS as always visible or not
  92249. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92250. */
  92251. /**
  92252. * Sets the SPS as always visible or not
  92253. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92254. */
  92255. isAlwaysVisible: boolean;
  92256. /**
  92257. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92258. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92259. */
  92260. /**
  92261. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  92262. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  92263. */
  92264. isVisibilityBoxLocked: boolean;
  92265. /**
  92266. * Tells to `setParticles()` to compute the particle rotations or not.
  92267. * Default value : true. The SPS is faster when it's set to false.
  92268. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92269. */
  92270. /**
  92271. * Gets if `setParticles()` computes the particle rotations or not.
  92272. * Default value : true. The SPS is faster when it's set to false.
  92273. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  92274. */
  92275. computeParticleRotation: boolean;
  92276. /**
  92277. * Tells to `setParticles()` to compute the particle colors or not.
  92278. * Default value : true. The SPS is faster when it's set to false.
  92279. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92280. */
  92281. /**
  92282. * Gets if `setParticles()` computes the particle colors or not.
  92283. * Default value : true. The SPS is faster when it's set to false.
  92284. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  92285. */
  92286. computeParticleColor: boolean;
  92287. /**
  92288. * Gets if `setParticles()` computes the particle textures or not.
  92289. * Default value : true. The SPS is faster when it's set to false.
  92290. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  92291. */
  92292. computeParticleTexture: boolean;
  92293. /**
  92294. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  92295. * Default value : false. The SPS is faster when it's set to false.
  92296. * Note : the particle custom vertex positions aren't stored values.
  92297. */
  92298. /**
  92299. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  92300. * Default value : false. The SPS is faster when it's set to false.
  92301. * Note : the particle custom vertex positions aren't stored values.
  92302. */
  92303. computeParticleVertex: boolean;
  92304. /**
  92305. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  92306. */
  92307. /**
  92308. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  92309. */
  92310. computeBoundingBox: boolean;
  92311. /**
  92312. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  92313. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92314. * Default : `true`
  92315. */
  92316. /**
  92317. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  92318. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  92319. * Default : `true`
  92320. */
  92321. depthSortParticles: boolean;
  92322. /**
  92323. * This function does nothing. It may be overwritten to set all the particle first values.
  92324. * The SPS doesn't call this function, you may have to call it by your own.
  92325. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92326. */
  92327. initParticles(): void;
  92328. /**
  92329. * This function does nothing. It may be overwritten to recycle a particle.
  92330. * The SPS doesn't call this function, you may have to call it by your own.
  92331. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92332. * @param particle The particle to recycle
  92333. * @returns the recycled particle
  92334. */
  92335. recycleParticle(particle: SolidParticle): SolidParticle;
  92336. /**
  92337. * Updates a particle : this function should be overwritten by the user.
  92338. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  92339. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  92340. * @example : just set a particle position or velocity and recycle conditions
  92341. * @param particle The particle to update
  92342. * @returns the updated particle
  92343. */
  92344. updateParticle(particle: SolidParticle): SolidParticle;
  92345. /**
  92346. * Updates a vertex of a particle : it can be overwritten by the user.
  92347. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  92348. * @param particle the current particle
  92349. * @param vertex the current index of the current particle
  92350. * @param pt the index of the current vertex in the particle shape
  92351. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  92352. * @example : just set a vertex particle position
  92353. * @returns the updated vertex
  92354. */
  92355. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  92356. /**
  92357. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  92358. * This does nothing and may be overwritten by the user.
  92359. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92360. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92361. * @param update the boolean update value actually passed to setParticles()
  92362. */
  92363. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92364. /**
  92365. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  92366. * This will be passed three parameters.
  92367. * This does nothing and may be overwritten by the user.
  92368. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92369. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  92370. * @param update the boolean update value actually passed to setParticles()
  92371. */
  92372. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  92373. }
  92374. }
  92375. declare module BABYLON {
  92376. /**
  92377. * Represents one particle of a solid particle system.
  92378. */
  92379. export class SolidParticle {
  92380. /**
  92381. * particle global index
  92382. */
  92383. idx: number;
  92384. /**
  92385. * The color of the particle
  92386. */
  92387. color: Nullable<Color4>;
  92388. /**
  92389. * The world space position of the particle.
  92390. */
  92391. position: Vector3;
  92392. /**
  92393. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  92394. */
  92395. rotation: Vector3;
  92396. /**
  92397. * The world space rotation quaternion of the particle.
  92398. */
  92399. rotationQuaternion: Nullable<Quaternion>;
  92400. /**
  92401. * The scaling of the particle.
  92402. */
  92403. scaling: Vector3;
  92404. /**
  92405. * The uvs of the particle.
  92406. */
  92407. uvs: Vector4;
  92408. /**
  92409. * The current speed of the particle.
  92410. */
  92411. velocity: Vector3;
  92412. /**
  92413. * The pivot point in the particle local space.
  92414. */
  92415. pivot: Vector3;
  92416. /**
  92417. * Must the particle be translated from its pivot point in its local space ?
  92418. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  92419. * Default : false
  92420. */
  92421. translateFromPivot: boolean;
  92422. /**
  92423. * Is the particle active or not ?
  92424. */
  92425. alive: boolean;
  92426. /**
  92427. * Is the particle visible or not ?
  92428. */
  92429. isVisible: boolean;
  92430. /**
  92431. * Index of this particle in the global "positions" array (Internal use)
  92432. * @hidden
  92433. */
  92434. _pos: number;
  92435. /**
  92436. * @hidden Index of this particle in the global "indices" array (Internal use)
  92437. */
  92438. _ind: number;
  92439. /**
  92440. * @hidden ModelShape of this particle (Internal use)
  92441. */
  92442. _model: ModelShape;
  92443. /**
  92444. * ModelShape id of this particle
  92445. */
  92446. shapeId: number;
  92447. /**
  92448. * Index of the particle in its shape id
  92449. */
  92450. idxInShape: number;
  92451. /**
  92452. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  92453. */
  92454. _modelBoundingInfo: BoundingInfo;
  92455. /**
  92456. * @hidden Particle BoundingInfo object (Internal use)
  92457. */
  92458. _boundingInfo: BoundingInfo;
  92459. /**
  92460. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  92461. */
  92462. _sps: SolidParticleSystem;
  92463. /**
  92464. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  92465. */
  92466. _stillInvisible: boolean;
  92467. /**
  92468. * @hidden Last computed particle rotation matrix
  92469. */
  92470. _rotationMatrix: number[];
  92471. /**
  92472. * Parent particle Id, if any.
  92473. * Default null.
  92474. */
  92475. parentId: Nullable<number>;
  92476. /**
  92477. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  92478. * The possible values are :
  92479. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92480. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92481. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92482. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92483. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92484. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  92485. * */
  92486. cullingStrategy: number;
  92487. /**
  92488. * @hidden Internal global position in the SPS.
  92489. */
  92490. _globalPosition: Vector3;
  92491. /**
  92492. * Creates a Solid Particle object.
  92493. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  92494. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  92495. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  92496. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  92497. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  92498. * @param shapeId (integer) is the model shape identifier in the SPS.
  92499. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  92500. * @param sps defines the sps it is associated to
  92501. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  92502. */
  92503. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  92504. /**
  92505. * Legacy support, changed scale to scaling
  92506. */
  92507. /**
  92508. * Legacy support, changed scale to scaling
  92509. */
  92510. scale: Vector3;
  92511. /**
  92512. * Legacy support, changed quaternion to rotationQuaternion
  92513. */
  92514. /**
  92515. * Legacy support, changed quaternion to rotationQuaternion
  92516. */
  92517. quaternion: Nullable<Quaternion>;
  92518. /**
  92519. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  92520. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  92521. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  92522. * @returns true if it intersects
  92523. */
  92524. intersectsMesh(target: Mesh | SolidParticle): boolean;
  92525. /**
  92526. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  92527. * A particle is in the frustum if its bounding box intersects the frustum
  92528. * @param frustumPlanes defines the frustum to test
  92529. * @returns true if the particle is in the frustum planes
  92530. */
  92531. isInFrustum(frustumPlanes: Plane[]): boolean;
  92532. /**
  92533. * get the rotation matrix of the particle
  92534. * @hidden
  92535. */
  92536. getRotationMatrix(m: Matrix): void;
  92537. }
  92538. /**
  92539. * Represents the shape of the model used by one particle of a solid particle system.
  92540. * SPS internal tool, don't use it manually.
  92541. */
  92542. export class ModelShape {
  92543. /**
  92544. * The shape id
  92545. * @hidden
  92546. */
  92547. shapeID: number;
  92548. /**
  92549. * flat array of model positions (internal use)
  92550. * @hidden
  92551. */
  92552. _shape: Vector3[];
  92553. /**
  92554. * flat array of model UVs (internal use)
  92555. * @hidden
  92556. */
  92557. _shapeUV: number[];
  92558. /**
  92559. * length of the shape in the model indices array (internal use)
  92560. * @hidden
  92561. */
  92562. _indicesLength: number;
  92563. /**
  92564. * Custom position function (internal use)
  92565. * @hidden
  92566. */
  92567. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  92568. /**
  92569. * Custom vertex function (internal use)
  92570. * @hidden
  92571. */
  92572. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  92573. /**
  92574. * 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.
  92575. * SPS internal tool, don't use it manually.
  92576. * @hidden
  92577. */
  92578. 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>);
  92579. }
  92580. /**
  92581. * Represents a Depth Sorted Particle in the solid particle system.
  92582. */
  92583. export class DepthSortedParticle {
  92584. /**
  92585. * Index of the particle in the "indices" array
  92586. */
  92587. ind: number;
  92588. /**
  92589. * Length of the particle shape in the "indices" array
  92590. */
  92591. indicesLength: number;
  92592. /**
  92593. * Squared distance from the particle to the camera
  92594. */
  92595. sqDistance: number;
  92596. }
  92597. }
  92598. declare module BABYLON {
  92599. /**
  92600. * @hidden
  92601. */
  92602. export class _MeshCollisionData {
  92603. _checkCollisions: boolean;
  92604. _collisionMask: number;
  92605. _collisionGroup: number;
  92606. _collider: Nullable<Collider>;
  92607. _oldPositionForCollisions: Vector3;
  92608. _diffPositionForCollisions: Vector3;
  92609. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  92610. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  92611. }
  92612. }
  92613. declare module BABYLON {
  92614. /** @hidden */
  92615. class _FacetDataStorage {
  92616. facetPositions: Vector3[];
  92617. facetNormals: Vector3[];
  92618. facetPartitioning: number[][];
  92619. facetNb: number;
  92620. partitioningSubdivisions: number;
  92621. partitioningBBoxRatio: number;
  92622. facetDataEnabled: boolean;
  92623. facetParameters: any;
  92624. bbSize: Vector3;
  92625. subDiv: {
  92626. max: number;
  92627. X: number;
  92628. Y: number;
  92629. Z: number;
  92630. };
  92631. facetDepthSort: boolean;
  92632. facetDepthSortEnabled: boolean;
  92633. depthSortedIndices: IndicesArray;
  92634. depthSortedFacets: {
  92635. ind: number;
  92636. sqDistance: number;
  92637. }[];
  92638. facetDepthSortFunction: (f1: {
  92639. ind: number;
  92640. sqDistance: number;
  92641. }, f2: {
  92642. ind: number;
  92643. sqDistance: number;
  92644. }) => number;
  92645. facetDepthSortFrom: Vector3;
  92646. facetDepthSortOrigin: Vector3;
  92647. invertedMatrix: Matrix;
  92648. }
  92649. /**
  92650. * @hidden
  92651. **/
  92652. class _InternalAbstractMeshDataInfo {
  92653. _hasVertexAlpha: boolean;
  92654. _useVertexColors: boolean;
  92655. _numBoneInfluencers: number;
  92656. _applyFog: boolean;
  92657. _receiveShadows: boolean;
  92658. _facetData: _FacetDataStorage;
  92659. _visibility: number;
  92660. _skeleton: Nullable<Skeleton>;
  92661. _layerMask: number;
  92662. _computeBonesUsingShaders: boolean;
  92663. _isActive: boolean;
  92664. _onlyForInstances: boolean;
  92665. _isActiveIntermediate: boolean;
  92666. _onlyForInstancesIntermediate: boolean;
  92667. }
  92668. /**
  92669. * Class used to store all common mesh properties
  92670. */
  92671. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  92672. /** No occlusion */
  92673. static OCCLUSION_TYPE_NONE: number;
  92674. /** Occlusion set to optimisitic */
  92675. static OCCLUSION_TYPE_OPTIMISTIC: number;
  92676. /** Occlusion set to strict */
  92677. static OCCLUSION_TYPE_STRICT: number;
  92678. /** Use an accurante occlusion algorithm */
  92679. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  92680. /** Use a conservative occlusion algorithm */
  92681. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  92682. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  92683. * Test order :
  92684. * Is the bounding sphere outside the frustum ?
  92685. * If not, are the bounding box vertices outside the frustum ?
  92686. * It not, then the cullable object is in the frustum.
  92687. */
  92688. static readonly CULLINGSTRATEGY_STANDARD: number;
  92689. /** Culling strategy : Bounding Sphere Only.
  92690. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  92691. * It's also less accurate than the standard because some not visible objects can still be selected.
  92692. * Test : is the bounding sphere outside the frustum ?
  92693. * If not, then the cullable object is in the frustum.
  92694. */
  92695. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  92696. /** Culling strategy : Optimistic Inclusion.
  92697. * This in an inclusion test first, then the standard exclusion test.
  92698. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  92699. * 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.
  92700. * Anyway, it's as accurate as the standard strategy.
  92701. * Test :
  92702. * Is the cullable object bounding sphere center in the frustum ?
  92703. * If not, apply the default culling strategy.
  92704. */
  92705. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  92706. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  92707. * This in an inclusion test first, then the bounding sphere only exclusion test.
  92708. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  92709. * 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.
  92710. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  92711. * Test :
  92712. * Is the cullable object bounding sphere center in the frustum ?
  92713. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  92714. */
  92715. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  92716. /**
  92717. * No billboard
  92718. */
  92719. static readonly BILLBOARDMODE_NONE: number;
  92720. /** Billboard on X axis */
  92721. static readonly BILLBOARDMODE_X: number;
  92722. /** Billboard on Y axis */
  92723. static readonly BILLBOARDMODE_Y: number;
  92724. /** Billboard on Z axis */
  92725. static readonly BILLBOARDMODE_Z: number;
  92726. /** Billboard on all axes */
  92727. static readonly BILLBOARDMODE_ALL: number;
  92728. /** Billboard on using position instead of orientation */
  92729. static readonly BILLBOARDMODE_USE_POSITION: number;
  92730. /** @hidden */
  92731. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  92732. /**
  92733. * The culling strategy to use to check whether the mesh must be rendered or not.
  92734. * This value can be changed at any time and will be used on the next render mesh selection.
  92735. * The possible values are :
  92736. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  92737. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  92738. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  92739. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  92740. * Please read each static variable documentation to get details about the culling process.
  92741. * */
  92742. cullingStrategy: number;
  92743. /**
  92744. * Gets the number of facets in the mesh
  92745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92746. */
  92747. readonly facetNb: number;
  92748. /**
  92749. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  92750. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92751. */
  92752. partitioningSubdivisions: number;
  92753. /**
  92754. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  92755. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  92756. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  92757. */
  92758. partitioningBBoxRatio: number;
  92759. /**
  92760. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  92761. * Works only for updatable meshes.
  92762. * Doesn't work with multi-materials
  92763. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92764. */
  92765. mustDepthSortFacets: boolean;
  92766. /**
  92767. * The location (Vector3) where the facet depth sort must be computed from.
  92768. * By default, the active camera position.
  92769. * Used only when facet depth sort is enabled
  92770. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  92771. */
  92772. facetDepthSortFrom: Vector3;
  92773. /**
  92774. * gets a boolean indicating if facetData is enabled
  92775. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  92776. */
  92777. readonly isFacetDataEnabled: boolean;
  92778. /** @hidden */
  92779. _updateNonUniformScalingState(value: boolean): boolean;
  92780. /**
  92781. * An event triggered when this mesh collides with another one
  92782. */
  92783. onCollideObservable: Observable<AbstractMesh>;
  92784. /** Set a function to call when this mesh collides with another one */
  92785. onCollide: () => void;
  92786. /**
  92787. * An event triggered when the collision's position changes
  92788. */
  92789. onCollisionPositionChangeObservable: Observable<Vector3>;
  92790. /** Set a function to call when the collision's position changes */
  92791. onCollisionPositionChange: () => void;
  92792. /**
  92793. * An event triggered when material is changed
  92794. */
  92795. onMaterialChangedObservable: Observable<AbstractMesh>;
  92796. /**
  92797. * Gets or sets the orientation for POV movement & rotation
  92798. */
  92799. definedFacingForward: boolean;
  92800. /** @hidden */
  92801. _occlusionQuery: Nullable<WebGLQuery>;
  92802. /** @hidden */
  92803. _renderingGroup: Nullable<RenderingGroup>;
  92804. /**
  92805. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92806. */
  92807. /**
  92808. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  92809. */
  92810. visibility: number;
  92811. /** Gets or sets the alpha index used to sort transparent meshes
  92812. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  92813. */
  92814. alphaIndex: number;
  92815. /**
  92816. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  92817. */
  92818. isVisible: boolean;
  92819. /**
  92820. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  92821. */
  92822. isPickable: boolean;
  92823. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  92824. showSubMeshesBoundingBox: boolean;
  92825. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  92826. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  92827. */
  92828. isBlocker: boolean;
  92829. /**
  92830. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  92831. */
  92832. enablePointerMoveEvents: boolean;
  92833. /**
  92834. * Specifies the rendering group id for this mesh (0 by default)
  92835. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  92836. */
  92837. renderingGroupId: number;
  92838. private _material;
  92839. /** Gets or sets current material */
  92840. material: Nullable<Material>;
  92841. /**
  92842. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  92843. * @see http://doc.babylonjs.com/babylon101/shadows
  92844. */
  92845. receiveShadows: boolean;
  92846. /** Defines color to use when rendering outline */
  92847. outlineColor: Color3;
  92848. /** Define width to use when rendering outline */
  92849. outlineWidth: number;
  92850. /** Defines color to use when rendering overlay */
  92851. overlayColor: Color3;
  92852. /** Defines alpha to use when rendering overlay */
  92853. overlayAlpha: number;
  92854. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  92855. hasVertexAlpha: boolean;
  92856. /** 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) */
  92857. useVertexColors: boolean;
  92858. /**
  92859. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  92860. */
  92861. computeBonesUsingShaders: boolean;
  92862. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  92863. numBoneInfluencers: number;
  92864. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  92865. applyFog: boolean;
  92866. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  92867. useOctreeForRenderingSelection: boolean;
  92868. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  92869. useOctreeForPicking: boolean;
  92870. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  92871. useOctreeForCollisions: boolean;
  92872. /**
  92873. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  92874. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  92875. */
  92876. layerMask: number;
  92877. /**
  92878. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  92879. */
  92880. alwaysSelectAsActiveMesh: boolean;
  92881. /**
  92882. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  92883. */
  92884. doNotSyncBoundingInfo: boolean;
  92885. /**
  92886. * Gets or sets the current action manager
  92887. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92888. */
  92889. actionManager: Nullable<AbstractActionManager>;
  92890. private _meshCollisionData;
  92891. /**
  92892. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  92893. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92894. */
  92895. ellipsoid: Vector3;
  92896. /**
  92897. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  92898. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  92899. */
  92900. ellipsoidOffset: Vector3;
  92901. /**
  92902. * Gets or sets a collision mask used to mask collisions (default is -1).
  92903. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92904. */
  92905. collisionMask: number;
  92906. /**
  92907. * Gets or sets the current collision group mask (-1 by default).
  92908. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  92909. */
  92910. collisionGroup: number;
  92911. /**
  92912. * Defines edge width used when edgesRenderer is enabled
  92913. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92914. */
  92915. edgesWidth: number;
  92916. /**
  92917. * Defines edge color used when edgesRenderer is enabled
  92918. * @see https://www.babylonjs-playground.com/#10OJSG#13
  92919. */
  92920. edgesColor: Color4;
  92921. /** @hidden */
  92922. _edgesRenderer: Nullable<IEdgesRenderer>;
  92923. /** @hidden */
  92924. _masterMesh: Nullable<AbstractMesh>;
  92925. /** @hidden */
  92926. _boundingInfo: Nullable<BoundingInfo>;
  92927. /** @hidden */
  92928. _renderId: number;
  92929. /**
  92930. * Gets or sets the list of subMeshes
  92931. * @see http://doc.babylonjs.com/how_to/multi_materials
  92932. */
  92933. subMeshes: SubMesh[];
  92934. /** @hidden */
  92935. _intersectionsInProgress: AbstractMesh[];
  92936. /** @hidden */
  92937. _unIndexed: boolean;
  92938. /** @hidden */
  92939. _lightSources: Light[];
  92940. /** Gets the list of lights affecting that mesh */
  92941. readonly lightSources: Light[];
  92942. /** @hidden */
  92943. readonly _positions: Nullable<Vector3[]>;
  92944. /** @hidden */
  92945. _waitingData: {
  92946. lods: Nullable<any>;
  92947. actions: Nullable<any>;
  92948. freezeWorldMatrix: Nullable<boolean>;
  92949. };
  92950. /** @hidden */
  92951. _bonesTransformMatrices: Nullable<Float32Array>;
  92952. /** @hidden */
  92953. _transformMatrixTexture: Nullable<RawTexture>;
  92954. /**
  92955. * Gets or sets a skeleton to apply skining transformations
  92956. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  92957. */
  92958. skeleton: Nullable<Skeleton>;
  92959. /**
  92960. * An event triggered when the mesh is rebuilt.
  92961. */
  92962. onRebuildObservable: Observable<AbstractMesh>;
  92963. /**
  92964. * Creates a new AbstractMesh
  92965. * @param name defines the name of the mesh
  92966. * @param scene defines the hosting scene
  92967. */
  92968. constructor(name: string, scene?: Nullable<Scene>);
  92969. /**
  92970. * Returns the string "AbstractMesh"
  92971. * @returns "AbstractMesh"
  92972. */
  92973. getClassName(): string;
  92974. /**
  92975. * Gets a string representation of the current mesh
  92976. * @param fullDetails defines a boolean indicating if full details must be included
  92977. * @returns a string representation of the current mesh
  92978. */
  92979. toString(fullDetails?: boolean): string;
  92980. /**
  92981. * @hidden
  92982. */
  92983. protected _getEffectiveParent(): Nullable<Node>;
  92984. /** @hidden */
  92985. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  92986. /** @hidden */
  92987. _rebuild(): void;
  92988. /** @hidden */
  92989. _resyncLightSources(): void;
  92990. /** @hidden */
  92991. _resyncLighSource(light: Light): void;
  92992. /** @hidden */
  92993. _unBindEffect(): void;
  92994. /** @hidden */
  92995. _removeLightSource(light: Light, dispose: boolean): void;
  92996. private _markSubMeshesAsDirty;
  92997. /** @hidden */
  92998. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  92999. /** @hidden */
  93000. _markSubMeshesAsAttributesDirty(): void;
  93001. /** @hidden */
  93002. _markSubMeshesAsMiscDirty(): void;
  93003. /**
  93004. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  93005. */
  93006. scaling: Vector3;
  93007. /**
  93008. * Returns true if the mesh is blocked. Implemented by child classes
  93009. */
  93010. readonly isBlocked: boolean;
  93011. /**
  93012. * Returns the mesh itself by default. Implemented by child classes
  93013. * @param camera defines the camera to use to pick the right LOD level
  93014. * @returns the currentAbstractMesh
  93015. */
  93016. getLOD(camera: Camera): Nullable<AbstractMesh>;
  93017. /**
  93018. * Returns 0 by default. Implemented by child classes
  93019. * @returns an integer
  93020. */
  93021. getTotalVertices(): number;
  93022. /**
  93023. * Returns a positive integer : the total number of indices in this mesh geometry.
  93024. * @returns the numner of indices or zero if the mesh has no geometry.
  93025. */
  93026. getTotalIndices(): number;
  93027. /**
  93028. * Returns null by default. Implemented by child classes
  93029. * @returns null
  93030. */
  93031. getIndices(): Nullable<IndicesArray>;
  93032. /**
  93033. * Returns the array of the requested vertex data kind. Implemented by child classes
  93034. * @param kind defines the vertex data kind to use
  93035. * @returns null
  93036. */
  93037. getVerticesData(kind: string): Nullable<FloatArray>;
  93038. /**
  93039. * Sets the vertex data of the mesh geometry for the requested `kind`.
  93040. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  93041. * Note that a new underlying VertexBuffer object is created each call.
  93042. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  93043. * @param kind defines vertex data kind:
  93044. * * VertexBuffer.PositionKind
  93045. * * VertexBuffer.UVKind
  93046. * * VertexBuffer.UV2Kind
  93047. * * VertexBuffer.UV3Kind
  93048. * * VertexBuffer.UV4Kind
  93049. * * VertexBuffer.UV5Kind
  93050. * * VertexBuffer.UV6Kind
  93051. * * VertexBuffer.ColorKind
  93052. * * VertexBuffer.MatricesIndicesKind
  93053. * * VertexBuffer.MatricesIndicesExtraKind
  93054. * * VertexBuffer.MatricesWeightsKind
  93055. * * VertexBuffer.MatricesWeightsExtraKind
  93056. * @param data defines the data source
  93057. * @param updatable defines if the data must be flagged as updatable (or static)
  93058. * @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
  93059. * @returns the current mesh
  93060. */
  93061. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  93062. /**
  93063. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  93064. * If the mesh has no geometry, it is simply returned as it is.
  93065. * @param kind defines vertex data kind:
  93066. * * VertexBuffer.PositionKind
  93067. * * VertexBuffer.UVKind
  93068. * * VertexBuffer.UV2Kind
  93069. * * VertexBuffer.UV3Kind
  93070. * * VertexBuffer.UV4Kind
  93071. * * VertexBuffer.UV5Kind
  93072. * * VertexBuffer.UV6Kind
  93073. * * VertexBuffer.ColorKind
  93074. * * VertexBuffer.MatricesIndicesKind
  93075. * * VertexBuffer.MatricesIndicesExtraKind
  93076. * * VertexBuffer.MatricesWeightsKind
  93077. * * VertexBuffer.MatricesWeightsExtraKind
  93078. * @param data defines the data source
  93079. * @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
  93080. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  93081. * @returns the current mesh
  93082. */
  93083. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  93084. /**
  93085. * Sets the mesh indices,
  93086. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  93087. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  93088. * @param totalVertices Defines the total number of vertices
  93089. * @returns the current mesh
  93090. */
  93091. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  93092. /**
  93093. * Gets a boolean indicating if specific vertex data is present
  93094. * @param kind defines the vertex data kind to use
  93095. * @returns true is data kind is present
  93096. */
  93097. isVerticesDataPresent(kind: string): boolean;
  93098. /**
  93099. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  93100. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  93101. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  93102. * @returns a BoundingInfo
  93103. */
  93104. getBoundingInfo(): BoundingInfo;
  93105. /**
  93106. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  93107. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  93108. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  93109. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  93110. * @returns the current mesh
  93111. */
  93112. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  93113. /**
  93114. * Overwrite the current bounding info
  93115. * @param boundingInfo defines the new bounding info
  93116. * @returns the current mesh
  93117. */
  93118. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  93119. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  93120. readonly useBones: boolean;
  93121. /** @hidden */
  93122. _preActivate(): void;
  93123. /** @hidden */
  93124. _preActivateForIntermediateRendering(renderId: number): void;
  93125. /** @hidden */
  93126. _activate(renderId: number, intermediateRendering: boolean): boolean;
  93127. /** @hidden */
  93128. _postActivate(): void;
  93129. /** @hidden */
  93130. _freeze(): void;
  93131. /** @hidden */
  93132. _unFreeze(): void;
  93133. /**
  93134. * Gets the current world matrix
  93135. * @returns a Matrix
  93136. */
  93137. getWorldMatrix(): Matrix;
  93138. /** @hidden */
  93139. _getWorldMatrixDeterminant(): number;
  93140. /**
  93141. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  93142. */
  93143. readonly isAnInstance: boolean;
  93144. /**
  93145. * Gets a boolean indicating if this mesh has instances
  93146. */
  93147. readonly hasInstances: boolean;
  93148. /**
  93149. * Perform relative position change from the point of view of behind the front of the mesh.
  93150. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93151. * Supports definition of mesh facing forward or backward
  93152. * @param amountRight defines the distance on the right axis
  93153. * @param amountUp defines the distance on the up axis
  93154. * @param amountForward defines the distance on the forward axis
  93155. * @returns the current mesh
  93156. */
  93157. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  93158. /**
  93159. * Calculate relative position change from the point of view of behind the front of the mesh.
  93160. * This is performed taking into account the meshes current rotation, so you do not have to care.
  93161. * Supports definition of mesh facing forward or backward
  93162. * @param amountRight defines the distance on the right axis
  93163. * @param amountUp defines the distance on the up axis
  93164. * @param amountForward defines the distance on the forward axis
  93165. * @returns the new displacement vector
  93166. */
  93167. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  93168. /**
  93169. * Perform relative rotation change from the point of view of behind the front of the mesh.
  93170. * Supports definition of mesh facing forward or backward
  93171. * @param flipBack defines the flip
  93172. * @param twirlClockwise defines the twirl
  93173. * @param tiltRight defines the tilt
  93174. * @returns the current mesh
  93175. */
  93176. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  93177. /**
  93178. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  93179. * Supports definition of mesh facing forward or backward.
  93180. * @param flipBack defines the flip
  93181. * @param twirlClockwise defines the twirl
  93182. * @param tiltRight defines the tilt
  93183. * @returns the new rotation vector
  93184. */
  93185. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  93186. /**
  93187. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  93188. * This means the mesh underlying bounding box and sphere are recomputed.
  93189. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  93190. * @returns the current mesh
  93191. */
  93192. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  93193. /** @hidden */
  93194. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  93195. /** @hidden */
  93196. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  93197. /** @hidden */
  93198. _updateBoundingInfo(): AbstractMesh;
  93199. /** @hidden */
  93200. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  93201. /** @hidden */
  93202. protected _afterComputeWorldMatrix(): void;
  93203. /** @hidden */
  93204. readonly _effectiveMesh: AbstractMesh;
  93205. /**
  93206. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  93207. * A mesh is in the frustum if its bounding box intersects the frustum
  93208. * @param frustumPlanes defines the frustum to test
  93209. * @returns true if the mesh is in the frustum planes
  93210. */
  93211. isInFrustum(frustumPlanes: Plane[]): boolean;
  93212. /**
  93213. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  93214. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  93215. * @param frustumPlanes defines the frustum to test
  93216. * @returns true if the mesh is completely in the frustum planes
  93217. */
  93218. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  93219. /**
  93220. * True if the mesh intersects another mesh or a SolidParticle object
  93221. * @param mesh defines a target mesh or SolidParticle to test
  93222. * @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)
  93223. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  93224. * @returns true if there is an intersection
  93225. */
  93226. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  93227. /**
  93228. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  93229. * @param point defines the point to test
  93230. * @returns true if there is an intersection
  93231. */
  93232. intersectsPoint(point: Vector3): boolean;
  93233. /**
  93234. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  93235. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93236. */
  93237. checkCollisions: boolean;
  93238. /**
  93239. * Gets Collider object used to compute collisions (not physics)
  93240. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93241. */
  93242. readonly collider: Nullable<Collider>;
  93243. /**
  93244. * Move the mesh using collision engine
  93245. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  93246. * @param displacement defines the requested displacement vector
  93247. * @returns the current mesh
  93248. */
  93249. moveWithCollisions(displacement: Vector3): AbstractMesh;
  93250. private _onCollisionPositionChange;
  93251. /** @hidden */
  93252. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  93253. /** @hidden */
  93254. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  93255. /** @hidden */
  93256. _checkCollision(collider: Collider): AbstractMesh;
  93257. /** @hidden */
  93258. _generatePointsArray(): boolean;
  93259. /**
  93260. * Checks if the passed Ray intersects with the mesh
  93261. * @param ray defines the ray to use
  93262. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  93263. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93264. * @returns the picking info
  93265. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  93266. */
  93267. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  93268. /**
  93269. * Clones the current mesh
  93270. * @param name defines the mesh name
  93271. * @param newParent defines the new mesh parent
  93272. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  93273. * @returns the new mesh
  93274. */
  93275. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  93276. /**
  93277. * Disposes all the submeshes of the current meshnp
  93278. * @returns the current mesh
  93279. */
  93280. releaseSubMeshes(): AbstractMesh;
  93281. /**
  93282. * Releases resources associated with this abstract mesh.
  93283. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93284. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93285. */
  93286. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93287. /**
  93288. * Adds the passed mesh as a child to the current mesh
  93289. * @param mesh defines the child mesh
  93290. * @returns the current mesh
  93291. */
  93292. addChild(mesh: AbstractMesh): AbstractMesh;
  93293. /**
  93294. * Removes the passed mesh from the current mesh children list
  93295. * @param mesh defines the child mesh
  93296. * @returns the current mesh
  93297. */
  93298. removeChild(mesh: AbstractMesh): AbstractMesh;
  93299. /** @hidden */
  93300. private _initFacetData;
  93301. /**
  93302. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  93303. * This method can be called within the render loop.
  93304. * 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
  93305. * @returns the current mesh
  93306. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93307. */
  93308. updateFacetData(): AbstractMesh;
  93309. /**
  93310. * Returns the facetLocalNormals array.
  93311. * The normals are expressed in the mesh local spac
  93312. * @returns an array of Vector3
  93313. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93314. */
  93315. getFacetLocalNormals(): Vector3[];
  93316. /**
  93317. * Returns the facetLocalPositions array.
  93318. * The facet positions are expressed in the mesh local space
  93319. * @returns an array of Vector3
  93320. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93321. */
  93322. getFacetLocalPositions(): Vector3[];
  93323. /**
  93324. * Returns the facetLocalPartioning array
  93325. * @returns an array of array of numbers
  93326. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93327. */
  93328. getFacetLocalPartitioning(): number[][];
  93329. /**
  93330. * Returns the i-th facet position in the world system.
  93331. * This method allocates a new Vector3 per call
  93332. * @param i defines the facet index
  93333. * @returns a new Vector3
  93334. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93335. */
  93336. getFacetPosition(i: number): Vector3;
  93337. /**
  93338. * Sets the reference Vector3 with the i-th facet position in the world system
  93339. * @param i defines the facet index
  93340. * @param ref defines the target vector
  93341. * @returns the current mesh
  93342. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93343. */
  93344. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  93345. /**
  93346. * Returns the i-th facet normal in the world system.
  93347. * This method allocates a new Vector3 per call
  93348. * @param i defines the facet index
  93349. * @returns a new Vector3
  93350. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93351. */
  93352. getFacetNormal(i: number): Vector3;
  93353. /**
  93354. * Sets the reference Vector3 with the i-th facet normal in the world system
  93355. * @param i defines the facet index
  93356. * @param ref defines the target vector
  93357. * @returns the current mesh
  93358. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93359. */
  93360. getFacetNormalToRef(i: number, ref: Vector3): this;
  93361. /**
  93362. * 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)
  93363. * @param x defines x coordinate
  93364. * @param y defines y coordinate
  93365. * @param z defines z coordinate
  93366. * @returns the array of facet indexes
  93367. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93368. */
  93369. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  93370. /**
  93371. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  93372. * @param projected sets as the (x,y,z) world projection on the facet
  93373. * @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
  93374. * @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
  93375. * @param x defines x coordinate
  93376. * @param y defines y coordinate
  93377. * @param z defines z coordinate
  93378. * @returns the face index if found (or null instead)
  93379. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93380. */
  93381. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93382. /**
  93383. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  93384. * @param projected sets as the (x,y,z) local projection on the facet
  93385. * @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
  93386. * @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
  93387. * @param x defines x coordinate
  93388. * @param y defines y coordinate
  93389. * @param z defines z coordinate
  93390. * @returns the face index if found (or null instead)
  93391. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93392. */
  93393. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  93394. /**
  93395. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  93396. * @returns the parameters
  93397. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93398. */
  93399. getFacetDataParameters(): any;
  93400. /**
  93401. * Disables the feature FacetData and frees the related memory
  93402. * @returns the current mesh
  93403. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  93404. */
  93405. disableFacetData(): AbstractMesh;
  93406. /**
  93407. * Updates the AbstractMesh indices array
  93408. * @param indices defines the data source
  93409. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  93410. * @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)
  93411. * @returns the current mesh
  93412. */
  93413. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  93414. /**
  93415. * Creates new normals data for the mesh
  93416. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  93417. * @returns the current mesh
  93418. */
  93419. createNormals(updatable: boolean): AbstractMesh;
  93420. /**
  93421. * Align the mesh with a normal
  93422. * @param normal defines the normal to use
  93423. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  93424. * @returns the current mesh
  93425. */
  93426. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  93427. /** @hidden */
  93428. _checkOcclusionQuery(): boolean;
  93429. /**
  93430. * Disables the mesh edge rendering mode
  93431. * @returns the currentAbstractMesh
  93432. */
  93433. disableEdgesRendering(): AbstractMesh;
  93434. /**
  93435. * Enables the edge rendering mode on the mesh.
  93436. * This mode makes the mesh edges visible
  93437. * @param epsilon defines the maximal distance between two angles to detect a face
  93438. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  93439. * @returns the currentAbstractMesh
  93440. * @see https://www.babylonjs-playground.com/#19O9TU#0
  93441. */
  93442. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  93443. }
  93444. }
  93445. declare module BABYLON {
  93446. /**
  93447. * Interface used to define ActionEvent
  93448. */
  93449. export interface IActionEvent {
  93450. /** The mesh or sprite that triggered the action */
  93451. source: any;
  93452. /** The X mouse cursor position at the time of the event */
  93453. pointerX: number;
  93454. /** The Y mouse cursor position at the time of the event */
  93455. pointerY: number;
  93456. /** The mesh that is currently pointed at (can be null) */
  93457. meshUnderPointer: Nullable<AbstractMesh>;
  93458. /** the original (browser) event that triggered the ActionEvent */
  93459. sourceEvent?: any;
  93460. /** additional data for the event */
  93461. additionalData?: any;
  93462. }
  93463. /**
  93464. * ActionEvent is the event being sent when an action is triggered.
  93465. */
  93466. export class ActionEvent implements IActionEvent {
  93467. /** The mesh or sprite that triggered the action */
  93468. source: any;
  93469. /** The X mouse cursor position at the time of the event */
  93470. pointerX: number;
  93471. /** The Y mouse cursor position at the time of the event */
  93472. pointerY: number;
  93473. /** The mesh that is currently pointed at (can be null) */
  93474. meshUnderPointer: Nullable<AbstractMesh>;
  93475. /** the original (browser) event that triggered the ActionEvent */
  93476. sourceEvent?: any;
  93477. /** additional data for the event */
  93478. additionalData?: any;
  93479. /**
  93480. * Creates a new ActionEvent
  93481. * @param source The mesh or sprite that triggered the action
  93482. * @param pointerX The X mouse cursor position at the time of the event
  93483. * @param pointerY The Y mouse cursor position at the time of the event
  93484. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  93485. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  93486. * @param additionalData additional data for the event
  93487. */
  93488. constructor(
  93489. /** The mesh or sprite that triggered the action */
  93490. source: any,
  93491. /** The X mouse cursor position at the time of the event */
  93492. pointerX: number,
  93493. /** The Y mouse cursor position at the time of the event */
  93494. pointerY: number,
  93495. /** The mesh that is currently pointed at (can be null) */
  93496. meshUnderPointer: Nullable<AbstractMesh>,
  93497. /** the original (browser) event that triggered the ActionEvent */
  93498. sourceEvent?: any,
  93499. /** additional data for the event */
  93500. additionalData?: any);
  93501. /**
  93502. * Helper function to auto-create an ActionEvent from a source mesh.
  93503. * @param source The source mesh that triggered the event
  93504. * @param evt The original (browser) event
  93505. * @param additionalData additional data for the event
  93506. * @returns the new ActionEvent
  93507. */
  93508. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  93509. /**
  93510. * Helper function to auto-create an ActionEvent from a source sprite
  93511. * @param source The source sprite that triggered the event
  93512. * @param scene Scene associated with the sprite
  93513. * @param evt The original (browser) event
  93514. * @param additionalData additional data for the event
  93515. * @returns the new ActionEvent
  93516. */
  93517. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  93518. /**
  93519. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  93520. * @param scene the scene where the event occurred
  93521. * @param evt The original (browser) event
  93522. * @returns the new ActionEvent
  93523. */
  93524. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  93525. /**
  93526. * Helper function to auto-create an ActionEvent from a primitive
  93527. * @param prim defines the target primitive
  93528. * @param pointerPos defines the pointer position
  93529. * @param evt The original (browser) event
  93530. * @param additionalData additional data for the event
  93531. * @returns the new ActionEvent
  93532. */
  93533. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  93534. }
  93535. }
  93536. declare module BABYLON {
  93537. /**
  93538. * Abstract class used to decouple action Manager from scene and meshes.
  93539. * Do not instantiate.
  93540. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93541. */
  93542. export abstract class AbstractActionManager implements IDisposable {
  93543. /** Gets the list of active triggers */
  93544. static Triggers: {
  93545. [key: string]: number;
  93546. };
  93547. /** Gets the cursor to use when hovering items */
  93548. hoverCursor: string;
  93549. /** Gets the list of actions */
  93550. actions: IAction[];
  93551. /**
  93552. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  93553. */
  93554. isRecursive: boolean;
  93555. /**
  93556. * Releases all associated resources
  93557. */
  93558. abstract dispose(): void;
  93559. /**
  93560. * Does this action manager has pointer triggers
  93561. */
  93562. abstract readonly hasPointerTriggers: boolean;
  93563. /**
  93564. * Does this action manager has pick triggers
  93565. */
  93566. abstract readonly hasPickTriggers: boolean;
  93567. /**
  93568. * Process a specific trigger
  93569. * @param trigger defines the trigger to process
  93570. * @param evt defines the event details to be processed
  93571. */
  93572. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  93573. /**
  93574. * Does this action manager handles actions of any of the given triggers
  93575. * @param triggers defines the triggers to be tested
  93576. * @return a boolean indicating whether one (or more) of the triggers is handled
  93577. */
  93578. abstract hasSpecificTriggers(triggers: number[]): boolean;
  93579. /**
  93580. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  93581. * speed.
  93582. * @param triggerA defines the trigger to be tested
  93583. * @param triggerB defines the trigger to be tested
  93584. * @return a boolean indicating whether one (or more) of the triggers is handled
  93585. */
  93586. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  93587. /**
  93588. * Does this action manager handles actions of a given trigger
  93589. * @param trigger defines the trigger to be tested
  93590. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  93591. * @return whether the trigger is handled
  93592. */
  93593. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  93594. /**
  93595. * Serialize this manager to a JSON object
  93596. * @param name defines the property name to store this manager
  93597. * @returns a JSON representation of this manager
  93598. */
  93599. abstract serialize(name: string): any;
  93600. /**
  93601. * Registers an action to this action manager
  93602. * @param action defines the action to be registered
  93603. * @return the action amended (prepared) after registration
  93604. */
  93605. abstract registerAction(action: IAction): Nullable<IAction>;
  93606. /**
  93607. * Unregisters an action to this action manager
  93608. * @param action defines the action to be unregistered
  93609. * @return a boolean indicating whether the action has been unregistered
  93610. */
  93611. abstract unregisterAction(action: IAction): Boolean;
  93612. /**
  93613. * Does exist one action manager with at least one trigger
  93614. **/
  93615. static readonly HasTriggers: boolean;
  93616. /**
  93617. * Does exist one action manager with at least one pick trigger
  93618. **/
  93619. static readonly HasPickTriggers: boolean;
  93620. /**
  93621. * Does exist one action manager that handles actions of a given trigger
  93622. * @param trigger defines the trigger to be tested
  93623. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  93624. **/
  93625. static HasSpecificTrigger(trigger: number): boolean;
  93626. }
  93627. }
  93628. declare module BABYLON {
  93629. /**
  93630. * Defines how a node can be built from a string name.
  93631. */
  93632. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  93633. /**
  93634. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  93635. */
  93636. export class Node implements IBehaviorAware<Node> {
  93637. /** @hidden */
  93638. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  93639. private static _NodeConstructors;
  93640. /**
  93641. * Add a new node constructor
  93642. * @param type defines the type name of the node to construct
  93643. * @param constructorFunc defines the constructor function
  93644. */
  93645. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  93646. /**
  93647. * Returns a node constructor based on type name
  93648. * @param type defines the type name
  93649. * @param name defines the new node name
  93650. * @param scene defines the hosting scene
  93651. * @param options defines optional options to transmit to constructors
  93652. * @returns the new constructor or null
  93653. */
  93654. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  93655. /**
  93656. * Gets or sets the name of the node
  93657. */
  93658. name: string;
  93659. /**
  93660. * Gets or sets the id of the node
  93661. */
  93662. id: string;
  93663. /**
  93664. * Gets or sets the unique id of the node
  93665. */
  93666. uniqueId: number;
  93667. /**
  93668. * Gets or sets a string used to store user defined state for the node
  93669. */
  93670. state: string;
  93671. /**
  93672. * Gets or sets an object used to store user defined information for the node
  93673. */
  93674. metadata: any;
  93675. /**
  93676. * For internal use only. Please do not use.
  93677. */
  93678. reservedDataStore: any;
  93679. /**
  93680. * List of inspectable custom properties (used by the Inspector)
  93681. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  93682. */
  93683. inspectableCustomProperties: IInspectable[];
  93684. private _doNotSerialize;
  93685. /**
  93686. * Gets or sets a boolean used to define if the node must be serialized
  93687. */
  93688. doNotSerialize: boolean;
  93689. /** @hidden */
  93690. _isDisposed: boolean;
  93691. /**
  93692. * Gets a list of Animations associated with the node
  93693. */
  93694. animations: Animation[];
  93695. protected _ranges: {
  93696. [name: string]: Nullable<AnimationRange>;
  93697. };
  93698. /**
  93699. * Callback raised when the node is ready to be used
  93700. */
  93701. onReady: Nullable<(node: Node) => void>;
  93702. private _isEnabled;
  93703. private _isParentEnabled;
  93704. private _isReady;
  93705. /** @hidden */
  93706. _currentRenderId: number;
  93707. private _parentUpdateId;
  93708. /** @hidden */
  93709. _childUpdateId: number;
  93710. /** @hidden */
  93711. _waitingParentId: Nullable<string>;
  93712. /** @hidden */
  93713. _scene: Scene;
  93714. /** @hidden */
  93715. _cache: any;
  93716. private _parentNode;
  93717. private _children;
  93718. /** @hidden */
  93719. _worldMatrix: Matrix;
  93720. /** @hidden */
  93721. _worldMatrixDeterminant: number;
  93722. /** @hidden */
  93723. _worldMatrixDeterminantIsDirty: boolean;
  93724. /** @hidden */
  93725. private _sceneRootNodesIndex;
  93726. /**
  93727. * Gets a boolean indicating if the node has been disposed
  93728. * @returns true if the node was disposed
  93729. */
  93730. isDisposed(): boolean;
  93731. /**
  93732. * Gets or sets the parent of the node (without keeping the current position in the scene)
  93733. * @see https://doc.babylonjs.com/how_to/parenting
  93734. */
  93735. parent: Nullable<Node>;
  93736. private addToSceneRootNodes;
  93737. private removeFromSceneRootNodes;
  93738. private _animationPropertiesOverride;
  93739. /**
  93740. * Gets or sets the animation properties override
  93741. */
  93742. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  93743. /**
  93744. * Gets a string idenfifying the name of the class
  93745. * @returns "Node" string
  93746. */
  93747. getClassName(): string;
  93748. /** @hidden */
  93749. readonly _isNode: boolean;
  93750. /**
  93751. * An event triggered when the mesh is disposed
  93752. */
  93753. onDisposeObservable: Observable<Node>;
  93754. private _onDisposeObserver;
  93755. /**
  93756. * Sets a callback that will be raised when the node will be disposed
  93757. */
  93758. onDispose: () => void;
  93759. /**
  93760. * Creates a new Node
  93761. * @param name the name and id to be given to this node
  93762. * @param scene the scene this node will be added to
  93763. * @param addToRootNodes the node will be added to scene.rootNodes
  93764. */
  93765. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  93766. /**
  93767. * Gets the scene of the node
  93768. * @returns a scene
  93769. */
  93770. getScene(): Scene;
  93771. /**
  93772. * Gets the engine of the node
  93773. * @returns a Engine
  93774. */
  93775. getEngine(): Engine;
  93776. private _behaviors;
  93777. /**
  93778. * Attach a behavior to the node
  93779. * @see http://doc.babylonjs.com/features/behaviour
  93780. * @param behavior defines the behavior to attach
  93781. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  93782. * @returns the current Node
  93783. */
  93784. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  93785. /**
  93786. * Remove an attached behavior
  93787. * @see http://doc.babylonjs.com/features/behaviour
  93788. * @param behavior defines the behavior to attach
  93789. * @returns the current Node
  93790. */
  93791. removeBehavior(behavior: Behavior<Node>): Node;
  93792. /**
  93793. * Gets the list of attached behaviors
  93794. * @see http://doc.babylonjs.com/features/behaviour
  93795. */
  93796. readonly behaviors: Behavior<Node>[];
  93797. /**
  93798. * Gets an attached behavior by name
  93799. * @param name defines the name of the behavior to look for
  93800. * @see http://doc.babylonjs.com/features/behaviour
  93801. * @returns null if behavior was not found else the requested behavior
  93802. */
  93803. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  93804. /**
  93805. * Returns the latest update of the World matrix
  93806. * @returns a Matrix
  93807. */
  93808. getWorldMatrix(): Matrix;
  93809. /** @hidden */
  93810. _getWorldMatrixDeterminant(): number;
  93811. /**
  93812. * Returns directly the latest state of the mesh World matrix.
  93813. * A Matrix is returned.
  93814. */
  93815. readonly worldMatrixFromCache: Matrix;
  93816. /** @hidden */
  93817. _initCache(): void;
  93818. /** @hidden */
  93819. updateCache(force?: boolean): void;
  93820. /** @hidden */
  93821. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  93822. /** @hidden */
  93823. _updateCache(ignoreParentClass?: boolean): void;
  93824. /** @hidden */
  93825. _isSynchronized(): boolean;
  93826. /** @hidden */
  93827. _markSyncedWithParent(): void;
  93828. /** @hidden */
  93829. isSynchronizedWithParent(): boolean;
  93830. /** @hidden */
  93831. isSynchronized(): boolean;
  93832. /**
  93833. * Is this node ready to be used/rendered
  93834. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  93835. * @return true if the node is ready
  93836. */
  93837. isReady(completeCheck?: boolean): boolean;
  93838. /**
  93839. * Is this node enabled?
  93840. * 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
  93841. * @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
  93842. * @return whether this node (and its parent) is enabled
  93843. */
  93844. isEnabled(checkAncestors?: boolean): boolean;
  93845. /** @hidden */
  93846. protected _syncParentEnabledState(): void;
  93847. /**
  93848. * Set the enabled state of this node
  93849. * @param value defines the new enabled state
  93850. */
  93851. setEnabled(value: boolean): void;
  93852. /**
  93853. * Is this node a descendant of the given node?
  93854. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  93855. * @param ancestor defines the parent node to inspect
  93856. * @returns a boolean indicating if this node is a descendant of the given node
  93857. */
  93858. isDescendantOf(ancestor: Node): boolean;
  93859. /** @hidden */
  93860. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  93861. /**
  93862. * Will return all nodes that have this node as ascendant
  93863. * @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
  93864. * @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
  93865. * @return all children nodes of all types
  93866. */
  93867. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  93868. /**
  93869. * Get all child-meshes of this node
  93870. * @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)
  93871. * @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
  93872. * @returns an array of AbstractMesh
  93873. */
  93874. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  93875. /**
  93876. * Get all direct children of this node
  93877. * @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
  93878. * @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)
  93879. * @returns an array of Node
  93880. */
  93881. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  93882. /** @hidden */
  93883. _setReady(state: boolean): void;
  93884. /**
  93885. * Get an animation by name
  93886. * @param name defines the name of the animation to look for
  93887. * @returns null if not found else the requested animation
  93888. */
  93889. getAnimationByName(name: string): Nullable<Animation>;
  93890. /**
  93891. * Creates an animation range for this node
  93892. * @param name defines the name of the range
  93893. * @param from defines the starting key
  93894. * @param to defines the end key
  93895. */
  93896. createAnimationRange(name: string, from: number, to: number): void;
  93897. /**
  93898. * Delete a specific animation range
  93899. * @param name defines the name of the range to delete
  93900. * @param deleteFrames defines if animation frames from the range must be deleted as well
  93901. */
  93902. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  93903. /**
  93904. * Get an animation range by name
  93905. * @param name defines the name of the animation range to look for
  93906. * @returns null if not found else the requested animation range
  93907. */
  93908. getAnimationRange(name: string): Nullable<AnimationRange>;
  93909. /**
  93910. * Gets the list of all animation ranges defined on this node
  93911. * @returns an array
  93912. */
  93913. getAnimationRanges(): Nullable<AnimationRange>[];
  93914. /**
  93915. * Will start the animation sequence
  93916. * @param name defines the range frames for animation sequence
  93917. * @param loop defines if the animation should loop (false by default)
  93918. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  93919. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  93920. * @returns the object created for this animation. If range does not exist, it will return null
  93921. */
  93922. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  93923. /**
  93924. * Serialize animation ranges into a JSON compatible object
  93925. * @returns serialization object
  93926. */
  93927. serializeAnimationRanges(): any;
  93928. /**
  93929. * Computes the world matrix of the node
  93930. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93931. * @returns the world matrix
  93932. */
  93933. computeWorldMatrix(force?: boolean): Matrix;
  93934. /**
  93935. * Releases resources associated with this node.
  93936. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  93937. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  93938. */
  93939. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  93940. /**
  93941. * Parse animation range data from a serialization object and store them into a given node
  93942. * @param node defines where to store the animation ranges
  93943. * @param parsedNode defines the serialization object to read data from
  93944. * @param scene defines the hosting scene
  93945. */
  93946. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  93947. /**
  93948. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  93949. * @param includeDescendants Include bounding info from descendants as well (true by default)
  93950. * @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
  93951. * @returns the new bounding vectors
  93952. */
  93953. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  93954. min: Vector3;
  93955. max: Vector3;
  93956. };
  93957. }
  93958. }
  93959. declare module BABYLON {
  93960. /**
  93961. * @hidden
  93962. */
  93963. export class _IAnimationState {
  93964. key: number;
  93965. repeatCount: number;
  93966. workValue?: any;
  93967. loopMode?: number;
  93968. offsetValue?: any;
  93969. highLimitValue?: any;
  93970. }
  93971. /**
  93972. * Class used to store any kind of animation
  93973. */
  93974. export class Animation {
  93975. /**Name of the animation */
  93976. name: string;
  93977. /**Property to animate */
  93978. targetProperty: string;
  93979. /**The frames per second of the animation */
  93980. framePerSecond: number;
  93981. /**The data type of the animation */
  93982. dataType: number;
  93983. /**The loop mode of the animation */
  93984. loopMode?: number | undefined;
  93985. /**Specifies if blending should be enabled */
  93986. enableBlending?: boolean | undefined;
  93987. /**
  93988. * Use matrix interpolation instead of using direct key value when animating matrices
  93989. */
  93990. static AllowMatricesInterpolation: boolean;
  93991. /**
  93992. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  93993. */
  93994. static AllowMatrixDecomposeForInterpolation: boolean;
  93995. /**
  93996. * Stores the key frames of the animation
  93997. */
  93998. private _keys;
  93999. /**
  94000. * Stores the easing function of the animation
  94001. */
  94002. private _easingFunction;
  94003. /**
  94004. * @hidden Internal use only
  94005. */
  94006. _runtimeAnimations: RuntimeAnimation[];
  94007. /**
  94008. * The set of event that will be linked to this animation
  94009. */
  94010. private _events;
  94011. /**
  94012. * Stores an array of target property paths
  94013. */
  94014. targetPropertyPath: string[];
  94015. /**
  94016. * Stores the blending speed of the animation
  94017. */
  94018. blendingSpeed: number;
  94019. /**
  94020. * Stores the animation ranges for the animation
  94021. */
  94022. private _ranges;
  94023. /**
  94024. * @hidden Internal use
  94025. */
  94026. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  94027. /**
  94028. * Sets up an animation
  94029. * @param property The property to animate
  94030. * @param animationType The animation type to apply
  94031. * @param framePerSecond The frames per second of the animation
  94032. * @param easingFunction The easing function used in the animation
  94033. * @returns The created animation
  94034. */
  94035. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  94036. /**
  94037. * Create and start an animation on a node
  94038. * @param name defines the name of the global animation that will be run on all nodes
  94039. * @param node defines the root node where the animation will take place
  94040. * @param targetProperty defines property to animate
  94041. * @param framePerSecond defines the number of frame per second yo use
  94042. * @param totalFrame defines the number of frames in total
  94043. * @param from defines the initial value
  94044. * @param to defines the final value
  94045. * @param loopMode defines which loop mode you want to use (off by default)
  94046. * @param easingFunction defines the easing function to use (linear by default)
  94047. * @param onAnimationEnd defines the callback to call when animation end
  94048. * @returns the animatable created for this animation
  94049. */
  94050. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94051. /**
  94052. * Create and start an animation on a node and its descendants
  94053. * @param name defines the name of the global animation that will be run on all nodes
  94054. * @param node defines the root node where the animation will take place
  94055. * @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
  94056. * @param targetProperty defines property to animate
  94057. * @param framePerSecond defines the number of frame per second to use
  94058. * @param totalFrame defines the number of frames in total
  94059. * @param from defines the initial value
  94060. * @param to defines the final value
  94061. * @param loopMode defines which loop mode you want to use (off by default)
  94062. * @param easingFunction defines the easing function to use (linear by default)
  94063. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  94064. * @returns the list of animatables created for all nodes
  94065. * @example https://www.babylonjs-playground.com/#MH0VLI
  94066. */
  94067. 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[]>;
  94068. /**
  94069. * Creates a new animation, merges it with the existing animations and starts it
  94070. * @param name Name of the animation
  94071. * @param node Node which contains the scene that begins the animations
  94072. * @param targetProperty Specifies which property to animate
  94073. * @param framePerSecond The frames per second of the animation
  94074. * @param totalFrame The total number of frames
  94075. * @param from The frame at the beginning of the animation
  94076. * @param to The frame at the end of the animation
  94077. * @param loopMode Specifies the loop mode of the animation
  94078. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  94079. * @param onAnimationEnd Callback to run once the animation is complete
  94080. * @returns Nullable animation
  94081. */
  94082. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  94083. /**
  94084. * Transition property of an host to the target Value
  94085. * @param property The property to transition
  94086. * @param targetValue The target Value of the property
  94087. * @param host The object where the property to animate belongs
  94088. * @param scene Scene used to run the animation
  94089. * @param frameRate Framerate (in frame/s) to use
  94090. * @param transition The transition type we want to use
  94091. * @param duration The duration of the animation, in milliseconds
  94092. * @param onAnimationEnd Callback trigger at the end of the animation
  94093. * @returns Nullable animation
  94094. */
  94095. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  94096. /**
  94097. * Return the array of runtime animations currently using this animation
  94098. */
  94099. readonly runtimeAnimations: RuntimeAnimation[];
  94100. /**
  94101. * Specifies if any of the runtime animations are currently running
  94102. */
  94103. readonly hasRunningRuntimeAnimations: boolean;
  94104. /**
  94105. * Initializes the animation
  94106. * @param name Name of the animation
  94107. * @param targetProperty Property to animate
  94108. * @param framePerSecond The frames per second of the animation
  94109. * @param dataType The data type of the animation
  94110. * @param loopMode The loop mode of the animation
  94111. * @param enableBlending Specifies if blending should be enabled
  94112. */
  94113. constructor(
  94114. /**Name of the animation */
  94115. name: string,
  94116. /**Property to animate */
  94117. targetProperty: string,
  94118. /**The frames per second of the animation */
  94119. framePerSecond: number,
  94120. /**The data type of the animation */
  94121. dataType: number,
  94122. /**The loop mode of the animation */
  94123. loopMode?: number | undefined,
  94124. /**Specifies if blending should be enabled */
  94125. enableBlending?: boolean | undefined);
  94126. /**
  94127. * Converts the animation to a string
  94128. * @param fullDetails support for multiple levels of logging within scene loading
  94129. * @returns String form of the animation
  94130. */
  94131. toString(fullDetails?: boolean): string;
  94132. /**
  94133. * Add an event to this animation
  94134. * @param event Event to add
  94135. */
  94136. addEvent(event: AnimationEvent): void;
  94137. /**
  94138. * Remove all events found at the given frame
  94139. * @param frame The frame to remove events from
  94140. */
  94141. removeEvents(frame: number): void;
  94142. /**
  94143. * Retrieves all the events from the animation
  94144. * @returns Events from the animation
  94145. */
  94146. getEvents(): AnimationEvent[];
  94147. /**
  94148. * Creates an animation range
  94149. * @param name Name of the animation range
  94150. * @param from Starting frame of the animation range
  94151. * @param to Ending frame of the animation
  94152. */
  94153. createRange(name: string, from: number, to: number): void;
  94154. /**
  94155. * Deletes an animation range by name
  94156. * @param name Name of the animation range to delete
  94157. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  94158. */
  94159. deleteRange(name: string, deleteFrames?: boolean): void;
  94160. /**
  94161. * Gets the animation range by name, or null if not defined
  94162. * @param name Name of the animation range
  94163. * @returns Nullable animation range
  94164. */
  94165. getRange(name: string): Nullable<AnimationRange>;
  94166. /**
  94167. * Gets the key frames from the animation
  94168. * @returns The key frames of the animation
  94169. */
  94170. getKeys(): Array<IAnimationKey>;
  94171. /**
  94172. * Gets the highest frame rate of the animation
  94173. * @returns Highest frame rate of the animation
  94174. */
  94175. getHighestFrame(): number;
  94176. /**
  94177. * Gets the easing function of the animation
  94178. * @returns Easing function of the animation
  94179. */
  94180. getEasingFunction(): IEasingFunction;
  94181. /**
  94182. * Sets the easing function of the animation
  94183. * @param easingFunction A custom mathematical formula for animation
  94184. */
  94185. setEasingFunction(easingFunction: EasingFunction): void;
  94186. /**
  94187. * Interpolates a scalar linearly
  94188. * @param startValue Start value of the animation curve
  94189. * @param endValue End value of the animation curve
  94190. * @param gradient Scalar amount to interpolate
  94191. * @returns Interpolated scalar value
  94192. */
  94193. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  94194. /**
  94195. * Interpolates a scalar cubically
  94196. * @param startValue Start value of the animation curve
  94197. * @param outTangent End tangent of the animation
  94198. * @param endValue End value of the animation curve
  94199. * @param inTangent Start tangent of the animation curve
  94200. * @param gradient Scalar amount to interpolate
  94201. * @returns Interpolated scalar value
  94202. */
  94203. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  94204. /**
  94205. * Interpolates a quaternion using a spherical linear interpolation
  94206. * @param startValue Start value of the animation curve
  94207. * @param endValue End value of the animation curve
  94208. * @param gradient Scalar amount to interpolate
  94209. * @returns Interpolated quaternion value
  94210. */
  94211. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  94212. /**
  94213. * Interpolates a quaternion cubically
  94214. * @param startValue Start value of the animation curve
  94215. * @param outTangent End tangent of the animation curve
  94216. * @param endValue End value of the animation curve
  94217. * @param inTangent Start tangent of the animation curve
  94218. * @param gradient Scalar amount to interpolate
  94219. * @returns Interpolated quaternion value
  94220. */
  94221. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  94222. /**
  94223. * Interpolates a Vector3 linearl
  94224. * @param startValue Start value of the animation curve
  94225. * @param endValue End value of the animation curve
  94226. * @param gradient Scalar amount to interpolate
  94227. * @returns Interpolated scalar value
  94228. */
  94229. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  94230. /**
  94231. * Interpolates a Vector3 cubically
  94232. * @param startValue Start value of the animation curve
  94233. * @param outTangent End tangent of the animation
  94234. * @param endValue End value of the animation curve
  94235. * @param inTangent Start tangent of the animation curve
  94236. * @param gradient Scalar amount to interpolate
  94237. * @returns InterpolatedVector3 value
  94238. */
  94239. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  94240. /**
  94241. * Interpolates a Vector2 linearly
  94242. * @param startValue Start value of the animation curve
  94243. * @param endValue End value of the animation curve
  94244. * @param gradient Scalar amount to interpolate
  94245. * @returns Interpolated Vector2 value
  94246. */
  94247. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  94248. /**
  94249. * Interpolates a Vector2 cubically
  94250. * @param startValue Start value of the animation curve
  94251. * @param outTangent End tangent of the animation
  94252. * @param endValue End value of the animation curve
  94253. * @param inTangent Start tangent of the animation curve
  94254. * @param gradient Scalar amount to interpolate
  94255. * @returns Interpolated Vector2 value
  94256. */
  94257. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  94258. /**
  94259. * Interpolates a size linearly
  94260. * @param startValue Start value of the animation curve
  94261. * @param endValue End value of the animation curve
  94262. * @param gradient Scalar amount to interpolate
  94263. * @returns Interpolated Size value
  94264. */
  94265. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  94266. /**
  94267. * Interpolates a Color3 linearly
  94268. * @param startValue Start value of the animation curve
  94269. * @param endValue End value of the animation curve
  94270. * @param gradient Scalar amount to interpolate
  94271. * @returns Interpolated Color3 value
  94272. */
  94273. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  94274. /**
  94275. * @hidden Internal use only
  94276. */
  94277. _getKeyValue(value: any): any;
  94278. /**
  94279. * @hidden Internal use only
  94280. */
  94281. _interpolate(currentFrame: number, state: _IAnimationState): any;
  94282. /**
  94283. * Defines the function to use to interpolate matrices
  94284. * @param startValue defines the start matrix
  94285. * @param endValue defines the end matrix
  94286. * @param gradient defines the gradient between both matrices
  94287. * @param result defines an optional target matrix where to store the interpolation
  94288. * @returns the interpolated matrix
  94289. */
  94290. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  94291. /**
  94292. * Makes a copy of the animation
  94293. * @returns Cloned animation
  94294. */
  94295. clone(): Animation;
  94296. /**
  94297. * Sets the key frames of the animation
  94298. * @param values The animation key frames to set
  94299. */
  94300. setKeys(values: Array<IAnimationKey>): void;
  94301. /**
  94302. * Serializes the animation to an object
  94303. * @returns Serialized object
  94304. */
  94305. serialize(): any;
  94306. /**
  94307. * Float animation type
  94308. */
  94309. private static _ANIMATIONTYPE_FLOAT;
  94310. /**
  94311. * Vector3 animation type
  94312. */
  94313. private static _ANIMATIONTYPE_VECTOR3;
  94314. /**
  94315. * Quaternion animation type
  94316. */
  94317. private static _ANIMATIONTYPE_QUATERNION;
  94318. /**
  94319. * Matrix animation type
  94320. */
  94321. private static _ANIMATIONTYPE_MATRIX;
  94322. /**
  94323. * Color3 animation type
  94324. */
  94325. private static _ANIMATIONTYPE_COLOR3;
  94326. /**
  94327. * Vector2 animation type
  94328. */
  94329. private static _ANIMATIONTYPE_VECTOR2;
  94330. /**
  94331. * Size animation type
  94332. */
  94333. private static _ANIMATIONTYPE_SIZE;
  94334. /**
  94335. * Relative Loop Mode
  94336. */
  94337. private static _ANIMATIONLOOPMODE_RELATIVE;
  94338. /**
  94339. * Cycle Loop Mode
  94340. */
  94341. private static _ANIMATIONLOOPMODE_CYCLE;
  94342. /**
  94343. * Constant Loop Mode
  94344. */
  94345. private static _ANIMATIONLOOPMODE_CONSTANT;
  94346. /**
  94347. * Get the float animation type
  94348. */
  94349. static readonly ANIMATIONTYPE_FLOAT: number;
  94350. /**
  94351. * Get the Vector3 animation type
  94352. */
  94353. static readonly ANIMATIONTYPE_VECTOR3: number;
  94354. /**
  94355. * Get the Vector2 animation type
  94356. */
  94357. static readonly ANIMATIONTYPE_VECTOR2: number;
  94358. /**
  94359. * Get the Size animation type
  94360. */
  94361. static readonly ANIMATIONTYPE_SIZE: number;
  94362. /**
  94363. * Get the Quaternion animation type
  94364. */
  94365. static readonly ANIMATIONTYPE_QUATERNION: number;
  94366. /**
  94367. * Get the Matrix animation type
  94368. */
  94369. static readonly ANIMATIONTYPE_MATRIX: number;
  94370. /**
  94371. * Get the Color3 animation type
  94372. */
  94373. static readonly ANIMATIONTYPE_COLOR3: number;
  94374. /**
  94375. * Get the Relative Loop Mode
  94376. */
  94377. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  94378. /**
  94379. * Get the Cycle Loop Mode
  94380. */
  94381. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  94382. /**
  94383. * Get the Constant Loop Mode
  94384. */
  94385. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  94386. /** @hidden */
  94387. static _UniversalLerp(left: any, right: any, amount: number): any;
  94388. /**
  94389. * Parses an animation object and creates an animation
  94390. * @param parsedAnimation Parsed animation object
  94391. * @returns Animation object
  94392. */
  94393. static Parse(parsedAnimation: any): Animation;
  94394. /**
  94395. * Appends the serialized animations from the source animations
  94396. * @param source Source containing the animations
  94397. * @param destination Target to store the animations
  94398. */
  94399. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94400. }
  94401. }
  94402. declare module BABYLON {
  94403. /**
  94404. * Interface containing an array of animations
  94405. */
  94406. export interface IAnimatable {
  94407. /**
  94408. * Array of animations
  94409. */
  94410. animations: Nullable<Array<Animation>>;
  94411. }
  94412. }
  94413. declare module BABYLON {
  94414. /**
  94415. * This represents all the required information to add a fresnel effect on a material:
  94416. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  94417. */
  94418. export class FresnelParameters {
  94419. private _isEnabled;
  94420. /**
  94421. * Define if the fresnel effect is enable or not.
  94422. */
  94423. isEnabled: boolean;
  94424. /**
  94425. * Define the color used on edges (grazing angle)
  94426. */
  94427. leftColor: Color3;
  94428. /**
  94429. * Define the color used on center
  94430. */
  94431. rightColor: Color3;
  94432. /**
  94433. * Define bias applied to computed fresnel term
  94434. */
  94435. bias: number;
  94436. /**
  94437. * Defined the power exponent applied to fresnel term
  94438. */
  94439. power: number;
  94440. /**
  94441. * Clones the current fresnel and its valuues
  94442. * @returns a clone fresnel configuration
  94443. */
  94444. clone(): FresnelParameters;
  94445. /**
  94446. * Serializes the current fresnel parameters to a JSON representation.
  94447. * @return the JSON serialization
  94448. */
  94449. serialize(): any;
  94450. /**
  94451. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  94452. * @param parsedFresnelParameters Define the JSON representation
  94453. * @returns the parsed parameters
  94454. */
  94455. static Parse(parsedFresnelParameters: any): FresnelParameters;
  94456. }
  94457. }
  94458. declare module BABYLON {
  94459. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  94460. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94461. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94462. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94463. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94464. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94465. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94466. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94467. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94468. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94469. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94470. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94471. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94472. /**
  94473. * Decorator used to define property that can be serialized as reference to a camera
  94474. * @param sourceName defines the name of the property to decorate
  94475. */
  94476. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  94477. /**
  94478. * Class used to help serialization objects
  94479. */
  94480. export class SerializationHelper {
  94481. /** @hidden */
  94482. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  94483. /** @hidden */
  94484. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  94485. /** @hidden */
  94486. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  94487. /** @hidden */
  94488. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  94489. /**
  94490. * Appends the serialized animations from the source animations
  94491. * @param source Source containing the animations
  94492. * @param destination Target to store the animations
  94493. */
  94494. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  94495. /**
  94496. * Static function used to serialized a specific entity
  94497. * @param entity defines the entity to serialize
  94498. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94499. * @returns a JSON compatible object representing the serialization of the entity
  94500. */
  94501. static Serialize<T>(entity: T, serializationObject?: any): any;
  94502. /**
  94503. * Creates a new entity from a serialization data object
  94504. * @param creationFunction defines a function used to instanciated the new entity
  94505. * @param source defines the source serialization data
  94506. * @param scene defines the hosting scene
  94507. * @param rootUrl defines the root url for resources
  94508. * @returns a new entity
  94509. */
  94510. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  94511. /**
  94512. * Clones an object
  94513. * @param creationFunction defines the function used to instanciate the new object
  94514. * @param source defines the source object
  94515. * @returns the cloned object
  94516. */
  94517. static Clone<T>(creationFunction: () => T, source: T): T;
  94518. /**
  94519. * Instanciates a new object based on a source one (some data will be shared between both object)
  94520. * @param creationFunction defines the function used to instanciate the new object
  94521. * @param source defines the source object
  94522. * @returns the new object
  94523. */
  94524. static Instanciate<T>(creationFunction: () => T, source: T): T;
  94525. }
  94526. }
  94527. declare module BABYLON {
  94528. /**
  94529. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  94530. */
  94531. export interface CubeMapInfo {
  94532. /**
  94533. * The pixel array for the front face.
  94534. * This is stored in format, left to right, up to down format.
  94535. */
  94536. front: Nullable<ArrayBufferView>;
  94537. /**
  94538. * The pixel array for the back face.
  94539. * This is stored in format, left to right, up to down format.
  94540. */
  94541. back: Nullable<ArrayBufferView>;
  94542. /**
  94543. * The pixel array for the left face.
  94544. * This is stored in format, left to right, up to down format.
  94545. */
  94546. left: Nullable<ArrayBufferView>;
  94547. /**
  94548. * The pixel array for the right face.
  94549. * This is stored in format, left to right, up to down format.
  94550. */
  94551. right: Nullable<ArrayBufferView>;
  94552. /**
  94553. * The pixel array for the up face.
  94554. * This is stored in format, left to right, up to down format.
  94555. */
  94556. up: Nullable<ArrayBufferView>;
  94557. /**
  94558. * The pixel array for the down face.
  94559. * This is stored in format, left to right, up to down format.
  94560. */
  94561. down: Nullable<ArrayBufferView>;
  94562. /**
  94563. * The size of the cubemap stored.
  94564. *
  94565. * Each faces will be size * size pixels.
  94566. */
  94567. size: number;
  94568. /**
  94569. * The format of the texture.
  94570. *
  94571. * RGBA, RGB.
  94572. */
  94573. format: number;
  94574. /**
  94575. * The type of the texture data.
  94576. *
  94577. * UNSIGNED_INT, FLOAT.
  94578. */
  94579. type: number;
  94580. /**
  94581. * Specifies whether the texture is in gamma space.
  94582. */
  94583. gammaSpace: boolean;
  94584. }
  94585. /**
  94586. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  94587. */
  94588. export class PanoramaToCubeMapTools {
  94589. private static FACE_FRONT;
  94590. private static FACE_BACK;
  94591. private static FACE_RIGHT;
  94592. private static FACE_LEFT;
  94593. private static FACE_DOWN;
  94594. private static FACE_UP;
  94595. /**
  94596. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  94597. *
  94598. * @param float32Array The source data.
  94599. * @param inputWidth The width of the input panorama.
  94600. * @param inputHeight The height of the input panorama.
  94601. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  94602. * @return The cubemap data
  94603. */
  94604. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  94605. private static CreateCubemapTexture;
  94606. private static CalcProjectionSpherical;
  94607. }
  94608. }
  94609. declare module BABYLON {
  94610. /**
  94611. * Helper class dealing with the extraction of spherical polynomial dataArray
  94612. * from a cube map.
  94613. */
  94614. export class CubeMapToSphericalPolynomialTools {
  94615. private static FileFaces;
  94616. /**
  94617. * Converts a texture to the according Spherical Polynomial data.
  94618. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94619. *
  94620. * @param texture The texture to extract the information from.
  94621. * @return The Spherical Polynomial data.
  94622. */
  94623. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  94624. /**
  94625. * Converts a cubemap to the according Spherical Polynomial data.
  94626. * This extracts the first 3 orders only as they are the only one used in the lighting.
  94627. *
  94628. * @param cubeInfo The Cube map to extract the information from.
  94629. * @return The Spherical Polynomial data.
  94630. */
  94631. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  94632. }
  94633. }
  94634. declare module BABYLON {
  94635. /**
  94636. * Class used to manipulate GUIDs
  94637. */
  94638. export class GUID {
  94639. /**
  94640. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  94641. * Be aware Math.random() could cause collisions, but:
  94642. * "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"
  94643. * @returns a pseudo random id
  94644. */
  94645. static RandomId(): string;
  94646. }
  94647. }
  94648. declare module BABYLON {
  94649. /**
  94650. * Base class of all the textures in babylon.
  94651. * It groups all the common properties the materials, post process, lights... might need
  94652. * in order to make a correct use of the texture.
  94653. */
  94654. export class BaseTexture implements IAnimatable {
  94655. /**
  94656. * Default anisotropic filtering level for the application.
  94657. * It is set to 4 as a good tradeoff between perf and quality.
  94658. */
  94659. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  94660. /**
  94661. * Gets or sets the unique id of the texture
  94662. */
  94663. uniqueId: number;
  94664. /**
  94665. * Define the name of the texture.
  94666. */
  94667. name: string;
  94668. /**
  94669. * Gets or sets an object used to store user defined information.
  94670. */
  94671. metadata: any;
  94672. /**
  94673. * For internal use only. Please do not use.
  94674. */
  94675. reservedDataStore: any;
  94676. private _hasAlpha;
  94677. /**
  94678. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  94679. */
  94680. hasAlpha: boolean;
  94681. /**
  94682. * Defines if the alpha value should be determined via the rgb values.
  94683. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  94684. */
  94685. getAlphaFromRGB: boolean;
  94686. /**
  94687. * Intensity or strength of the texture.
  94688. * It is commonly used by materials to fine tune the intensity of the texture
  94689. */
  94690. level: number;
  94691. /**
  94692. * Define the UV chanel to use starting from 0 and defaulting to 0.
  94693. * This is part of the texture as textures usually maps to one uv set.
  94694. */
  94695. coordinatesIndex: number;
  94696. private _coordinatesMode;
  94697. /**
  94698. * How a texture is mapped.
  94699. *
  94700. * | Value | Type | Description |
  94701. * | ----- | ----------------------------------- | ----------- |
  94702. * | 0 | EXPLICIT_MODE | |
  94703. * | 1 | SPHERICAL_MODE | |
  94704. * | 2 | PLANAR_MODE | |
  94705. * | 3 | CUBIC_MODE | |
  94706. * | 4 | PROJECTION_MODE | |
  94707. * | 5 | SKYBOX_MODE | |
  94708. * | 6 | INVCUBIC_MODE | |
  94709. * | 7 | EQUIRECTANGULAR_MODE | |
  94710. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  94711. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  94712. */
  94713. coordinatesMode: number;
  94714. /**
  94715. * | Value | Type | Description |
  94716. * | ----- | ------------------ | ----------- |
  94717. * | 0 | CLAMP_ADDRESSMODE | |
  94718. * | 1 | WRAP_ADDRESSMODE | |
  94719. * | 2 | MIRROR_ADDRESSMODE | |
  94720. */
  94721. wrapU: number;
  94722. /**
  94723. * | Value | Type | Description |
  94724. * | ----- | ------------------ | ----------- |
  94725. * | 0 | CLAMP_ADDRESSMODE | |
  94726. * | 1 | WRAP_ADDRESSMODE | |
  94727. * | 2 | MIRROR_ADDRESSMODE | |
  94728. */
  94729. wrapV: number;
  94730. /**
  94731. * | Value | Type | Description |
  94732. * | ----- | ------------------ | ----------- |
  94733. * | 0 | CLAMP_ADDRESSMODE | |
  94734. * | 1 | WRAP_ADDRESSMODE | |
  94735. * | 2 | MIRROR_ADDRESSMODE | |
  94736. */
  94737. wrapR: number;
  94738. /**
  94739. * With compliant hardware and browser (supporting anisotropic filtering)
  94740. * this defines the level of anisotropic filtering in the texture.
  94741. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  94742. */
  94743. anisotropicFilteringLevel: number;
  94744. /**
  94745. * Define if the texture is a cube texture or if false a 2d texture.
  94746. */
  94747. isCube: boolean;
  94748. /**
  94749. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  94750. */
  94751. is3D: boolean;
  94752. /**
  94753. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  94754. * HDR texture are usually stored in linear space.
  94755. * This only impacts the PBR and Background materials
  94756. */
  94757. gammaSpace: boolean;
  94758. /**
  94759. * Gets or sets whether or not the texture contains RGBD data.
  94760. */
  94761. isRGBD: boolean;
  94762. /**
  94763. * Is Z inverted in the texture (useful in a cube texture).
  94764. */
  94765. invertZ: boolean;
  94766. /**
  94767. * Are mip maps generated for this texture or not.
  94768. */
  94769. readonly noMipmap: boolean;
  94770. /**
  94771. * @hidden
  94772. */
  94773. lodLevelInAlpha: boolean;
  94774. /**
  94775. * With prefiltered texture, defined the offset used during the prefiltering steps.
  94776. */
  94777. lodGenerationOffset: number;
  94778. /**
  94779. * With prefiltered texture, defined the scale used during the prefiltering steps.
  94780. */
  94781. lodGenerationScale: number;
  94782. /**
  94783. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  94784. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  94785. * average roughness values.
  94786. */
  94787. linearSpecularLOD: boolean;
  94788. /**
  94789. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  94790. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  94791. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  94792. */
  94793. irradianceTexture: Nullable<BaseTexture>;
  94794. /**
  94795. * Define if the texture is a render target.
  94796. */
  94797. isRenderTarget: boolean;
  94798. /**
  94799. * Define the unique id of the texture in the scene.
  94800. */
  94801. readonly uid: string;
  94802. /**
  94803. * Return a string representation of the texture.
  94804. * @returns the texture as a string
  94805. */
  94806. toString(): string;
  94807. /**
  94808. * Get the class name of the texture.
  94809. * @returns "BaseTexture"
  94810. */
  94811. getClassName(): string;
  94812. /**
  94813. * Define the list of animation attached to the texture.
  94814. */
  94815. animations: Animation[];
  94816. /**
  94817. * An event triggered when the texture is disposed.
  94818. */
  94819. onDisposeObservable: Observable<BaseTexture>;
  94820. private _onDisposeObserver;
  94821. /**
  94822. * Callback triggered when the texture has been disposed.
  94823. * Kept for back compatibility, you can use the onDisposeObservable instead.
  94824. */
  94825. onDispose: () => void;
  94826. /**
  94827. * Define the current state of the loading sequence when in delayed load mode.
  94828. */
  94829. delayLoadState: number;
  94830. private _scene;
  94831. /** @hidden */
  94832. _texture: Nullable<InternalTexture>;
  94833. private _uid;
  94834. /**
  94835. * Define if the texture is preventinga material to render or not.
  94836. * If not and the texture is not ready, the engine will use a default black texture instead.
  94837. */
  94838. readonly isBlocking: boolean;
  94839. /**
  94840. * Instantiates a new BaseTexture.
  94841. * Base class of all the textures in babylon.
  94842. * It groups all the common properties the materials, post process, lights... might need
  94843. * in order to make a correct use of the texture.
  94844. * @param scene Define the scene the texture blongs to
  94845. */
  94846. constructor(scene: Nullable<Scene>);
  94847. /**
  94848. * Get the scene the texture belongs to.
  94849. * @returns the scene or null if undefined
  94850. */
  94851. getScene(): Nullable<Scene>;
  94852. /**
  94853. * Get the texture transform matrix used to offset tile the texture for istance.
  94854. * @returns the transformation matrix
  94855. */
  94856. getTextureMatrix(): Matrix;
  94857. /**
  94858. * Get the texture reflection matrix used to rotate/transform the reflection.
  94859. * @returns the reflection matrix
  94860. */
  94861. getReflectionTextureMatrix(): Matrix;
  94862. /**
  94863. * Get the underlying lower level texture from Babylon.
  94864. * @returns the insternal texture
  94865. */
  94866. getInternalTexture(): Nullable<InternalTexture>;
  94867. /**
  94868. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  94869. * @returns true if ready or not blocking
  94870. */
  94871. isReadyOrNotBlocking(): boolean;
  94872. /**
  94873. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  94874. * @returns true if fully ready
  94875. */
  94876. isReady(): boolean;
  94877. private _cachedSize;
  94878. /**
  94879. * Get the size of the texture.
  94880. * @returns the texture size.
  94881. */
  94882. getSize(): ISize;
  94883. /**
  94884. * Get the base size of the texture.
  94885. * It can be different from the size if the texture has been resized for POT for instance
  94886. * @returns the base size
  94887. */
  94888. getBaseSize(): ISize;
  94889. /**
  94890. * Update the sampling mode of the texture.
  94891. * Default is Trilinear mode.
  94892. *
  94893. * | Value | Type | Description |
  94894. * | ----- | ------------------ | ----------- |
  94895. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  94896. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  94897. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  94898. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  94899. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  94900. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  94901. * | 7 | NEAREST_LINEAR | |
  94902. * | 8 | NEAREST_NEAREST | |
  94903. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  94904. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  94905. * | 11 | LINEAR_LINEAR | |
  94906. * | 12 | LINEAR_NEAREST | |
  94907. *
  94908. * > _mag_: magnification filter (close to the viewer)
  94909. * > _min_: minification filter (far from the viewer)
  94910. * > _mip_: filter used between mip map levels
  94911. *@param samplingMode Define the new sampling mode of the texture
  94912. */
  94913. updateSamplingMode(samplingMode: number): void;
  94914. /**
  94915. * Scales the texture if is `canRescale()`
  94916. * @param ratio the resize factor we want to use to rescale
  94917. */
  94918. scale(ratio: number): void;
  94919. /**
  94920. * Get if the texture can rescale.
  94921. */
  94922. readonly canRescale: boolean;
  94923. /** @hidden */
  94924. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  94925. /** @hidden */
  94926. _rebuild(): void;
  94927. /**
  94928. * Triggers the load sequence in delayed load mode.
  94929. */
  94930. delayLoad(): void;
  94931. /**
  94932. * Clones the texture.
  94933. * @returns the cloned texture
  94934. */
  94935. clone(): Nullable<BaseTexture>;
  94936. /**
  94937. * Get the texture underlying type (INT, FLOAT...)
  94938. */
  94939. readonly textureType: number;
  94940. /**
  94941. * Get the texture underlying format (RGB, RGBA...)
  94942. */
  94943. readonly textureFormat: number;
  94944. /**
  94945. * Indicates that textures need to be re-calculated for all materials
  94946. */
  94947. protected _markAllSubMeshesAsTexturesDirty(): void;
  94948. /**
  94949. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  94950. * This will returns an RGBA array buffer containing either in values (0-255) or
  94951. * float values (0-1) depending of the underlying buffer type.
  94952. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  94953. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  94954. * @param buffer defines a user defined buffer to fill with data (can be null)
  94955. * @returns The Array buffer containing the pixels data.
  94956. */
  94957. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  94958. /**
  94959. * Release and destroy the underlying lower level texture aka internalTexture.
  94960. */
  94961. releaseInternalTexture(): void;
  94962. /**
  94963. * Get the polynomial representation of the texture data.
  94964. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  94965. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  94966. */
  94967. sphericalPolynomial: Nullable<SphericalPolynomial>;
  94968. /** @hidden */
  94969. readonly _lodTextureHigh: Nullable<BaseTexture>;
  94970. /** @hidden */
  94971. readonly _lodTextureMid: Nullable<BaseTexture>;
  94972. /** @hidden */
  94973. readonly _lodTextureLow: Nullable<BaseTexture>;
  94974. /**
  94975. * Dispose the texture and release its associated resources.
  94976. */
  94977. dispose(): void;
  94978. /**
  94979. * Serialize the texture into a JSON representation that can be parsed later on.
  94980. * @returns the JSON representation of the texture
  94981. */
  94982. serialize(): any;
  94983. /**
  94984. * Helper function to be called back once a list of texture contains only ready textures.
  94985. * @param textures Define the list of textures to wait for
  94986. * @param callback Define the callback triggered once the entire list will be ready
  94987. */
  94988. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  94989. }
  94990. }
  94991. declare module BABYLON {
  94992. /**
  94993. * Options to be used when creating an effect.
  94994. */
  94995. export class EffectCreationOptions {
  94996. /**
  94997. * Atrributes that will be used in the shader.
  94998. */
  94999. attributes: string[];
  95000. /**
  95001. * Uniform varible names that will be set in the shader.
  95002. */
  95003. uniformsNames: string[];
  95004. /**
  95005. * Uniform buffer varible names that will be set in the shader.
  95006. */
  95007. uniformBuffersNames: string[];
  95008. /**
  95009. * Sampler texture variable names that will be set in the shader.
  95010. */
  95011. samplers: string[];
  95012. /**
  95013. * Define statements that will be set in the shader.
  95014. */
  95015. defines: any;
  95016. /**
  95017. * Possible fallbacks for this effect to improve performance when needed.
  95018. */
  95019. fallbacks: Nullable<IEffectFallbacks>;
  95020. /**
  95021. * Callback that will be called when the shader is compiled.
  95022. */
  95023. onCompiled: Nullable<(effect: Effect) => void>;
  95024. /**
  95025. * Callback that will be called if an error occurs during shader compilation.
  95026. */
  95027. onError: Nullable<(effect: Effect, errors: string) => void>;
  95028. /**
  95029. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95030. */
  95031. indexParameters?: any;
  95032. /**
  95033. * Max number of lights that can be used in the shader.
  95034. */
  95035. maxSimultaneousLights?: number;
  95036. /**
  95037. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  95038. */
  95039. transformFeedbackVaryings?: Nullable<string[]>;
  95040. }
  95041. /**
  95042. * Effect containing vertex and fragment shader that can be executed on an object.
  95043. */
  95044. export class Effect implements IDisposable {
  95045. /**
  95046. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95047. */
  95048. static ShadersRepository: string;
  95049. /**
  95050. * Name of the effect.
  95051. */
  95052. name: any;
  95053. /**
  95054. * String container all the define statements that should be set on the shader.
  95055. */
  95056. defines: string;
  95057. /**
  95058. * Callback that will be called when the shader is compiled.
  95059. */
  95060. onCompiled: Nullable<(effect: Effect) => void>;
  95061. /**
  95062. * Callback that will be called if an error occurs during shader compilation.
  95063. */
  95064. onError: Nullable<(effect: Effect, errors: string) => void>;
  95065. /**
  95066. * Callback that will be called when effect is bound.
  95067. */
  95068. onBind: Nullable<(effect: Effect) => void>;
  95069. /**
  95070. * Unique ID of the effect.
  95071. */
  95072. uniqueId: number;
  95073. /**
  95074. * Observable that will be called when the shader is compiled.
  95075. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  95076. */
  95077. onCompileObservable: Observable<Effect>;
  95078. /**
  95079. * Observable that will be called if an error occurs during shader compilation.
  95080. */
  95081. onErrorObservable: Observable<Effect>;
  95082. /** @hidden */
  95083. _onBindObservable: Nullable<Observable<Effect>>;
  95084. /**
  95085. * Observable that will be called when effect is bound.
  95086. */
  95087. readonly onBindObservable: Observable<Effect>;
  95088. /** @hidden */
  95089. _bonesComputationForcedToCPU: boolean;
  95090. private static _uniqueIdSeed;
  95091. private _engine;
  95092. private _uniformBuffersNames;
  95093. private _uniformsNames;
  95094. private _samplerList;
  95095. private _samplers;
  95096. private _isReady;
  95097. private _compilationError;
  95098. private _attributesNames;
  95099. private _attributes;
  95100. private _uniforms;
  95101. /**
  95102. * Key for the effect.
  95103. * @hidden
  95104. */
  95105. _key: string;
  95106. private _indexParameters;
  95107. private _fallbacks;
  95108. private _vertexSourceCode;
  95109. private _fragmentSourceCode;
  95110. private _vertexSourceCodeOverride;
  95111. private _fragmentSourceCodeOverride;
  95112. private _transformFeedbackVaryings;
  95113. /**
  95114. * Compiled shader to webGL program.
  95115. * @hidden
  95116. */
  95117. _pipelineContext: Nullable<IPipelineContext>;
  95118. private _valueCache;
  95119. private static _baseCache;
  95120. /**
  95121. * Instantiates an effect.
  95122. * An effect can be used to create/manage/execute vertex and fragment shaders.
  95123. * @param baseName Name of the effect.
  95124. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  95125. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  95126. * @param samplers List of sampler variables that will be passed to the shader.
  95127. * @param engine Engine to be used to render the effect
  95128. * @param defines Define statements to be added to the shader.
  95129. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  95130. * @param onCompiled Callback that will be called when the shader is compiled.
  95131. * @param onError Callback that will be called if an error occurs during shader compilation.
  95132. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  95133. */
  95134. constructor(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: Nullable<string[]>, engine?: ThinEngine, defines?: Nullable<string>, fallbacks?: Nullable<IEffectFallbacks>, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any);
  95135. private _useFinalCode;
  95136. /**
  95137. * Unique key for this effect
  95138. */
  95139. readonly key: string;
  95140. /**
  95141. * If the effect has been compiled and prepared.
  95142. * @returns if the effect is compiled and prepared.
  95143. */
  95144. isReady(): boolean;
  95145. private _isReadyInternal;
  95146. /**
  95147. * The engine the effect was initialized with.
  95148. * @returns the engine.
  95149. */
  95150. getEngine(): Engine;
  95151. /**
  95152. * The pipeline context for this effect
  95153. * @returns the associated pipeline context
  95154. */
  95155. getPipelineContext(): Nullable<IPipelineContext>;
  95156. /**
  95157. * The set of names of attribute variables for the shader.
  95158. * @returns An array of attribute names.
  95159. */
  95160. getAttributesNames(): string[];
  95161. /**
  95162. * Returns the attribute at the given index.
  95163. * @param index The index of the attribute.
  95164. * @returns The location of the attribute.
  95165. */
  95166. getAttributeLocation(index: number): number;
  95167. /**
  95168. * Returns the attribute based on the name of the variable.
  95169. * @param name of the attribute to look up.
  95170. * @returns the attribute location.
  95171. */
  95172. getAttributeLocationByName(name: string): number;
  95173. /**
  95174. * The number of attributes.
  95175. * @returns the numnber of attributes.
  95176. */
  95177. getAttributesCount(): number;
  95178. /**
  95179. * Gets the index of a uniform variable.
  95180. * @param uniformName of the uniform to look up.
  95181. * @returns the index.
  95182. */
  95183. getUniformIndex(uniformName: string): number;
  95184. /**
  95185. * Returns the attribute based on the name of the variable.
  95186. * @param uniformName of the uniform to look up.
  95187. * @returns the location of the uniform.
  95188. */
  95189. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  95190. /**
  95191. * Returns an array of sampler variable names
  95192. * @returns The array of sampler variable neames.
  95193. */
  95194. getSamplers(): string[];
  95195. /**
  95196. * The error from the last compilation.
  95197. * @returns the error string.
  95198. */
  95199. getCompilationError(): string;
  95200. /**
  95201. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  95202. * @param func The callback to be used.
  95203. */
  95204. executeWhenCompiled(func: (effect: Effect) => void): void;
  95205. private _checkIsReady;
  95206. /** @hidden */
  95207. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  95208. /** @hidden */
  95209. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  95210. /** @hidden */
  95211. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  95212. /**
  95213. * Recompiles the webGL program
  95214. * @param vertexSourceCode The source code for the vertex shader.
  95215. * @param fragmentSourceCode The source code for the fragment shader.
  95216. * @param onCompiled Callback called when completed.
  95217. * @param onError Callback called on error.
  95218. * @hidden
  95219. */
  95220. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  95221. /**
  95222. * Prepares the effect
  95223. * @hidden
  95224. */
  95225. _prepareEffect(): void;
  95226. private _processCompilationErrors;
  95227. /**
  95228. * Checks if the effect is supported. (Must be called after compilation)
  95229. */
  95230. readonly isSupported: boolean;
  95231. /**
  95232. * Binds a texture to the engine to be used as output of the shader.
  95233. * @param channel Name of the output variable.
  95234. * @param texture Texture to bind.
  95235. * @hidden
  95236. */
  95237. _bindTexture(channel: string, texture: InternalTexture): void;
  95238. /**
  95239. * Sets a texture on the engine to be used in the shader.
  95240. * @param channel Name of the sampler variable.
  95241. * @param texture Texture to set.
  95242. */
  95243. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  95244. /**
  95245. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  95246. * @param channel Name of the sampler variable.
  95247. * @param texture Texture to set.
  95248. */
  95249. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  95250. /**
  95251. * Sets an array of textures on the engine to be used in the shader.
  95252. * @param channel Name of the variable.
  95253. * @param textures Textures to set.
  95254. */
  95255. setTextureArray(channel: string, textures: BaseTexture[]): void;
  95256. /**
  95257. * 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)
  95258. * @param channel Name of the sampler variable.
  95259. * @param postProcess Post process to get the input texture from.
  95260. */
  95261. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  95262. /**
  95263. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  95264. * 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)
  95265. * @param channel Name of the sampler variable.
  95266. * @param postProcess Post process to get the output texture from.
  95267. */
  95268. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  95269. /** @hidden */
  95270. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  95271. /** @hidden */
  95272. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  95273. /** @hidden */
  95274. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  95275. /** @hidden */
  95276. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  95277. /**
  95278. * Binds a buffer to a uniform.
  95279. * @param buffer Buffer to bind.
  95280. * @param name Name of the uniform variable to bind to.
  95281. */
  95282. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  95283. /**
  95284. * Binds block to a uniform.
  95285. * @param blockName Name of the block to bind.
  95286. * @param index Index to bind.
  95287. */
  95288. bindUniformBlock(blockName: string, index: number): void;
  95289. /**
  95290. * Sets an interger value on a uniform variable.
  95291. * @param uniformName Name of the variable.
  95292. * @param value Value to be set.
  95293. * @returns this effect.
  95294. */
  95295. setInt(uniformName: string, value: number): Effect;
  95296. /**
  95297. * Sets an int array on a uniform variable.
  95298. * @param uniformName Name of the variable.
  95299. * @param array array to be set.
  95300. * @returns this effect.
  95301. */
  95302. setIntArray(uniformName: string, array: Int32Array): Effect;
  95303. /**
  95304. * 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)
  95305. * @param uniformName Name of the variable.
  95306. * @param array array to be set.
  95307. * @returns this effect.
  95308. */
  95309. setIntArray2(uniformName: string, array: Int32Array): Effect;
  95310. /**
  95311. * 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)
  95312. * @param uniformName Name of the variable.
  95313. * @param array array to be set.
  95314. * @returns this effect.
  95315. */
  95316. setIntArray3(uniformName: string, array: Int32Array): Effect;
  95317. /**
  95318. * 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)
  95319. * @param uniformName Name of the variable.
  95320. * @param array array to be set.
  95321. * @returns this effect.
  95322. */
  95323. setIntArray4(uniformName: string, array: Int32Array): Effect;
  95324. /**
  95325. * Sets an float array on a uniform variable.
  95326. * @param uniformName Name of the variable.
  95327. * @param array array to be set.
  95328. * @returns this effect.
  95329. */
  95330. setFloatArray(uniformName: string, array: Float32Array): Effect;
  95331. /**
  95332. * 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)
  95333. * @param uniformName Name of the variable.
  95334. * @param array array to be set.
  95335. * @returns this effect.
  95336. */
  95337. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  95338. /**
  95339. * 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)
  95340. * @param uniformName Name of the variable.
  95341. * @param array array to be set.
  95342. * @returns this effect.
  95343. */
  95344. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  95345. /**
  95346. * 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)
  95347. * @param uniformName Name of the variable.
  95348. * @param array array to be set.
  95349. * @returns this effect.
  95350. */
  95351. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  95352. /**
  95353. * Sets an array on a uniform variable.
  95354. * @param uniformName Name of the variable.
  95355. * @param array array to be set.
  95356. * @returns this effect.
  95357. */
  95358. setArray(uniformName: string, array: number[]): Effect;
  95359. /**
  95360. * 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)
  95361. * @param uniformName Name of the variable.
  95362. * @param array array to be set.
  95363. * @returns this effect.
  95364. */
  95365. setArray2(uniformName: string, array: number[]): Effect;
  95366. /**
  95367. * 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)
  95368. * @param uniformName Name of the variable.
  95369. * @param array array to be set.
  95370. * @returns this effect.
  95371. */
  95372. setArray3(uniformName: string, array: number[]): Effect;
  95373. /**
  95374. * 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)
  95375. * @param uniformName Name of the variable.
  95376. * @param array array to be set.
  95377. * @returns this effect.
  95378. */
  95379. setArray4(uniformName: string, array: number[]): Effect;
  95380. /**
  95381. * Sets matrices on a uniform variable.
  95382. * @param uniformName Name of the variable.
  95383. * @param matrices matrices to be set.
  95384. * @returns this effect.
  95385. */
  95386. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  95387. /**
  95388. * Sets matrix on a uniform variable.
  95389. * @param uniformName Name of the variable.
  95390. * @param matrix matrix to be set.
  95391. * @returns this effect.
  95392. */
  95393. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  95394. /**
  95395. * 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)
  95396. * @param uniformName Name of the variable.
  95397. * @param matrix matrix to be set.
  95398. * @returns this effect.
  95399. */
  95400. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  95401. /**
  95402. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  95403. * @param uniformName Name of the variable.
  95404. * @param matrix matrix to be set.
  95405. * @returns this effect.
  95406. */
  95407. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  95408. /**
  95409. * Sets a float on a uniform variable.
  95410. * @param uniformName Name of the variable.
  95411. * @param value value to be set.
  95412. * @returns this effect.
  95413. */
  95414. setFloat(uniformName: string, value: number): Effect;
  95415. /**
  95416. * Sets a boolean on a uniform variable.
  95417. * @param uniformName Name of the variable.
  95418. * @param bool value to be set.
  95419. * @returns this effect.
  95420. */
  95421. setBool(uniformName: string, bool: boolean): Effect;
  95422. /**
  95423. * Sets a Vector2 on a uniform variable.
  95424. * @param uniformName Name of the variable.
  95425. * @param vector2 vector2 to be set.
  95426. * @returns this effect.
  95427. */
  95428. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  95429. /**
  95430. * Sets a float2 on a uniform variable.
  95431. * @param uniformName Name of the variable.
  95432. * @param x First float in float2.
  95433. * @param y Second float in float2.
  95434. * @returns this effect.
  95435. */
  95436. setFloat2(uniformName: string, x: number, y: number): Effect;
  95437. /**
  95438. * Sets a Vector3 on a uniform variable.
  95439. * @param uniformName Name of the variable.
  95440. * @param vector3 Value to be set.
  95441. * @returns this effect.
  95442. */
  95443. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  95444. /**
  95445. * Sets a float3 on a uniform variable.
  95446. * @param uniformName Name of the variable.
  95447. * @param x First float in float3.
  95448. * @param y Second float in float3.
  95449. * @param z Third float in float3.
  95450. * @returns this effect.
  95451. */
  95452. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  95453. /**
  95454. * Sets a Vector4 on a uniform variable.
  95455. * @param uniformName Name of the variable.
  95456. * @param vector4 Value to be set.
  95457. * @returns this effect.
  95458. */
  95459. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  95460. /**
  95461. * Sets a float4 on a uniform variable.
  95462. * @param uniformName Name of the variable.
  95463. * @param x First float in float4.
  95464. * @param y Second float in float4.
  95465. * @param z Third float in float4.
  95466. * @param w Fourth float in float4.
  95467. * @returns this effect.
  95468. */
  95469. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  95470. /**
  95471. * Sets a Color3 on a uniform variable.
  95472. * @param uniformName Name of the variable.
  95473. * @param color3 Value to be set.
  95474. * @returns this effect.
  95475. */
  95476. setColor3(uniformName: string, color3: IColor3Like): Effect;
  95477. /**
  95478. * Sets a Color4 on a uniform variable.
  95479. * @param uniformName Name of the variable.
  95480. * @param color3 Value to be set.
  95481. * @param alpha Alpha value to be set.
  95482. * @returns this effect.
  95483. */
  95484. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  95485. /**
  95486. * Sets a Color4 on a uniform variable
  95487. * @param uniformName defines the name of the variable
  95488. * @param color4 defines the value to be set
  95489. * @returns this effect.
  95490. */
  95491. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  95492. /** Release all associated resources */
  95493. dispose(): void;
  95494. /**
  95495. * This function will add a new shader to the shader store
  95496. * @param name the name of the shader
  95497. * @param pixelShader optional pixel shader content
  95498. * @param vertexShader optional vertex shader content
  95499. */
  95500. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  95501. /**
  95502. * Store of each shader (The can be looked up using effect.key)
  95503. */
  95504. static ShadersStore: {
  95505. [key: string]: string;
  95506. };
  95507. /**
  95508. * Store of each included file for a shader (The can be looked up using effect.key)
  95509. */
  95510. static IncludesShadersStore: {
  95511. [key: string]: string;
  95512. };
  95513. /**
  95514. * Resets the cache of effects.
  95515. */
  95516. static ResetCache(): void;
  95517. }
  95518. }
  95519. declare module BABYLON {
  95520. /**
  95521. * Class used to describe the capabilities of the engine relatively to the current browser
  95522. */
  95523. export class EngineCapabilities {
  95524. /** Maximum textures units per fragment shader */
  95525. maxTexturesImageUnits: number;
  95526. /** Maximum texture units per vertex shader */
  95527. maxVertexTextureImageUnits: number;
  95528. /** Maximum textures units in the entire pipeline */
  95529. maxCombinedTexturesImageUnits: number;
  95530. /** Maximum texture size */
  95531. maxTextureSize: number;
  95532. /** Maximum cube texture size */
  95533. maxCubemapTextureSize: number;
  95534. /** Maximum render texture size */
  95535. maxRenderTextureSize: number;
  95536. /** Maximum number of vertex attributes */
  95537. maxVertexAttribs: number;
  95538. /** Maximum number of varyings */
  95539. maxVaryingVectors: number;
  95540. /** Maximum number of uniforms per vertex shader */
  95541. maxVertexUniformVectors: number;
  95542. /** Maximum number of uniforms per fragment shader */
  95543. maxFragmentUniformVectors: number;
  95544. /** Defines if standard derivates (dx/dy) are supported */
  95545. standardDerivatives: boolean;
  95546. /** Defines if s3tc texture compression is supported */
  95547. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  95548. /** Defines if pvrtc texture compression is supported */
  95549. pvrtc: any;
  95550. /** Defines if etc1 texture compression is supported */
  95551. etc1: any;
  95552. /** Defines if etc2 texture compression is supported */
  95553. etc2: any;
  95554. /** Defines if astc texture compression is supported */
  95555. astc: any;
  95556. /** Defines if float textures are supported */
  95557. textureFloat: boolean;
  95558. /** Defines if vertex array objects are supported */
  95559. vertexArrayObject: boolean;
  95560. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  95561. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  95562. /** Gets the maximum level of anisotropy supported */
  95563. maxAnisotropy: number;
  95564. /** Defines if instancing is supported */
  95565. instancedArrays: boolean;
  95566. /** Defines if 32 bits indices are supported */
  95567. uintIndices: boolean;
  95568. /** Defines if high precision shaders are supported */
  95569. highPrecisionShaderSupported: boolean;
  95570. /** Defines if depth reading in the fragment shader is supported */
  95571. fragmentDepthSupported: boolean;
  95572. /** Defines if float texture linear filtering is supported*/
  95573. textureFloatLinearFiltering: boolean;
  95574. /** Defines if rendering to float textures is supported */
  95575. textureFloatRender: boolean;
  95576. /** Defines if half float textures are supported*/
  95577. textureHalfFloat: boolean;
  95578. /** Defines if half float texture linear filtering is supported*/
  95579. textureHalfFloatLinearFiltering: boolean;
  95580. /** Defines if rendering to half float textures is supported */
  95581. textureHalfFloatRender: boolean;
  95582. /** Defines if textureLOD shader command is supported */
  95583. textureLOD: boolean;
  95584. /** Defines if draw buffers extension is supported */
  95585. drawBuffersExtension: boolean;
  95586. /** Defines if depth textures are supported */
  95587. depthTextureExtension: boolean;
  95588. /** Defines if float color buffer are supported */
  95589. colorBufferFloat: boolean;
  95590. /** Gets disjoint timer query extension (null if not supported) */
  95591. timerQuery: EXT_disjoint_timer_query;
  95592. /** Defines if timestamp can be used with timer query */
  95593. canUseTimestampForTimerQuery: boolean;
  95594. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  95595. multiview: any;
  95596. /** Function used to let the system compiles shaders in background */
  95597. parallelShaderCompile: {
  95598. COMPLETION_STATUS_KHR: number;
  95599. };
  95600. /** Max number of texture samples for MSAA */
  95601. maxMSAASamples: number;
  95602. /** Defines if the blend min max extension is supported */
  95603. blendMinMax: boolean;
  95604. }
  95605. }
  95606. declare module BABYLON {
  95607. /**
  95608. * @hidden
  95609. **/
  95610. export class DepthCullingState {
  95611. private _isDepthTestDirty;
  95612. private _isDepthMaskDirty;
  95613. private _isDepthFuncDirty;
  95614. private _isCullFaceDirty;
  95615. private _isCullDirty;
  95616. private _isZOffsetDirty;
  95617. private _isFrontFaceDirty;
  95618. private _depthTest;
  95619. private _depthMask;
  95620. private _depthFunc;
  95621. private _cull;
  95622. private _cullFace;
  95623. private _zOffset;
  95624. private _frontFace;
  95625. /**
  95626. * Initializes the state.
  95627. */
  95628. constructor();
  95629. readonly isDirty: boolean;
  95630. zOffset: number;
  95631. cullFace: Nullable<number>;
  95632. cull: Nullable<boolean>;
  95633. depthFunc: Nullable<number>;
  95634. depthMask: boolean;
  95635. depthTest: boolean;
  95636. frontFace: Nullable<number>;
  95637. reset(): void;
  95638. apply(gl: WebGLRenderingContext): void;
  95639. }
  95640. }
  95641. declare module BABYLON {
  95642. /**
  95643. * @hidden
  95644. **/
  95645. export class StencilState {
  95646. /** 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 */
  95647. static readonly ALWAYS: number;
  95648. /** Passed to stencilOperation to specify that stencil value must be kept */
  95649. static readonly KEEP: number;
  95650. /** Passed to stencilOperation to specify that stencil value must be replaced */
  95651. static readonly REPLACE: number;
  95652. private _isStencilTestDirty;
  95653. private _isStencilMaskDirty;
  95654. private _isStencilFuncDirty;
  95655. private _isStencilOpDirty;
  95656. private _stencilTest;
  95657. private _stencilMask;
  95658. private _stencilFunc;
  95659. private _stencilFuncRef;
  95660. private _stencilFuncMask;
  95661. private _stencilOpStencilFail;
  95662. private _stencilOpDepthFail;
  95663. private _stencilOpStencilDepthPass;
  95664. readonly isDirty: boolean;
  95665. stencilFunc: number;
  95666. stencilFuncRef: number;
  95667. stencilFuncMask: number;
  95668. stencilOpStencilFail: number;
  95669. stencilOpDepthFail: number;
  95670. stencilOpStencilDepthPass: number;
  95671. stencilMask: number;
  95672. stencilTest: boolean;
  95673. constructor();
  95674. reset(): void;
  95675. apply(gl: WebGLRenderingContext): void;
  95676. }
  95677. }
  95678. declare module BABYLON {
  95679. /**
  95680. * @hidden
  95681. **/
  95682. export class AlphaState {
  95683. private _isAlphaBlendDirty;
  95684. private _isBlendFunctionParametersDirty;
  95685. private _isBlendEquationParametersDirty;
  95686. private _isBlendConstantsDirty;
  95687. private _alphaBlend;
  95688. private _blendFunctionParameters;
  95689. private _blendEquationParameters;
  95690. private _blendConstants;
  95691. /**
  95692. * Initializes the state.
  95693. */
  95694. constructor();
  95695. readonly isDirty: boolean;
  95696. alphaBlend: boolean;
  95697. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  95698. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  95699. setAlphaEquationParameters(rgb: number, alpha: number): void;
  95700. reset(): void;
  95701. apply(gl: WebGLRenderingContext): void;
  95702. }
  95703. }
  95704. declare module BABYLON {
  95705. /** @hidden */
  95706. export class WebGL2ShaderProcessor implements IShaderProcessor {
  95707. attributeProcessor(attribute: string): string;
  95708. varyingProcessor(varying: string, isFragment: boolean): string;
  95709. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  95710. }
  95711. }
  95712. declare module BABYLON {
  95713. /**
  95714. * Interface for attribute information associated with buffer instanciation
  95715. */
  95716. export class InstancingAttributeInfo {
  95717. /**
  95718. * Index/offset of the attribute in the vertex shader
  95719. */
  95720. index: number;
  95721. /**
  95722. * size of the attribute, 1, 2, 3 or 4
  95723. */
  95724. attributeSize: number;
  95725. /**
  95726. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  95727. * default is FLOAT
  95728. */
  95729. attribyteType: number;
  95730. /**
  95731. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  95732. */
  95733. normalized: boolean;
  95734. /**
  95735. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  95736. */
  95737. offset: number;
  95738. /**
  95739. * Name of the GLSL attribute, for debugging purpose only
  95740. */
  95741. attributeName: string;
  95742. }
  95743. }
  95744. declare module BABYLON {
  95745. interface ThinEngine {
  95746. /**
  95747. * Update a video texture
  95748. * @param texture defines the texture to update
  95749. * @param video defines the video element to use
  95750. * @param invertY defines if data must be stored with Y axis inverted
  95751. */
  95752. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  95753. }
  95754. }
  95755. declare module BABYLON {
  95756. /**
  95757. * Settings for finer control over video usage
  95758. */
  95759. export interface VideoTextureSettings {
  95760. /**
  95761. * Applies `autoplay` to video, if specified
  95762. */
  95763. autoPlay?: boolean;
  95764. /**
  95765. * Applies `loop` to video, if specified
  95766. */
  95767. loop?: boolean;
  95768. /**
  95769. * Automatically updates internal texture from video at every frame in the render loop
  95770. */
  95771. autoUpdateTexture: boolean;
  95772. /**
  95773. * Image src displayed during the video loading or until the user interacts with the video.
  95774. */
  95775. poster?: string;
  95776. }
  95777. /**
  95778. * If you want to display a video in your scene, this is the special texture for that.
  95779. * This special texture works similar to other textures, with the exception of a few parameters.
  95780. * @see https://doc.babylonjs.com/how_to/video_texture
  95781. */
  95782. export class VideoTexture extends Texture {
  95783. /**
  95784. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  95785. */
  95786. readonly autoUpdateTexture: boolean;
  95787. /**
  95788. * The video instance used by the texture internally
  95789. */
  95790. readonly video: HTMLVideoElement;
  95791. private _onUserActionRequestedObservable;
  95792. /**
  95793. * Event triggerd when a dom action is required by the user to play the video.
  95794. * This happens due to recent changes in browser policies preventing video to auto start.
  95795. */
  95796. readonly onUserActionRequestedObservable: Observable<Texture>;
  95797. private _generateMipMaps;
  95798. private _engine;
  95799. private _stillImageCaptured;
  95800. private _displayingPosterTexture;
  95801. private _settings;
  95802. private _createInternalTextureOnEvent;
  95803. private _frameId;
  95804. /**
  95805. * Creates a video texture.
  95806. * If you want to display a video in your scene, this is the special texture for that.
  95807. * This special texture works similar to other textures, with the exception of a few parameters.
  95808. * @see https://doc.babylonjs.com/how_to/video_texture
  95809. * @param name optional name, will detect from video source, if not defined
  95810. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  95811. * @param scene is obviously the current scene.
  95812. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  95813. * @param invertY is false by default but can be used to invert video on Y axis
  95814. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  95815. * @param settings allows finer control over video usage
  95816. */
  95817. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  95818. private _getName;
  95819. private _getVideo;
  95820. private _createInternalTexture;
  95821. private reset;
  95822. /**
  95823. * @hidden Internal method to initiate `update`.
  95824. */
  95825. _rebuild(): void;
  95826. /**
  95827. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  95828. */
  95829. update(): void;
  95830. /**
  95831. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  95832. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  95833. */
  95834. updateTexture(isVisible: boolean): void;
  95835. protected _updateInternalTexture: () => void;
  95836. /**
  95837. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  95838. * @param url New url.
  95839. */
  95840. updateURL(url: string): void;
  95841. /**
  95842. * Dispose the texture and release its associated resources.
  95843. */
  95844. dispose(): void;
  95845. /**
  95846. * Creates a video texture straight from a stream.
  95847. * @param scene Define the scene the texture should be created in
  95848. * @param stream Define the stream the texture should be created from
  95849. * @returns The created video texture as a promise
  95850. */
  95851. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  95852. /**
  95853. * Creates a video texture straight from your WebCam video feed.
  95854. * @param scene Define the scene the texture should be created in
  95855. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95856. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95857. * @returns The created video texture as a promise
  95858. */
  95859. static CreateFromWebCamAsync(scene: Scene, constraints: {
  95860. minWidth: number;
  95861. maxWidth: number;
  95862. minHeight: number;
  95863. maxHeight: number;
  95864. deviceId: string;
  95865. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  95866. /**
  95867. * Creates a video texture straight from your WebCam video feed.
  95868. * @param scene Define the scene the texture should be created in
  95869. * @param onReady Define a callback to triggered once the texture will be ready
  95870. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  95871. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  95872. */
  95873. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  95874. minWidth: number;
  95875. maxWidth: number;
  95876. minHeight: number;
  95877. maxHeight: number;
  95878. deviceId: string;
  95879. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  95880. }
  95881. }
  95882. declare module BABYLON {
  95883. /**
  95884. * Defines the interface used by objects working like Scene
  95885. * @hidden
  95886. */
  95887. interface ISceneLike {
  95888. _addPendingData(data: any): void;
  95889. _removePendingData(data: any): void;
  95890. offlineProvider: IOfflineProvider;
  95891. }
  95892. /** Interface defining initialization parameters for Engine class */
  95893. export interface EngineOptions extends WebGLContextAttributes {
  95894. /**
  95895. * Defines if the engine should no exceed a specified device ratio
  95896. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  95897. */
  95898. limitDeviceRatio?: number;
  95899. /**
  95900. * Defines if webvr should be enabled automatically
  95901. * @see http://doc.babylonjs.com/how_to/webvr_camera
  95902. */
  95903. autoEnableWebVR?: boolean;
  95904. /**
  95905. * Defines if webgl2 should be turned off even if supported
  95906. * @see http://doc.babylonjs.com/features/webgl2
  95907. */
  95908. disableWebGL2Support?: boolean;
  95909. /**
  95910. * Defines if webaudio should be initialized as well
  95911. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  95912. */
  95913. audioEngine?: boolean;
  95914. /**
  95915. * Defines if animations should run using a deterministic lock step
  95916. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  95917. */
  95918. deterministicLockstep?: boolean;
  95919. /** Defines the maximum steps to use with deterministic lock step mode */
  95920. lockstepMaxSteps?: number;
  95921. /**
  95922. * Defines that engine should ignore context lost events
  95923. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  95924. */
  95925. doNotHandleContextLost?: boolean;
  95926. /**
  95927. * Defines that engine should ignore modifying touch action attribute and style
  95928. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  95929. */
  95930. doNotHandleTouchAction?: boolean;
  95931. /**
  95932. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  95933. */
  95934. useHighPrecisionFloats?: boolean;
  95935. }
  95936. /**
  95937. * The base engine class (root of all engines)
  95938. */
  95939. export class ThinEngine {
  95940. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  95941. static ExceptionList: ({
  95942. key: string;
  95943. capture: string;
  95944. captureConstraint: number;
  95945. targets: string[];
  95946. } | {
  95947. key: string;
  95948. capture: null;
  95949. captureConstraint: null;
  95950. targets: string[];
  95951. })[];
  95952. /** @hidden */
  95953. static _TextureLoaders: IInternalTextureLoader[];
  95954. /**
  95955. * Returns the current npm package of the sdk
  95956. */
  95957. static readonly NpmPackage: string;
  95958. /**
  95959. * Returns the current version of the framework
  95960. */
  95961. static readonly Version: string;
  95962. /**
  95963. * Returns a string describing the current engine
  95964. */
  95965. readonly description: string;
  95966. /**
  95967. * Gets or sets the epsilon value used by collision engine
  95968. */
  95969. static CollisionsEpsilon: number;
  95970. /**
  95971. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  95972. */
  95973. static ShadersRepository: string;
  95974. /** @hidden */
  95975. _shaderProcessor: IShaderProcessor;
  95976. /**
  95977. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  95978. */
  95979. forcePOTTextures: boolean;
  95980. /**
  95981. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  95982. */
  95983. isFullscreen: boolean;
  95984. /**
  95985. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  95986. */
  95987. cullBackFaces: boolean;
  95988. /**
  95989. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  95990. */
  95991. renderEvenInBackground: boolean;
  95992. /**
  95993. * Gets or sets a boolean indicating that cache can be kept between frames
  95994. */
  95995. preventCacheWipeBetweenFrames: boolean;
  95996. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  95997. validateShaderPrograms: boolean;
  95998. /**
  95999. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  96000. */
  96001. disableUniformBuffers: boolean;
  96002. /** @hidden */
  96003. _uniformBuffers: UniformBuffer[];
  96004. /**
  96005. * Gets a boolean indicating that the engine supports uniform buffers
  96006. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  96007. */
  96008. readonly supportsUniformBuffers: boolean;
  96009. /** @hidden */
  96010. _gl: WebGLRenderingContext;
  96011. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  96012. protected _windowIsBackground: boolean;
  96013. protected _webGLVersion: number;
  96014. protected _highPrecisionShadersAllowed: boolean;
  96015. /** @hidden */
  96016. readonly _shouldUseHighPrecisionShader: boolean;
  96017. /**
  96018. * Gets a boolean indicating that only power of 2 textures are supported
  96019. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  96020. */
  96021. readonly needPOTTextures: boolean;
  96022. /** @hidden */
  96023. _badOS: boolean;
  96024. /** @hidden */
  96025. _badDesktopOS: boolean;
  96026. private _hardwareScalingLevel;
  96027. /** @hidden */
  96028. _caps: EngineCapabilities;
  96029. private _isStencilEnable;
  96030. protected _colorWrite: boolean;
  96031. private _glVersion;
  96032. private _glRenderer;
  96033. private _glVendor;
  96034. /** @hidden */
  96035. _videoTextureSupported: boolean;
  96036. protected _renderingQueueLaunched: boolean;
  96037. protected _activeRenderLoops: (() => void)[];
  96038. /**
  96039. * Observable signaled when a context lost event is raised
  96040. */
  96041. onContextLostObservable: Observable<ThinEngine>;
  96042. /**
  96043. * Observable signaled when a context restored event is raised
  96044. */
  96045. onContextRestoredObservable: Observable<ThinEngine>;
  96046. private _onContextLost;
  96047. private _onContextRestored;
  96048. protected _contextWasLost: boolean;
  96049. /** @hidden */
  96050. _doNotHandleContextLost: boolean;
  96051. /**
  96052. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  96053. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  96054. */
  96055. doNotHandleContextLost: boolean;
  96056. /**
  96057. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  96058. */
  96059. disableVertexArrayObjects: boolean;
  96060. /** @hidden */
  96061. protected _depthCullingState: DepthCullingState;
  96062. /** @hidden */
  96063. protected _stencilState: StencilState;
  96064. /** @hidden */
  96065. protected _alphaState: AlphaState;
  96066. /** @hidden */
  96067. _internalTexturesCache: InternalTexture[];
  96068. /** @hidden */
  96069. protected _activeChannel: number;
  96070. private _currentTextureChannel;
  96071. /** @hidden */
  96072. protected _boundTexturesCache: {
  96073. [key: string]: Nullable<InternalTexture>;
  96074. };
  96075. /** @hidden */
  96076. protected _currentEffect: Nullable<Effect>;
  96077. /** @hidden */
  96078. protected _currentProgram: Nullable<WebGLProgram>;
  96079. private _compiledEffects;
  96080. private _vertexAttribArraysEnabled;
  96081. /** @hidden */
  96082. protected _cachedViewport: Nullable<IViewportLike>;
  96083. private _cachedVertexArrayObject;
  96084. /** @hidden */
  96085. protected _cachedVertexBuffers: any;
  96086. /** @hidden */
  96087. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  96088. /** @hidden */
  96089. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  96090. /** @hidden */
  96091. _currentRenderTarget: Nullable<InternalTexture>;
  96092. private _uintIndicesCurrentlySet;
  96093. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  96094. /** @hidden */
  96095. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  96096. private _currentBufferPointers;
  96097. private _currentInstanceLocations;
  96098. private _currentInstanceBuffers;
  96099. private _textureUnits;
  96100. /** @hidden */
  96101. _workingCanvas: Nullable<HTMLCanvasElement>;
  96102. /** @hidden */
  96103. _workingContext: Nullable<CanvasRenderingContext2D>;
  96104. /** @hidden */
  96105. _bindedRenderFunction: any;
  96106. private _vaoRecordInProgress;
  96107. private _mustWipeVertexAttributes;
  96108. private _emptyTexture;
  96109. private _emptyCubeTexture;
  96110. private _emptyTexture3D;
  96111. /** @hidden */
  96112. _frameHandler: number;
  96113. private _nextFreeTextureSlots;
  96114. private _maxSimultaneousTextures;
  96115. private _activeRequests;
  96116. protected _texturesSupported: string[];
  96117. /** @hidden */
  96118. _textureFormatInUse: Nullable<string>;
  96119. protected readonly _supportsHardwareTextureRescaling: boolean;
  96120. /**
  96121. * Gets the list of texture formats supported
  96122. */
  96123. readonly texturesSupported: Array<string>;
  96124. /**
  96125. * Gets the list of texture formats in use
  96126. */
  96127. readonly textureFormatInUse: Nullable<string>;
  96128. /**
  96129. * Gets the current viewport
  96130. */
  96131. readonly currentViewport: Nullable<IViewportLike>;
  96132. /**
  96133. * Gets the default empty texture
  96134. */
  96135. readonly emptyTexture: InternalTexture;
  96136. /**
  96137. * Gets the default empty 3D texture
  96138. */
  96139. readonly emptyTexture3D: InternalTexture;
  96140. /**
  96141. * Gets the default empty cube texture
  96142. */
  96143. readonly emptyCubeTexture: InternalTexture;
  96144. /**
  96145. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  96146. */
  96147. readonly premultipliedAlpha: boolean;
  96148. /**
  96149. * Creates a new engine
  96150. * @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
  96151. * @param antialias defines enable antialiasing (default: false)
  96152. * @param options defines further options to be sent to the getContext() function
  96153. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  96154. */
  96155. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  96156. private _rebuildInternalTextures;
  96157. private _rebuildEffects;
  96158. /**
  96159. * Gets a boolean indicating if all created effects are ready
  96160. * @returns true if all effects are ready
  96161. */
  96162. areAllEffectsReady(): boolean;
  96163. protected _rebuildBuffers(): void;
  96164. private _initGLContext;
  96165. /**
  96166. * Gets version of the current webGL context
  96167. */
  96168. readonly webGLVersion: number;
  96169. /**
  96170. * Gets a string idenfifying the name of the class
  96171. * @returns "Engine" string
  96172. */
  96173. getClassName(): string;
  96174. /**
  96175. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  96176. */
  96177. readonly isStencilEnable: boolean;
  96178. /** @hidden */
  96179. _prepareWorkingCanvas(): void;
  96180. /**
  96181. * Reset the texture cache to empty state
  96182. */
  96183. resetTextureCache(): void;
  96184. /**
  96185. * Gets an object containing information about the current webGL context
  96186. * @returns an object containing the vender, the renderer and the version of the current webGL context
  96187. */
  96188. getGlInfo(): {
  96189. vendor: string;
  96190. renderer: string;
  96191. version: string;
  96192. };
  96193. /**
  96194. * Defines the hardware scaling level.
  96195. * By default the hardware scaling level is computed from the window device ratio.
  96196. * 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.
  96197. * @param level defines the level to use
  96198. */
  96199. setHardwareScalingLevel(level: number): void;
  96200. /**
  96201. * Gets the current hardware scaling level.
  96202. * By default the hardware scaling level is computed from the window device ratio.
  96203. * 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.
  96204. * @returns a number indicating the current hardware scaling level
  96205. */
  96206. getHardwareScalingLevel(): number;
  96207. /**
  96208. * Gets the list of loaded textures
  96209. * @returns an array containing all loaded textures
  96210. */
  96211. getLoadedTexturesCache(): InternalTexture[];
  96212. /**
  96213. * Gets the object containing all engine capabilities
  96214. * @returns the EngineCapabilities object
  96215. */
  96216. getCaps(): EngineCapabilities;
  96217. /**
  96218. * stop executing a render loop function and remove it from the execution array
  96219. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  96220. */
  96221. stopRenderLoop(renderFunction?: () => void): void;
  96222. /** @hidden */
  96223. _renderLoop(): void;
  96224. /**
  96225. * Gets the HTML canvas attached with the current webGL context
  96226. * @returns a HTML canvas
  96227. */
  96228. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  96229. /**
  96230. * Gets host window
  96231. * @returns the host window object
  96232. */
  96233. getHostWindow(): Window;
  96234. /**
  96235. * Gets the current render width
  96236. * @param useScreen defines if screen size must be used (or the current render target if any)
  96237. * @returns a number defining the current render width
  96238. */
  96239. getRenderWidth(useScreen?: boolean): number;
  96240. /**
  96241. * Gets the current render height
  96242. * @param useScreen defines if screen size must be used (or the current render target if any)
  96243. * @returns a number defining the current render height
  96244. */
  96245. getRenderHeight(useScreen?: boolean): number;
  96246. /**
  96247. * Can be used to override the current requestAnimationFrame requester.
  96248. * @hidden
  96249. */
  96250. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  96251. /**
  96252. * Register and execute a render loop. The engine can have more than one render function
  96253. * @param renderFunction defines the function to continuously execute
  96254. */
  96255. runRenderLoop(renderFunction: () => void): void;
  96256. /**
  96257. * Clear the current render buffer or the current render target (if any is set up)
  96258. * @param color defines the color to use
  96259. * @param backBuffer defines if the back buffer must be cleared
  96260. * @param depth defines if the depth buffer must be cleared
  96261. * @param stencil defines if the stencil buffer must be cleared
  96262. */
  96263. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  96264. private _viewportCached;
  96265. /** @hidden */
  96266. _viewport(x: number, y: number, width: number, height: number): void;
  96267. /**
  96268. * Set the WebGL's viewport
  96269. * @param viewport defines the viewport element to be used
  96270. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  96271. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  96272. */
  96273. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  96274. /**
  96275. * Begin a new frame
  96276. */
  96277. beginFrame(): void;
  96278. /**
  96279. * Enf the current frame
  96280. */
  96281. endFrame(): void;
  96282. /**
  96283. * Resize the view according to the canvas' size
  96284. */
  96285. resize(): void;
  96286. /**
  96287. * Force a specific size of the canvas
  96288. * @param width defines the new canvas' width
  96289. * @param height defines the new canvas' height
  96290. */
  96291. setSize(width: number, height: number): void;
  96292. /**
  96293. * Binds the frame buffer to the specified texture.
  96294. * @param texture The texture to render to or null for the default canvas
  96295. * @param faceIndex The face of the texture to render to in case of cube texture
  96296. * @param requiredWidth The width of the target to render to
  96297. * @param requiredHeight The height of the target to render to
  96298. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  96299. * @param depthStencilTexture The depth stencil texture to use to render
  96300. * @param lodLevel defines le lod level to bind to the frame buffer
  96301. */
  96302. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  96303. /** @hidden */
  96304. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  96305. /**
  96306. * Unbind the current render target texture from the webGL context
  96307. * @param texture defines the render target texture to unbind
  96308. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  96309. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  96310. */
  96311. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  96312. /**
  96313. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  96314. */
  96315. flushFramebuffer(): void;
  96316. /**
  96317. * Unbind the current render target and bind the default framebuffer
  96318. */
  96319. restoreDefaultFramebuffer(): void;
  96320. private _resetVertexBufferBinding;
  96321. /**
  96322. * Creates a vertex buffer
  96323. * @param data the data for the vertex buffer
  96324. * @returns the new WebGL static buffer
  96325. */
  96326. createVertexBuffer(data: DataArray): DataBuffer;
  96327. private _createVertexBuffer;
  96328. /**
  96329. * Creates a dynamic vertex buffer
  96330. * @param data the data for the dynamic vertex buffer
  96331. * @returns the new WebGL dynamic buffer
  96332. */
  96333. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  96334. /**
  96335. * Updates a dynamic vertex buffer.
  96336. * @param vertexBuffer the vertex buffer to update
  96337. * @param data the data used to update the vertex buffer
  96338. * @param byteOffset the byte offset of the data
  96339. * @param byteLength the byte length of the data
  96340. */
  96341. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  96342. protected _resetIndexBufferBinding(): void;
  96343. /**
  96344. * Creates a new index buffer
  96345. * @param indices defines the content of the index buffer
  96346. * @param updatable defines if the index buffer must be updatable
  96347. * @returns a new webGL buffer
  96348. */
  96349. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  96350. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  96351. /**
  96352. * Bind a webGL buffer to the webGL context
  96353. * @param buffer defines the buffer to bind
  96354. */
  96355. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  96356. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  96357. private bindBuffer;
  96358. /**
  96359. * update the bound buffer with the given data
  96360. * @param data defines the data to update
  96361. */
  96362. updateArrayBuffer(data: Float32Array): void;
  96363. private _vertexAttribPointer;
  96364. private _bindIndexBufferWithCache;
  96365. private _bindVertexBuffersAttributes;
  96366. /**
  96367. * Records a vertex array object
  96368. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96369. * @param vertexBuffers defines the list of vertex buffers to store
  96370. * @param indexBuffer defines the index buffer to store
  96371. * @param effect defines the effect to store
  96372. * @returns the new vertex array object
  96373. */
  96374. recordVertexArrayObject(vertexBuffers: {
  96375. [key: string]: VertexBuffer;
  96376. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  96377. /**
  96378. * Bind a specific vertex array object
  96379. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  96380. * @param vertexArrayObject defines the vertex array object to bind
  96381. * @param indexBuffer defines the index buffer to bind
  96382. */
  96383. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  96384. /**
  96385. * Bind webGl buffers directly to the webGL context
  96386. * @param vertexBuffer defines the vertex buffer to bind
  96387. * @param indexBuffer defines the index buffer to bind
  96388. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  96389. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  96390. * @param effect defines the effect associated with the vertex buffer
  96391. */
  96392. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  96393. private _unbindVertexArrayObject;
  96394. /**
  96395. * Bind a list of vertex buffers to the webGL context
  96396. * @param vertexBuffers defines the list of vertex buffers to bind
  96397. * @param indexBuffer defines the index buffer to bind
  96398. * @param effect defines the effect associated with the vertex buffers
  96399. */
  96400. bindBuffers(vertexBuffers: {
  96401. [key: string]: Nullable<VertexBuffer>;
  96402. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  96403. /**
  96404. * Unbind all instance attributes
  96405. */
  96406. unbindInstanceAttributes(): void;
  96407. /**
  96408. * Release and free the memory of a vertex array object
  96409. * @param vao defines the vertex array object to delete
  96410. */
  96411. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  96412. /** @hidden */
  96413. _releaseBuffer(buffer: DataBuffer): boolean;
  96414. protected _deleteBuffer(buffer: DataBuffer): void;
  96415. /**
  96416. * Creates a webGL buffer to use with instanciation
  96417. * @param capacity defines the size of the buffer
  96418. * @returns the webGL buffer
  96419. */
  96420. createInstancesBuffer(capacity: number): DataBuffer;
  96421. /**
  96422. * Delete a webGL buffer used with instanciation
  96423. * @param buffer defines the webGL buffer to delete
  96424. */
  96425. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  96426. /**
  96427. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  96428. * @param instancesBuffer defines the webGL buffer to update and bind
  96429. * @param data defines the data to store in the buffer
  96430. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  96431. */
  96432. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  96433. /**
  96434. * Apply all cached states (depth, culling, stencil and alpha)
  96435. */
  96436. applyStates(): void;
  96437. /**
  96438. * Send a draw order
  96439. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96440. * @param indexStart defines the starting index
  96441. * @param indexCount defines the number of index to draw
  96442. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96443. */
  96444. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  96445. /**
  96446. * Draw a list of points
  96447. * @param verticesStart defines the index of first vertex to draw
  96448. * @param verticesCount defines the count of vertices to draw
  96449. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96450. */
  96451. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96452. /**
  96453. * Draw a list of unindexed primitives
  96454. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  96455. * @param verticesStart defines the index of first vertex to draw
  96456. * @param verticesCount defines the count of vertices to draw
  96457. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96458. */
  96459. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96460. /**
  96461. * Draw a list of indexed primitives
  96462. * @param fillMode defines the primitive to use
  96463. * @param indexStart defines the starting index
  96464. * @param indexCount defines the number of index to draw
  96465. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96466. */
  96467. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  96468. /**
  96469. * Draw a list of unindexed primitives
  96470. * @param fillMode defines the primitive to use
  96471. * @param verticesStart defines the index of first vertex to draw
  96472. * @param verticesCount defines the count of vertices to draw
  96473. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  96474. */
  96475. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  96476. private _drawMode;
  96477. /** @hidden */
  96478. protected _reportDrawCall(): void;
  96479. /** @hidden */
  96480. _releaseEffect(effect: Effect): void;
  96481. /** @hidden */
  96482. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  96483. /**
  96484. * Create a new effect (used to store vertex/fragment shaders)
  96485. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  96486. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  96487. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  96488. * @param samplers defines an array of string used to represent textures
  96489. * @param defines defines the string containing the defines to use to compile the shaders
  96490. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  96491. * @param onCompiled defines a function to call when the effect creation is successful
  96492. * @param onError defines a function to call when the effect creation has failed
  96493. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  96494. * @returns the new Effect
  96495. */
  96496. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | ThinEngine, samplers?: string[], defines?: string, fallbacks?: IEffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  96497. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  96498. private _compileShader;
  96499. private _compileRawShader;
  96500. /**
  96501. * Directly creates a webGL program
  96502. * @param pipelineContext defines the pipeline context to attach to
  96503. * @param vertexCode defines the vertex shader code to use
  96504. * @param fragmentCode defines the fragment shader code to use
  96505. * @param context defines the webGL context to use (if not set, the current one will be used)
  96506. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96507. * @returns the new webGL program
  96508. */
  96509. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96510. /**
  96511. * Creates a webGL program
  96512. * @param pipelineContext defines the pipeline context to attach to
  96513. * @param vertexCode defines the vertex shader code to use
  96514. * @param fragmentCode defines the fragment shader code to use
  96515. * @param defines defines the string containing the defines to use to compile the shaders
  96516. * @param context defines the webGL context to use (if not set, the current one will be used)
  96517. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  96518. * @returns the new webGL program
  96519. */
  96520. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96521. /**
  96522. * Creates a new pipeline context
  96523. * @returns the new pipeline
  96524. */
  96525. createPipelineContext(): IPipelineContext;
  96526. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  96527. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  96528. /** @hidden */
  96529. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  96530. /** @hidden */
  96531. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  96532. /** @hidden */
  96533. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  96534. /**
  96535. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  96536. * @param pipelineContext defines the pipeline context to use
  96537. * @param uniformsNames defines the list of uniform names
  96538. * @returns an array of webGL uniform locations
  96539. */
  96540. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  96541. /**
  96542. * Gets the lsit of active attributes for a given webGL program
  96543. * @param pipelineContext defines the pipeline context to use
  96544. * @param attributesNames defines the list of attribute names to get
  96545. * @returns an array of indices indicating the offset of each attribute
  96546. */
  96547. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  96548. /**
  96549. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  96550. * @param effect defines the effect to activate
  96551. */
  96552. enableEffect(effect: Nullable<Effect>): void;
  96553. /**
  96554. * Set the value of an uniform to an array of int32
  96555. * @param uniform defines the webGL uniform location where to store the value
  96556. * @param array defines the array of int32 to store
  96557. */
  96558. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96559. /**
  96560. * Set the value of an uniform to an array of int32 (stored as vec2)
  96561. * @param uniform defines the webGL uniform location where to store the value
  96562. * @param array defines the array of int32 to store
  96563. */
  96564. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96565. /**
  96566. * Set the value of an uniform to an array of int32 (stored as vec3)
  96567. * @param uniform defines the webGL uniform location where to store the value
  96568. * @param array defines the array of int32 to store
  96569. */
  96570. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96571. /**
  96572. * Set the value of an uniform to an array of int32 (stored as vec4)
  96573. * @param uniform defines the webGL uniform location where to store the value
  96574. * @param array defines the array of int32 to store
  96575. */
  96576. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  96577. /**
  96578. * Set the value of an uniform to an array of float32
  96579. * @param uniform defines the webGL uniform location where to store the value
  96580. * @param array defines the array of float32 to store
  96581. */
  96582. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96583. /**
  96584. * Set the value of an uniform to an array of float32 (stored as vec2)
  96585. * @param uniform defines the webGL uniform location where to store the value
  96586. * @param array defines the array of float32 to store
  96587. */
  96588. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96589. /**
  96590. * Set the value of an uniform to an array of float32 (stored as vec3)
  96591. * @param uniform defines the webGL uniform location where to store the value
  96592. * @param array defines the array of float32 to store
  96593. */
  96594. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96595. /**
  96596. * Set the value of an uniform to an array of float32 (stored as vec4)
  96597. * @param uniform defines the webGL uniform location where to store the value
  96598. * @param array defines the array of float32 to store
  96599. */
  96600. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  96601. /**
  96602. * Set the value of an uniform to an array of number
  96603. * @param uniform defines the webGL uniform location where to store the value
  96604. * @param array defines the array of number to store
  96605. */
  96606. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96607. /**
  96608. * Set the value of an uniform to an array of number (stored as vec2)
  96609. * @param uniform defines the webGL uniform location where to store the value
  96610. * @param array defines the array of number to store
  96611. */
  96612. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96613. /**
  96614. * Set the value of an uniform to an array of number (stored as vec3)
  96615. * @param uniform defines the webGL uniform location where to store the value
  96616. * @param array defines the array of number to store
  96617. */
  96618. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96619. /**
  96620. * Set the value of an uniform to an array of number (stored as vec4)
  96621. * @param uniform defines the webGL uniform location where to store the value
  96622. * @param array defines the array of number to store
  96623. */
  96624. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  96625. /**
  96626. * Set the value of an uniform to an array of float32 (stored as matrices)
  96627. * @param uniform defines the webGL uniform location where to store the value
  96628. * @param matrices defines the array of float32 to store
  96629. */
  96630. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  96631. /**
  96632. * Set the value of an uniform to a matrix (3x3)
  96633. * @param uniform defines the webGL uniform location where to store the value
  96634. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  96635. */
  96636. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96637. /**
  96638. * Set the value of an uniform to a matrix (2x2)
  96639. * @param uniform defines the webGL uniform location where to store the value
  96640. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  96641. */
  96642. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  96643. /**
  96644. * Set the value of an uniform to a number (int)
  96645. * @param uniform defines the webGL uniform location where to store the value
  96646. * @param value defines the int number to store
  96647. */
  96648. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96649. /**
  96650. * Set the value of an uniform to a number (float)
  96651. * @param uniform defines the webGL uniform location where to store the value
  96652. * @param value defines the float number to store
  96653. */
  96654. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  96655. /**
  96656. * Set the value of an uniform to a vec2
  96657. * @param uniform defines the webGL uniform location where to store the value
  96658. * @param x defines the 1st component of the value
  96659. * @param y defines the 2nd component of the value
  96660. */
  96661. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  96662. /**
  96663. * Set the value of an uniform to a vec3
  96664. * @param uniform defines the webGL uniform location where to store the value
  96665. * @param x defines the 1st component of the value
  96666. * @param y defines the 2nd component of the value
  96667. * @param z defines the 3rd component of the value
  96668. */
  96669. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  96670. /**
  96671. * Set the value of an uniform to a boolean
  96672. * @param uniform defines the webGL uniform location where to store the value
  96673. * @param bool defines the boolean to store
  96674. */
  96675. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  96676. /**
  96677. * Set the value of an uniform to a vec4
  96678. * @param uniform defines the webGL uniform location where to store the value
  96679. * @param x defines the 1st component of the value
  96680. * @param y defines the 2nd component of the value
  96681. * @param z defines the 3rd component of the value
  96682. * @param w defines the 4th component of the value
  96683. */
  96684. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  96685. /**
  96686. * Sets a Color4 on a uniform variable
  96687. * @param uniform defines the uniform location
  96688. * @param color4 defines the value to be set
  96689. */
  96690. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: IColor4Like): void;
  96691. /**
  96692. * Gets the depth culling state manager
  96693. */
  96694. readonly depthCullingState: DepthCullingState;
  96695. /**
  96696. * Gets the alpha state manager
  96697. */
  96698. readonly alphaState: AlphaState;
  96699. /**
  96700. * Gets the stencil state manager
  96701. */
  96702. readonly stencilState: StencilState;
  96703. /**
  96704. * Clears the list of texture accessible through engine.
  96705. * This can help preventing texture load conflict due to name collision.
  96706. */
  96707. clearInternalTexturesCache(): void;
  96708. /**
  96709. * Force the entire cache to be cleared
  96710. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  96711. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  96712. */
  96713. wipeCaches(bruteForce?: boolean): void;
  96714. /** @hidden */
  96715. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  96716. min: number;
  96717. mag: number;
  96718. };
  96719. /** @hidden */
  96720. _createTexture(): WebGLTexture;
  96721. /**
  96722. * Usually called from Texture.ts.
  96723. * Passed information to create a WebGLTexture
  96724. * @param urlArg defines a value which contains one of the following:
  96725. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  96726. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  96727. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  96728. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  96729. * @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)
  96730. * @param scene needed for loading to the correct scene
  96731. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  96732. * @param onLoad optional callback to be called upon successful completion
  96733. * @param onError optional callback to be called upon failure
  96734. * @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
  96735. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  96736. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  96737. * @param forcedExtension defines the extension to use to pick the right loader
  96738. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  96739. * @returns a InternalTexture for assignment back into BABYLON.Texture
  96740. */
  96741. createTexture(urlArg: Nullable<string>, noMipmap: boolean, invertY: boolean, scene: Nullable<ISceneLike>, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<(message: string, exception: any) => void>, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, fallback?: Nullable<InternalTexture>, format?: Nullable<number>, forcedExtension?: Nullable<string>, excludeLoaders?: Array<IInternalTextureLoader>): InternalTexture;
  96742. /**
  96743. * @hidden
  96744. */
  96745. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  96746. /**
  96747. * Creates a raw texture
  96748. * @param data defines the data to store in the texture
  96749. * @param width defines the width of the texture
  96750. * @param height defines the height of the texture
  96751. * @param format defines the format of the data
  96752. * @param generateMipMaps defines if the engine should generate the mip levels
  96753. * @param invertY defines if data must be stored with Y axis inverted
  96754. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  96755. * @param compression defines the compression used (null by default)
  96756. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  96757. * @returns the raw texture inside an InternalTexture
  96758. */
  96759. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  96760. /**
  96761. * Creates a new raw cube texture
  96762. * @param data defines the array of data to use to create each face
  96763. * @param size defines the size of the textures
  96764. * @param format defines the format of the data
  96765. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  96766. * @param generateMipMaps defines if the engine should generate the mip levels
  96767. * @param invertY defines if data must be stored with Y axis inverted
  96768. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96769. * @param compression defines the compression used (null by default)
  96770. * @returns the cube texture as an InternalTexture
  96771. */
  96772. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  96773. /**
  96774. * Creates a new raw 3D texture
  96775. * @param data defines the data used to create the texture
  96776. * @param width defines the width of the texture
  96777. * @param height defines the height of the texture
  96778. * @param depth defines the depth of the texture
  96779. * @param format defines the format of the texture
  96780. * @param generateMipMaps defines if the engine must generate mip levels
  96781. * @param invertY defines if data must be stored with Y axis inverted
  96782. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  96783. * @param compression defines the compressed used (can be null)
  96784. * @param textureType defines the compressed used (can be null)
  96785. * @returns a new raw 3D texture (stored in an InternalTexture)
  96786. */
  96787. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  96788. private _unpackFlipYCached;
  96789. /**
  96790. * In case you are sharing the context with other applications, it might
  96791. * be interested to not cache the unpack flip y state to ensure a consistent
  96792. * value would be set.
  96793. */
  96794. enableUnpackFlipYCached: boolean;
  96795. /** @hidden */
  96796. _unpackFlipY(value: boolean): void;
  96797. /** @hidden */
  96798. _getUnpackAlignement(): number;
  96799. /**
  96800. * Update the sampling mode of a given texture
  96801. * @param samplingMode defines the required sampling mode
  96802. * @param texture defines the texture to update
  96803. */
  96804. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  96805. /**
  96806. * Updates a depth texture Comparison Mode and Function.
  96807. * If the comparison Function is equal to 0, the mode will be set to none.
  96808. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  96809. * @param texture The texture to set the comparison function for
  96810. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  96811. */
  96812. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  96813. /** @hidden */
  96814. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  96815. width: number;
  96816. height: number;
  96817. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  96818. /**
  96819. * Creates a depth stencil texture.
  96820. * This is only available in WebGL 2 or with the depth texture extension available.
  96821. * @param size The size of face edge in the texture.
  96822. * @param options The options defining the texture.
  96823. * @returns The texture
  96824. */
  96825. createDepthStencilTexture(size: number | {
  96826. width: number;
  96827. height: number;
  96828. }, options: DepthTextureCreationOptions): InternalTexture;
  96829. /**
  96830. * Creates a depth stencil texture.
  96831. * This is only available in WebGL 2 or with the depth texture extension available.
  96832. * @param size The size of face edge in the texture.
  96833. * @param options The options defining the texture.
  96834. * @returns The texture
  96835. */
  96836. private _createDepthStencilTexture;
  96837. /** @hidden */
  96838. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96839. /** @hidden */
  96840. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  96841. /** @hidden */
  96842. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  96843. /** @hidden */
  96844. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  96845. /**
  96846. * @hidden
  96847. */
  96848. _setCubeMapTextureParams(loadMipmap: boolean): void;
  96849. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  96850. private _prepareWebGLTexture;
  96851. /** @hidden */
  96852. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  96853. /** @hidden */
  96854. _releaseFramebufferObjects(texture: InternalTexture): void;
  96855. /** @hidden */
  96856. _releaseTexture(texture: InternalTexture): void;
  96857. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  96858. protected _setProgram(program: WebGLProgram): void;
  96859. protected _boundUniforms: {
  96860. [key: number]: WebGLUniformLocation;
  96861. };
  96862. /**
  96863. * Binds an effect to the webGL context
  96864. * @param effect defines the effect to bind
  96865. */
  96866. bindSamplers(effect: Effect): void;
  96867. private _activateCurrentTexture;
  96868. /** @hidden */
  96869. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  96870. /** @hidden */
  96871. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  96872. /**
  96873. * Unbind all textures from the webGL context
  96874. */
  96875. unbindAllTextures(): void;
  96876. /**
  96877. * Sets a texture to the according uniform.
  96878. * @param channel The texture channel
  96879. * @param uniform The uniform to set
  96880. * @param texture The texture to apply
  96881. */
  96882. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  96883. private _bindSamplerUniformToChannel;
  96884. private _getTextureWrapMode;
  96885. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  96886. /**
  96887. * Sets an array of texture to the webGL context
  96888. * @param channel defines the channel where the texture array must be set
  96889. * @param uniform defines the associated uniform location
  96890. * @param textures defines the array of textures to bind
  96891. */
  96892. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  96893. /** @hidden */
  96894. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  96895. private _setTextureParameterFloat;
  96896. private _setTextureParameterInteger;
  96897. /**
  96898. * Unbind all vertex attributes from the webGL context
  96899. */
  96900. unbindAllAttributes(): void;
  96901. /**
  96902. * 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
  96903. */
  96904. releaseEffects(): void;
  96905. /**
  96906. * Dispose and release all associated resources
  96907. */
  96908. dispose(): void;
  96909. /**
  96910. * Attach a new callback raised when context lost event is fired
  96911. * @param callback defines the callback to call
  96912. */
  96913. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96914. /**
  96915. * Attach a new callback raised when context restored event is fired
  96916. * @param callback defines the callback to call
  96917. */
  96918. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  96919. /**
  96920. * Get the current error code of the webGL context
  96921. * @returns the error code
  96922. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  96923. */
  96924. getError(): number;
  96925. private _canRenderToFloatFramebuffer;
  96926. private _canRenderToHalfFloatFramebuffer;
  96927. private _canRenderToFramebuffer;
  96928. /** @hidden */
  96929. _getWebGLTextureType(type: number): number;
  96930. /** @hidden */
  96931. _getInternalFormat(format: number): number;
  96932. /** @hidden */
  96933. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  96934. /** @hidden */
  96935. _getRGBAMultiSampleBufferFormat(type: number): number;
  96936. /** @hidden */
  96937. _loadFile(url: string, onSuccess: (data: string | ArrayBuffer, responseURL?: string) => void, onProgress?: (data: any) => void, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean, onError?: (request?: IWebRequest, exception?: any) => void): IFileRequest;
  96938. /**
  96939. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  96940. * @returns true if the engine can be created
  96941. * @ignorenaming
  96942. */
  96943. static isSupported(): boolean;
  96944. /**
  96945. * Find the next highest power of two.
  96946. * @param x Number to start search from.
  96947. * @return Next highest power of two.
  96948. */
  96949. static CeilingPOT(x: number): number;
  96950. /**
  96951. * Find the next lowest power of two.
  96952. * @param x Number to start search from.
  96953. * @return Next lowest power of two.
  96954. */
  96955. static FloorPOT(x: number): number;
  96956. /**
  96957. * Find the nearest power of two.
  96958. * @param x Number to start search from.
  96959. * @return Next nearest power of two.
  96960. */
  96961. static NearestPOT(x: number): number;
  96962. /**
  96963. * Get the closest exponent of two
  96964. * @param value defines the value to approximate
  96965. * @param max defines the maximum value to return
  96966. * @param mode defines how to define the closest value
  96967. * @returns closest exponent of two of the given value
  96968. */
  96969. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  96970. /**
  96971. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  96972. * @param func - the function to be called
  96973. * @param requester - the object that will request the next frame. Falls back to window.
  96974. * @returns frame number
  96975. */
  96976. static QueueNewFrame(func: () => void, requester?: any): number;
  96977. }
  96978. }
  96979. declare module BABYLON {
  96980. /**
  96981. * Defines the source of the internal texture
  96982. */
  96983. export enum InternalTextureSource {
  96984. /**
  96985. * The source of the texture data is unknown
  96986. */
  96987. Unknown = 0,
  96988. /**
  96989. * Texture data comes from an URL
  96990. */
  96991. Url = 1,
  96992. /**
  96993. * Texture data is only used for temporary storage
  96994. */
  96995. Temp = 2,
  96996. /**
  96997. * Texture data comes from raw data (ArrayBuffer)
  96998. */
  96999. Raw = 3,
  97000. /**
  97001. * Texture content is dynamic (video or dynamic texture)
  97002. */
  97003. Dynamic = 4,
  97004. /**
  97005. * Texture content is generated by rendering to it
  97006. */
  97007. RenderTarget = 5,
  97008. /**
  97009. * Texture content is part of a multi render target process
  97010. */
  97011. MultiRenderTarget = 6,
  97012. /**
  97013. * Texture data comes from a cube data file
  97014. */
  97015. Cube = 7,
  97016. /**
  97017. * Texture data comes from a raw cube data
  97018. */
  97019. CubeRaw = 8,
  97020. /**
  97021. * Texture data come from a prefiltered cube data file
  97022. */
  97023. CubePrefiltered = 9,
  97024. /**
  97025. * Texture content is raw 3D data
  97026. */
  97027. Raw3D = 10,
  97028. /**
  97029. * Texture content is a depth texture
  97030. */
  97031. Depth = 11,
  97032. /**
  97033. * Texture data comes from a raw cube data encoded with RGBD
  97034. */
  97035. CubeRawRGBD = 12
  97036. }
  97037. /**
  97038. * Class used to store data associated with WebGL texture data for the engine
  97039. * This class should not be used directly
  97040. */
  97041. export class InternalTexture {
  97042. /** @hidden */
  97043. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  97044. /**
  97045. * Defines if the texture is ready
  97046. */
  97047. isReady: boolean;
  97048. /**
  97049. * Defines if the texture is a cube texture
  97050. */
  97051. isCube: boolean;
  97052. /**
  97053. * Defines if the texture contains 3D data
  97054. */
  97055. is3D: boolean;
  97056. /**
  97057. * Defines if the texture contains multiview data
  97058. */
  97059. isMultiview: boolean;
  97060. /**
  97061. * Gets the URL used to load this texture
  97062. */
  97063. url: string;
  97064. /**
  97065. * Gets the sampling mode of the texture
  97066. */
  97067. samplingMode: number;
  97068. /**
  97069. * Gets a boolean indicating if the texture needs mipmaps generation
  97070. */
  97071. generateMipMaps: boolean;
  97072. /**
  97073. * Gets the number of samples used by the texture (WebGL2+ only)
  97074. */
  97075. samples: number;
  97076. /**
  97077. * Gets the type of the texture (int, float...)
  97078. */
  97079. type: number;
  97080. /**
  97081. * Gets the format of the texture (RGB, RGBA...)
  97082. */
  97083. format: number;
  97084. /**
  97085. * Observable called when the texture is loaded
  97086. */
  97087. onLoadedObservable: Observable<InternalTexture>;
  97088. /**
  97089. * Gets the width of the texture
  97090. */
  97091. width: number;
  97092. /**
  97093. * Gets the height of the texture
  97094. */
  97095. height: number;
  97096. /**
  97097. * Gets the depth of the texture
  97098. */
  97099. depth: number;
  97100. /**
  97101. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  97102. */
  97103. baseWidth: number;
  97104. /**
  97105. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  97106. */
  97107. baseHeight: number;
  97108. /**
  97109. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  97110. */
  97111. baseDepth: number;
  97112. /**
  97113. * Gets a boolean indicating if the texture is inverted on Y axis
  97114. */
  97115. invertY: boolean;
  97116. /** @hidden */
  97117. _invertVScale: boolean;
  97118. /** @hidden */
  97119. _associatedChannel: number;
  97120. /** @hidden */
  97121. _source: InternalTextureSource;
  97122. /** @hidden */
  97123. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>;
  97124. /** @hidden */
  97125. _bufferView: Nullable<ArrayBufferView>;
  97126. /** @hidden */
  97127. _bufferViewArray: Nullable<ArrayBufferView[]>;
  97128. /** @hidden */
  97129. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  97130. /** @hidden */
  97131. _size: number;
  97132. /** @hidden */
  97133. _extension: string;
  97134. /** @hidden */
  97135. _files: Nullable<string[]>;
  97136. /** @hidden */
  97137. _workingCanvas: Nullable<HTMLCanvasElement>;
  97138. /** @hidden */
  97139. _workingContext: Nullable<CanvasRenderingContext2D>;
  97140. /** @hidden */
  97141. _framebuffer: Nullable<WebGLFramebuffer>;
  97142. /** @hidden */
  97143. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  97144. /** @hidden */
  97145. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  97146. /** @hidden */
  97147. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  97148. /** @hidden */
  97149. _attachments: Nullable<number[]>;
  97150. /** @hidden */
  97151. _cachedCoordinatesMode: Nullable<number>;
  97152. /** @hidden */
  97153. _cachedWrapU: Nullable<number>;
  97154. /** @hidden */
  97155. _cachedWrapV: Nullable<number>;
  97156. /** @hidden */
  97157. _cachedWrapR: Nullable<number>;
  97158. /** @hidden */
  97159. _cachedAnisotropicFilteringLevel: Nullable<number>;
  97160. /** @hidden */
  97161. _isDisabled: boolean;
  97162. /** @hidden */
  97163. _compression: Nullable<string>;
  97164. /** @hidden */
  97165. _generateStencilBuffer: boolean;
  97166. /** @hidden */
  97167. _generateDepthBuffer: boolean;
  97168. /** @hidden */
  97169. _comparisonFunction: number;
  97170. /** @hidden */
  97171. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  97172. /** @hidden */
  97173. _lodGenerationScale: number;
  97174. /** @hidden */
  97175. _lodGenerationOffset: number;
  97176. /** @hidden */
  97177. _colorTextureArray: Nullable<WebGLTexture>;
  97178. /** @hidden */
  97179. _depthStencilTextureArray: Nullable<WebGLTexture>;
  97180. /** @hidden */
  97181. _lodTextureHigh: Nullable<BaseTexture>;
  97182. /** @hidden */
  97183. _lodTextureMid: Nullable<BaseTexture>;
  97184. /** @hidden */
  97185. _lodTextureLow: Nullable<BaseTexture>;
  97186. /** @hidden */
  97187. _isRGBD: boolean;
  97188. /** @hidden */
  97189. _linearSpecularLOD: boolean;
  97190. /** @hidden */
  97191. _irradianceTexture: Nullable<BaseTexture>;
  97192. /** @hidden */
  97193. _webGLTexture: Nullable<WebGLTexture>;
  97194. /** @hidden */
  97195. _references: number;
  97196. private _engine;
  97197. /**
  97198. * Gets the Engine the texture belongs to.
  97199. * @returns The babylon engine
  97200. */
  97201. getEngine(): ThinEngine;
  97202. /**
  97203. * Gets the data source type of the texture
  97204. */
  97205. readonly source: InternalTextureSource;
  97206. /**
  97207. * Creates a new InternalTexture
  97208. * @param engine defines the engine to use
  97209. * @param source defines the type of data that will be used
  97210. * @param delayAllocation if the texture allocation should be delayed (default: false)
  97211. */
  97212. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  97213. /**
  97214. * Increments the number of references (ie. the number of Texture that point to it)
  97215. */
  97216. incrementReferences(): void;
  97217. /**
  97218. * Change the size of the texture (not the size of the content)
  97219. * @param width defines the new width
  97220. * @param height defines the new height
  97221. * @param depth defines the new depth (1 by default)
  97222. */
  97223. updateSize(width: int, height: int, depth?: int): void;
  97224. /** @hidden */
  97225. _rebuild(): void;
  97226. /** @hidden */
  97227. _swapAndDie(target: InternalTexture): void;
  97228. /**
  97229. * Dispose the current allocated resources
  97230. */
  97231. dispose(): void;
  97232. }
  97233. }
  97234. declare module BABYLON {
  97235. /**
  97236. * Class used to work with sound analyzer using fast fourier transform (FFT)
  97237. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97238. */
  97239. export class Analyser {
  97240. /**
  97241. * Gets or sets the smoothing
  97242. * @ignorenaming
  97243. */
  97244. SMOOTHING: number;
  97245. /**
  97246. * Gets or sets the FFT table size
  97247. * @ignorenaming
  97248. */
  97249. FFT_SIZE: number;
  97250. /**
  97251. * Gets or sets the bar graph amplitude
  97252. * @ignorenaming
  97253. */
  97254. BARGRAPHAMPLITUDE: number;
  97255. /**
  97256. * Gets or sets the position of the debug canvas
  97257. * @ignorenaming
  97258. */
  97259. DEBUGCANVASPOS: {
  97260. x: number;
  97261. y: number;
  97262. };
  97263. /**
  97264. * Gets or sets the debug canvas size
  97265. * @ignorenaming
  97266. */
  97267. DEBUGCANVASSIZE: {
  97268. width: number;
  97269. height: number;
  97270. };
  97271. private _byteFreqs;
  97272. private _byteTime;
  97273. private _floatFreqs;
  97274. private _webAudioAnalyser;
  97275. private _debugCanvas;
  97276. private _debugCanvasContext;
  97277. private _scene;
  97278. private _registerFunc;
  97279. private _audioEngine;
  97280. /**
  97281. * Creates a new analyser
  97282. * @param scene defines hosting scene
  97283. */
  97284. constructor(scene: Scene);
  97285. /**
  97286. * Get the number of data values you will have to play with for the visualization
  97287. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  97288. * @returns a number
  97289. */
  97290. getFrequencyBinCount(): number;
  97291. /**
  97292. * Gets the current frequency data as a byte array
  97293. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97294. * @returns a Uint8Array
  97295. */
  97296. getByteFrequencyData(): Uint8Array;
  97297. /**
  97298. * Gets the current waveform as a byte array
  97299. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  97300. * @returns a Uint8Array
  97301. */
  97302. getByteTimeDomainData(): Uint8Array;
  97303. /**
  97304. * Gets the current frequency data as a float array
  97305. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  97306. * @returns a Float32Array
  97307. */
  97308. getFloatFrequencyData(): Float32Array;
  97309. /**
  97310. * Renders the debug canvas
  97311. */
  97312. drawDebugCanvas(): void;
  97313. /**
  97314. * Stops rendering the debug canvas and removes it
  97315. */
  97316. stopDebugCanvas(): void;
  97317. /**
  97318. * Connects two audio nodes
  97319. * @param inputAudioNode defines first node to connect
  97320. * @param outputAudioNode defines second node to connect
  97321. */
  97322. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  97323. /**
  97324. * Releases all associated resources
  97325. */
  97326. dispose(): void;
  97327. }
  97328. }
  97329. declare module BABYLON {
  97330. /**
  97331. * This represents an audio engine and it is responsible
  97332. * to play, synchronize and analyse sounds throughout the application.
  97333. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97334. */
  97335. export interface IAudioEngine extends IDisposable {
  97336. /**
  97337. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97338. */
  97339. readonly canUseWebAudio: boolean;
  97340. /**
  97341. * Gets the current AudioContext if available.
  97342. */
  97343. readonly audioContext: Nullable<AudioContext>;
  97344. /**
  97345. * The master gain node defines the global audio volume of your audio engine.
  97346. */
  97347. readonly masterGain: GainNode;
  97348. /**
  97349. * Gets whether or not mp3 are supported by your browser.
  97350. */
  97351. readonly isMP3supported: boolean;
  97352. /**
  97353. * Gets whether or not ogg are supported by your browser.
  97354. */
  97355. readonly isOGGsupported: boolean;
  97356. /**
  97357. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97358. * @ignoreNaming
  97359. */
  97360. WarnedWebAudioUnsupported: boolean;
  97361. /**
  97362. * Defines if the audio engine relies on a custom unlocked button.
  97363. * In this case, the embedded button will not be displayed.
  97364. */
  97365. useCustomUnlockedButton: boolean;
  97366. /**
  97367. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  97368. */
  97369. readonly unlocked: boolean;
  97370. /**
  97371. * Event raised when audio has been unlocked on the browser.
  97372. */
  97373. onAudioUnlockedObservable: Observable<AudioEngine>;
  97374. /**
  97375. * Event raised when audio has been locked on the browser.
  97376. */
  97377. onAudioLockedObservable: Observable<AudioEngine>;
  97378. /**
  97379. * Flags the audio engine in Locked state.
  97380. * This happens due to new browser policies preventing audio to autoplay.
  97381. */
  97382. lock(): void;
  97383. /**
  97384. * Unlocks the audio engine once a user action has been done on the dom.
  97385. * This is helpful to resume play once browser policies have been satisfied.
  97386. */
  97387. unlock(): void;
  97388. }
  97389. /**
  97390. * This represents the default audio engine used in babylon.
  97391. * It is responsible to play, synchronize and analyse sounds throughout the application.
  97392. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  97393. */
  97394. export class AudioEngine implements IAudioEngine {
  97395. private _audioContext;
  97396. private _audioContextInitialized;
  97397. private _muteButton;
  97398. private _hostElement;
  97399. /**
  97400. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  97401. */
  97402. canUseWebAudio: boolean;
  97403. /**
  97404. * The master gain node defines the global audio volume of your audio engine.
  97405. */
  97406. masterGain: GainNode;
  97407. /**
  97408. * Defines if Babylon should emit a warning if WebAudio is not supported.
  97409. * @ignoreNaming
  97410. */
  97411. WarnedWebAudioUnsupported: boolean;
  97412. /**
  97413. * Gets whether or not mp3 are supported by your browser.
  97414. */
  97415. isMP3supported: boolean;
  97416. /**
  97417. * Gets whether or not ogg are supported by your browser.
  97418. */
  97419. isOGGsupported: boolean;
  97420. /**
  97421. * Gets whether audio has been unlocked on the device.
  97422. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  97423. * a user interaction has happened.
  97424. */
  97425. unlocked: boolean;
  97426. /**
  97427. * Defines if the audio engine relies on a custom unlocked button.
  97428. * In this case, the embedded button will not be displayed.
  97429. */
  97430. useCustomUnlockedButton: boolean;
  97431. /**
  97432. * Event raised when audio has been unlocked on the browser.
  97433. */
  97434. onAudioUnlockedObservable: Observable<AudioEngine>;
  97435. /**
  97436. * Event raised when audio has been locked on the browser.
  97437. */
  97438. onAudioLockedObservable: Observable<AudioEngine>;
  97439. /**
  97440. * Gets the current AudioContext if available.
  97441. */
  97442. readonly audioContext: Nullable<AudioContext>;
  97443. private _connectedAnalyser;
  97444. /**
  97445. * Instantiates a new audio engine.
  97446. *
  97447. * There should be only one per page as some browsers restrict the number
  97448. * of audio contexts you can create.
  97449. * @param hostElement defines the host element where to display the mute icon if necessary
  97450. */
  97451. constructor(hostElement?: Nullable<HTMLElement>);
  97452. /**
  97453. * Flags the audio engine in Locked state.
  97454. * This happens due to new browser policies preventing audio to autoplay.
  97455. */
  97456. lock(): void;
  97457. /**
  97458. * Unlocks the audio engine once a user action has been done on the dom.
  97459. * This is helpful to resume play once browser policies have been satisfied.
  97460. */
  97461. unlock(): void;
  97462. private _resumeAudioContext;
  97463. private _initializeAudioContext;
  97464. private _tryToRun;
  97465. private _triggerRunningState;
  97466. private _triggerSuspendedState;
  97467. private _displayMuteButton;
  97468. private _moveButtonToTopLeft;
  97469. private _onResize;
  97470. private _hideMuteButton;
  97471. /**
  97472. * Destroy and release the resources associated with the audio ccontext.
  97473. */
  97474. dispose(): void;
  97475. /**
  97476. * Gets the global volume sets on the master gain.
  97477. * @returns the global volume if set or -1 otherwise
  97478. */
  97479. getGlobalVolume(): number;
  97480. /**
  97481. * Sets the global volume of your experience (sets on the master gain).
  97482. * @param newVolume Defines the new global volume of the application
  97483. */
  97484. setGlobalVolume(newVolume: number): void;
  97485. /**
  97486. * Connect the audio engine to an audio analyser allowing some amazing
  97487. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  97488. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  97489. * @param analyser The analyser to connect to the engine
  97490. */
  97491. connectToAnalyser(analyser: Analyser): void;
  97492. }
  97493. }
  97494. declare module BABYLON {
  97495. /**
  97496. * Interface used to present a loading screen while loading a scene
  97497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97498. */
  97499. export interface ILoadingScreen {
  97500. /**
  97501. * Function called to display the loading screen
  97502. */
  97503. displayLoadingUI: () => void;
  97504. /**
  97505. * Function called to hide the loading screen
  97506. */
  97507. hideLoadingUI: () => void;
  97508. /**
  97509. * Gets or sets the color to use for the background
  97510. */
  97511. loadingUIBackgroundColor: string;
  97512. /**
  97513. * Gets or sets the text to display while loading
  97514. */
  97515. loadingUIText: string;
  97516. }
  97517. /**
  97518. * Class used for the default loading screen
  97519. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  97520. */
  97521. export class DefaultLoadingScreen implements ILoadingScreen {
  97522. private _renderingCanvas;
  97523. private _loadingText;
  97524. private _loadingDivBackgroundColor;
  97525. private _loadingDiv;
  97526. private _loadingTextDiv;
  97527. /** Gets or sets the logo url to use for the default loading screen */
  97528. static DefaultLogoUrl: string;
  97529. /** Gets or sets the spinner url to use for the default loading screen */
  97530. static DefaultSpinnerUrl: string;
  97531. /**
  97532. * Creates a new default loading screen
  97533. * @param _renderingCanvas defines the canvas used to render the scene
  97534. * @param _loadingText defines the default text to display
  97535. * @param _loadingDivBackgroundColor defines the default background color
  97536. */
  97537. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  97538. /**
  97539. * Function called to display the loading screen
  97540. */
  97541. displayLoadingUI(): void;
  97542. /**
  97543. * Function called to hide the loading screen
  97544. */
  97545. hideLoadingUI(): void;
  97546. /**
  97547. * Gets or sets the text to display while loading
  97548. */
  97549. loadingUIText: string;
  97550. /**
  97551. * Gets or sets the color to use for the background
  97552. */
  97553. loadingUIBackgroundColor: string;
  97554. private _resizeLoadingUI;
  97555. }
  97556. }
  97557. declare module BABYLON {
  97558. /**
  97559. * Interface for any object that can request an animation frame
  97560. */
  97561. export interface ICustomAnimationFrameRequester {
  97562. /**
  97563. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  97564. */
  97565. renderFunction?: Function;
  97566. /**
  97567. * Called to request the next frame to render to
  97568. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  97569. */
  97570. requestAnimationFrame: Function;
  97571. /**
  97572. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  97573. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  97574. */
  97575. requestID?: number;
  97576. }
  97577. }
  97578. declare module BABYLON {
  97579. /**
  97580. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  97581. */
  97582. export class PerformanceMonitor {
  97583. private _enabled;
  97584. private _rollingFrameTime;
  97585. private _lastFrameTimeMs;
  97586. /**
  97587. * constructor
  97588. * @param frameSampleSize The number of samples required to saturate the sliding window
  97589. */
  97590. constructor(frameSampleSize?: number);
  97591. /**
  97592. * Samples current frame
  97593. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  97594. */
  97595. sampleFrame(timeMs?: number): void;
  97596. /**
  97597. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97598. */
  97599. readonly averageFrameTime: number;
  97600. /**
  97601. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  97602. */
  97603. readonly averageFrameTimeVariance: number;
  97604. /**
  97605. * Returns the frame time of the most recent frame
  97606. */
  97607. readonly instantaneousFrameTime: number;
  97608. /**
  97609. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  97610. */
  97611. readonly averageFPS: number;
  97612. /**
  97613. * Returns the average framerate in frames per second using the most recent frame time
  97614. */
  97615. readonly instantaneousFPS: number;
  97616. /**
  97617. * Returns true if enough samples have been taken to completely fill the sliding window
  97618. */
  97619. readonly isSaturated: boolean;
  97620. /**
  97621. * Enables contributions to the sliding window sample set
  97622. */
  97623. enable(): void;
  97624. /**
  97625. * Disables contributions to the sliding window sample set
  97626. * Samples will not be interpolated over the disabled period
  97627. */
  97628. disable(): void;
  97629. /**
  97630. * Returns true if sampling is enabled
  97631. */
  97632. readonly isEnabled: boolean;
  97633. /**
  97634. * Resets performance monitor
  97635. */
  97636. reset(): void;
  97637. }
  97638. /**
  97639. * RollingAverage
  97640. *
  97641. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  97642. */
  97643. export class RollingAverage {
  97644. /**
  97645. * Current average
  97646. */
  97647. average: number;
  97648. /**
  97649. * Current variance
  97650. */
  97651. variance: number;
  97652. protected _samples: Array<number>;
  97653. protected _sampleCount: number;
  97654. protected _pos: number;
  97655. protected _m2: number;
  97656. /**
  97657. * constructor
  97658. * @param length The number of samples required to saturate the sliding window
  97659. */
  97660. constructor(length: number);
  97661. /**
  97662. * Adds a sample to the sample set
  97663. * @param v The sample value
  97664. */
  97665. add(v: number): void;
  97666. /**
  97667. * Returns previously added values or null if outside of history or outside the sliding window domain
  97668. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  97669. * @return Value previously recorded with add() or null if outside of range
  97670. */
  97671. history(i: number): number;
  97672. /**
  97673. * Returns true if enough samples have been taken to completely fill the sliding window
  97674. * @return true if sample-set saturated
  97675. */
  97676. isSaturated(): boolean;
  97677. /**
  97678. * Resets the rolling average (equivalent to 0 samples taken so far)
  97679. */
  97680. reset(): void;
  97681. /**
  97682. * Wraps a value around the sample range boundaries
  97683. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  97684. * @return Wrapped position in sample range
  97685. */
  97686. protected _wrapPosition(i: number): number;
  97687. }
  97688. }
  97689. declare module BABYLON {
  97690. /**
  97691. * This class is used to track a performance counter which is number based.
  97692. * The user has access to many properties which give statistics of different nature.
  97693. *
  97694. * The implementer can track two kinds of Performance Counter: time and count.
  97695. * 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.
  97696. * 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.
  97697. */
  97698. export class PerfCounter {
  97699. /**
  97700. * Gets or sets a global boolean to turn on and off all the counters
  97701. */
  97702. static Enabled: boolean;
  97703. /**
  97704. * Returns the smallest value ever
  97705. */
  97706. readonly min: number;
  97707. /**
  97708. * Returns the biggest value ever
  97709. */
  97710. readonly max: number;
  97711. /**
  97712. * Returns the average value since the performance counter is running
  97713. */
  97714. readonly average: number;
  97715. /**
  97716. * Returns the average value of the last second the counter was monitored
  97717. */
  97718. readonly lastSecAverage: number;
  97719. /**
  97720. * Returns the current value
  97721. */
  97722. readonly current: number;
  97723. /**
  97724. * Gets the accumulated total
  97725. */
  97726. readonly total: number;
  97727. /**
  97728. * Gets the total value count
  97729. */
  97730. readonly count: number;
  97731. /**
  97732. * Creates a new counter
  97733. */
  97734. constructor();
  97735. /**
  97736. * Call this method to start monitoring a new frame.
  97737. * 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.
  97738. */
  97739. fetchNewFrame(): void;
  97740. /**
  97741. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  97742. * @param newCount the count value to add to the monitored count
  97743. * @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.
  97744. */
  97745. addCount(newCount: number, fetchResult: boolean): void;
  97746. /**
  97747. * Start monitoring this performance counter
  97748. */
  97749. beginMonitoring(): void;
  97750. /**
  97751. * Compute the time lapsed since the previous beginMonitoring() call.
  97752. * @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
  97753. */
  97754. endMonitoring(newFrame?: boolean): void;
  97755. private _fetchResult;
  97756. private _startMonitoringTime;
  97757. private _min;
  97758. private _max;
  97759. private _average;
  97760. private _current;
  97761. private _totalValueCount;
  97762. private _totalAccumulated;
  97763. private _lastSecAverage;
  97764. private _lastSecAccumulated;
  97765. private _lastSecTime;
  97766. private _lastSecValueCount;
  97767. }
  97768. }
  97769. declare module BABYLON {
  97770. /**
  97771. * Defines the interface used by display changed events
  97772. */
  97773. export interface IDisplayChangedEventArgs {
  97774. /** Gets the vrDisplay object (if any) */
  97775. vrDisplay: Nullable<any>;
  97776. /** Gets a boolean indicating if webVR is supported */
  97777. vrSupported: boolean;
  97778. }
  97779. /**
  97780. * Defines the interface used by objects containing a viewport (like a camera)
  97781. */
  97782. interface IViewportOwnerLike {
  97783. /**
  97784. * Gets or sets the viewport
  97785. */
  97786. viewport: IViewportLike;
  97787. }
  97788. /**
  97789. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  97790. */
  97791. export class Engine extends ThinEngine {
  97792. /** Defines that alpha blending is disabled */
  97793. static readonly ALPHA_DISABLE: number;
  97794. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  97795. static readonly ALPHA_ADD: number;
  97796. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  97797. static readonly ALPHA_COMBINE: number;
  97798. /** Defines that alpha blending to DEST - SRC * DEST */
  97799. static readonly ALPHA_SUBTRACT: number;
  97800. /** Defines that alpha blending to SRC * DEST */
  97801. static readonly ALPHA_MULTIPLY: number;
  97802. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  97803. static readonly ALPHA_MAXIMIZED: number;
  97804. /** Defines that alpha blending to SRC + DEST */
  97805. static readonly ALPHA_ONEONE: number;
  97806. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  97807. static readonly ALPHA_PREMULTIPLIED: number;
  97808. /**
  97809. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  97810. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  97811. */
  97812. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  97813. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  97814. static readonly ALPHA_INTERPOLATE: number;
  97815. /**
  97816. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  97817. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  97818. */
  97819. static readonly ALPHA_SCREENMODE: number;
  97820. /** Defines that the ressource is not delayed*/
  97821. static readonly DELAYLOADSTATE_NONE: number;
  97822. /** Defines that the ressource was successfully delay loaded */
  97823. static readonly DELAYLOADSTATE_LOADED: number;
  97824. /** Defines that the ressource is currently delay loading */
  97825. static readonly DELAYLOADSTATE_LOADING: number;
  97826. /** Defines that the ressource is delayed and has not started loading */
  97827. static readonly DELAYLOADSTATE_NOTLOADED: number;
  97828. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  97829. static readonly NEVER: number;
  97830. /** 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 */
  97831. static readonly ALWAYS: number;
  97832. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  97833. static readonly LESS: number;
  97834. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  97835. static readonly EQUAL: number;
  97836. /** 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 */
  97837. static readonly LEQUAL: number;
  97838. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  97839. static readonly GREATER: number;
  97840. /** 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 */
  97841. static readonly GEQUAL: number;
  97842. /** 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 */
  97843. static readonly NOTEQUAL: number;
  97844. /** Passed to stencilOperation to specify that stencil value must be kept */
  97845. static readonly KEEP: number;
  97846. /** Passed to stencilOperation to specify that stencil value must be replaced */
  97847. static readonly REPLACE: number;
  97848. /** Passed to stencilOperation to specify that stencil value must be incremented */
  97849. static readonly INCR: number;
  97850. /** Passed to stencilOperation to specify that stencil value must be decremented */
  97851. static readonly DECR: number;
  97852. /** Passed to stencilOperation to specify that stencil value must be inverted */
  97853. static readonly INVERT: number;
  97854. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  97855. static readonly INCR_WRAP: number;
  97856. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  97857. static readonly DECR_WRAP: number;
  97858. /** Texture is not repeating outside of 0..1 UVs */
  97859. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  97860. /** Texture is repeating outside of 0..1 UVs */
  97861. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  97862. /** Texture is repeating and mirrored */
  97863. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  97864. /** ALPHA */
  97865. static readonly TEXTUREFORMAT_ALPHA: number;
  97866. /** LUMINANCE */
  97867. static readonly TEXTUREFORMAT_LUMINANCE: number;
  97868. /** LUMINANCE_ALPHA */
  97869. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  97870. /** RGB */
  97871. static readonly TEXTUREFORMAT_RGB: number;
  97872. /** RGBA */
  97873. static readonly TEXTUREFORMAT_RGBA: number;
  97874. /** RED */
  97875. static readonly TEXTUREFORMAT_RED: number;
  97876. /** RED (2nd reference) */
  97877. static readonly TEXTUREFORMAT_R: number;
  97878. /** RG */
  97879. static readonly TEXTUREFORMAT_RG: number;
  97880. /** RED_INTEGER */
  97881. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  97882. /** RED_INTEGER (2nd reference) */
  97883. static readonly TEXTUREFORMAT_R_INTEGER: number;
  97884. /** RG_INTEGER */
  97885. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  97886. /** RGB_INTEGER */
  97887. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  97888. /** RGBA_INTEGER */
  97889. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  97890. /** UNSIGNED_BYTE */
  97891. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  97892. /** UNSIGNED_BYTE (2nd reference) */
  97893. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  97894. /** FLOAT */
  97895. static readonly TEXTURETYPE_FLOAT: number;
  97896. /** HALF_FLOAT */
  97897. static readonly TEXTURETYPE_HALF_FLOAT: number;
  97898. /** BYTE */
  97899. static readonly TEXTURETYPE_BYTE: number;
  97900. /** SHORT */
  97901. static readonly TEXTURETYPE_SHORT: number;
  97902. /** UNSIGNED_SHORT */
  97903. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  97904. /** INT */
  97905. static readonly TEXTURETYPE_INT: number;
  97906. /** UNSIGNED_INT */
  97907. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  97908. /** UNSIGNED_SHORT_4_4_4_4 */
  97909. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  97910. /** UNSIGNED_SHORT_5_5_5_1 */
  97911. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  97912. /** UNSIGNED_SHORT_5_6_5 */
  97913. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  97914. /** UNSIGNED_INT_2_10_10_10_REV */
  97915. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  97916. /** UNSIGNED_INT_24_8 */
  97917. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  97918. /** UNSIGNED_INT_10F_11F_11F_REV */
  97919. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  97920. /** UNSIGNED_INT_5_9_9_9_REV */
  97921. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  97922. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  97923. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  97924. /** nearest is mag = nearest and min = nearest and mip = linear */
  97925. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  97926. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97927. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  97928. /** Trilinear is mag = linear and min = linear and mip = linear */
  97929. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  97930. /** nearest is mag = nearest and min = nearest and mip = linear */
  97931. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  97932. /** Bilinear is mag = linear and min = linear and mip = nearest */
  97933. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  97934. /** Trilinear is mag = linear and min = linear and mip = linear */
  97935. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  97936. /** mag = nearest and min = nearest and mip = nearest */
  97937. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  97938. /** mag = nearest and min = linear and mip = nearest */
  97939. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  97940. /** mag = nearest and min = linear and mip = linear */
  97941. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  97942. /** mag = nearest and min = linear and mip = none */
  97943. static readonly TEXTURE_NEAREST_LINEAR: number;
  97944. /** mag = nearest and min = nearest and mip = none */
  97945. static readonly TEXTURE_NEAREST_NEAREST: number;
  97946. /** mag = linear and min = nearest and mip = nearest */
  97947. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  97948. /** mag = linear and min = nearest and mip = linear */
  97949. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  97950. /** mag = linear and min = linear and mip = none */
  97951. static readonly TEXTURE_LINEAR_LINEAR: number;
  97952. /** mag = linear and min = nearest and mip = none */
  97953. static readonly TEXTURE_LINEAR_NEAREST: number;
  97954. /** Explicit coordinates mode */
  97955. static readonly TEXTURE_EXPLICIT_MODE: number;
  97956. /** Spherical coordinates mode */
  97957. static readonly TEXTURE_SPHERICAL_MODE: number;
  97958. /** Planar coordinates mode */
  97959. static readonly TEXTURE_PLANAR_MODE: number;
  97960. /** Cubic coordinates mode */
  97961. static readonly TEXTURE_CUBIC_MODE: number;
  97962. /** Projection coordinates mode */
  97963. static readonly TEXTURE_PROJECTION_MODE: number;
  97964. /** Skybox coordinates mode */
  97965. static readonly TEXTURE_SKYBOX_MODE: number;
  97966. /** Inverse Cubic coordinates mode */
  97967. static readonly TEXTURE_INVCUBIC_MODE: number;
  97968. /** Equirectangular coordinates mode */
  97969. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  97970. /** Equirectangular Fixed coordinates mode */
  97971. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  97972. /** Equirectangular Fixed Mirrored coordinates mode */
  97973. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  97974. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  97975. static readonly SCALEMODE_FLOOR: number;
  97976. /** Defines that texture rescaling will look for the nearest power of 2 size */
  97977. static readonly SCALEMODE_NEAREST: number;
  97978. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  97979. static readonly SCALEMODE_CEILING: number;
  97980. /**
  97981. * Returns the current npm package of the sdk
  97982. */
  97983. static readonly NpmPackage: string;
  97984. /**
  97985. * Returns the current version of the framework
  97986. */
  97987. static readonly Version: string;
  97988. /** Gets the list of created engines */
  97989. static readonly Instances: Engine[];
  97990. /**
  97991. * Gets the latest created engine
  97992. */
  97993. static readonly LastCreatedEngine: Nullable<Engine>;
  97994. /**
  97995. * Gets the latest created scene
  97996. */
  97997. static readonly LastCreatedScene: Nullable<Scene>;
  97998. /**
  97999. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  98000. * @param flag defines which part of the materials must be marked as dirty
  98001. * @param predicate defines a predicate used to filter which materials should be affected
  98002. */
  98003. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  98004. /**
  98005. * Method called to create the default loading screen.
  98006. * This can be overriden in your own app.
  98007. * @param canvas The rendering canvas element
  98008. * @returns The loading screen
  98009. */
  98010. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  98011. /**
  98012. * Method called to create the default rescale post process on each engine.
  98013. */
  98014. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  98015. /**
  98016. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  98017. **/
  98018. enableOfflineSupport: boolean;
  98019. /**
  98020. * 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)
  98021. **/
  98022. disableManifestCheck: boolean;
  98023. /**
  98024. * Gets the list of created scenes
  98025. */
  98026. scenes: Scene[];
  98027. /**
  98028. * Event raised when a new scene is created
  98029. */
  98030. onNewSceneAddedObservable: Observable<Scene>;
  98031. /**
  98032. * Gets the list of created postprocesses
  98033. */
  98034. postProcesses: PostProcess[];
  98035. /**
  98036. * Gets a boolean indicating if the pointer is currently locked
  98037. */
  98038. isPointerLock: boolean;
  98039. /**
  98040. * Observable event triggered each time the rendering canvas is resized
  98041. */
  98042. onResizeObservable: Observable<Engine>;
  98043. /**
  98044. * Observable event triggered each time the canvas loses focus
  98045. */
  98046. onCanvasBlurObservable: Observable<Engine>;
  98047. /**
  98048. * Observable event triggered each time the canvas gains focus
  98049. */
  98050. onCanvasFocusObservable: Observable<Engine>;
  98051. /**
  98052. * Observable event triggered each time the canvas receives pointerout event
  98053. */
  98054. onCanvasPointerOutObservable: Observable<PointerEvent>;
  98055. /**
  98056. * Observable event triggered before each texture is initialized
  98057. */
  98058. onBeforeTextureInitObservable: Observable<Texture>;
  98059. /**
  98060. * Observable raised when the engine begins a new frame
  98061. */
  98062. onBeginFrameObservable: Observable<Engine>;
  98063. /**
  98064. * If set, will be used to request the next animation frame for the render loop
  98065. */
  98066. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  98067. /**
  98068. * Observable raised when the engine ends the current frame
  98069. */
  98070. onEndFrameObservable: Observable<Engine>;
  98071. /**
  98072. * Observable raised when the engine is about to compile a shader
  98073. */
  98074. onBeforeShaderCompilationObservable: Observable<Engine>;
  98075. /**
  98076. * Observable raised when the engine has jsut compiled a shader
  98077. */
  98078. onAfterShaderCompilationObservable: Observable<Engine>;
  98079. /**
  98080. * Gets the audio engine
  98081. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  98082. * @ignorenaming
  98083. */
  98084. static audioEngine: IAudioEngine;
  98085. /**
  98086. * Default AudioEngine factory responsible of creating the Audio Engine.
  98087. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  98088. */
  98089. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  98090. /**
  98091. * Default offline support factory responsible of creating a tool used to store data locally.
  98092. * By default, this will create a Database object if the workload has been embedded.
  98093. */
  98094. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  98095. private _loadingScreen;
  98096. private _pointerLockRequested;
  98097. private _dummyFramebuffer;
  98098. private _rescalePostProcess;
  98099. /** @hidden */
  98100. protected _alphaMode: number;
  98101. /** @hidden */
  98102. protected _alphaEquation: number;
  98103. private _deterministicLockstep;
  98104. private _lockstepMaxSteps;
  98105. protected readonly _supportsHardwareTextureRescaling: boolean;
  98106. private _fps;
  98107. private _deltaTime;
  98108. /** @hidden */
  98109. _drawCalls: PerfCounter;
  98110. /**
  98111. * Turn this value on if you want to pause FPS computation when in background
  98112. */
  98113. disablePerformanceMonitorInBackground: boolean;
  98114. private _performanceMonitor;
  98115. /**
  98116. * Gets the performance monitor attached to this engine
  98117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  98118. */
  98119. readonly performanceMonitor: PerformanceMonitor;
  98120. private _onFocus;
  98121. private _onBlur;
  98122. private _onCanvasPointerOut;
  98123. private _onCanvasBlur;
  98124. private _onCanvasFocus;
  98125. private _onFullscreenChange;
  98126. private _onPointerLockChange;
  98127. /**
  98128. * Creates a new engine
  98129. * @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
  98130. * @param antialias defines enable antialiasing (default: false)
  98131. * @param options defines further options to be sent to the getContext() function
  98132. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  98133. */
  98134. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  98135. /**
  98136. * Gets current aspect ratio
  98137. * @param viewportOwner defines the camera to use to get the aspect ratio
  98138. * @param useScreen defines if screen size must be used (or the current render target if any)
  98139. * @returns a number defining the aspect ratio
  98140. */
  98141. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  98142. /**
  98143. * Gets current screen aspect ratio
  98144. * @returns a number defining the aspect ratio
  98145. */
  98146. getScreenAspectRatio(): number;
  98147. /**
  98148. * Gets host document
  98149. * @returns the host document object
  98150. */
  98151. getHostDocument(): Document;
  98152. /**
  98153. * Gets the client rect of the HTML canvas attached with the current webGL context
  98154. * @returns a client rectanglee
  98155. */
  98156. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  98157. /**
  98158. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  98159. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98160. * @returns true if engine is in deterministic lock step mode
  98161. */
  98162. isDeterministicLockStep(): boolean;
  98163. /**
  98164. * Gets the max steps when engine is running in deterministic lock step
  98165. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  98166. * @returns the max steps
  98167. */
  98168. getLockstepMaxSteps(): number;
  98169. /**
  98170. * Force the mipmap generation for the given render target texture
  98171. * @param texture defines the render target texture to use
  98172. */
  98173. generateMipMapsForCubemap(texture: InternalTexture): void;
  98174. /** States */
  98175. /**
  98176. * Set various states to the webGL context
  98177. * @param culling defines backface culling state
  98178. * @param zOffset defines the value to apply to zOffset (0 by default)
  98179. * @param force defines if states must be applied even if cache is up to date
  98180. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  98181. */
  98182. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  98183. /**
  98184. * Set the z offset to apply to current rendering
  98185. * @param value defines the offset to apply
  98186. */
  98187. setZOffset(value: number): void;
  98188. /**
  98189. * Gets the current value of the zOffset
  98190. * @returns the current zOffset state
  98191. */
  98192. getZOffset(): number;
  98193. /**
  98194. * Enable or disable depth buffering
  98195. * @param enable defines the state to set
  98196. */
  98197. setDepthBuffer(enable: boolean): void;
  98198. /**
  98199. * Gets a boolean indicating if depth writing is enabled
  98200. * @returns the current depth writing state
  98201. */
  98202. getDepthWrite(): boolean;
  98203. /**
  98204. * Enable or disable depth writing
  98205. * @param enable defines the state to set
  98206. */
  98207. setDepthWrite(enable: boolean): void;
  98208. /**
  98209. * Enable or disable color writing
  98210. * @param enable defines the state to set
  98211. */
  98212. setColorWrite(enable: boolean): void;
  98213. /**
  98214. * Gets a boolean indicating if color writing is enabled
  98215. * @returns the current color writing state
  98216. */
  98217. getColorWrite(): boolean;
  98218. /**
  98219. * Sets alpha constants used by some alpha blending modes
  98220. * @param r defines the red component
  98221. * @param g defines the green component
  98222. * @param b defines the blue component
  98223. * @param a defines the alpha component
  98224. */
  98225. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  98226. /**
  98227. * Sets the current alpha mode
  98228. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  98229. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  98230. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98231. */
  98232. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  98233. /**
  98234. * Gets the current alpha mode
  98235. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  98236. * @returns the current alpha mode
  98237. */
  98238. getAlphaMode(): number;
  98239. /**
  98240. * Sets the current alpha equation
  98241. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  98242. */
  98243. setAlphaEquation(equation: number): void;
  98244. /**
  98245. * Gets the current alpha equation.
  98246. * @returns the current alpha equation
  98247. */
  98248. getAlphaEquation(): number;
  98249. /**
  98250. * Gets a boolean indicating if stencil buffer is enabled
  98251. * @returns the current stencil buffer state
  98252. */
  98253. getStencilBuffer(): boolean;
  98254. /**
  98255. * Enable or disable the stencil buffer
  98256. * @param enable defines if the stencil buffer must be enabled or disabled
  98257. */
  98258. setStencilBuffer(enable: boolean): void;
  98259. /**
  98260. * Gets the current stencil mask
  98261. * @returns a number defining the new stencil mask to use
  98262. */
  98263. getStencilMask(): number;
  98264. /**
  98265. * Sets the current stencil mask
  98266. * @param mask defines the new stencil mask to use
  98267. */
  98268. setStencilMask(mask: number): void;
  98269. /**
  98270. * Gets the current stencil function
  98271. * @returns a number defining the stencil function to use
  98272. */
  98273. getStencilFunction(): number;
  98274. /**
  98275. * Gets the current stencil reference value
  98276. * @returns a number defining the stencil reference value to use
  98277. */
  98278. getStencilFunctionReference(): number;
  98279. /**
  98280. * Gets the current stencil mask
  98281. * @returns a number defining the stencil mask to use
  98282. */
  98283. getStencilFunctionMask(): number;
  98284. /**
  98285. * Sets the current stencil function
  98286. * @param stencilFunc defines the new stencil function to use
  98287. */
  98288. setStencilFunction(stencilFunc: number): void;
  98289. /**
  98290. * Sets the current stencil reference
  98291. * @param reference defines the new stencil reference to use
  98292. */
  98293. setStencilFunctionReference(reference: number): void;
  98294. /**
  98295. * Sets the current stencil mask
  98296. * @param mask defines the new stencil mask to use
  98297. */
  98298. setStencilFunctionMask(mask: number): void;
  98299. /**
  98300. * Gets the current stencil operation when stencil fails
  98301. * @returns a number defining stencil operation to use when stencil fails
  98302. */
  98303. getStencilOperationFail(): number;
  98304. /**
  98305. * Gets the current stencil operation when depth fails
  98306. * @returns a number defining stencil operation to use when depth fails
  98307. */
  98308. getStencilOperationDepthFail(): number;
  98309. /**
  98310. * Gets the current stencil operation when stencil passes
  98311. * @returns a number defining stencil operation to use when stencil passes
  98312. */
  98313. getStencilOperationPass(): number;
  98314. /**
  98315. * Sets the stencil operation to use when stencil fails
  98316. * @param operation defines the stencil operation to use when stencil fails
  98317. */
  98318. setStencilOperationFail(operation: number): void;
  98319. /**
  98320. * Sets the stencil operation to use when depth fails
  98321. * @param operation defines the stencil operation to use when depth fails
  98322. */
  98323. setStencilOperationDepthFail(operation: number): void;
  98324. /**
  98325. * Sets the stencil operation to use when stencil passes
  98326. * @param operation defines the stencil operation to use when stencil passes
  98327. */
  98328. setStencilOperationPass(operation: number): void;
  98329. /**
  98330. * Sets a boolean indicating if the dithering state is enabled or disabled
  98331. * @param value defines the dithering state
  98332. */
  98333. setDitheringState(value: boolean): void;
  98334. /**
  98335. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  98336. * @param value defines the rasterizer state
  98337. */
  98338. setRasterizerState(value: boolean): void;
  98339. /**
  98340. * Gets the current depth function
  98341. * @returns a number defining the depth function
  98342. */
  98343. getDepthFunction(): Nullable<number>;
  98344. /**
  98345. * Sets the current depth function
  98346. * @param depthFunc defines the function to use
  98347. */
  98348. setDepthFunction(depthFunc: number): void;
  98349. /**
  98350. * Sets the current depth function to GREATER
  98351. */
  98352. setDepthFunctionToGreater(): void;
  98353. /**
  98354. * Sets the current depth function to GEQUAL
  98355. */
  98356. setDepthFunctionToGreaterOrEqual(): void;
  98357. /**
  98358. * Sets the current depth function to LESS
  98359. */
  98360. setDepthFunctionToLess(): void;
  98361. /**
  98362. * Sets the current depth function to LEQUAL
  98363. */
  98364. setDepthFunctionToLessOrEqual(): void;
  98365. private _cachedStencilBuffer;
  98366. private _cachedStencilFunction;
  98367. private _cachedStencilMask;
  98368. private _cachedStencilOperationPass;
  98369. private _cachedStencilOperationFail;
  98370. private _cachedStencilOperationDepthFail;
  98371. private _cachedStencilReference;
  98372. /**
  98373. * Caches the the state of the stencil buffer
  98374. */
  98375. cacheStencilState(): void;
  98376. /**
  98377. * Restores the state of the stencil buffer
  98378. */
  98379. restoreStencilState(): void;
  98380. /**
  98381. * Directly set the WebGL Viewport
  98382. * @param x defines the x coordinate of the viewport (in screen space)
  98383. * @param y defines the y coordinate of the viewport (in screen space)
  98384. * @param width defines the width of the viewport (in screen space)
  98385. * @param height defines the height of the viewport (in screen space)
  98386. * @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
  98387. */
  98388. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  98389. /**
  98390. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  98391. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98392. * @param y defines the y-coordinate of the corner of the clear rectangle
  98393. * @param width defines the width of the clear rectangle
  98394. * @param height defines the height of the clear rectangle
  98395. * @param clearColor defines the clear color
  98396. */
  98397. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  98398. /**
  98399. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  98400. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  98401. * @param y defines the y-coordinate of the corner of the clear rectangle
  98402. * @param width defines the width of the clear rectangle
  98403. * @param height defines the height of the clear rectangle
  98404. */
  98405. enableScissor(x: number, y: number, width: number, height: number): void;
  98406. /**
  98407. * Disable previously set scissor test rectangle
  98408. */
  98409. disableScissor(): void;
  98410. protected _reportDrawCall(): void;
  98411. /**
  98412. * Initializes a webVR display and starts listening to display change events
  98413. * The onVRDisplayChangedObservable will be notified upon these changes
  98414. * @returns The onVRDisplayChangedObservable
  98415. */
  98416. initWebVR(): Observable<IDisplayChangedEventArgs>;
  98417. /** @hidden */
  98418. _prepareVRComponent(): void;
  98419. /** @hidden */
  98420. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  98421. /** @hidden */
  98422. _submitVRFrame(): void;
  98423. /**
  98424. * Call this function to leave webVR mode
  98425. * Will do nothing if webVR is not supported or if there is no webVR device
  98426. * @see http://doc.babylonjs.com/how_to/webvr_camera
  98427. */
  98428. disableVR(): void;
  98429. /**
  98430. * Gets a boolean indicating that the system is in VR mode and is presenting
  98431. * @returns true if VR mode is engaged
  98432. */
  98433. isVRPresenting(): boolean;
  98434. /** @hidden */
  98435. _requestVRFrame(): void;
  98436. /** @hidden */
  98437. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  98438. /**
  98439. * Gets the source code of the vertex shader associated with a specific webGL program
  98440. * @param program defines the program to use
  98441. * @returns a string containing the source code of the vertex shader associated with the program
  98442. */
  98443. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  98444. /**
  98445. * Gets the source code of the fragment shader associated with a specific webGL program
  98446. * @param program defines the program to use
  98447. * @returns a string containing the source code of the fragment shader associated with the program
  98448. */
  98449. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  98450. /**
  98451. * Reads pixels from the current frame buffer. Please note that this function can be slow
  98452. * @param x defines the x coordinate of the rectangle where pixels must be read
  98453. * @param y defines the y coordinate of the rectangle where pixels must be read
  98454. * @param width defines the width of the rectangle where pixels must be read
  98455. * @param height defines the height of the rectangle where pixels must be read
  98456. * @returns a Uint8Array containing RGBA colors
  98457. */
  98458. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  98459. /**
  98460. * Sets a depth stencil texture from a render target to the according uniform.
  98461. * @param channel The texture channel
  98462. * @param uniform The uniform to set
  98463. * @param texture The render target texture containing the depth stencil texture to apply
  98464. */
  98465. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  98466. /**
  98467. * Sets a texture to the webGL context from a postprocess
  98468. * @param channel defines the channel to use
  98469. * @param postProcess defines the source postprocess
  98470. */
  98471. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  98472. /**
  98473. * Binds the output of the passed in post process to the texture channel specified
  98474. * @param channel The channel the texture should be bound to
  98475. * @param postProcess The post process which's output should be bound
  98476. */
  98477. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  98478. /** @hidden */
  98479. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  98480. protected _rebuildBuffers(): void;
  98481. _renderLoop(): void;
  98482. /**
  98483. * Toggle full screen mode
  98484. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98485. */
  98486. switchFullscreen(requestPointerLock: boolean): void;
  98487. /**
  98488. * Enters full screen mode
  98489. * @param requestPointerLock defines if a pointer lock should be requested from the user
  98490. */
  98491. enterFullscreen(requestPointerLock: boolean): void;
  98492. /**
  98493. * Exits full screen mode
  98494. */
  98495. exitFullscreen(): void;
  98496. /**
  98497. * Enters Pointerlock mode
  98498. */
  98499. enterPointerlock(): void;
  98500. /**
  98501. * Exits Pointerlock mode
  98502. */
  98503. exitPointerlock(): void;
  98504. /**
  98505. * Begin a new frame
  98506. */
  98507. beginFrame(): void;
  98508. /**
  98509. * Enf the current frame
  98510. */
  98511. endFrame(): void;
  98512. resize(): void;
  98513. /**
  98514. * Set the compressed texture format to use, based on the formats you have, and the formats
  98515. * supported by the hardware / browser.
  98516. *
  98517. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  98518. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  98519. * to API arguments needed to compressed textures. This puts the burden on the container
  98520. * generator to house the arcane code for determining these for current & future formats.
  98521. *
  98522. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  98523. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  98524. *
  98525. * Note: The result of this call is not taken into account when a texture is base64.
  98526. *
  98527. * @param formatsAvailable defines the list of those format families you have created
  98528. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  98529. *
  98530. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  98531. * @returns The extension selected.
  98532. */
  98533. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  98534. /**
  98535. * Force a specific size of the canvas
  98536. * @param width defines the new canvas' width
  98537. * @param height defines the new canvas' height
  98538. */
  98539. setSize(width: number, height: number): void;
  98540. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  98541. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98542. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  98543. _releaseTexture(texture: InternalTexture): void;
  98544. /**
  98545. * @hidden
  98546. * Rescales a texture
  98547. * @param source input texutre
  98548. * @param destination destination texture
  98549. * @param scene scene to use to render the resize
  98550. * @param internalFormat format to use when resizing
  98551. * @param onComplete callback to be called when resize has completed
  98552. */
  98553. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  98554. /**
  98555. * Gets the current framerate
  98556. * @returns a number representing the framerate
  98557. */
  98558. getFps(): number;
  98559. /**
  98560. * Gets the time spent between current and previous frame
  98561. * @returns a number representing the delta time in ms
  98562. */
  98563. getDeltaTime(): number;
  98564. private _measureFps;
  98565. /**
  98566. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  98567. * @param renderTarget The render target to set the frame buffer for
  98568. */
  98569. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  98570. /**
  98571. * Update a dynamic index buffer
  98572. * @param indexBuffer defines the target index buffer
  98573. * @param indices defines the data to update
  98574. * @param offset defines the offset in the target index buffer where update should start
  98575. */
  98576. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  98577. /**
  98578. * Creates a new render target texture
  98579. * @param size defines the size of the texture
  98580. * @param options defines the options used to create the texture
  98581. * @returns a new render target texture stored in an InternalTexture
  98582. */
  98583. createRenderTargetTexture(size: number | {
  98584. width: number;
  98585. height: number;
  98586. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  98587. /**
  98588. * Updates the sample count of a render target texture
  98589. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  98590. * @param texture defines the texture to update
  98591. * @param samples defines the sample count to set
  98592. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  98593. */
  98594. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  98595. /** @hidden */
  98596. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  98597. dispose(): void;
  98598. private _disableTouchAction;
  98599. /**
  98600. * Display the loading screen
  98601. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98602. */
  98603. displayLoadingUI(): void;
  98604. /**
  98605. * Hide the loading screen
  98606. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98607. */
  98608. hideLoadingUI(): void;
  98609. /**
  98610. * Gets the current loading screen object
  98611. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98612. */
  98613. /**
  98614. * Sets the current loading screen object
  98615. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98616. */
  98617. loadingScreen: ILoadingScreen;
  98618. /**
  98619. * Sets the current loading screen text
  98620. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98621. */
  98622. loadingUIText: string;
  98623. /**
  98624. * Sets the current loading screen background color
  98625. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  98626. */
  98627. loadingUIBackgroundColor: string;
  98628. /** Pointerlock and fullscreen */
  98629. /**
  98630. * Ask the browser to promote the current element to pointerlock mode
  98631. * @param element defines the DOM element to promote
  98632. */
  98633. static _RequestPointerlock(element: HTMLElement): void;
  98634. /**
  98635. * Asks the browser to exit pointerlock mode
  98636. */
  98637. static _ExitPointerlock(): void;
  98638. /**
  98639. * Ask the browser to promote the current element to fullscreen rendering mode
  98640. * @param element defines the DOM element to promote
  98641. */
  98642. static _RequestFullscreen(element: HTMLElement): void;
  98643. /**
  98644. * Asks the browser to exit fullscreen mode
  98645. */
  98646. static _ExitFullscreen(): void;
  98647. }
  98648. }
  98649. declare module BABYLON {
  98650. /**
  98651. * The engine store class is responsible to hold all the instances of Engine and Scene created
  98652. * during the life time of the application.
  98653. */
  98654. export class EngineStore {
  98655. /** Gets the list of created engines */
  98656. static Instances: Engine[];
  98657. /** @hidden */
  98658. static _LastCreatedScene: Nullable<Scene>;
  98659. /**
  98660. * Gets the latest created engine
  98661. */
  98662. static readonly LastCreatedEngine: Nullable<Engine>;
  98663. /**
  98664. * Gets the latest created scene
  98665. */
  98666. static readonly LastCreatedScene: Nullable<Scene>;
  98667. /**
  98668. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98669. * @ignorenaming
  98670. */
  98671. static UseFallbackTexture: boolean;
  98672. /**
  98673. * Texture content used if a texture cannot loaded
  98674. * @ignorenaming
  98675. */
  98676. static FallbackTexture: string;
  98677. }
  98678. }
  98679. declare module BABYLON {
  98680. /**
  98681. * Helper class that provides a small promise polyfill
  98682. */
  98683. export class PromisePolyfill {
  98684. /**
  98685. * Static function used to check if the polyfill is required
  98686. * If this is the case then the function will inject the polyfill to window.Promise
  98687. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  98688. */
  98689. static Apply(force?: boolean): void;
  98690. }
  98691. }
  98692. declare module BABYLON {
  98693. /**
  98694. * Interface for screenshot methods with describe argument called `size` as object with options
  98695. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  98696. */
  98697. export interface IScreenshotSize {
  98698. /**
  98699. * number in pixels for canvas height
  98700. */
  98701. height?: number;
  98702. /**
  98703. * multiplier allowing render at a higher or lower resolution
  98704. * If value is defined then height and width will be ignored and taken from camera
  98705. */
  98706. precision?: number;
  98707. /**
  98708. * number in pixels for canvas width
  98709. */
  98710. width?: number;
  98711. }
  98712. }
  98713. declare module BABYLON {
  98714. interface IColor4Like {
  98715. r: float;
  98716. g: float;
  98717. b: float;
  98718. a: float;
  98719. }
  98720. /**
  98721. * Class containing a set of static utilities functions
  98722. */
  98723. export class Tools {
  98724. /**
  98725. * Gets or sets the base URL to use to load assets
  98726. */
  98727. static BaseUrl: string;
  98728. /**
  98729. * Enable/Disable Custom HTTP Request Headers globally.
  98730. * default = false
  98731. * @see CustomRequestHeaders
  98732. */
  98733. static UseCustomRequestHeaders: boolean;
  98734. /**
  98735. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  98736. * i.e. when loading files, where the server/service expects an Authorization header
  98737. */
  98738. static CustomRequestHeaders: {
  98739. [key: string]: string;
  98740. };
  98741. /**
  98742. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  98743. */
  98744. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  98745. /**
  98746. * Default behaviour for cors in the application.
  98747. * It can be a string if the expected behavior is identical in the entire app.
  98748. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  98749. */
  98750. static CorsBehavior: string | ((url: string | string[]) => string);
  98751. /**
  98752. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  98753. * @ignorenaming
  98754. */
  98755. static UseFallbackTexture: boolean;
  98756. /**
  98757. * Use this object to register external classes like custom textures or material
  98758. * to allow the laoders to instantiate them
  98759. */
  98760. static RegisteredExternalClasses: {
  98761. [key: string]: Object;
  98762. };
  98763. /**
  98764. * Texture content used if a texture cannot loaded
  98765. * @ignorenaming
  98766. */
  98767. static fallbackTexture: string;
  98768. /**
  98769. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  98770. * @param u defines the coordinate on X axis
  98771. * @param v defines the coordinate on Y axis
  98772. * @param width defines the width of the source data
  98773. * @param height defines the height of the source data
  98774. * @param pixels defines the source byte array
  98775. * @param color defines the output color
  98776. */
  98777. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  98778. /**
  98779. * Interpolates between a and b via alpha
  98780. * @param a The lower value (returned when alpha = 0)
  98781. * @param b The upper value (returned when alpha = 1)
  98782. * @param alpha The interpolation-factor
  98783. * @return The mixed value
  98784. */
  98785. static Mix(a: number, b: number, alpha: number): number;
  98786. /**
  98787. * Tries to instantiate a new object from a given class name
  98788. * @param className defines the class name to instantiate
  98789. * @returns the new object or null if the system was not able to do the instantiation
  98790. */
  98791. static Instantiate(className: string): any;
  98792. /**
  98793. * Provides a slice function that will work even on IE
  98794. * @param data defines the array to slice
  98795. * @param start defines the start of the data (optional)
  98796. * @param end defines the end of the data (optional)
  98797. * @returns the new sliced array
  98798. */
  98799. static Slice<T>(data: T, start?: number, end?: number): T;
  98800. /**
  98801. * Polyfill for setImmediate
  98802. * @param action defines the action to execute after the current execution block
  98803. */
  98804. static SetImmediate(action: () => void): void;
  98805. /**
  98806. * Function indicating if a number is an exponent of 2
  98807. * @param value defines the value to test
  98808. * @returns true if the value is an exponent of 2
  98809. */
  98810. static IsExponentOfTwo(value: number): boolean;
  98811. private static _tmpFloatArray;
  98812. /**
  98813. * Returns the nearest 32-bit single precision float representation of a Number
  98814. * @param value A Number. If the parameter is of a different type, it will get converted
  98815. * to a number or to NaN if it cannot be converted
  98816. * @returns number
  98817. */
  98818. static FloatRound(value: number): number;
  98819. /**
  98820. * Extracts the filename from a path
  98821. * @param path defines the path to use
  98822. * @returns the filename
  98823. */
  98824. static GetFilename(path: string): string;
  98825. /**
  98826. * Extracts the "folder" part of a path (everything before the filename).
  98827. * @param uri The URI to extract the info from
  98828. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  98829. * @returns The "folder" part of the path
  98830. */
  98831. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  98832. /**
  98833. * Extracts text content from a DOM element hierarchy
  98834. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  98835. */
  98836. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  98837. /**
  98838. * Convert an angle in radians to degrees
  98839. * @param angle defines the angle to convert
  98840. * @returns the angle in degrees
  98841. */
  98842. static ToDegrees(angle: number): number;
  98843. /**
  98844. * Convert an angle in degrees to radians
  98845. * @param angle defines the angle to convert
  98846. * @returns the angle in radians
  98847. */
  98848. static ToRadians(angle: number): number;
  98849. /**
  98850. * Encode a buffer to a base64 string
  98851. * @param buffer defines the buffer to encode
  98852. * @returns the encoded string
  98853. */
  98854. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  98855. /**
  98856. * Returns an array if obj is not an array
  98857. * @param obj defines the object to evaluate as an array
  98858. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  98859. * @returns either obj directly if obj is an array or a new array containing obj
  98860. */
  98861. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  98862. /**
  98863. * Gets the pointer prefix to use
  98864. * @returns "pointer" if touch is enabled. Else returns "mouse"
  98865. */
  98866. static GetPointerPrefix(): string;
  98867. /**
  98868. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  98869. * @param url define the url we are trying
  98870. * @param element define the dom element where to configure the cors policy
  98871. */
  98872. static SetCorsBehavior(url: string | string[], element: {
  98873. crossOrigin: string | null;
  98874. }): void;
  98875. /**
  98876. * Removes unwanted characters from an url
  98877. * @param url defines the url to clean
  98878. * @returns the cleaned url
  98879. */
  98880. static CleanUrl(url: string): string;
  98881. /**
  98882. * Gets or sets a function used to pre-process url before using them to load assets
  98883. */
  98884. static PreprocessUrl: (url: string) => string;
  98885. /**
  98886. * Loads an image as an HTMLImageElement.
  98887. * @param input url string, ArrayBuffer, or Blob to load
  98888. * @param onLoad callback called when the image successfully loads
  98889. * @param onError callback called when the image fails to load
  98890. * @param offlineProvider offline provider for caching
  98891. * @returns the HTMLImageElement of the loaded image
  98892. */
  98893. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  98894. /**
  98895. * Loads a file
  98896. * @param url url string, ArrayBuffer, or Blob to load
  98897. * @param onSuccess callback called when the file successfully loads
  98898. * @param onProgress callback called while file is loading (if the server supports this mode)
  98899. * @param offlineProvider defines the offline provider for caching
  98900. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  98901. * @param onError callback called when the file fails to load
  98902. * @returns a file request object
  98903. */
  98904. 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;
  98905. /**
  98906. * Loads a file from a url
  98907. * @param url the file url to load
  98908. * @returns a promise containing an ArrayBuffer corrisponding to the loaded file
  98909. */
  98910. static LoadFileAsync(url: string): Promise<ArrayBuffer>;
  98911. /**
  98912. * Load a script (identified by an url). When the url returns, the
  98913. * content of this file is added into a new script element, attached to the DOM (body element)
  98914. * @param scriptUrl defines the url of the script to laod
  98915. * @param onSuccess defines the callback called when the script is loaded
  98916. * @param onError defines the callback to call if an error occurs
  98917. * @param scriptId defines the id of the script element
  98918. */
  98919. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  98920. /**
  98921. * Load an asynchronous script (identified by an url). When the url returns, the
  98922. * content of this file is added into a new script element, attached to the DOM (body element)
  98923. * @param scriptUrl defines the url of the script to laod
  98924. * @param scriptId defines the id of the script element
  98925. * @returns a promise request object
  98926. */
  98927. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<boolean>;
  98928. /**
  98929. * Loads a file from a blob
  98930. * @param fileToLoad defines the blob to use
  98931. * @param callback defines the callback to call when data is loaded
  98932. * @param progressCallback defines the callback to call during loading process
  98933. * @returns a file request object
  98934. */
  98935. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  98936. /**
  98937. * Loads a file
  98938. * @param fileToLoad defines the file to load
  98939. * @param callback defines the callback to call when data is loaded
  98940. * @param progressCallBack defines the callback to call during loading process
  98941. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  98942. * @returns a file request object
  98943. */
  98944. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  98945. /**
  98946. * Creates a data url from a given string content
  98947. * @param content defines the content to convert
  98948. * @returns the new data url link
  98949. */
  98950. static FileAsURL(content: string): string;
  98951. /**
  98952. * Format the given number to a specific decimal format
  98953. * @param value defines the number to format
  98954. * @param decimals defines the number of decimals to use
  98955. * @returns the formatted string
  98956. */
  98957. static Format(value: number, decimals?: number): string;
  98958. /**
  98959. * Tries to copy an object by duplicating every property
  98960. * @param source defines the source object
  98961. * @param destination defines the target object
  98962. * @param doNotCopyList defines a list of properties to avoid
  98963. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  98964. */
  98965. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  98966. /**
  98967. * Gets a boolean indicating if the given object has no own property
  98968. * @param obj defines the object to test
  98969. * @returns true if object has no own property
  98970. */
  98971. static IsEmpty(obj: any): boolean;
  98972. /**
  98973. * Function used to register events at window level
  98974. * @param windowElement defines the Window object to use
  98975. * @param events defines the events to register
  98976. */
  98977. static RegisterTopRootEvents(windowElement: Window, events: {
  98978. name: string;
  98979. handler: Nullable<(e: FocusEvent) => any>;
  98980. }[]): void;
  98981. /**
  98982. * Function used to unregister events from window level
  98983. * @param windowElement defines the Window object to use
  98984. * @param events defines the events to unregister
  98985. */
  98986. static UnregisterTopRootEvents(windowElement: Window, events: {
  98987. name: string;
  98988. handler: Nullable<(e: FocusEvent) => any>;
  98989. }[]): void;
  98990. /**
  98991. * @ignore
  98992. */
  98993. static _ScreenshotCanvas: HTMLCanvasElement;
  98994. /**
  98995. * Dumps the current bound framebuffer
  98996. * @param width defines the rendering width
  98997. * @param height defines the rendering height
  98998. * @param engine defines the hosting engine
  98999. * @param successCallback defines the callback triggered once the data are available
  99000. * @param mimeType defines the mime type of the result
  99001. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99002. */
  99003. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99004. /**
  99005. * Converts the canvas data to blob.
  99006. * This acts as a polyfill for browsers not supporting the to blob function.
  99007. * @param canvas Defines the canvas to extract the data from
  99008. * @param successCallback Defines the callback triggered once the data are available
  99009. * @param mimeType Defines the mime type of the result
  99010. */
  99011. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  99012. /**
  99013. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99014. * @param successCallback defines the callback triggered once the data are available
  99015. * @param mimeType defines the mime type of the result
  99016. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99017. */
  99018. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  99019. /**
  99020. * Downloads a blob in the browser
  99021. * @param blob defines the blob to download
  99022. * @param fileName defines the name of the downloaded file
  99023. */
  99024. static Download(blob: Blob, fileName: string): void;
  99025. /**
  99026. * Captures a screenshot of the current rendering
  99027. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99028. * @param engine defines the rendering engine
  99029. * @param camera defines the source camera
  99030. * @param size This parameter can be set to a single number or to an object with the
  99031. * following (optional) properties: precision, width, height. If a single number is passed,
  99032. * it will be used for both width and height. If an object is passed, the screenshot size
  99033. * will be derived from the parameters. The precision property is a multiplier allowing
  99034. * rendering at a higher or lower resolution
  99035. * @param successCallback defines the callback receives a single parameter which contains the
  99036. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99037. * src parameter of an <img> to display it
  99038. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99039. * Check your browser for supported MIME types
  99040. */
  99041. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  99042. /**
  99043. * Captures a screenshot of the current rendering
  99044. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99045. * @param engine defines the rendering engine
  99046. * @param camera defines the source camera
  99047. * @param size This parameter can be set to a single number or to an object with the
  99048. * following (optional) properties: precision, width, height. If a single number is passed,
  99049. * it will be used for both width and height. If an object is passed, the screenshot size
  99050. * will be derived from the parameters. The precision property is a multiplier allowing
  99051. * rendering at a higher or lower resolution
  99052. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99053. * Check your browser for supported MIME types
  99054. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99055. * to the src parameter of an <img> to display it
  99056. */
  99057. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  99058. /**
  99059. * Generates an image screenshot from the specified camera.
  99060. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99061. * @param engine The engine to use for rendering
  99062. * @param camera The camera to use for rendering
  99063. * @param size This parameter can be set to a single number or to an object with the
  99064. * following (optional) properties: precision, width, height. If a single number is passed,
  99065. * it will be used for both width and height. If an object is passed, the screenshot size
  99066. * will be derived from the parameters. The precision property is a multiplier allowing
  99067. * rendering at a higher or lower resolution
  99068. * @param successCallback The callback receives a single parameter which contains the
  99069. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99070. * src parameter of an <img> to display it
  99071. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99072. * Check your browser for supported MIME types
  99073. * @param samples Texture samples (default: 1)
  99074. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99075. * @param fileName A name for for the downloaded file.
  99076. */
  99077. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  99078. /**
  99079. * Generates an image screenshot from the specified camera.
  99080. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99081. * @param engine The engine to use for rendering
  99082. * @param camera The camera to use for rendering
  99083. * @param size This parameter can be set to a single number or to an object with the
  99084. * following (optional) properties: precision, width, height. If a single number is passed,
  99085. * it will be used for both width and height. If an object is passed, the screenshot size
  99086. * will be derived from the parameters. The precision property is a multiplier allowing
  99087. * rendering at a higher or lower resolution
  99088. * @param mimeType The MIME type of the screenshot image (default: image/png).
  99089. * Check your browser for supported MIME types
  99090. * @param samples Texture samples (default: 1)
  99091. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  99092. * @param fileName A name for for the downloaded file.
  99093. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  99094. * to the src parameter of an <img> to display it
  99095. */
  99096. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  99097. /**
  99098. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  99099. * Be aware Math.random() could cause collisions, but:
  99100. * "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"
  99101. * @returns a pseudo random id
  99102. */
  99103. static RandomId(): string;
  99104. /**
  99105. * Test if the given uri is a base64 string
  99106. * @param uri The uri to test
  99107. * @return True if the uri is a base64 string or false otherwise
  99108. */
  99109. static IsBase64(uri: string): boolean;
  99110. /**
  99111. * Decode the given base64 uri.
  99112. * @param uri The uri to decode
  99113. * @return The decoded base64 data.
  99114. */
  99115. static DecodeBase64(uri: string): ArrayBuffer;
  99116. /**
  99117. * Gets the absolute url.
  99118. * @param url the input url
  99119. * @return the absolute url
  99120. */
  99121. static GetAbsoluteUrl(url: string): string;
  99122. /**
  99123. * No log
  99124. */
  99125. static readonly NoneLogLevel: number;
  99126. /**
  99127. * Only message logs
  99128. */
  99129. static readonly MessageLogLevel: number;
  99130. /**
  99131. * Only warning logs
  99132. */
  99133. static readonly WarningLogLevel: number;
  99134. /**
  99135. * Only error logs
  99136. */
  99137. static readonly ErrorLogLevel: number;
  99138. /**
  99139. * All logs
  99140. */
  99141. static readonly AllLogLevel: number;
  99142. /**
  99143. * Gets a value indicating the number of loading errors
  99144. * @ignorenaming
  99145. */
  99146. static readonly errorsCount: number;
  99147. /**
  99148. * Callback called when a new log is added
  99149. */
  99150. static OnNewCacheEntry: (entry: string) => void;
  99151. /**
  99152. * Log a message to the console
  99153. * @param message defines the message to log
  99154. */
  99155. static Log(message: string): void;
  99156. /**
  99157. * Write a warning message to the console
  99158. * @param message defines the message to log
  99159. */
  99160. static Warn(message: string): void;
  99161. /**
  99162. * Write an error message to the console
  99163. * @param message defines the message to log
  99164. */
  99165. static Error(message: string): void;
  99166. /**
  99167. * Gets current log cache (list of logs)
  99168. */
  99169. static readonly LogCache: string;
  99170. /**
  99171. * Clears the log cache
  99172. */
  99173. static ClearLogCache(): void;
  99174. /**
  99175. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  99176. */
  99177. static LogLevels: number;
  99178. /**
  99179. * Checks if the window object exists
  99180. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  99181. */
  99182. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  99183. /**
  99184. * No performance log
  99185. */
  99186. static readonly PerformanceNoneLogLevel: number;
  99187. /**
  99188. * Use user marks to log performance
  99189. */
  99190. static readonly PerformanceUserMarkLogLevel: number;
  99191. /**
  99192. * Log performance to the console
  99193. */
  99194. static readonly PerformanceConsoleLogLevel: number;
  99195. private static _performance;
  99196. /**
  99197. * Sets the current performance log level
  99198. */
  99199. static PerformanceLogLevel: number;
  99200. private static _StartPerformanceCounterDisabled;
  99201. private static _EndPerformanceCounterDisabled;
  99202. private static _StartUserMark;
  99203. private static _EndUserMark;
  99204. private static _StartPerformanceConsole;
  99205. private static _EndPerformanceConsole;
  99206. /**
  99207. * Starts a performance counter
  99208. */
  99209. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99210. /**
  99211. * Ends a specific performance coutner
  99212. */
  99213. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  99214. /**
  99215. * Gets either window.performance.now() if supported or Date.now() else
  99216. */
  99217. static readonly Now: number;
  99218. /**
  99219. * This method will return the name of the class used to create the instance of the given object.
  99220. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  99221. * @param object the object to get the class name from
  99222. * @param isType defines if the object is actually a type
  99223. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  99224. */
  99225. static GetClassName(object: any, isType?: boolean): string;
  99226. /**
  99227. * Gets the first element of an array satisfying a given predicate
  99228. * @param array defines the array to browse
  99229. * @param predicate defines the predicate to use
  99230. * @returns null if not found or the element
  99231. */
  99232. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  99233. /**
  99234. * This method will return the name of the full name of the class, including its owning module (if any).
  99235. * 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).
  99236. * @param object the object to get the class name from
  99237. * @param isType defines if the object is actually a type
  99238. * @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.
  99239. * @ignorenaming
  99240. */
  99241. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  99242. /**
  99243. * Returns a promise that resolves after the given amount of time.
  99244. * @param delay Number of milliseconds to delay
  99245. * @returns Promise that resolves after the given amount of time
  99246. */
  99247. static DelayAsync(delay: number): Promise<void>;
  99248. }
  99249. /**
  99250. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  99251. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  99252. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  99253. * @param name The name of the class, case should be preserved
  99254. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  99255. */
  99256. export function className(name: string, module?: string): (target: Object) => void;
  99257. /**
  99258. * An implementation of a loop for asynchronous functions.
  99259. */
  99260. export class AsyncLoop {
  99261. /**
  99262. * Defines the number of iterations for the loop
  99263. */
  99264. iterations: number;
  99265. /**
  99266. * Defines the current index of the loop.
  99267. */
  99268. index: number;
  99269. private _done;
  99270. private _fn;
  99271. private _successCallback;
  99272. /**
  99273. * Constructor.
  99274. * @param iterations the number of iterations.
  99275. * @param func the function to run each iteration
  99276. * @param successCallback the callback that will be called upon succesful execution
  99277. * @param offset starting offset.
  99278. */
  99279. constructor(
  99280. /**
  99281. * Defines the number of iterations for the loop
  99282. */
  99283. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  99284. /**
  99285. * Execute the next iteration. Must be called after the last iteration was finished.
  99286. */
  99287. executeNext(): void;
  99288. /**
  99289. * Break the loop and run the success callback.
  99290. */
  99291. breakLoop(): void;
  99292. /**
  99293. * Create and run an async loop.
  99294. * @param iterations the number of iterations.
  99295. * @param fn the function to run each iteration
  99296. * @param successCallback the callback that will be called upon succesful execution
  99297. * @param offset starting offset.
  99298. * @returns the created async loop object
  99299. */
  99300. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  99301. /**
  99302. * A for-loop that will run a given number of iterations synchronous and the rest async.
  99303. * @param iterations total number of iterations
  99304. * @param syncedIterations number of synchronous iterations in each async iteration.
  99305. * @param fn the function to call each iteration.
  99306. * @param callback a success call back that will be called when iterating stops.
  99307. * @param breakFunction a break condition (optional)
  99308. * @param timeout timeout settings for the setTimeout function. default - 0.
  99309. * @returns the created async loop object
  99310. */
  99311. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  99312. }
  99313. }
  99314. declare module BABYLON {
  99315. /**
  99316. * This class implement a typical dictionary using a string as key and the generic type T as value.
  99317. * The underlying implementation relies on an associative array to ensure the best performances.
  99318. * The value can be anything including 'null' but except 'undefined'
  99319. */
  99320. export class StringDictionary<T> {
  99321. /**
  99322. * This will clear this dictionary and copy the content from the 'source' one.
  99323. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  99324. * @param source the dictionary to take the content from and copy to this dictionary
  99325. */
  99326. copyFrom(source: StringDictionary<T>): void;
  99327. /**
  99328. * Get a value based from its key
  99329. * @param key the given key to get the matching value from
  99330. * @return the value if found, otherwise undefined is returned
  99331. */
  99332. get(key: string): T | undefined;
  99333. /**
  99334. * Get a value from its key or add it if it doesn't exist.
  99335. * This method will ensure you that a given key/data will be present in the dictionary.
  99336. * @param key the given key to get the matching value from
  99337. * @param factory the factory that will create the value if the key is not present in the dictionary.
  99338. * The factory will only be invoked if there's no data for the given key.
  99339. * @return the value corresponding to the key.
  99340. */
  99341. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  99342. /**
  99343. * Get a value from its key if present in the dictionary otherwise add it
  99344. * @param key the key to get the value from
  99345. * @param val if there's no such key/value pair in the dictionary add it with this value
  99346. * @return the value corresponding to the key
  99347. */
  99348. getOrAdd(key: string, val: T): T;
  99349. /**
  99350. * Check if there's a given key in the dictionary
  99351. * @param key the key to check for
  99352. * @return true if the key is present, false otherwise
  99353. */
  99354. contains(key: string): boolean;
  99355. /**
  99356. * Add a new key and its corresponding value
  99357. * @param key the key to add
  99358. * @param value the value corresponding to the key
  99359. * @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
  99360. */
  99361. add(key: string, value: T): boolean;
  99362. /**
  99363. * Update a specific value associated to a key
  99364. * @param key defines the key to use
  99365. * @param value defines the value to store
  99366. * @returns true if the value was updated (or false if the key was not found)
  99367. */
  99368. set(key: string, value: T): boolean;
  99369. /**
  99370. * Get the element of the given key and remove it from the dictionary
  99371. * @param key defines the key to search
  99372. * @returns the value associated with the key or null if not found
  99373. */
  99374. getAndRemove(key: string): Nullable<T>;
  99375. /**
  99376. * Remove a key/value from the dictionary.
  99377. * @param key the key to remove
  99378. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  99379. */
  99380. remove(key: string): boolean;
  99381. /**
  99382. * Clear the whole content of the dictionary
  99383. */
  99384. clear(): void;
  99385. /**
  99386. * Gets the current count
  99387. */
  99388. readonly count: number;
  99389. /**
  99390. * Execute a callback on each key/val of the dictionary.
  99391. * Note that you can remove any element in this dictionary in the callback implementation
  99392. * @param callback the callback to execute on a given key/value pair
  99393. */
  99394. forEach(callback: (key: string, val: T) => void): void;
  99395. /**
  99396. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  99397. * If the callback returns null or undefined the method will iterate to the next key/value pair
  99398. * Note that you can remove any element in this dictionary in the callback implementation
  99399. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  99400. * @returns the first item
  99401. */
  99402. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  99403. private _count;
  99404. private _data;
  99405. }
  99406. }
  99407. declare module BABYLON {
  99408. /** @hidden */
  99409. export interface ICollisionCoordinator {
  99410. createCollider(): Collider;
  99411. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99412. init(scene: Scene): void;
  99413. }
  99414. /** @hidden */
  99415. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  99416. private _scene;
  99417. private _scaledPosition;
  99418. private _scaledVelocity;
  99419. private _finalPosition;
  99420. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  99421. createCollider(): Collider;
  99422. init(scene: Scene): void;
  99423. private _collideWithWorld;
  99424. }
  99425. }
  99426. declare module BABYLON {
  99427. /**
  99428. * Class used to manage all inputs for the scene.
  99429. */
  99430. export class InputManager {
  99431. /** The distance in pixel that you have to move to prevent some events */
  99432. static DragMovementThreshold: number;
  99433. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  99434. static LongPressDelay: number;
  99435. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  99436. static DoubleClickDelay: number;
  99437. /** If you need to check double click without raising a single click at first click, enable this flag */
  99438. static ExclusiveDoubleClickMode: boolean;
  99439. private _wheelEventName;
  99440. private _onPointerMove;
  99441. private _onPointerDown;
  99442. private _onPointerUp;
  99443. private _initClickEvent;
  99444. private _initActionManager;
  99445. private _delayedSimpleClick;
  99446. private _delayedSimpleClickTimeout;
  99447. private _previousDelayedSimpleClickTimeout;
  99448. private _meshPickProceed;
  99449. private _previousButtonPressed;
  99450. private _currentPickResult;
  99451. private _previousPickResult;
  99452. private _totalPointersPressed;
  99453. private _doubleClickOccured;
  99454. private _pointerOverMesh;
  99455. private _pickedDownMesh;
  99456. private _pickedUpMesh;
  99457. private _pointerX;
  99458. private _pointerY;
  99459. private _unTranslatedPointerX;
  99460. private _unTranslatedPointerY;
  99461. private _startingPointerPosition;
  99462. private _previousStartingPointerPosition;
  99463. private _startingPointerTime;
  99464. private _previousStartingPointerTime;
  99465. private _pointerCaptures;
  99466. private _onKeyDown;
  99467. private _onKeyUp;
  99468. private _onCanvasFocusObserver;
  99469. private _onCanvasBlurObserver;
  99470. private _scene;
  99471. /**
  99472. * Creates a new InputManager
  99473. * @param scene defines the hosting scene
  99474. */
  99475. constructor(scene: Scene);
  99476. /**
  99477. * Gets the mesh that is currently under the pointer
  99478. */
  99479. readonly meshUnderPointer: Nullable<AbstractMesh>;
  99480. /**
  99481. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  99482. */
  99483. readonly unTranslatedPointer: Vector2;
  99484. /**
  99485. * Gets or sets the current on-screen X position of the pointer
  99486. */
  99487. pointerX: number;
  99488. /**
  99489. * Gets or sets the current on-screen Y position of the pointer
  99490. */
  99491. pointerY: number;
  99492. private _updatePointerPosition;
  99493. private _processPointerMove;
  99494. private _setRayOnPointerInfo;
  99495. private _checkPrePointerObservable;
  99496. /**
  99497. * Use this method to simulate a pointer move on a mesh
  99498. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99499. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99500. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99501. */
  99502. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99503. /**
  99504. * Use this method to simulate a pointer down on a mesh
  99505. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99506. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99507. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99508. */
  99509. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  99510. private _processPointerDown;
  99511. /** @hidden */
  99512. _isPointerSwiping(): boolean;
  99513. /**
  99514. * Use this method to simulate a pointer up on a mesh
  99515. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  99516. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  99517. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  99518. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  99519. */
  99520. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  99521. private _processPointerUp;
  99522. /**
  99523. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  99524. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  99525. * @returns true if the pointer was captured
  99526. */
  99527. isPointerCaptured(pointerId?: number): boolean;
  99528. /**
  99529. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  99530. * @param attachUp defines if you want to attach events to pointerup
  99531. * @param attachDown defines if you want to attach events to pointerdown
  99532. * @param attachMove defines if you want to attach events to pointermove
  99533. */
  99534. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  99535. /**
  99536. * Detaches all event handlers
  99537. */
  99538. detachControl(): void;
  99539. /**
  99540. * Force the value of meshUnderPointer
  99541. * @param mesh defines the mesh to use
  99542. */
  99543. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  99544. /**
  99545. * Gets the mesh under the pointer
  99546. * @returns a Mesh or null if no mesh is under the pointer
  99547. */
  99548. getPointerOverMesh(): Nullable<AbstractMesh>;
  99549. }
  99550. }
  99551. declare module BABYLON {
  99552. /**
  99553. * Helper class used to generate session unique ID
  99554. */
  99555. export class UniqueIdGenerator {
  99556. private static _UniqueIdCounter;
  99557. /**
  99558. * Gets an unique (relatively to the current scene) Id
  99559. */
  99560. static readonly UniqueId: number;
  99561. }
  99562. }
  99563. declare module BABYLON {
  99564. /**
  99565. * This class defines the direct association between an animation and a target
  99566. */
  99567. export class TargetedAnimation {
  99568. /**
  99569. * Animation to perform
  99570. */
  99571. animation: Animation;
  99572. /**
  99573. * Target to animate
  99574. */
  99575. target: any;
  99576. /**
  99577. * Serialize the object
  99578. * @returns the JSON object representing the current entity
  99579. */
  99580. serialize(): any;
  99581. }
  99582. /**
  99583. * Use this class to create coordinated animations on multiple targets
  99584. */
  99585. export class AnimationGroup implements IDisposable {
  99586. /** The name of the animation group */
  99587. name: string;
  99588. private _scene;
  99589. private _targetedAnimations;
  99590. private _animatables;
  99591. private _from;
  99592. private _to;
  99593. private _isStarted;
  99594. private _isPaused;
  99595. private _speedRatio;
  99596. private _loopAnimation;
  99597. /**
  99598. * Gets or sets the unique id of the node
  99599. */
  99600. uniqueId: number;
  99601. /**
  99602. * This observable will notify when one animation have ended
  99603. */
  99604. onAnimationEndObservable: Observable<TargetedAnimation>;
  99605. /**
  99606. * Observer raised when one animation loops
  99607. */
  99608. onAnimationLoopObservable: Observable<TargetedAnimation>;
  99609. /**
  99610. * This observable will notify when all animations have ended.
  99611. */
  99612. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  99613. /**
  99614. * This observable will notify when all animations have paused.
  99615. */
  99616. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  99617. /**
  99618. * This observable will notify when all animations are playing.
  99619. */
  99620. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  99621. /**
  99622. * Gets the first frame
  99623. */
  99624. readonly from: number;
  99625. /**
  99626. * Gets the last frame
  99627. */
  99628. readonly to: number;
  99629. /**
  99630. * Define if the animations are started
  99631. */
  99632. readonly isStarted: boolean;
  99633. /**
  99634. * Gets a value indicating that the current group is playing
  99635. */
  99636. readonly isPlaying: boolean;
  99637. /**
  99638. * Gets or sets the speed ratio to use for all animations
  99639. */
  99640. /**
  99641. * Gets or sets the speed ratio to use for all animations
  99642. */
  99643. speedRatio: number;
  99644. /**
  99645. * Gets or sets if all animations should loop or not
  99646. */
  99647. loopAnimation: boolean;
  99648. /**
  99649. * Gets the targeted animations for this animation group
  99650. */
  99651. readonly targetedAnimations: Array<TargetedAnimation>;
  99652. /**
  99653. * returning the list of animatables controlled by this animation group.
  99654. */
  99655. readonly animatables: Array<Animatable>;
  99656. /**
  99657. * Instantiates a new Animation Group.
  99658. * This helps managing several animations at once.
  99659. * @see http://doc.babylonjs.com/how_to/group
  99660. * @param name Defines the name of the group
  99661. * @param scene Defines the scene the group belongs to
  99662. */
  99663. constructor(
  99664. /** The name of the animation group */
  99665. name: string, scene?: Nullable<Scene>);
  99666. /**
  99667. * Add an animation (with its target) in the group
  99668. * @param animation defines the animation we want to add
  99669. * @param target defines the target of the animation
  99670. * @returns the TargetedAnimation object
  99671. */
  99672. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  99673. /**
  99674. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  99675. * It can add constant keys at begin or end
  99676. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  99677. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  99678. * @returns the animation group
  99679. */
  99680. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  99681. /**
  99682. * Start all animations on given targets
  99683. * @param loop defines if animations must loop
  99684. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  99685. * @param from defines the from key (optional)
  99686. * @param to defines the to key (optional)
  99687. * @returns the current animation group
  99688. */
  99689. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  99690. /**
  99691. * Pause all animations
  99692. * @returns the animation group
  99693. */
  99694. pause(): AnimationGroup;
  99695. /**
  99696. * Play all animations to initial state
  99697. * This function will start() the animations if they were not started or will restart() them if they were paused
  99698. * @param loop defines if animations must loop
  99699. * @returns the animation group
  99700. */
  99701. play(loop?: boolean): AnimationGroup;
  99702. /**
  99703. * Reset all animations to initial state
  99704. * @returns the animation group
  99705. */
  99706. reset(): AnimationGroup;
  99707. /**
  99708. * Restart animations from key 0
  99709. * @returns the animation group
  99710. */
  99711. restart(): AnimationGroup;
  99712. /**
  99713. * Stop all animations
  99714. * @returns the animation group
  99715. */
  99716. stop(): AnimationGroup;
  99717. /**
  99718. * Set animation weight for all animatables
  99719. * @param weight defines the weight to use
  99720. * @return the animationGroup
  99721. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99722. */
  99723. setWeightForAllAnimatables(weight: number): AnimationGroup;
  99724. /**
  99725. * Synchronize and normalize all animatables with a source animatable
  99726. * @param root defines the root animatable to synchronize with
  99727. * @return the animationGroup
  99728. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  99729. */
  99730. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  99731. /**
  99732. * Goes to a specific frame in this animation group
  99733. * @param frame the frame number to go to
  99734. * @return the animationGroup
  99735. */
  99736. goToFrame(frame: number): AnimationGroup;
  99737. /**
  99738. * Dispose all associated resources
  99739. */
  99740. dispose(): void;
  99741. private _checkAnimationGroupEnded;
  99742. /**
  99743. * Clone the current animation group and returns a copy
  99744. * @param newName defines the name of the new group
  99745. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  99746. * @returns the new aniamtion group
  99747. */
  99748. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  99749. /**
  99750. * Serializes the animationGroup to an object
  99751. * @returns Serialized object
  99752. */
  99753. serialize(): any;
  99754. /**
  99755. * Returns a new AnimationGroup object parsed from the source provided.
  99756. * @param parsedAnimationGroup defines the source
  99757. * @param scene defines the scene that will receive the animationGroup
  99758. * @returns a new AnimationGroup
  99759. */
  99760. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  99761. /**
  99762. * Returns the string "AnimationGroup"
  99763. * @returns "AnimationGroup"
  99764. */
  99765. getClassName(): string;
  99766. /**
  99767. * Creates a detailled string about the object
  99768. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  99769. * @returns a string representing the object
  99770. */
  99771. toString(fullDetails?: boolean): string;
  99772. }
  99773. }
  99774. declare module BABYLON {
  99775. /**
  99776. * Define an interface for all classes that will hold resources
  99777. */
  99778. export interface IDisposable {
  99779. /**
  99780. * Releases all held resources
  99781. */
  99782. dispose(): void;
  99783. }
  99784. /** Interface defining initialization parameters for Scene class */
  99785. export interface SceneOptions {
  99786. /**
  99787. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  99788. * It will improve performance when the number of geometries becomes important.
  99789. */
  99790. useGeometryUniqueIdsMap?: boolean;
  99791. /**
  99792. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  99793. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99794. */
  99795. useMaterialMeshMap?: boolean;
  99796. /**
  99797. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  99798. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  99799. */
  99800. useClonedMeshhMap?: boolean;
  99801. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  99802. virtual?: boolean;
  99803. }
  99804. /**
  99805. * Represents a scene to be rendered by the engine.
  99806. * @see http://doc.babylonjs.com/features/scene
  99807. */
  99808. export class Scene extends AbstractScene implements IAnimatable {
  99809. /** The fog is deactivated */
  99810. static readonly FOGMODE_NONE: number;
  99811. /** The fog density is following an exponential function */
  99812. static readonly FOGMODE_EXP: number;
  99813. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  99814. static readonly FOGMODE_EXP2: number;
  99815. /** The fog density is following a linear function. */
  99816. static readonly FOGMODE_LINEAR: number;
  99817. /**
  99818. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  99819. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99820. */
  99821. static MinDeltaTime: number;
  99822. /**
  99823. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  99824. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  99825. */
  99826. static MaxDeltaTime: number;
  99827. /**
  99828. * Factory used to create the default material.
  99829. * @param name The name of the material to create
  99830. * @param scene The scene to create the material for
  99831. * @returns The default material
  99832. */
  99833. static DefaultMaterialFactory(scene: Scene): Material;
  99834. /**
  99835. * Factory used to create the a collision coordinator.
  99836. * @returns The collision coordinator
  99837. */
  99838. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  99839. /** @hidden */
  99840. _inputManager: InputManager;
  99841. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  99842. cameraToUseForPointers: Nullable<Camera>;
  99843. /** @hidden */
  99844. readonly _isScene: boolean;
  99845. /**
  99846. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  99847. */
  99848. autoClear: boolean;
  99849. /**
  99850. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  99851. */
  99852. autoClearDepthAndStencil: boolean;
  99853. /**
  99854. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  99855. */
  99856. clearColor: Color4;
  99857. /**
  99858. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  99859. */
  99860. ambientColor: Color3;
  99861. /**
  99862. * This is use to store the default BRDF lookup for PBR materials in your scene.
  99863. * It should only be one of the following (if not the default embedded one):
  99864. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  99865. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  99866. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  99867. * The material properties need to be setup according to the type of texture in use.
  99868. */
  99869. environmentBRDFTexture: BaseTexture;
  99870. /** @hidden */
  99871. protected _environmentTexture: Nullable<BaseTexture>;
  99872. /**
  99873. * Texture used in all pbr material as the reflection texture.
  99874. * As in the majority of the scene they are the same (exception for multi room and so on),
  99875. * this is easier to reference from here than from all the materials.
  99876. */
  99877. /**
  99878. * Texture used in all pbr material as the reflection texture.
  99879. * As in the majority of the scene they are the same (exception for multi room and so on),
  99880. * this is easier to set here than in all the materials.
  99881. */
  99882. environmentTexture: Nullable<BaseTexture>;
  99883. /** @hidden */
  99884. protected _environmentIntensity: number;
  99885. /**
  99886. * Intensity of the environment in all pbr material.
  99887. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99888. * As in the majority of the scene they are the same (exception for multi room and so on),
  99889. * this is easier to reference from here than from all the materials.
  99890. */
  99891. /**
  99892. * Intensity of the environment in all pbr material.
  99893. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  99894. * As in the majority of the scene they are the same (exception for multi room and so on),
  99895. * this is easier to set here than in all the materials.
  99896. */
  99897. environmentIntensity: number;
  99898. /** @hidden */
  99899. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  99900. /**
  99901. * Default image processing configuration used either in the rendering
  99902. * Forward main pass or through the imageProcessingPostProcess if present.
  99903. * As in the majority of the scene they are the same (exception for multi camera),
  99904. * this is easier to reference from here than from all the materials and post process.
  99905. *
  99906. * No setter as we it is a shared configuration, you can set the values instead.
  99907. */
  99908. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  99909. private _forceWireframe;
  99910. /**
  99911. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  99912. */
  99913. forceWireframe: boolean;
  99914. private _forcePointsCloud;
  99915. /**
  99916. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  99917. */
  99918. forcePointsCloud: boolean;
  99919. /**
  99920. * Gets or sets the active clipplane 1
  99921. */
  99922. clipPlane: Nullable<Plane>;
  99923. /**
  99924. * Gets or sets the active clipplane 2
  99925. */
  99926. clipPlane2: Nullable<Plane>;
  99927. /**
  99928. * Gets or sets the active clipplane 3
  99929. */
  99930. clipPlane3: Nullable<Plane>;
  99931. /**
  99932. * Gets or sets the active clipplane 4
  99933. */
  99934. clipPlane4: Nullable<Plane>;
  99935. /**
  99936. * Gets or sets a boolean indicating if animations are enabled
  99937. */
  99938. animationsEnabled: boolean;
  99939. private _animationPropertiesOverride;
  99940. /**
  99941. * Gets or sets the animation properties override
  99942. */
  99943. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  99944. /**
  99945. * Gets or sets a boolean indicating if a constant deltatime has to be used
  99946. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  99947. */
  99948. useConstantAnimationDeltaTime: boolean;
  99949. /**
  99950. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  99951. * Please note that it requires to run a ray cast through the scene on every frame
  99952. */
  99953. constantlyUpdateMeshUnderPointer: boolean;
  99954. /**
  99955. * Defines the HTML cursor to use when hovering over interactive elements
  99956. */
  99957. hoverCursor: string;
  99958. /**
  99959. * Defines the HTML default cursor to use (empty by default)
  99960. */
  99961. defaultCursor: string;
  99962. /**
  99963. * This is used to call preventDefault() on pointer down
  99964. * in order to block unwanted artifacts like system double clicks
  99965. */
  99966. preventDefaultOnPointerDown: boolean;
  99967. /**
  99968. * This is used to call preventDefault() on pointer up
  99969. * in order to block unwanted artifacts like system double clicks
  99970. */
  99971. preventDefaultOnPointerUp: boolean;
  99972. /**
  99973. * Gets or sets user defined metadata
  99974. */
  99975. metadata: any;
  99976. /**
  99977. * For internal use only. Please do not use.
  99978. */
  99979. reservedDataStore: any;
  99980. /**
  99981. * Gets the name of the plugin used to load this scene (null by default)
  99982. */
  99983. loadingPluginName: string;
  99984. /**
  99985. * Use this array to add regular expressions used to disable offline support for specific urls
  99986. */
  99987. disableOfflineSupportExceptionRules: RegExp[];
  99988. /**
  99989. * An event triggered when the scene is disposed.
  99990. */
  99991. onDisposeObservable: Observable<Scene>;
  99992. private _onDisposeObserver;
  99993. /** Sets a function to be executed when this scene is disposed. */
  99994. onDispose: () => void;
  99995. /**
  99996. * An event triggered before rendering the scene (right after animations and physics)
  99997. */
  99998. onBeforeRenderObservable: Observable<Scene>;
  99999. private _onBeforeRenderObserver;
  100000. /** Sets a function to be executed before rendering this scene */
  100001. beforeRender: Nullable<() => void>;
  100002. /**
  100003. * An event triggered after rendering the scene
  100004. */
  100005. onAfterRenderObservable: Observable<Scene>;
  100006. /**
  100007. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  100008. */
  100009. onAfterRenderCameraObservable: Observable<Camera>;
  100010. private _onAfterRenderObserver;
  100011. /** Sets a function to be executed after rendering this scene */
  100012. afterRender: Nullable<() => void>;
  100013. /**
  100014. * An event triggered before animating the scene
  100015. */
  100016. onBeforeAnimationsObservable: Observable<Scene>;
  100017. /**
  100018. * An event triggered after animations processing
  100019. */
  100020. onAfterAnimationsObservable: Observable<Scene>;
  100021. /**
  100022. * An event triggered before draw calls are ready to be sent
  100023. */
  100024. onBeforeDrawPhaseObservable: Observable<Scene>;
  100025. /**
  100026. * An event triggered after draw calls have been sent
  100027. */
  100028. onAfterDrawPhaseObservable: Observable<Scene>;
  100029. /**
  100030. * An event triggered when the scene is ready
  100031. */
  100032. onReadyObservable: Observable<Scene>;
  100033. /**
  100034. * An event triggered before rendering a camera
  100035. */
  100036. onBeforeCameraRenderObservable: Observable<Camera>;
  100037. private _onBeforeCameraRenderObserver;
  100038. /** Sets a function to be executed before rendering a camera*/
  100039. beforeCameraRender: () => void;
  100040. /**
  100041. * An event triggered after rendering a camera
  100042. */
  100043. onAfterCameraRenderObservable: Observable<Camera>;
  100044. private _onAfterCameraRenderObserver;
  100045. /** Sets a function to be executed after rendering a camera*/
  100046. afterCameraRender: () => void;
  100047. /**
  100048. * An event triggered when active meshes evaluation is about to start
  100049. */
  100050. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  100051. /**
  100052. * An event triggered when active meshes evaluation is done
  100053. */
  100054. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  100055. /**
  100056. * An event triggered when particles rendering is about to start
  100057. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100058. */
  100059. onBeforeParticlesRenderingObservable: Observable<Scene>;
  100060. /**
  100061. * An event triggered when particles rendering is done
  100062. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  100063. */
  100064. onAfterParticlesRenderingObservable: Observable<Scene>;
  100065. /**
  100066. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  100067. */
  100068. onDataLoadedObservable: Observable<Scene>;
  100069. /**
  100070. * An event triggered when a camera is created
  100071. */
  100072. onNewCameraAddedObservable: Observable<Camera>;
  100073. /**
  100074. * An event triggered when a camera is removed
  100075. */
  100076. onCameraRemovedObservable: Observable<Camera>;
  100077. /**
  100078. * An event triggered when a light is created
  100079. */
  100080. onNewLightAddedObservable: Observable<Light>;
  100081. /**
  100082. * An event triggered when a light is removed
  100083. */
  100084. onLightRemovedObservable: Observable<Light>;
  100085. /**
  100086. * An event triggered when a geometry is created
  100087. */
  100088. onNewGeometryAddedObservable: Observable<Geometry>;
  100089. /**
  100090. * An event triggered when a geometry is removed
  100091. */
  100092. onGeometryRemovedObservable: Observable<Geometry>;
  100093. /**
  100094. * An event triggered when a transform node is created
  100095. */
  100096. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  100097. /**
  100098. * An event triggered when a transform node is removed
  100099. */
  100100. onTransformNodeRemovedObservable: Observable<TransformNode>;
  100101. /**
  100102. * An event triggered when a mesh is created
  100103. */
  100104. onNewMeshAddedObservable: Observable<AbstractMesh>;
  100105. /**
  100106. * An event triggered when a mesh is removed
  100107. */
  100108. onMeshRemovedObservable: Observable<AbstractMesh>;
  100109. /**
  100110. * An event triggered when a skeleton is created
  100111. */
  100112. onNewSkeletonAddedObservable: Observable<Skeleton>;
  100113. /**
  100114. * An event triggered when a skeleton is removed
  100115. */
  100116. onSkeletonRemovedObservable: Observable<Skeleton>;
  100117. /**
  100118. * An event triggered when a material is created
  100119. */
  100120. onNewMaterialAddedObservable: Observable<Material>;
  100121. /**
  100122. * An event triggered when a material is removed
  100123. */
  100124. onMaterialRemovedObservable: Observable<Material>;
  100125. /**
  100126. * An event triggered when a texture is created
  100127. */
  100128. onNewTextureAddedObservable: Observable<BaseTexture>;
  100129. /**
  100130. * An event triggered when a texture is removed
  100131. */
  100132. onTextureRemovedObservable: Observable<BaseTexture>;
  100133. /**
  100134. * An event triggered when render targets are about to be rendered
  100135. * Can happen multiple times per frame.
  100136. */
  100137. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  100138. /**
  100139. * An event triggered when render targets were rendered.
  100140. * Can happen multiple times per frame.
  100141. */
  100142. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  100143. /**
  100144. * An event triggered before calculating deterministic simulation step
  100145. */
  100146. onBeforeStepObservable: Observable<Scene>;
  100147. /**
  100148. * An event triggered after calculating deterministic simulation step
  100149. */
  100150. onAfterStepObservable: Observable<Scene>;
  100151. /**
  100152. * An event triggered when the activeCamera property is updated
  100153. */
  100154. onActiveCameraChanged: Observable<Scene>;
  100155. /**
  100156. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  100157. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100158. * 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)
  100159. */
  100160. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100161. /**
  100162. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  100163. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  100164. * 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)
  100165. */
  100166. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  100167. /**
  100168. * This Observable will when a mesh has been imported into the scene.
  100169. */
  100170. onMeshImportedObservable: Observable<AbstractMesh>;
  100171. /**
  100172. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  100173. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  100174. */
  100175. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  100176. /** @hidden */
  100177. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  100178. /**
  100179. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  100180. */
  100181. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  100182. /**
  100183. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  100184. */
  100185. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  100186. /**
  100187. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  100188. */
  100189. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  100190. /** Callback called when a pointer move is detected */
  100191. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100192. /** Callback called when a pointer down is detected */
  100193. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  100194. /** Callback called when a pointer up is detected */
  100195. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  100196. /** Callback called when a pointer pick is detected */
  100197. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  100198. /**
  100199. * 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).
  100200. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  100201. */
  100202. onPrePointerObservable: Observable<PointerInfoPre>;
  100203. /**
  100204. * Observable event triggered each time an input event is received from the rendering canvas
  100205. */
  100206. onPointerObservable: Observable<PointerInfo>;
  100207. /**
  100208. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  100209. */
  100210. readonly unTranslatedPointer: Vector2;
  100211. /**
  100212. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  100213. */
  100214. static DragMovementThreshold: number;
  100215. /**
  100216. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  100217. */
  100218. static LongPressDelay: number;
  100219. /**
  100220. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  100221. */
  100222. static DoubleClickDelay: number;
  100223. /** If you need to check double click without raising a single click at first click, enable this flag */
  100224. static ExclusiveDoubleClickMode: boolean;
  100225. /** @hidden */
  100226. _mirroredCameraPosition: Nullable<Vector3>;
  100227. /**
  100228. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  100229. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  100230. */
  100231. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  100232. /**
  100233. * Observable event triggered each time an keyboard event is received from the hosting window
  100234. */
  100235. onKeyboardObservable: Observable<KeyboardInfo>;
  100236. private _useRightHandedSystem;
  100237. /**
  100238. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  100239. */
  100240. useRightHandedSystem: boolean;
  100241. private _timeAccumulator;
  100242. private _currentStepId;
  100243. private _currentInternalStep;
  100244. /**
  100245. * Sets the step Id used by deterministic lock step
  100246. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100247. * @param newStepId defines the step Id
  100248. */
  100249. setStepId(newStepId: number): void;
  100250. /**
  100251. * Gets the step Id used by deterministic lock step
  100252. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100253. * @returns the step Id
  100254. */
  100255. getStepId(): number;
  100256. /**
  100257. * Gets the internal step used by deterministic lock step
  100258. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100259. * @returns the internal step
  100260. */
  100261. getInternalStep(): number;
  100262. private _fogEnabled;
  100263. /**
  100264. * Gets or sets a boolean indicating if fog is enabled on this scene
  100265. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100266. * (Default is true)
  100267. */
  100268. fogEnabled: boolean;
  100269. private _fogMode;
  100270. /**
  100271. * Gets or sets the fog mode to use
  100272. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100273. * | mode | value |
  100274. * | --- | --- |
  100275. * | FOGMODE_NONE | 0 |
  100276. * | FOGMODE_EXP | 1 |
  100277. * | FOGMODE_EXP2 | 2 |
  100278. * | FOGMODE_LINEAR | 3 |
  100279. */
  100280. fogMode: number;
  100281. /**
  100282. * Gets or sets the fog color to use
  100283. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100284. * (Default is Color3(0.2, 0.2, 0.3))
  100285. */
  100286. fogColor: Color3;
  100287. /**
  100288. * Gets or sets the fog density to use
  100289. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100290. * (Default is 0.1)
  100291. */
  100292. fogDensity: number;
  100293. /**
  100294. * Gets or sets the fog start distance to use
  100295. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100296. * (Default is 0)
  100297. */
  100298. fogStart: number;
  100299. /**
  100300. * Gets or sets the fog end distance to use
  100301. * @see http://doc.babylonjs.com/babylon101/environment#fog
  100302. * (Default is 1000)
  100303. */
  100304. fogEnd: number;
  100305. private _shadowsEnabled;
  100306. /**
  100307. * Gets or sets a boolean indicating if shadows are enabled on this scene
  100308. */
  100309. shadowsEnabled: boolean;
  100310. private _lightsEnabled;
  100311. /**
  100312. * Gets or sets a boolean indicating if lights are enabled on this scene
  100313. */
  100314. lightsEnabled: boolean;
  100315. /** All of the active cameras added to this scene. */
  100316. activeCameras: Camera[];
  100317. /** @hidden */
  100318. _activeCamera: Nullable<Camera>;
  100319. /** Gets or sets the current active camera */
  100320. activeCamera: Nullable<Camera>;
  100321. private _defaultMaterial;
  100322. /** The default material used on meshes when no material is affected */
  100323. /** The default material used on meshes when no material is affected */
  100324. defaultMaterial: Material;
  100325. private _texturesEnabled;
  100326. /**
  100327. * Gets or sets a boolean indicating if textures are enabled on this scene
  100328. */
  100329. texturesEnabled: boolean;
  100330. /**
  100331. * Gets or sets a boolean indicating if particles are enabled on this scene
  100332. */
  100333. particlesEnabled: boolean;
  100334. /**
  100335. * Gets or sets a boolean indicating if sprites are enabled on this scene
  100336. */
  100337. spritesEnabled: boolean;
  100338. private _skeletonsEnabled;
  100339. /**
  100340. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  100341. */
  100342. skeletonsEnabled: boolean;
  100343. /**
  100344. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  100345. */
  100346. lensFlaresEnabled: boolean;
  100347. /**
  100348. * Gets or sets a boolean indicating if collisions are enabled on this scene
  100349. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100350. */
  100351. collisionsEnabled: boolean;
  100352. private _collisionCoordinator;
  100353. /** @hidden */
  100354. readonly collisionCoordinator: ICollisionCoordinator;
  100355. /**
  100356. * Defines the gravity applied to this scene (used only for collisions)
  100357. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  100358. */
  100359. gravity: Vector3;
  100360. /**
  100361. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  100362. */
  100363. postProcessesEnabled: boolean;
  100364. /**
  100365. * The list of postprocesses added to the scene
  100366. */
  100367. postProcesses: PostProcess[];
  100368. /**
  100369. * Gets the current postprocess manager
  100370. */
  100371. postProcessManager: PostProcessManager;
  100372. /**
  100373. * Gets or sets a boolean indicating if render targets are enabled on this scene
  100374. */
  100375. renderTargetsEnabled: boolean;
  100376. /**
  100377. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  100378. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  100379. */
  100380. dumpNextRenderTargets: boolean;
  100381. /**
  100382. * The list of user defined render targets added to the scene
  100383. */
  100384. customRenderTargets: RenderTargetTexture[];
  100385. /**
  100386. * Defines if texture loading must be delayed
  100387. * If true, textures will only be loaded when they need to be rendered
  100388. */
  100389. useDelayedTextureLoading: boolean;
  100390. /**
  100391. * Gets the list of meshes imported to the scene through SceneLoader
  100392. */
  100393. importedMeshesFiles: String[];
  100394. /**
  100395. * Gets or sets a boolean indicating if probes are enabled on this scene
  100396. */
  100397. probesEnabled: boolean;
  100398. /**
  100399. * Gets or sets the current offline provider to use to store scene data
  100400. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  100401. */
  100402. offlineProvider: IOfflineProvider;
  100403. /**
  100404. * Gets or sets the action manager associated with the scene
  100405. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  100406. */
  100407. actionManager: AbstractActionManager;
  100408. private _meshesForIntersections;
  100409. /**
  100410. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  100411. */
  100412. proceduralTexturesEnabled: boolean;
  100413. private _engine;
  100414. private _totalVertices;
  100415. /** @hidden */
  100416. _activeIndices: PerfCounter;
  100417. /** @hidden */
  100418. _activeParticles: PerfCounter;
  100419. /** @hidden */
  100420. _activeBones: PerfCounter;
  100421. private _animationRatio;
  100422. /** @hidden */
  100423. _animationTimeLast: number;
  100424. /** @hidden */
  100425. _animationTime: number;
  100426. /**
  100427. * Gets or sets a general scale for animation speed
  100428. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  100429. */
  100430. animationTimeScale: number;
  100431. /** @hidden */
  100432. _cachedMaterial: Nullable<Material>;
  100433. /** @hidden */
  100434. _cachedEffect: Nullable<Effect>;
  100435. /** @hidden */
  100436. _cachedVisibility: Nullable<number>;
  100437. private _renderId;
  100438. private _frameId;
  100439. private _executeWhenReadyTimeoutId;
  100440. private _intermediateRendering;
  100441. private _viewUpdateFlag;
  100442. private _projectionUpdateFlag;
  100443. /** @hidden */
  100444. _toBeDisposed: Nullable<IDisposable>[];
  100445. private _activeRequests;
  100446. /** @hidden */
  100447. _pendingData: any[];
  100448. private _isDisposed;
  100449. /**
  100450. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  100451. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  100452. */
  100453. dispatchAllSubMeshesOfActiveMeshes: boolean;
  100454. private _activeMeshes;
  100455. private _processedMaterials;
  100456. private _renderTargets;
  100457. /** @hidden */
  100458. _activeParticleSystems: SmartArray<IParticleSystem>;
  100459. private _activeSkeletons;
  100460. private _softwareSkinnedMeshes;
  100461. private _renderingManager;
  100462. /** @hidden */
  100463. _activeAnimatables: Animatable[];
  100464. private _transformMatrix;
  100465. private _sceneUbo;
  100466. /** @hidden */
  100467. _viewMatrix: Matrix;
  100468. private _projectionMatrix;
  100469. /** @hidden */
  100470. _forcedViewPosition: Nullable<Vector3>;
  100471. /** @hidden */
  100472. _frustumPlanes: Plane[];
  100473. /**
  100474. * Gets the list of frustum planes (built from the active camera)
  100475. */
  100476. readonly frustumPlanes: Plane[];
  100477. /**
  100478. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  100479. * This is useful if there are more lights that the maximum simulteanous authorized
  100480. */
  100481. requireLightSorting: boolean;
  100482. /** @hidden */
  100483. readonly useMaterialMeshMap: boolean;
  100484. /** @hidden */
  100485. readonly useClonedMeshhMap: boolean;
  100486. private _externalData;
  100487. private _uid;
  100488. /**
  100489. * @hidden
  100490. * Backing store of defined scene components.
  100491. */
  100492. _components: ISceneComponent[];
  100493. /**
  100494. * @hidden
  100495. * Backing store of defined scene components.
  100496. */
  100497. _serializableComponents: ISceneSerializableComponent[];
  100498. /**
  100499. * List of components to register on the next registration step.
  100500. */
  100501. private _transientComponents;
  100502. /**
  100503. * Registers the transient components if needed.
  100504. */
  100505. private _registerTransientComponents;
  100506. /**
  100507. * @hidden
  100508. * Add a component to the scene.
  100509. * Note that the ccomponent could be registered on th next frame if this is called after
  100510. * the register component stage.
  100511. * @param component Defines the component to add to the scene
  100512. */
  100513. _addComponent(component: ISceneComponent): void;
  100514. /**
  100515. * @hidden
  100516. * Gets a component from the scene.
  100517. * @param name defines the name of the component to retrieve
  100518. * @returns the component or null if not present
  100519. */
  100520. _getComponent(name: string): Nullable<ISceneComponent>;
  100521. /**
  100522. * @hidden
  100523. * Defines the actions happening before camera updates.
  100524. */
  100525. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  100526. /**
  100527. * @hidden
  100528. * Defines the actions happening before clear the canvas.
  100529. */
  100530. _beforeClearStage: Stage<SimpleStageAction>;
  100531. /**
  100532. * @hidden
  100533. * Defines the actions when collecting render targets for the frame.
  100534. */
  100535. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100536. /**
  100537. * @hidden
  100538. * Defines the actions happening for one camera in the frame.
  100539. */
  100540. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  100541. /**
  100542. * @hidden
  100543. * Defines the actions happening during the per mesh ready checks.
  100544. */
  100545. _isReadyForMeshStage: Stage<MeshStageAction>;
  100546. /**
  100547. * @hidden
  100548. * Defines the actions happening before evaluate active mesh checks.
  100549. */
  100550. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  100551. /**
  100552. * @hidden
  100553. * Defines the actions happening during the evaluate sub mesh checks.
  100554. */
  100555. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  100556. /**
  100557. * @hidden
  100558. * Defines the actions happening during the active mesh stage.
  100559. */
  100560. _activeMeshStage: Stage<ActiveMeshStageAction>;
  100561. /**
  100562. * @hidden
  100563. * Defines the actions happening during the per camera render target step.
  100564. */
  100565. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  100566. /**
  100567. * @hidden
  100568. * Defines the actions happening just before the active camera is drawing.
  100569. */
  100570. _beforeCameraDrawStage: Stage<CameraStageAction>;
  100571. /**
  100572. * @hidden
  100573. * Defines the actions happening just before a render target is drawing.
  100574. */
  100575. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100576. /**
  100577. * @hidden
  100578. * Defines the actions happening just before a rendering group is drawing.
  100579. */
  100580. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100581. /**
  100582. * @hidden
  100583. * Defines the actions happening just before a mesh is drawing.
  100584. */
  100585. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100586. /**
  100587. * @hidden
  100588. * Defines the actions happening just after a mesh has been drawn.
  100589. */
  100590. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  100591. /**
  100592. * @hidden
  100593. * Defines the actions happening just after a rendering group has been drawn.
  100594. */
  100595. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  100596. /**
  100597. * @hidden
  100598. * Defines the actions happening just after the active camera has been drawn.
  100599. */
  100600. _afterCameraDrawStage: Stage<CameraStageAction>;
  100601. /**
  100602. * @hidden
  100603. * Defines the actions happening just after a render target has been drawn.
  100604. */
  100605. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  100606. /**
  100607. * @hidden
  100608. * Defines the actions happening just after rendering all cameras and computing intersections.
  100609. */
  100610. _afterRenderStage: Stage<SimpleStageAction>;
  100611. /**
  100612. * @hidden
  100613. * Defines the actions happening when a pointer move event happens.
  100614. */
  100615. _pointerMoveStage: Stage<PointerMoveStageAction>;
  100616. /**
  100617. * @hidden
  100618. * Defines the actions happening when a pointer down event happens.
  100619. */
  100620. _pointerDownStage: Stage<PointerUpDownStageAction>;
  100621. /**
  100622. * @hidden
  100623. * Defines the actions happening when a pointer up event happens.
  100624. */
  100625. _pointerUpStage: Stage<PointerUpDownStageAction>;
  100626. /**
  100627. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  100628. */
  100629. private geometriesByUniqueId;
  100630. /**
  100631. * Creates a new Scene
  100632. * @param engine defines the engine to use to render this scene
  100633. * @param options defines the scene options
  100634. */
  100635. constructor(engine: Engine, options?: SceneOptions);
  100636. /**
  100637. * Gets a string idenfifying the name of the class
  100638. * @returns "Scene" string
  100639. */
  100640. getClassName(): string;
  100641. private _defaultMeshCandidates;
  100642. /**
  100643. * @hidden
  100644. */
  100645. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  100646. private _defaultSubMeshCandidates;
  100647. /**
  100648. * @hidden
  100649. */
  100650. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  100651. /**
  100652. * Sets the default candidate providers for the scene.
  100653. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  100654. * and getCollidingSubMeshCandidates to their default function
  100655. */
  100656. setDefaultCandidateProviders(): void;
  100657. /**
  100658. * Gets the mesh that is currently under the pointer
  100659. */
  100660. readonly meshUnderPointer: Nullable<AbstractMesh>;
  100661. /**
  100662. * Gets or sets the current on-screen X position of the pointer
  100663. */
  100664. pointerX: number;
  100665. /**
  100666. * Gets or sets the current on-screen Y position of the pointer
  100667. */
  100668. pointerY: number;
  100669. /**
  100670. * Gets the cached material (ie. the latest rendered one)
  100671. * @returns the cached material
  100672. */
  100673. getCachedMaterial(): Nullable<Material>;
  100674. /**
  100675. * Gets the cached effect (ie. the latest rendered one)
  100676. * @returns the cached effect
  100677. */
  100678. getCachedEffect(): Nullable<Effect>;
  100679. /**
  100680. * Gets the cached visibility state (ie. the latest rendered one)
  100681. * @returns the cached visibility state
  100682. */
  100683. getCachedVisibility(): Nullable<number>;
  100684. /**
  100685. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  100686. * @param material defines the current material
  100687. * @param effect defines the current effect
  100688. * @param visibility defines the current visibility state
  100689. * @returns true if one parameter is not cached
  100690. */
  100691. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  100692. /**
  100693. * Gets the engine associated with the scene
  100694. * @returns an Engine
  100695. */
  100696. getEngine(): Engine;
  100697. /**
  100698. * Gets the total number of vertices rendered per frame
  100699. * @returns the total number of vertices rendered per frame
  100700. */
  100701. getTotalVertices(): number;
  100702. /**
  100703. * Gets the performance counter for total vertices
  100704. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100705. */
  100706. readonly totalVerticesPerfCounter: PerfCounter;
  100707. /**
  100708. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  100709. * @returns the total number of active indices rendered per frame
  100710. */
  100711. getActiveIndices(): number;
  100712. /**
  100713. * Gets the performance counter for active indices
  100714. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100715. */
  100716. readonly totalActiveIndicesPerfCounter: PerfCounter;
  100717. /**
  100718. * Gets the total number of active particles rendered per frame
  100719. * @returns the total number of active particles rendered per frame
  100720. */
  100721. getActiveParticles(): number;
  100722. /**
  100723. * Gets the performance counter for active particles
  100724. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100725. */
  100726. readonly activeParticlesPerfCounter: PerfCounter;
  100727. /**
  100728. * Gets the total number of active bones rendered per frame
  100729. * @returns the total number of active bones rendered per frame
  100730. */
  100731. getActiveBones(): number;
  100732. /**
  100733. * Gets the performance counter for active bones
  100734. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  100735. */
  100736. readonly activeBonesPerfCounter: PerfCounter;
  100737. /**
  100738. * Gets the array of active meshes
  100739. * @returns an array of AbstractMesh
  100740. */
  100741. getActiveMeshes(): SmartArray<AbstractMesh>;
  100742. /**
  100743. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  100744. * @returns a number
  100745. */
  100746. getAnimationRatio(): number;
  100747. /**
  100748. * Gets an unique Id for the current render phase
  100749. * @returns a number
  100750. */
  100751. getRenderId(): number;
  100752. /**
  100753. * Gets an unique Id for the current frame
  100754. * @returns a number
  100755. */
  100756. getFrameId(): number;
  100757. /** Call this function if you want to manually increment the render Id*/
  100758. incrementRenderId(): void;
  100759. private _createUbo;
  100760. /**
  100761. * Use this method to simulate a pointer move on a mesh
  100762. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100763. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100764. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100765. * @returns the current scene
  100766. */
  100767. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100768. /**
  100769. * Use this method to simulate a pointer down on a mesh
  100770. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100771. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100772. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100773. * @returns the current scene
  100774. */
  100775. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  100776. /**
  100777. * Use this method to simulate a pointer up on a mesh
  100778. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  100779. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  100780. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  100781. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  100782. * @returns the current scene
  100783. */
  100784. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  100785. /**
  100786. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  100787. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  100788. * @returns true if the pointer was captured
  100789. */
  100790. isPointerCaptured(pointerId?: number): boolean;
  100791. /**
  100792. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  100793. * @param attachUp defines if you want to attach events to pointerup
  100794. * @param attachDown defines if you want to attach events to pointerdown
  100795. * @param attachMove defines if you want to attach events to pointermove
  100796. */
  100797. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  100798. /** Detaches all event handlers*/
  100799. detachControl(): void;
  100800. /**
  100801. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  100802. * Delay loaded resources are not taking in account
  100803. * @return true if all required resources are ready
  100804. */
  100805. isReady(): boolean;
  100806. /** Resets all cached information relative to material (including effect and visibility) */
  100807. resetCachedMaterial(): void;
  100808. /**
  100809. * Registers a function to be called before every frame render
  100810. * @param func defines the function to register
  100811. */
  100812. registerBeforeRender(func: () => void): void;
  100813. /**
  100814. * Unregisters a function called before every frame render
  100815. * @param func defines the function to unregister
  100816. */
  100817. unregisterBeforeRender(func: () => void): void;
  100818. /**
  100819. * Registers a function to be called after every frame render
  100820. * @param func defines the function to register
  100821. */
  100822. registerAfterRender(func: () => void): void;
  100823. /**
  100824. * Unregisters a function called after every frame render
  100825. * @param func defines the function to unregister
  100826. */
  100827. unregisterAfterRender(func: () => void): void;
  100828. private _executeOnceBeforeRender;
  100829. /**
  100830. * The provided function will run before render once and will be disposed afterwards.
  100831. * A timeout delay can be provided so that the function will be executed in N ms.
  100832. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  100833. * @param func The function to be executed.
  100834. * @param timeout optional delay in ms
  100835. */
  100836. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  100837. /** @hidden */
  100838. _addPendingData(data: any): void;
  100839. /** @hidden */
  100840. _removePendingData(data: any): void;
  100841. /**
  100842. * Returns the number of items waiting to be loaded
  100843. * @returns the number of items waiting to be loaded
  100844. */
  100845. getWaitingItemsCount(): number;
  100846. /**
  100847. * Returns a boolean indicating if the scene is still loading data
  100848. */
  100849. readonly isLoading: boolean;
  100850. /**
  100851. * Registers a function to be executed when the scene is ready
  100852. * @param {Function} func - the function to be executed
  100853. */
  100854. executeWhenReady(func: () => void): void;
  100855. /**
  100856. * Returns a promise that resolves when the scene is ready
  100857. * @returns A promise that resolves when the scene is ready
  100858. */
  100859. whenReadyAsync(): Promise<void>;
  100860. /** @hidden */
  100861. _checkIsReady(): void;
  100862. /**
  100863. * Gets all animatable attached to the scene
  100864. */
  100865. readonly animatables: Animatable[];
  100866. /**
  100867. * Resets the last animation time frame.
  100868. * Useful to override when animations start running when loading a scene for the first time.
  100869. */
  100870. resetLastAnimationTimeFrame(): void;
  100871. /**
  100872. * Gets the current view matrix
  100873. * @returns a Matrix
  100874. */
  100875. getViewMatrix(): Matrix;
  100876. /**
  100877. * Gets the current projection matrix
  100878. * @returns a Matrix
  100879. */
  100880. getProjectionMatrix(): Matrix;
  100881. /**
  100882. * Gets the current transform matrix
  100883. * @returns a Matrix made of View * Projection
  100884. */
  100885. getTransformMatrix(): Matrix;
  100886. /**
  100887. * Sets the current transform matrix
  100888. * @param viewL defines the View matrix to use
  100889. * @param projectionL defines the Projection matrix to use
  100890. * @param viewR defines the right View matrix to use (if provided)
  100891. * @param projectionR defines the right Projection matrix to use (if provided)
  100892. */
  100893. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  100894. /**
  100895. * Gets the uniform buffer used to store scene data
  100896. * @returns a UniformBuffer
  100897. */
  100898. getSceneUniformBuffer(): UniformBuffer;
  100899. /**
  100900. * Gets an unique (relatively to the current scene) Id
  100901. * @returns an unique number for the scene
  100902. */
  100903. getUniqueId(): number;
  100904. /**
  100905. * Add a mesh to the list of scene's meshes
  100906. * @param newMesh defines the mesh to add
  100907. * @param recursive if all child meshes should also be added to the scene
  100908. */
  100909. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  100910. /**
  100911. * Remove a mesh for the list of scene's meshes
  100912. * @param toRemove defines the mesh to remove
  100913. * @param recursive if all child meshes should also be removed from the scene
  100914. * @returns the index where the mesh was in the mesh list
  100915. */
  100916. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  100917. /**
  100918. * Add a transform node to the list of scene's transform nodes
  100919. * @param newTransformNode defines the transform node to add
  100920. */
  100921. addTransformNode(newTransformNode: TransformNode): void;
  100922. /**
  100923. * Remove a transform node for the list of scene's transform nodes
  100924. * @param toRemove defines the transform node to remove
  100925. * @returns the index where the transform node was in the transform node list
  100926. */
  100927. removeTransformNode(toRemove: TransformNode): number;
  100928. /**
  100929. * Remove a skeleton for the list of scene's skeletons
  100930. * @param toRemove defines the skeleton to remove
  100931. * @returns the index where the skeleton was in the skeleton list
  100932. */
  100933. removeSkeleton(toRemove: Skeleton): number;
  100934. /**
  100935. * Remove a morph target for the list of scene's morph targets
  100936. * @param toRemove defines the morph target to remove
  100937. * @returns the index where the morph target was in the morph target list
  100938. */
  100939. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  100940. /**
  100941. * Remove a light for the list of scene's lights
  100942. * @param toRemove defines the light to remove
  100943. * @returns the index where the light was in the light list
  100944. */
  100945. removeLight(toRemove: Light): number;
  100946. /**
  100947. * Remove a camera for the list of scene's cameras
  100948. * @param toRemove defines the camera to remove
  100949. * @returns the index where the camera was in the camera list
  100950. */
  100951. removeCamera(toRemove: Camera): number;
  100952. /**
  100953. * Remove a particle system for the list of scene's particle systems
  100954. * @param toRemove defines the particle system to remove
  100955. * @returns the index where the particle system was in the particle system list
  100956. */
  100957. removeParticleSystem(toRemove: IParticleSystem): number;
  100958. /**
  100959. * Remove a animation for the list of scene's animations
  100960. * @param toRemove defines the animation to remove
  100961. * @returns the index where the animation was in the animation list
  100962. */
  100963. removeAnimation(toRemove: Animation): number;
  100964. /**
  100965. * Will stop the animation of the given target
  100966. * @param target - the target
  100967. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  100968. * @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)
  100969. */
  100970. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  100971. /**
  100972. * Removes the given animation group from this scene.
  100973. * @param toRemove The animation group to remove
  100974. * @returns The index of the removed animation group
  100975. */
  100976. removeAnimationGroup(toRemove: AnimationGroup): number;
  100977. /**
  100978. * Removes the given multi-material from this scene.
  100979. * @param toRemove The multi-material to remove
  100980. * @returns The index of the removed multi-material
  100981. */
  100982. removeMultiMaterial(toRemove: MultiMaterial): number;
  100983. /**
  100984. * Removes the given material from this scene.
  100985. * @param toRemove The material to remove
  100986. * @returns The index of the removed material
  100987. */
  100988. removeMaterial(toRemove: Material): number;
  100989. /**
  100990. * Removes the given action manager from this scene.
  100991. * @param toRemove The action manager to remove
  100992. * @returns The index of the removed action manager
  100993. */
  100994. removeActionManager(toRemove: AbstractActionManager): number;
  100995. /**
  100996. * Removes the given texture from this scene.
  100997. * @param toRemove The texture to remove
  100998. * @returns The index of the removed texture
  100999. */
  101000. removeTexture(toRemove: BaseTexture): number;
  101001. /**
  101002. * Adds the given light to this scene
  101003. * @param newLight The light to add
  101004. */
  101005. addLight(newLight: Light): void;
  101006. /**
  101007. * Sorts the list list based on light priorities
  101008. */
  101009. sortLightsByPriority(): void;
  101010. /**
  101011. * Adds the given camera to this scene
  101012. * @param newCamera The camera to add
  101013. */
  101014. addCamera(newCamera: Camera): void;
  101015. /**
  101016. * Adds the given skeleton to this scene
  101017. * @param newSkeleton The skeleton to add
  101018. */
  101019. addSkeleton(newSkeleton: Skeleton): void;
  101020. /**
  101021. * Adds the given particle system to this scene
  101022. * @param newParticleSystem The particle system to add
  101023. */
  101024. addParticleSystem(newParticleSystem: IParticleSystem): void;
  101025. /**
  101026. * Adds the given animation to this scene
  101027. * @param newAnimation The animation to add
  101028. */
  101029. addAnimation(newAnimation: Animation): void;
  101030. /**
  101031. * Adds the given animation group to this scene.
  101032. * @param newAnimationGroup The animation group to add
  101033. */
  101034. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  101035. /**
  101036. * Adds the given multi-material to this scene
  101037. * @param newMultiMaterial The multi-material to add
  101038. */
  101039. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  101040. /**
  101041. * Adds the given material to this scene
  101042. * @param newMaterial The material to add
  101043. */
  101044. addMaterial(newMaterial: Material): void;
  101045. /**
  101046. * Adds the given morph target to this scene
  101047. * @param newMorphTargetManager The morph target to add
  101048. */
  101049. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  101050. /**
  101051. * Adds the given geometry to this scene
  101052. * @param newGeometry The geometry to add
  101053. */
  101054. addGeometry(newGeometry: Geometry): void;
  101055. /**
  101056. * Adds the given action manager to this scene
  101057. * @param newActionManager The action manager to add
  101058. */
  101059. addActionManager(newActionManager: AbstractActionManager): void;
  101060. /**
  101061. * Adds the given texture to this scene.
  101062. * @param newTexture The texture to add
  101063. */
  101064. addTexture(newTexture: BaseTexture): void;
  101065. /**
  101066. * Switch active camera
  101067. * @param newCamera defines the new active camera
  101068. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  101069. */
  101070. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  101071. /**
  101072. * sets the active camera of the scene using its ID
  101073. * @param id defines the camera's ID
  101074. * @return the new active camera or null if none found.
  101075. */
  101076. setActiveCameraByID(id: string): Nullable<Camera>;
  101077. /**
  101078. * sets the active camera of the scene using its name
  101079. * @param name defines the camera's name
  101080. * @returns the new active camera or null if none found.
  101081. */
  101082. setActiveCameraByName(name: string): Nullable<Camera>;
  101083. /**
  101084. * get an animation group using its name
  101085. * @param name defines the material's name
  101086. * @return the animation group or null if none found.
  101087. */
  101088. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  101089. /**
  101090. * Get a material using its unique id
  101091. * @param uniqueId defines the material's unique id
  101092. * @return the material or null if none found.
  101093. */
  101094. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  101095. /**
  101096. * get a material using its id
  101097. * @param id defines the material's ID
  101098. * @return the material or null if none found.
  101099. */
  101100. getMaterialByID(id: string): Nullable<Material>;
  101101. /**
  101102. * Gets a the last added material using a given id
  101103. * @param id defines the material's ID
  101104. * @return the last material with the given id or null if none found.
  101105. */
  101106. getLastMaterialByID(id: string): Nullable<Material>;
  101107. /**
  101108. * Gets a material using its name
  101109. * @param name defines the material's name
  101110. * @return the material or null if none found.
  101111. */
  101112. getMaterialByName(name: string): Nullable<Material>;
  101113. /**
  101114. * Get a texture using its unique id
  101115. * @param uniqueId defines the texture's unique id
  101116. * @return the texture or null if none found.
  101117. */
  101118. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  101119. /**
  101120. * Gets a camera using its id
  101121. * @param id defines the id to look for
  101122. * @returns the camera or null if not found
  101123. */
  101124. getCameraByID(id: string): Nullable<Camera>;
  101125. /**
  101126. * Gets a camera using its unique id
  101127. * @param uniqueId defines the unique id to look for
  101128. * @returns the camera or null if not found
  101129. */
  101130. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  101131. /**
  101132. * Gets a camera using its name
  101133. * @param name defines the camera's name
  101134. * @return the camera or null if none found.
  101135. */
  101136. getCameraByName(name: string): Nullable<Camera>;
  101137. /**
  101138. * Gets a bone using its id
  101139. * @param id defines the bone's id
  101140. * @return the bone or null if not found
  101141. */
  101142. getBoneByID(id: string): Nullable<Bone>;
  101143. /**
  101144. * Gets a bone using its id
  101145. * @param name defines the bone's name
  101146. * @return the bone or null if not found
  101147. */
  101148. getBoneByName(name: string): Nullable<Bone>;
  101149. /**
  101150. * Gets a light node using its name
  101151. * @param name defines the the light's name
  101152. * @return the light or null if none found.
  101153. */
  101154. getLightByName(name: string): Nullable<Light>;
  101155. /**
  101156. * Gets a light node using its id
  101157. * @param id defines the light's id
  101158. * @return the light or null if none found.
  101159. */
  101160. getLightByID(id: string): Nullable<Light>;
  101161. /**
  101162. * Gets a light node using its scene-generated unique ID
  101163. * @param uniqueId defines the light's unique id
  101164. * @return the light or null if none found.
  101165. */
  101166. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  101167. /**
  101168. * Gets a particle system by id
  101169. * @param id defines the particle system id
  101170. * @return the corresponding system or null if none found
  101171. */
  101172. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  101173. /**
  101174. * Gets a geometry using its ID
  101175. * @param id defines the geometry's id
  101176. * @return the geometry or null if none found.
  101177. */
  101178. getGeometryByID(id: string): Nullable<Geometry>;
  101179. private _getGeometryByUniqueID;
  101180. /**
  101181. * Add a new geometry to this scene
  101182. * @param geometry defines the geometry to be added to the scene.
  101183. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  101184. * @return a boolean defining if the geometry was added or not
  101185. */
  101186. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  101187. /**
  101188. * Removes an existing geometry
  101189. * @param geometry defines the geometry to be removed from the scene
  101190. * @return a boolean defining if the geometry was removed or not
  101191. */
  101192. removeGeometry(geometry: Geometry): boolean;
  101193. /**
  101194. * Gets the list of geometries attached to the scene
  101195. * @returns an array of Geometry
  101196. */
  101197. getGeometries(): Geometry[];
  101198. /**
  101199. * Gets the first added mesh found of a given ID
  101200. * @param id defines the id to search for
  101201. * @return the mesh found or null if not found at all
  101202. */
  101203. getMeshByID(id: string): Nullable<AbstractMesh>;
  101204. /**
  101205. * Gets a list of meshes using their id
  101206. * @param id defines the id to search for
  101207. * @returns a list of meshes
  101208. */
  101209. getMeshesByID(id: string): Array<AbstractMesh>;
  101210. /**
  101211. * Gets the first added transform node found of a given ID
  101212. * @param id defines the id to search for
  101213. * @return the found transform node or null if not found at all.
  101214. */
  101215. getTransformNodeByID(id: string): Nullable<TransformNode>;
  101216. /**
  101217. * Gets a transform node with its auto-generated unique id
  101218. * @param uniqueId efines the unique id to search for
  101219. * @return the found transform node or null if not found at all.
  101220. */
  101221. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  101222. /**
  101223. * Gets a list of transform nodes using their id
  101224. * @param id defines the id to search for
  101225. * @returns a list of transform nodes
  101226. */
  101227. getTransformNodesByID(id: string): Array<TransformNode>;
  101228. /**
  101229. * Gets a mesh with its auto-generated unique id
  101230. * @param uniqueId defines the unique id to search for
  101231. * @return the found mesh or null if not found at all.
  101232. */
  101233. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  101234. /**
  101235. * Gets a the last added mesh using a given id
  101236. * @param id defines the id to search for
  101237. * @return the found mesh or null if not found at all.
  101238. */
  101239. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  101240. /**
  101241. * Gets a the last added node (Mesh, Camera, Light) using a given id
  101242. * @param id defines the id to search for
  101243. * @return the found node or null if not found at all
  101244. */
  101245. getLastEntryByID(id: string): Nullable<Node>;
  101246. /**
  101247. * Gets a node (Mesh, Camera, Light) using a given id
  101248. * @param id defines the id to search for
  101249. * @return the found node or null if not found at all
  101250. */
  101251. getNodeByID(id: string): Nullable<Node>;
  101252. /**
  101253. * Gets a node (Mesh, Camera, Light) using a given name
  101254. * @param name defines the name to search for
  101255. * @return the found node or null if not found at all.
  101256. */
  101257. getNodeByName(name: string): Nullable<Node>;
  101258. /**
  101259. * Gets a mesh using a given name
  101260. * @param name defines the name to search for
  101261. * @return the found mesh or null if not found at all.
  101262. */
  101263. getMeshByName(name: string): Nullable<AbstractMesh>;
  101264. /**
  101265. * Gets a transform node using a given name
  101266. * @param name defines the name to search for
  101267. * @return the found transform node or null if not found at all.
  101268. */
  101269. getTransformNodeByName(name: string): Nullable<TransformNode>;
  101270. /**
  101271. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  101272. * @param id defines the id to search for
  101273. * @return the found skeleton or null if not found at all.
  101274. */
  101275. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  101276. /**
  101277. * Gets a skeleton using a given auto generated unique id
  101278. * @param uniqueId defines the unique id to search for
  101279. * @return the found skeleton or null if not found at all.
  101280. */
  101281. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  101282. /**
  101283. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  101284. * @param id defines the id to search for
  101285. * @return the found skeleton or null if not found at all.
  101286. */
  101287. getSkeletonById(id: string): Nullable<Skeleton>;
  101288. /**
  101289. * Gets a skeleton using a given name
  101290. * @param name defines the name to search for
  101291. * @return the found skeleton or null if not found at all.
  101292. */
  101293. getSkeletonByName(name: string): Nullable<Skeleton>;
  101294. /**
  101295. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  101296. * @param id defines the id to search for
  101297. * @return the found morph target manager or null if not found at all.
  101298. */
  101299. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  101300. /**
  101301. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  101302. * @param id defines the id to search for
  101303. * @return the found morph target or null if not found at all.
  101304. */
  101305. getMorphTargetById(id: string): Nullable<MorphTarget>;
  101306. /**
  101307. * Gets a boolean indicating if the given mesh is active
  101308. * @param mesh defines the mesh to look for
  101309. * @returns true if the mesh is in the active list
  101310. */
  101311. isActiveMesh(mesh: AbstractMesh): boolean;
  101312. /**
  101313. * Return a unique id as a string which can serve as an identifier for the scene
  101314. */
  101315. readonly uid: string;
  101316. /**
  101317. * Add an externaly attached data from its key.
  101318. * This method call will fail and return false, if such key already exists.
  101319. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  101320. * @param key the unique key that identifies the data
  101321. * @param data the data object to associate to the key for this Engine instance
  101322. * @return true if no such key were already present and the data was added successfully, false otherwise
  101323. */
  101324. addExternalData<T>(key: string, data: T): boolean;
  101325. /**
  101326. * Get an externaly attached data from its key
  101327. * @param key the unique key that identifies the data
  101328. * @return the associated data, if present (can be null), or undefined if not present
  101329. */
  101330. getExternalData<T>(key: string): Nullable<T>;
  101331. /**
  101332. * Get an externaly attached data from its key, create it using a factory if it's not already present
  101333. * @param key the unique key that identifies the data
  101334. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  101335. * @return the associated data, can be null if the factory returned null.
  101336. */
  101337. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  101338. /**
  101339. * Remove an externaly attached data from the Engine instance
  101340. * @param key the unique key that identifies the data
  101341. * @return true if the data was successfully removed, false if it doesn't exist
  101342. */
  101343. removeExternalData(key: string): boolean;
  101344. private _evaluateSubMesh;
  101345. /**
  101346. * Clear the processed materials smart array preventing retention point in material dispose.
  101347. */
  101348. freeProcessedMaterials(): void;
  101349. private _preventFreeActiveMeshesAndRenderingGroups;
  101350. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  101351. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  101352. * when disposing several meshes in a row or a hierarchy of meshes.
  101353. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  101354. */
  101355. blockfreeActiveMeshesAndRenderingGroups: boolean;
  101356. /**
  101357. * Clear the active meshes smart array preventing retention point in mesh dispose.
  101358. */
  101359. freeActiveMeshes(): void;
  101360. /**
  101361. * Clear the info related to rendering groups preventing retention points during dispose.
  101362. */
  101363. freeRenderingGroups(): void;
  101364. /** @hidden */
  101365. _isInIntermediateRendering(): boolean;
  101366. /**
  101367. * Lambda returning the list of potentially active meshes.
  101368. */
  101369. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  101370. /**
  101371. * Lambda returning the list of potentially active sub meshes.
  101372. */
  101373. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  101374. /**
  101375. * Lambda returning the list of potentially intersecting sub meshes.
  101376. */
  101377. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  101378. /**
  101379. * Lambda returning the list of potentially colliding sub meshes.
  101380. */
  101381. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  101382. private _activeMeshesFrozen;
  101383. /**
  101384. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  101385. * @returns the current scene
  101386. */
  101387. freezeActiveMeshes(): Scene;
  101388. /**
  101389. * Use this function to restart evaluating active meshes on every frame
  101390. * @returns the current scene
  101391. */
  101392. unfreezeActiveMeshes(): Scene;
  101393. private _evaluateActiveMeshes;
  101394. private _activeMesh;
  101395. /**
  101396. * Update the transform matrix to update from the current active camera
  101397. * @param force defines a boolean used to force the update even if cache is up to date
  101398. */
  101399. updateTransformMatrix(force?: boolean): void;
  101400. private _bindFrameBuffer;
  101401. /** @hidden */
  101402. _allowPostProcessClearColor: boolean;
  101403. /** @hidden */
  101404. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  101405. private _processSubCameras;
  101406. private _checkIntersections;
  101407. /** @hidden */
  101408. _advancePhysicsEngineStep(step: number): void;
  101409. /**
  101410. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  101411. */
  101412. getDeterministicFrameTime: () => number;
  101413. /** @hidden */
  101414. _animate(): void;
  101415. /** Execute all animations (for a frame) */
  101416. animate(): void;
  101417. /**
  101418. * Render the scene
  101419. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  101420. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  101421. */
  101422. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  101423. /**
  101424. * Freeze all materials
  101425. * A frozen material will not be updatable but should be faster to render
  101426. */
  101427. freezeMaterials(): void;
  101428. /**
  101429. * Unfreeze all materials
  101430. * A frozen material will not be updatable but should be faster to render
  101431. */
  101432. unfreezeMaterials(): void;
  101433. /**
  101434. * Releases all held ressources
  101435. */
  101436. dispose(): void;
  101437. /**
  101438. * Gets if the scene is already disposed
  101439. */
  101440. readonly isDisposed: boolean;
  101441. /**
  101442. * Call this function to reduce memory footprint of the scene.
  101443. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  101444. */
  101445. clearCachedVertexData(): void;
  101446. /**
  101447. * This function will remove the local cached buffer data from texture.
  101448. * It will save memory but will prevent the texture from being rebuilt
  101449. */
  101450. cleanCachedTextureBuffer(): void;
  101451. /**
  101452. * Get the world extend vectors with an optional filter
  101453. *
  101454. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  101455. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  101456. */
  101457. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  101458. min: Vector3;
  101459. max: Vector3;
  101460. };
  101461. /**
  101462. * Creates a ray that can be used to pick in the scene
  101463. * @param x defines the x coordinate of the origin (on-screen)
  101464. * @param y defines the y coordinate of the origin (on-screen)
  101465. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101466. * @param camera defines the camera to use for the picking
  101467. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101468. * @returns a Ray
  101469. */
  101470. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  101471. /**
  101472. * Creates a ray that can be used to pick in the scene
  101473. * @param x defines the x coordinate of the origin (on-screen)
  101474. * @param y defines the y coordinate of the origin (on-screen)
  101475. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  101476. * @param result defines the ray where to store the picking ray
  101477. * @param camera defines the camera to use for the picking
  101478. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  101479. * @returns the current scene
  101480. */
  101481. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  101482. /**
  101483. * Creates a ray that can be used to pick in the scene
  101484. * @param x defines the x coordinate of the origin (on-screen)
  101485. * @param y defines the y coordinate of the origin (on-screen)
  101486. * @param camera defines the camera to use for the picking
  101487. * @returns a Ray
  101488. */
  101489. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  101490. /**
  101491. * Creates a ray that can be used to pick in the scene
  101492. * @param x defines the x coordinate of the origin (on-screen)
  101493. * @param y defines the y coordinate of the origin (on-screen)
  101494. * @param result defines the ray where to store the picking ray
  101495. * @param camera defines the camera to use for the picking
  101496. * @returns the current scene
  101497. */
  101498. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  101499. /** Launch a ray to try to pick a mesh in the scene
  101500. * @param x position on screen
  101501. * @param y position on screen
  101502. * @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
  101503. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  101504. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101505. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101506. * @returns a PickingInfo
  101507. */
  101508. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101509. /** Use the given ray to pick a mesh in the scene
  101510. * @param ray The ray to use to pick meshes
  101511. * @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
  101512. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  101513. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101514. * @returns a PickingInfo
  101515. */
  101516. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  101517. /**
  101518. * Launch a ray to try to pick a mesh in the scene
  101519. * @param x X position on screen
  101520. * @param y Y position on screen
  101521. * @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
  101522. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  101523. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101524. * @returns an array of PickingInfo
  101525. */
  101526. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101527. /**
  101528. * Launch a ray to try to pick a mesh in the scene
  101529. * @param ray Ray to use
  101530. * @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
  101531. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  101532. * @returns an array of PickingInfo
  101533. */
  101534. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  101535. /**
  101536. * Force the value of meshUnderPointer
  101537. * @param mesh defines the mesh to use
  101538. */
  101539. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  101540. /**
  101541. * Gets the mesh under the pointer
  101542. * @returns a Mesh or null if no mesh is under the pointer
  101543. */
  101544. getPointerOverMesh(): Nullable<AbstractMesh>;
  101545. /** @hidden */
  101546. _rebuildGeometries(): void;
  101547. /** @hidden */
  101548. _rebuildTextures(): void;
  101549. private _getByTags;
  101550. /**
  101551. * Get a list of meshes by tags
  101552. * @param tagsQuery defines the tags query to use
  101553. * @param forEach defines a predicate used to filter results
  101554. * @returns an array of Mesh
  101555. */
  101556. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  101557. /**
  101558. * Get a list of cameras by tags
  101559. * @param tagsQuery defines the tags query to use
  101560. * @param forEach defines a predicate used to filter results
  101561. * @returns an array of Camera
  101562. */
  101563. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  101564. /**
  101565. * Get a list of lights by tags
  101566. * @param tagsQuery defines the tags query to use
  101567. * @param forEach defines a predicate used to filter results
  101568. * @returns an array of Light
  101569. */
  101570. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  101571. /**
  101572. * Get a list of materials by tags
  101573. * @param tagsQuery defines the tags query to use
  101574. * @param forEach defines a predicate used to filter results
  101575. * @returns an array of Material
  101576. */
  101577. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  101578. /**
  101579. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  101580. * This allowed control for front to back rendering or reversly depending of the special needs.
  101581. *
  101582. * @param renderingGroupId The rendering group id corresponding to its index
  101583. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  101584. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  101585. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  101586. */
  101587. 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;
  101588. /**
  101589. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  101590. *
  101591. * @param renderingGroupId The rendering group id corresponding to its index
  101592. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  101593. * @param depth Automatically clears depth between groups if true and autoClear is true.
  101594. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  101595. */
  101596. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  101597. /**
  101598. * Gets the current auto clear configuration for one rendering group of the rendering
  101599. * manager.
  101600. * @param index the rendering group index to get the information for
  101601. * @returns The auto clear setup for the requested rendering group
  101602. */
  101603. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  101604. private _blockMaterialDirtyMechanism;
  101605. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  101606. blockMaterialDirtyMechanism: boolean;
  101607. /**
  101608. * Will flag all materials as dirty to trigger new shader compilation
  101609. * @param flag defines the flag used to specify which material part must be marked as dirty
  101610. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  101611. */
  101612. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  101613. /** @hidden */
  101614. _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;
  101615. /** @hidden */
  101616. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  101617. }
  101618. }
  101619. declare module BABYLON {
  101620. /**
  101621. * Set of assets to keep when moving a scene into an asset container.
  101622. */
  101623. export class KeepAssets extends AbstractScene {
  101624. }
  101625. /**
  101626. * Container with a set of assets that can be added or removed from a scene.
  101627. */
  101628. export class AssetContainer extends AbstractScene {
  101629. /**
  101630. * The scene the AssetContainer belongs to.
  101631. */
  101632. scene: Scene;
  101633. /**
  101634. * Instantiates an AssetContainer.
  101635. * @param scene The scene the AssetContainer belongs to.
  101636. */
  101637. constructor(scene: Scene);
  101638. /**
  101639. * Adds all the assets from the container to the scene.
  101640. */
  101641. addAllToScene(): void;
  101642. /**
  101643. * Removes all the assets in the container from the scene
  101644. */
  101645. removeAllFromScene(): void;
  101646. /**
  101647. * Disposes all the assets in the container
  101648. */
  101649. dispose(): void;
  101650. private _moveAssets;
  101651. /**
  101652. * Removes all the assets contained in the scene and adds them to the container.
  101653. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  101654. */
  101655. moveAllFromScene(keepAssets?: KeepAssets): void;
  101656. /**
  101657. * 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.
  101658. * @returns the root mesh
  101659. */
  101660. createRootMesh(): Mesh;
  101661. }
  101662. }
  101663. declare module BABYLON {
  101664. /**
  101665. * Defines how the parser contract is defined.
  101666. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  101667. */
  101668. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  101669. /**
  101670. * Defines how the individual parser contract is defined.
  101671. * These parser can parse an individual asset
  101672. */
  101673. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  101674. /**
  101675. * Base class of the scene acting as a container for the different elements composing a scene.
  101676. * This class is dynamically extended by the different components of the scene increasing
  101677. * flexibility and reducing coupling
  101678. */
  101679. export abstract class AbstractScene {
  101680. /**
  101681. * Stores the list of available parsers in the application.
  101682. */
  101683. private static _BabylonFileParsers;
  101684. /**
  101685. * Stores the list of available individual parsers in the application.
  101686. */
  101687. private static _IndividualBabylonFileParsers;
  101688. /**
  101689. * Adds a parser in the list of available ones
  101690. * @param name Defines the name of the parser
  101691. * @param parser Defines the parser to add
  101692. */
  101693. static AddParser(name: string, parser: BabylonFileParser): void;
  101694. /**
  101695. * Gets a general parser from the list of avaialble ones
  101696. * @param name Defines the name of the parser
  101697. * @returns the requested parser or null
  101698. */
  101699. static GetParser(name: string): Nullable<BabylonFileParser>;
  101700. /**
  101701. * Adds n individual parser in the list of available ones
  101702. * @param name Defines the name of the parser
  101703. * @param parser Defines the parser to add
  101704. */
  101705. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  101706. /**
  101707. * Gets an individual parser from the list of avaialble ones
  101708. * @param name Defines the name of the parser
  101709. * @returns the requested parser or null
  101710. */
  101711. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  101712. /**
  101713. * Parser json data and populate both a scene and its associated container object
  101714. * @param jsonData Defines the data to parse
  101715. * @param scene Defines the scene to parse the data for
  101716. * @param container Defines the container attached to the parsing sequence
  101717. * @param rootUrl Defines the root url of the data
  101718. */
  101719. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  101720. /**
  101721. * Gets the list of root nodes (ie. nodes with no parent)
  101722. */
  101723. rootNodes: Node[];
  101724. /** All of the cameras added to this scene
  101725. * @see http://doc.babylonjs.com/babylon101/cameras
  101726. */
  101727. cameras: Camera[];
  101728. /**
  101729. * All of the lights added to this scene
  101730. * @see http://doc.babylonjs.com/babylon101/lights
  101731. */
  101732. lights: Light[];
  101733. /**
  101734. * All of the (abstract) meshes added to this scene
  101735. */
  101736. meshes: AbstractMesh[];
  101737. /**
  101738. * The list of skeletons added to the scene
  101739. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  101740. */
  101741. skeletons: Skeleton[];
  101742. /**
  101743. * All of the particle systems added to this scene
  101744. * @see http://doc.babylonjs.com/babylon101/particles
  101745. */
  101746. particleSystems: IParticleSystem[];
  101747. /**
  101748. * Gets a list of Animations associated with the scene
  101749. */
  101750. animations: Animation[];
  101751. /**
  101752. * All of the animation groups added to this scene
  101753. * @see http://doc.babylonjs.com/how_to/group
  101754. */
  101755. animationGroups: AnimationGroup[];
  101756. /**
  101757. * All of the multi-materials added to this scene
  101758. * @see http://doc.babylonjs.com/how_to/multi_materials
  101759. */
  101760. multiMaterials: MultiMaterial[];
  101761. /**
  101762. * All of the materials added to this scene
  101763. * In the context of a Scene, it is not supposed to be modified manually.
  101764. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  101765. * Note also that the order of the Material wihin the array is not significant and might change.
  101766. * @see http://doc.babylonjs.com/babylon101/materials
  101767. */
  101768. materials: Material[];
  101769. /**
  101770. * The list of morph target managers added to the scene
  101771. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  101772. */
  101773. morphTargetManagers: MorphTargetManager[];
  101774. /**
  101775. * The list of geometries used in the scene.
  101776. */
  101777. geometries: Geometry[];
  101778. /**
  101779. * All of the tranform nodes added to this scene
  101780. * In the context of a Scene, it is not supposed to be modified manually.
  101781. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  101782. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  101783. * @see http://doc.babylonjs.com/how_to/transformnode
  101784. */
  101785. transformNodes: TransformNode[];
  101786. /**
  101787. * ActionManagers available on the scene.
  101788. */
  101789. actionManagers: AbstractActionManager[];
  101790. /**
  101791. * Textures to keep.
  101792. */
  101793. textures: BaseTexture[];
  101794. /**
  101795. * Environment texture for the scene
  101796. */
  101797. environmentTexture: Nullable<BaseTexture>;
  101798. }
  101799. }
  101800. declare module BABYLON {
  101801. /**
  101802. * Interface used to define options for Sound class
  101803. */
  101804. export interface ISoundOptions {
  101805. /**
  101806. * Does the sound autoplay once loaded.
  101807. */
  101808. autoplay?: boolean;
  101809. /**
  101810. * Does the sound loop after it finishes playing once.
  101811. */
  101812. loop?: boolean;
  101813. /**
  101814. * Sound's volume
  101815. */
  101816. volume?: number;
  101817. /**
  101818. * Is it a spatial sound?
  101819. */
  101820. spatialSound?: boolean;
  101821. /**
  101822. * Maximum distance to hear that sound
  101823. */
  101824. maxDistance?: number;
  101825. /**
  101826. * Uses user defined attenuation function
  101827. */
  101828. useCustomAttenuation?: boolean;
  101829. /**
  101830. * Define the roll off factor of spatial sounds.
  101831. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101832. */
  101833. rolloffFactor?: number;
  101834. /**
  101835. * Define the reference distance the sound should be heard perfectly.
  101836. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101837. */
  101838. refDistance?: number;
  101839. /**
  101840. * Define the distance attenuation model the sound will follow.
  101841. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101842. */
  101843. distanceModel?: string;
  101844. /**
  101845. * Defines the playback speed (1 by default)
  101846. */
  101847. playbackRate?: number;
  101848. /**
  101849. * Defines if the sound is from a streaming source
  101850. */
  101851. streaming?: boolean;
  101852. /**
  101853. * Defines an optional length (in seconds) inside the sound file
  101854. */
  101855. length?: number;
  101856. /**
  101857. * Defines an optional offset (in seconds) inside the sound file
  101858. */
  101859. offset?: number;
  101860. /**
  101861. * If true, URLs will not be required to state the audio file codec to use.
  101862. */
  101863. skipCodecCheck?: boolean;
  101864. }
  101865. /**
  101866. * Defines a sound that can be played in the application.
  101867. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  101868. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  101869. */
  101870. export class Sound {
  101871. /**
  101872. * The name of the sound in the scene.
  101873. */
  101874. name: string;
  101875. /**
  101876. * Does the sound autoplay once loaded.
  101877. */
  101878. autoplay: boolean;
  101879. /**
  101880. * Does the sound loop after it finishes playing once.
  101881. */
  101882. loop: boolean;
  101883. /**
  101884. * Does the sound use a custom attenuation curve to simulate the falloff
  101885. * happening when the source gets further away from the camera.
  101886. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  101887. */
  101888. useCustomAttenuation: boolean;
  101889. /**
  101890. * The sound track id this sound belongs to.
  101891. */
  101892. soundTrackId: number;
  101893. /**
  101894. * Is this sound currently played.
  101895. */
  101896. isPlaying: boolean;
  101897. /**
  101898. * Is this sound currently paused.
  101899. */
  101900. isPaused: boolean;
  101901. /**
  101902. * Does this sound enables spatial sound.
  101903. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101904. */
  101905. spatialSound: boolean;
  101906. /**
  101907. * Define the reference distance the sound should be heard perfectly.
  101908. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101909. */
  101910. refDistance: number;
  101911. /**
  101912. * Define the roll off factor of spatial sounds.
  101913. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101914. */
  101915. rolloffFactor: number;
  101916. /**
  101917. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  101918. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101919. */
  101920. maxDistance: number;
  101921. /**
  101922. * Define the distance attenuation model the sound will follow.
  101923. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  101924. */
  101925. distanceModel: string;
  101926. /**
  101927. * @hidden
  101928. * Back Compat
  101929. **/
  101930. onended: () => any;
  101931. /**
  101932. * Observable event when the current playing sound finishes.
  101933. */
  101934. onEndedObservable: Observable<Sound>;
  101935. private _panningModel;
  101936. private _playbackRate;
  101937. private _streaming;
  101938. private _startTime;
  101939. private _startOffset;
  101940. private _position;
  101941. /** @hidden */
  101942. _positionInEmitterSpace: boolean;
  101943. private _localDirection;
  101944. private _volume;
  101945. private _isReadyToPlay;
  101946. private _isDirectional;
  101947. private _readyToPlayCallback;
  101948. private _audioBuffer;
  101949. private _soundSource;
  101950. private _streamingSource;
  101951. private _soundPanner;
  101952. private _soundGain;
  101953. private _inputAudioNode;
  101954. private _outputAudioNode;
  101955. private _coneInnerAngle;
  101956. private _coneOuterAngle;
  101957. private _coneOuterGain;
  101958. private _scene;
  101959. private _connectedTransformNode;
  101960. private _customAttenuationFunction;
  101961. private _registerFunc;
  101962. private _isOutputConnected;
  101963. private _htmlAudioElement;
  101964. private _urlType;
  101965. private _length?;
  101966. private _offset?;
  101967. /** @hidden */
  101968. static _SceneComponentInitialization: (scene: Scene) => void;
  101969. /**
  101970. * Create a sound and attach it to a scene
  101971. * @param name Name of your sound
  101972. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  101973. * @param scene defines the scene the sound belongs to
  101974. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  101975. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  101976. */
  101977. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  101978. /**
  101979. * Release the sound and its associated resources
  101980. */
  101981. dispose(): void;
  101982. /**
  101983. * Gets if the sounds is ready to be played or not.
  101984. * @returns true if ready, otherwise false
  101985. */
  101986. isReady(): boolean;
  101987. private _soundLoaded;
  101988. /**
  101989. * Sets the data of the sound from an audiobuffer
  101990. * @param audioBuffer The audioBuffer containing the data
  101991. */
  101992. setAudioBuffer(audioBuffer: AudioBuffer): void;
  101993. /**
  101994. * Updates the current sounds options such as maxdistance, loop...
  101995. * @param options A JSON object containing values named as the object properties
  101996. */
  101997. updateOptions(options: ISoundOptions): void;
  101998. private _createSpatialParameters;
  101999. private _updateSpatialParameters;
  102000. /**
  102001. * Switch the panning model to HRTF:
  102002. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102003. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102004. */
  102005. switchPanningModelToHRTF(): void;
  102006. /**
  102007. * Switch the panning model to Equal Power:
  102008. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102009. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102010. */
  102011. switchPanningModelToEqualPower(): void;
  102012. private _switchPanningModel;
  102013. /**
  102014. * Connect this sound to a sound track audio node like gain...
  102015. * @param soundTrackAudioNode the sound track audio node to connect to
  102016. */
  102017. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  102018. /**
  102019. * Transform this sound into a directional source
  102020. * @param coneInnerAngle Size of the inner cone in degree
  102021. * @param coneOuterAngle Size of the outer cone in degree
  102022. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  102023. */
  102024. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  102025. /**
  102026. * Gets or sets the inner angle for the directional cone.
  102027. */
  102028. /**
  102029. * Gets or sets the inner angle for the directional cone.
  102030. */
  102031. directionalConeInnerAngle: number;
  102032. /**
  102033. * Gets or sets the outer angle for the directional cone.
  102034. */
  102035. /**
  102036. * Gets or sets the outer angle for the directional cone.
  102037. */
  102038. directionalConeOuterAngle: number;
  102039. /**
  102040. * Sets the position of the emitter if spatial sound is enabled
  102041. * @param newPosition Defines the new posisiton
  102042. */
  102043. setPosition(newPosition: Vector3): void;
  102044. /**
  102045. * Sets the local direction of the emitter if spatial sound is enabled
  102046. * @param newLocalDirection Defines the new local direction
  102047. */
  102048. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  102049. private _updateDirection;
  102050. /** @hidden */
  102051. updateDistanceFromListener(): void;
  102052. /**
  102053. * Sets a new custom attenuation function for the sound.
  102054. * @param callback Defines the function used for the attenuation
  102055. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  102056. */
  102057. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  102058. /**
  102059. * Play the sound
  102060. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  102061. * @param offset (optional) Start the sound at a specific time in seconds
  102062. * @param length (optional) Sound duration (in seconds)
  102063. */
  102064. play(time?: number, offset?: number, length?: number): void;
  102065. private _onended;
  102066. /**
  102067. * Stop the sound
  102068. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  102069. */
  102070. stop(time?: number): void;
  102071. /**
  102072. * Put the sound in pause
  102073. */
  102074. pause(): void;
  102075. /**
  102076. * Sets a dedicated volume for this sounds
  102077. * @param newVolume Define the new volume of the sound
  102078. * @param time Define time for gradual change to new volume
  102079. */
  102080. setVolume(newVolume: number, time?: number): void;
  102081. /**
  102082. * Set the sound play back rate
  102083. * @param newPlaybackRate Define the playback rate the sound should be played at
  102084. */
  102085. setPlaybackRate(newPlaybackRate: number): void;
  102086. /**
  102087. * Gets the volume of the sound.
  102088. * @returns the volume of the sound
  102089. */
  102090. getVolume(): number;
  102091. /**
  102092. * Attach the sound to a dedicated mesh
  102093. * @param transformNode The transform node to connect the sound with
  102094. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102095. */
  102096. attachToMesh(transformNode: TransformNode): void;
  102097. /**
  102098. * Detach the sound from the previously attached mesh
  102099. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  102100. */
  102101. detachFromMesh(): void;
  102102. private _onRegisterAfterWorldMatrixUpdate;
  102103. /**
  102104. * Clone the current sound in the scene.
  102105. * @returns the new sound clone
  102106. */
  102107. clone(): Nullable<Sound>;
  102108. /**
  102109. * Gets the current underlying audio buffer containing the data
  102110. * @returns the audio buffer
  102111. */
  102112. getAudioBuffer(): Nullable<AudioBuffer>;
  102113. /**
  102114. * Serializes the Sound in a JSON representation
  102115. * @returns the JSON representation of the sound
  102116. */
  102117. serialize(): any;
  102118. /**
  102119. * Parse a JSON representation of a sound to innstantiate in a given scene
  102120. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  102121. * @param scene Define the scene the new parsed sound should be created in
  102122. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  102123. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  102124. * @returns the newly parsed sound
  102125. */
  102126. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  102127. }
  102128. }
  102129. declare module BABYLON {
  102130. /**
  102131. * This defines an action helpful to play a defined sound on a triggered action.
  102132. */
  102133. export class PlaySoundAction extends Action {
  102134. private _sound;
  102135. /**
  102136. * Instantiate the action
  102137. * @param triggerOptions defines the trigger options
  102138. * @param sound defines the sound to play
  102139. * @param condition defines the trigger related conditions
  102140. */
  102141. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102142. /** @hidden */
  102143. _prepare(): void;
  102144. /**
  102145. * Execute the action and play the sound.
  102146. */
  102147. execute(): void;
  102148. /**
  102149. * Serializes the actions and its related information.
  102150. * @param parent defines the object to serialize in
  102151. * @returns the serialized object
  102152. */
  102153. serialize(parent: any): any;
  102154. }
  102155. /**
  102156. * This defines an action helpful to stop a defined sound on a triggered action.
  102157. */
  102158. export class StopSoundAction extends Action {
  102159. private _sound;
  102160. /**
  102161. * Instantiate the action
  102162. * @param triggerOptions defines the trigger options
  102163. * @param sound defines the sound to stop
  102164. * @param condition defines the trigger related conditions
  102165. */
  102166. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  102167. /** @hidden */
  102168. _prepare(): void;
  102169. /**
  102170. * Execute the action and stop the sound.
  102171. */
  102172. execute(): void;
  102173. /**
  102174. * Serializes the actions and its related information.
  102175. * @param parent defines the object to serialize in
  102176. * @returns the serialized object
  102177. */
  102178. serialize(parent: any): any;
  102179. }
  102180. }
  102181. declare module BABYLON {
  102182. /**
  102183. * This defines an action responsible to change the value of a property
  102184. * by interpolating between its current value and the newly set one once triggered.
  102185. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102186. */
  102187. export class InterpolateValueAction extends Action {
  102188. /**
  102189. * Defines the path of the property where the value should be interpolated
  102190. */
  102191. propertyPath: string;
  102192. /**
  102193. * Defines the target value at the end of the interpolation.
  102194. */
  102195. value: any;
  102196. /**
  102197. * Defines the time it will take for the property to interpolate to the value.
  102198. */
  102199. duration: number;
  102200. /**
  102201. * Defines if the other scene animations should be stopped when the action has been triggered
  102202. */
  102203. stopOtherAnimations?: boolean;
  102204. /**
  102205. * Defines a callback raised once the interpolation animation has been done.
  102206. */
  102207. onInterpolationDone?: () => void;
  102208. /**
  102209. * Observable triggered once the interpolation animation has been done.
  102210. */
  102211. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  102212. private _target;
  102213. private _effectiveTarget;
  102214. private _property;
  102215. /**
  102216. * Instantiate the action
  102217. * @param triggerOptions defines the trigger options
  102218. * @param target defines the object containing the value to interpolate
  102219. * @param propertyPath defines the path to the property in the target object
  102220. * @param value defines the target value at the end of the interpolation
  102221. * @param duration deines the time it will take for the property to interpolate to the value.
  102222. * @param condition defines the trigger related conditions
  102223. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  102224. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  102225. */
  102226. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  102227. /** @hidden */
  102228. _prepare(): void;
  102229. /**
  102230. * Execute the action starts the value interpolation.
  102231. */
  102232. execute(): void;
  102233. /**
  102234. * Serializes the actions and its related information.
  102235. * @param parent defines the object to serialize in
  102236. * @returns the serialized object
  102237. */
  102238. serialize(parent: any): any;
  102239. }
  102240. }
  102241. declare module BABYLON {
  102242. /**
  102243. * Options allowed during the creation of a sound track.
  102244. */
  102245. export interface ISoundTrackOptions {
  102246. /**
  102247. * The volume the sound track should take during creation
  102248. */
  102249. volume?: number;
  102250. /**
  102251. * Define if the sound track is the main sound track of the scene
  102252. */
  102253. mainTrack?: boolean;
  102254. }
  102255. /**
  102256. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  102257. * It will be also used in a future release to apply effects on a specific track.
  102258. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102259. */
  102260. export class SoundTrack {
  102261. /**
  102262. * The unique identifier of the sound track in the scene.
  102263. */
  102264. id: number;
  102265. /**
  102266. * The list of sounds included in the sound track.
  102267. */
  102268. soundCollection: Array<Sound>;
  102269. private _outputAudioNode;
  102270. private _scene;
  102271. private _isMainTrack;
  102272. private _connectedAnalyser;
  102273. private _options;
  102274. private _isInitialized;
  102275. /**
  102276. * Creates a new sound track.
  102277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  102278. * @param scene Define the scene the sound track belongs to
  102279. * @param options
  102280. */
  102281. constructor(scene: Scene, options?: ISoundTrackOptions);
  102282. private _initializeSoundTrackAudioGraph;
  102283. /**
  102284. * Release the sound track and its associated resources
  102285. */
  102286. dispose(): void;
  102287. /**
  102288. * Adds a sound to this sound track
  102289. * @param sound define the cound to add
  102290. * @ignoreNaming
  102291. */
  102292. AddSound(sound: Sound): void;
  102293. /**
  102294. * Removes a sound to this sound track
  102295. * @param sound define the cound to remove
  102296. * @ignoreNaming
  102297. */
  102298. RemoveSound(sound: Sound): void;
  102299. /**
  102300. * Set a global volume for the full sound track.
  102301. * @param newVolume Define the new volume of the sound track
  102302. */
  102303. setVolume(newVolume: number): void;
  102304. /**
  102305. * Switch the panning model to HRTF:
  102306. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  102307. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102308. */
  102309. switchPanningModelToHRTF(): void;
  102310. /**
  102311. * Switch the panning model to Equal Power:
  102312. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  102313. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  102314. */
  102315. switchPanningModelToEqualPower(): void;
  102316. /**
  102317. * Connect the sound track to an audio analyser allowing some amazing
  102318. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  102319. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  102320. * @param analyser The analyser to connect to the engine
  102321. */
  102322. connectToAnalyser(analyser: Analyser): void;
  102323. }
  102324. }
  102325. declare module BABYLON {
  102326. interface AbstractScene {
  102327. /**
  102328. * The list of sounds used in the scene.
  102329. */
  102330. sounds: Nullable<Array<Sound>>;
  102331. }
  102332. interface Scene {
  102333. /**
  102334. * @hidden
  102335. * Backing field
  102336. */
  102337. _mainSoundTrack: SoundTrack;
  102338. /**
  102339. * The main sound track played by the scene.
  102340. * It cotains your primary collection of sounds.
  102341. */
  102342. mainSoundTrack: SoundTrack;
  102343. /**
  102344. * The list of sound tracks added to the scene
  102345. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102346. */
  102347. soundTracks: Nullable<Array<SoundTrack>>;
  102348. /**
  102349. * Gets a sound using a given name
  102350. * @param name defines the name to search for
  102351. * @return the found sound or null if not found at all.
  102352. */
  102353. getSoundByName(name: string): Nullable<Sound>;
  102354. /**
  102355. * Gets or sets if audio support is enabled
  102356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102357. */
  102358. audioEnabled: boolean;
  102359. /**
  102360. * Gets or sets if audio will be output to headphones
  102361. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102362. */
  102363. headphone: boolean;
  102364. /**
  102365. * Gets or sets custom audio listener position provider
  102366. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  102367. */
  102368. audioListenerPositionProvider: Nullable<() => Vector3>;
  102369. }
  102370. /**
  102371. * Defines the sound scene component responsible to manage any sounds
  102372. * in a given scene.
  102373. */
  102374. export class AudioSceneComponent implements ISceneSerializableComponent {
  102375. /**
  102376. * The component name helpfull to identify the component in the list of scene components.
  102377. */
  102378. readonly name: string;
  102379. /**
  102380. * The scene the component belongs to.
  102381. */
  102382. scene: Scene;
  102383. private _audioEnabled;
  102384. /**
  102385. * Gets whether audio is enabled or not.
  102386. * Please use related enable/disable method to switch state.
  102387. */
  102388. readonly audioEnabled: boolean;
  102389. private _headphone;
  102390. /**
  102391. * Gets whether audio is outputing to headphone or not.
  102392. * Please use the according Switch methods to change output.
  102393. */
  102394. readonly headphone: boolean;
  102395. private _audioListenerPositionProvider;
  102396. /**
  102397. * Gets the current audio listener position provider
  102398. */
  102399. /**
  102400. * Sets a custom listener position for all sounds in the scene
  102401. * By default, this is the position of the first active camera
  102402. */
  102403. audioListenerPositionProvider: Nullable<() => Vector3>;
  102404. /**
  102405. * Creates a new instance of the component for the given scene
  102406. * @param scene Defines the scene to register the component in
  102407. */
  102408. constructor(scene: Scene);
  102409. /**
  102410. * Registers the component in a given scene
  102411. */
  102412. register(): void;
  102413. /**
  102414. * Rebuilds the elements related to this component in case of
  102415. * context lost for instance.
  102416. */
  102417. rebuild(): void;
  102418. /**
  102419. * Serializes the component data to the specified json object
  102420. * @param serializationObject The object to serialize to
  102421. */
  102422. serialize(serializationObject: any): void;
  102423. /**
  102424. * Adds all the elements from the container to the scene
  102425. * @param container the container holding the elements
  102426. */
  102427. addFromContainer(container: AbstractScene): void;
  102428. /**
  102429. * Removes all the elements in the container from the scene
  102430. * @param container contains the elements to remove
  102431. * @param dispose if the removed element should be disposed (default: false)
  102432. */
  102433. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  102434. /**
  102435. * Disposes the component and the associated ressources.
  102436. */
  102437. dispose(): void;
  102438. /**
  102439. * Disables audio in the associated scene.
  102440. */
  102441. disableAudio(): void;
  102442. /**
  102443. * Enables audio in the associated scene.
  102444. */
  102445. enableAudio(): void;
  102446. /**
  102447. * Switch audio to headphone output.
  102448. */
  102449. switchAudioModeForHeadphones(): void;
  102450. /**
  102451. * Switch audio to normal speakers.
  102452. */
  102453. switchAudioModeForNormalSpeakers(): void;
  102454. private _afterRender;
  102455. }
  102456. }
  102457. declare module BABYLON {
  102458. /**
  102459. * Wraps one or more Sound objects and selects one with random weight for playback.
  102460. */
  102461. export class WeightedSound {
  102462. /** When true a Sound will be selected and played when the current playing Sound completes. */
  102463. loop: boolean;
  102464. private _coneInnerAngle;
  102465. private _coneOuterAngle;
  102466. private _volume;
  102467. /** A Sound is currently playing. */
  102468. isPlaying: boolean;
  102469. /** A Sound is currently paused. */
  102470. isPaused: boolean;
  102471. private _sounds;
  102472. private _weights;
  102473. private _currentIndex?;
  102474. /**
  102475. * Creates a new WeightedSound from the list of sounds given.
  102476. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  102477. * @param sounds Array of Sounds that will be selected from.
  102478. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  102479. */
  102480. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  102481. /**
  102482. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  102483. */
  102484. /**
  102485. * The size of cone in degress for a directional sound in which there will be no attenuation.
  102486. */
  102487. directionalConeInnerAngle: number;
  102488. /**
  102489. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102490. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102491. */
  102492. /**
  102493. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  102494. * Listener angles between innerAngle and outerAngle will falloff linearly.
  102495. */
  102496. directionalConeOuterAngle: number;
  102497. /**
  102498. * Playback volume.
  102499. */
  102500. /**
  102501. * Playback volume.
  102502. */
  102503. volume: number;
  102504. private _onended;
  102505. /**
  102506. * Suspend playback
  102507. */
  102508. pause(): void;
  102509. /**
  102510. * Stop playback
  102511. */
  102512. stop(): void;
  102513. /**
  102514. * Start playback.
  102515. * @param startOffset Position the clip head at a specific time in seconds.
  102516. */
  102517. play(startOffset?: number): void;
  102518. }
  102519. }
  102520. declare module BABYLON {
  102521. /**
  102522. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  102523. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  102524. */
  102525. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  102526. /**
  102527. * Gets the name of the behavior.
  102528. */
  102529. readonly name: string;
  102530. /**
  102531. * The easing function used by animations
  102532. */
  102533. static EasingFunction: BackEase;
  102534. /**
  102535. * The easing mode used by animations
  102536. */
  102537. static EasingMode: number;
  102538. /**
  102539. * The duration of the animation, in milliseconds
  102540. */
  102541. transitionDuration: number;
  102542. /**
  102543. * Length of the distance animated by the transition when lower radius is reached
  102544. */
  102545. lowerRadiusTransitionRange: number;
  102546. /**
  102547. * Length of the distance animated by the transition when upper radius is reached
  102548. */
  102549. upperRadiusTransitionRange: number;
  102550. private _autoTransitionRange;
  102551. /**
  102552. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102553. */
  102554. /**
  102555. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  102556. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  102557. */
  102558. autoTransitionRange: boolean;
  102559. private _attachedCamera;
  102560. private _onAfterCheckInputsObserver;
  102561. private _onMeshTargetChangedObserver;
  102562. /**
  102563. * Initializes the behavior.
  102564. */
  102565. init(): void;
  102566. /**
  102567. * Attaches the behavior to its arc rotate camera.
  102568. * @param camera Defines the camera to attach the behavior to
  102569. */
  102570. attach(camera: ArcRotateCamera): void;
  102571. /**
  102572. * Detaches the behavior from its current arc rotate camera.
  102573. */
  102574. detach(): void;
  102575. private _radiusIsAnimating;
  102576. private _radiusBounceTransition;
  102577. private _animatables;
  102578. private _cachedWheelPrecision;
  102579. /**
  102580. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  102581. * @param radiusLimit The limit to check against.
  102582. * @return Bool to indicate if at limit.
  102583. */
  102584. private _isRadiusAtLimit;
  102585. /**
  102586. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  102587. * @param radiusDelta The delta by which to animate to. Can be negative.
  102588. */
  102589. private _applyBoundRadiusAnimation;
  102590. /**
  102591. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  102592. */
  102593. protected _clearAnimationLocks(): void;
  102594. /**
  102595. * Stops and removes all animations that have been applied to the camera
  102596. */
  102597. stopAllAnimations(): void;
  102598. }
  102599. }
  102600. declare module BABYLON {
  102601. /**
  102602. * 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.
  102603. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  102604. */
  102605. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  102606. /**
  102607. * Gets the name of the behavior.
  102608. */
  102609. readonly name: string;
  102610. private _mode;
  102611. private _radiusScale;
  102612. private _positionScale;
  102613. private _defaultElevation;
  102614. private _elevationReturnTime;
  102615. private _elevationReturnWaitTime;
  102616. private _zoomStopsAnimation;
  102617. private _framingTime;
  102618. /**
  102619. * The easing function used by animations
  102620. */
  102621. static EasingFunction: ExponentialEase;
  102622. /**
  102623. * The easing mode used by animations
  102624. */
  102625. static EasingMode: number;
  102626. /**
  102627. * Sets the current mode used by the behavior
  102628. */
  102629. /**
  102630. * Gets current mode used by the behavior.
  102631. */
  102632. mode: number;
  102633. /**
  102634. * Sets the scale applied to the radius (1 by default)
  102635. */
  102636. /**
  102637. * Gets the scale applied to the radius
  102638. */
  102639. radiusScale: number;
  102640. /**
  102641. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102642. */
  102643. /**
  102644. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  102645. */
  102646. positionScale: number;
  102647. /**
  102648. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102649. * behaviour is triggered, in radians.
  102650. */
  102651. /**
  102652. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  102653. * behaviour is triggered, in radians.
  102654. */
  102655. defaultElevation: number;
  102656. /**
  102657. * Sets the time (in milliseconds) taken to return to the default beta position.
  102658. * Negative value indicates camera should not return to default.
  102659. */
  102660. /**
  102661. * Gets the time (in milliseconds) taken to return to the default beta position.
  102662. * Negative value indicates camera should not return to default.
  102663. */
  102664. elevationReturnTime: number;
  102665. /**
  102666. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102667. */
  102668. /**
  102669. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  102670. */
  102671. elevationReturnWaitTime: number;
  102672. /**
  102673. * Sets the flag that indicates if user zooming should stop animation.
  102674. */
  102675. /**
  102676. * Gets the flag that indicates if user zooming should stop animation.
  102677. */
  102678. zoomStopsAnimation: boolean;
  102679. /**
  102680. * Sets the transition time when framing the mesh, in milliseconds
  102681. */
  102682. /**
  102683. * Gets the transition time when framing the mesh, in milliseconds
  102684. */
  102685. framingTime: number;
  102686. /**
  102687. * Define if the behavior should automatically change the configured
  102688. * camera limits and sensibilities.
  102689. */
  102690. autoCorrectCameraLimitsAndSensibility: boolean;
  102691. private _onPrePointerObservableObserver;
  102692. private _onAfterCheckInputsObserver;
  102693. private _onMeshTargetChangedObserver;
  102694. private _attachedCamera;
  102695. private _isPointerDown;
  102696. private _lastInteractionTime;
  102697. /**
  102698. * Initializes the behavior.
  102699. */
  102700. init(): void;
  102701. /**
  102702. * Attaches the behavior to its arc rotate camera.
  102703. * @param camera Defines the camera to attach the behavior to
  102704. */
  102705. attach(camera: ArcRotateCamera): void;
  102706. /**
  102707. * Detaches the behavior from its current arc rotate camera.
  102708. */
  102709. detach(): void;
  102710. private _animatables;
  102711. private _betaIsAnimating;
  102712. private _betaTransition;
  102713. private _radiusTransition;
  102714. private _vectorTransition;
  102715. /**
  102716. * Targets the given mesh and updates zoom level accordingly.
  102717. * @param mesh The mesh to target.
  102718. * @param radius Optional. If a cached radius position already exists, overrides default.
  102719. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102720. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102721. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102722. */
  102723. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102724. /**
  102725. * Targets the given mesh with its children and updates zoom level accordingly.
  102726. * @param mesh The mesh to target.
  102727. * @param radius Optional. If a cached radius position already exists, overrides default.
  102728. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102729. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102730. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102731. */
  102732. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102733. /**
  102734. * Targets the given meshes with their children and updates zoom level accordingly.
  102735. * @param meshes The mesh to target.
  102736. * @param radius Optional. If a cached radius position already exists, overrides default.
  102737. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  102738. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102739. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102740. */
  102741. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102742. /**
  102743. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  102744. * @param minimumWorld Determines the smaller position of the bounding box extend
  102745. * @param maximumWorld Determines the bigger position of the bounding box extend
  102746. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  102747. * @param onAnimationEnd Callback triggered at the end of the framing animation
  102748. */
  102749. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  102750. /**
  102751. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  102752. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  102753. * frustum width.
  102754. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  102755. * to fully enclose the mesh in the viewing frustum.
  102756. */
  102757. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  102758. /**
  102759. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  102760. * is automatically returned to its default position (expected to be above ground plane).
  102761. */
  102762. private _maintainCameraAboveGround;
  102763. /**
  102764. * Returns the frustum slope based on the canvas ratio and camera FOV
  102765. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  102766. */
  102767. private _getFrustumSlope;
  102768. /**
  102769. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  102770. */
  102771. private _clearAnimationLocks;
  102772. /**
  102773. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  102774. */
  102775. private _applyUserInteraction;
  102776. /**
  102777. * Stops and removes all animations that have been applied to the camera
  102778. */
  102779. stopAllAnimations(): void;
  102780. /**
  102781. * Gets a value indicating if the user is moving the camera
  102782. */
  102783. readonly isUserIsMoving: boolean;
  102784. /**
  102785. * The camera can move all the way towards the mesh.
  102786. */
  102787. static IgnoreBoundsSizeMode: number;
  102788. /**
  102789. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  102790. */
  102791. static FitFrustumSidesMode: number;
  102792. }
  102793. }
  102794. declare module BABYLON {
  102795. /**
  102796. * Base class for Camera Pointer Inputs.
  102797. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  102798. * for example usage.
  102799. */
  102800. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  102801. /**
  102802. * Defines the camera the input is attached to.
  102803. */
  102804. abstract camera: Camera;
  102805. /**
  102806. * Whether keyboard modifier keys are pressed at time of last mouse event.
  102807. */
  102808. protected _altKey: boolean;
  102809. protected _ctrlKey: boolean;
  102810. protected _metaKey: boolean;
  102811. protected _shiftKey: boolean;
  102812. /**
  102813. * Which mouse buttons were pressed at time of last mouse event.
  102814. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  102815. */
  102816. protected _buttonsPressed: number;
  102817. /**
  102818. * Defines the buttons associated with the input to handle camera move.
  102819. */
  102820. buttons: number[];
  102821. /**
  102822. * Attach the input controls to a specific dom element to get the input from.
  102823. * @param element Defines the element the controls should be listened from
  102824. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  102825. */
  102826. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  102827. /**
  102828. * Detach the current controls from the specified dom element.
  102829. * @param element Defines the element to stop listening the inputs from
  102830. */
  102831. detachControl(element: Nullable<HTMLElement>): void;
  102832. /**
  102833. * Gets the class name of the current input.
  102834. * @returns the class name
  102835. */
  102836. getClassName(): string;
  102837. /**
  102838. * Get the friendly name associated with the input class.
  102839. * @returns the input friendly name
  102840. */
  102841. getSimpleName(): string;
  102842. /**
  102843. * Called on pointer POINTERDOUBLETAP event.
  102844. * Override this method to provide functionality on POINTERDOUBLETAP event.
  102845. */
  102846. protected onDoubleTap(type: string): void;
  102847. /**
  102848. * Called on pointer POINTERMOVE event if only a single touch is active.
  102849. * Override this method to provide functionality.
  102850. */
  102851. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102852. /**
  102853. * Called on pointer POINTERMOVE event if multiple touches are active.
  102854. * Override this method to provide functionality.
  102855. */
  102856. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102857. /**
  102858. * Called on JS contextmenu event.
  102859. * Override this method to provide functionality.
  102860. */
  102861. protected onContextMenu(evt: PointerEvent): void;
  102862. /**
  102863. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102864. * press.
  102865. * Override this method to provide functionality.
  102866. */
  102867. protected onButtonDown(evt: PointerEvent): void;
  102868. /**
  102869. * Called each time a new POINTERUP event occurs. Ie, for each button
  102870. * release.
  102871. * Override this method to provide functionality.
  102872. */
  102873. protected onButtonUp(evt: PointerEvent): void;
  102874. /**
  102875. * Called when window becomes inactive.
  102876. * Override this method to provide functionality.
  102877. */
  102878. protected onLostFocus(): void;
  102879. private _pointerInput;
  102880. private _observer;
  102881. private _onLostFocus;
  102882. private pointA;
  102883. private pointB;
  102884. }
  102885. }
  102886. declare module BABYLON {
  102887. /**
  102888. * Manage the pointers inputs to control an arc rotate camera.
  102889. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102890. */
  102891. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  102892. /**
  102893. * Defines the camera the input is attached to.
  102894. */
  102895. camera: ArcRotateCamera;
  102896. /**
  102897. * Gets the class name of the current input.
  102898. * @returns the class name
  102899. */
  102900. getClassName(): string;
  102901. /**
  102902. * Defines the buttons associated with the input to handle camera move.
  102903. */
  102904. buttons: number[];
  102905. /**
  102906. * Defines the pointer angular sensibility along the X axis or how fast is
  102907. * the camera rotating.
  102908. */
  102909. angularSensibilityX: number;
  102910. /**
  102911. * Defines the pointer angular sensibility along the Y axis or how fast is
  102912. * the camera rotating.
  102913. */
  102914. angularSensibilityY: number;
  102915. /**
  102916. * Defines the pointer pinch precision or how fast is the camera zooming.
  102917. */
  102918. pinchPrecision: number;
  102919. /**
  102920. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  102921. * from 0.
  102922. * It defines the percentage of current camera.radius to use as delta when
  102923. * pinch zoom is used.
  102924. */
  102925. pinchDeltaPercentage: number;
  102926. /**
  102927. * Defines the pointer panning sensibility or how fast is the camera moving.
  102928. */
  102929. panningSensibility: number;
  102930. /**
  102931. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  102932. */
  102933. multiTouchPanning: boolean;
  102934. /**
  102935. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  102936. * zoom (pinch) through multitouch.
  102937. */
  102938. multiTouchPanAndZoom: boolean;
  102939. /**
  102940. * Revers pinch action direction.
  102941. */
  102942. pinchInwards: boolean;
  102943. private _isPanClick;
  102944. private _twoFingerActivityCount;
  102945. private _isPinching;
  102946. /**
  102947. * Called on pointer POINTERMOVE event if only a single touch is active.
  102948. */
  102949. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  102950. /**
  102951. * Called on pointer POINTERDOUBLETAP event.
  102952. */
  102953. protected onDoubleTap(type: string): void;
  102954. /**
  102955. * Called on pointer POINTERMOVE event if multiple touches are active.
  102956. */
  102957. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  102958. /**
  102959. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  102960. * press.
  102961. */
  102962. protected onButtonDown(evt: PointerEvent): void;
  102963. /**
  102964. * Called each time a new POINTERUP event occurs. Ie, for each button
  102965. * release.
  102966. */
  102967. protected onButtonUp(evt: PointerEvent): void;
  102968. /**
  102969. * Called when window becomes inactive.
  102970. */
  102971. protected onLostFocus(): void;
  102972. }
  102973. }
  102974. declare module BABYLON {
  102975. /**
  102976. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  102977. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  102978. */
  102979. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  102980. /**
  102981. * Defines the camera the input is attached to.
  102982. */
  102983. camera: ArcRotateCamera;
  102984. /**
  102985. * Defines the list of key codes associated with the up action (increase alpha)
  102986. */
  102987. keysUp: number[];
  102988. /**
  102989. * Defines the list of key codes associated with the down action (decrease alpha)
  102990. */
  102991. keysDown: number[];
  102992. /**
  102993. * Defines the list of key codes associated with the left action (increase beta)
  102994. */
  102995. keysLeft: number[];
  102996. /**
  102997. * Defines the list of key codes associated with the right action (decrease beta)
  102998. */
  102999. keysRight: number[];
  103000. /**
  103001. * Defines the list of key codes associated with the reset action.
  103002. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  103003. */
  103004. keysReset: number[];
  103005. /**
  103006. * Defines the panning sensibility of the inputs.
  103007. * (How fast is the camera paning)
  103008. */
  103009. panningSensibility: number;
  103010. /**
  103011. * Defines the zooming sensibility of the inputs.
  103012. * (How fast is the camera zooming)
  103013. */
  103014. zoomingSensibility: number;
  103015. /**
  103016. * Defines wether maintaining the alt key down switch the movement mode from
  103017. * orientation to zoom.
  103018. */
  103019. useAltToZoom: boolean;
  103020. /**
  103021. * Rotation speed of the camera
  103022. */
  103023. angularSpeed: number;
  103024. private _keys;
  103025. private _ctrlPressed;
  103026. private _altPressed;
  103027. private _onCanvasBlurObserver;
  103028. private _onKeyboardObserver;
  103029. private _engine;
  103030. private _scene;
  103031. /**
  103032. * Attach the input controls to a specific dom element to get the input from.
  103033. * @param element Defines the element the controls should be listened from
  103034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103035. */
  103036. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103037. /**
  103038. * Detach the current controls from the specified dom element.
  103039. * @param element Defines the element to stop listening the inputs from
  103040. */
  103041. detachControl(element: Nullable<HTMLElement>): void;
  103042. /**
  103043. * Update the current camera state depending on the inputs that have been used this frame.
  103044. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  103045. */
  103046. checkInputs(): void;
  103047. /**
  103048. * Gets the class name of the current intput.
  103049. * @returns the class name
  103050. */
  103051. getClassName(): string;
  103052. /**
  103053. * Get the friendly name associated with the input class.
  103054. * @returns the input friendly name
  103055. */
  103056. getSimpleName(): string;
  103057. }
  103058. }
  103059. declare module BABYLON {
  103060. /**
  103061. * Manage the mouse wheel inputs to control an arc rotate camera.
  103062. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103063. */
  103064. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  103065. /**
  103066. * Defines the camera the input is attached to.
  103067. */
  103068. camera: ArcRotateCamera;
  103069. /**
  103070. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103071. */
  103072. wheelPrecision: number;
  103073. /**
  103074. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  103075. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  103076. */
  103077. wheelDeltaPercentage: number;
  103078. private _wheel;
  103079. private _observer;
  103080. private computeDeltaFromMouseWheelLegacyEvent;
  103081. /**
  103082. * Attach the input controls to a specific dom element to get the input from.
  103083. * @param element Defines the element the controls should be listened from
  103084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103085. */
  103086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  103087. /**
  103088. * Detach the current controls from the specified dom element.
  103089. * @param element Defines the element to stop listening the inputs from
  103090. */
  103091. detachControl(element: Nullable<HTMLElement>): void;
  103092. /**
  103093. * Gets the class name of the current intput.
  103094. * @returns the class name
  103095. */
  103096. getClassName(): string;
  103097. /**
  103098. * Get the friendly name associated with the input class.
  103099. * @returns the input friendly name
  103100. */
  103101. getSimpleName(): string;
  103102. }
  103103. }
  103104. declare module BABYLON {
  103105. /**
  103106. * Default Inputs manager for the ArcRotateCamera.
  103107. * It groups all the default supported inputs for ease of use.
  103108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  103109. */
  103110. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  103111. /**
  103112. * Instantiates a new ArcRotateCameraInputsManager.
  103113. * @param camera Defines the camera the inputs belong to
  103114. */
  103115. constructor(camera: ArcRotateCamera);
  103116. /**
  103117. * Add mouse wheel input support to the input manager.
  103118. * @returns the current input manager
  103119. */
  103120. addMouseWheel(): ArcRotateCameraInputsManager;
  103121. /**
  103122. * Add pointers input support to the input manager.
  103123. * @returns the current input manager
  103124. */
  103125. addPointers(): ArcRotateCameraInputsManager;
  103126. /**
  103127. * Add keyboard input support to the input manager.
  103128. * @returns the current input manager
  103129. */
  103130. addKeyboard(): ArcRotateCameraInputsManager;
  103131. }
  103132. }
  103133. declare module BABYLON {
  103134. /**
  103135. * This represents an orbital type of camera.
  103136. *
  103137. * 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.
  103138. * 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.
  103139. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  103140. */
  103141. export class ArcRotateCamera extends TargetCamera {
  103142. /**
  103143. * Defines the rotation angle of the camera along the longitudinal axis.
  103144. */
  103145. alpha: number;
  103146. /**
  103147. * Defines the rotation angle of the camera along the latitudinal axis.
  103148. */
  103149. beta: number;
  103150. /**
  103151. * Defines the radius of the camera from it s target point.
  103152. */
  103153. radius: number;
  103154. protected _target: Vector3;
  103155. protected _targetHost: Nullable<AbstractMesh>;
  103156. /**
  103157. * Defines the target point of the camera.
  103158. * The camera looks towards it form the radius distance.
  103159. */
  103160. target: Vector3;
  103161. /**
  103162. * Define the current local position of the camera in the scene
  103163. */
  103164. position: Vector3;
  103165. protected _upVector: Vector3;
  103166. protected _upToYMatrix: Matrix;
  103167. protected _YToUpMatrix: Matrix;
  103168. /**
  103169. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  103170. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  103171. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  103172. */
  103173. upVector: Vector3;
  103174. /**
  103175. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  103176. */
  103177. setMatUp(): void;
  103178. /**
  103179. * Current inertia value on the longitudinal axis.
  103180. * The bigger this number the longer it will take for the camera to stop.
  103181. */
  103182. inertialAlphaOffset: number;
  103183. /**
  103184. * Current inertia value on the latitudinal axis.
  103185. * The bigger this number the longer it will take for the camera to stop.
  103186. */
  103187. inertialBetaOffset: number;
  103188. /**
  103189. * Current inertia value on the radius axis.
  103190. * The bigger this number the longer it will take for the camera to stop.
  103191. */
  103192. inertialRadiusOffset: number;
  103193. /**
  103194. * Minimum allowed angle on the longitudinal axis.
  103195. * This can help limiting how the Camera is able to move in the scene.
  103196. */
  103197. lowerAlphaLimit: Nullable<number>;
  103198. /**
  103199. * Maximum allowed angle on the longitudinal axis.
  103200. * This can help limiting how the Camera is able to move in the scene.
  103201. */
  103202. upperAlphaLimit: Nullable<number>;
  103203. /**
  103204. * Minimum allowed angle on the latitudinal axis.
  103205. * This can help limiting how the Camera is able to move in the scene.
  103206. */
  103207. lowerBetaLimit: number;
  103208. /**
  103209. * Maximum allowed angle on the latitudinal axis.
  103210. * This can help limiting how the Camera is able to move in the scene.
  103211. */
  103212. upperBetaLimit: number;
  103213. /**
  103214. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  103215. * This can help limiting how the Camera is able to move in the scene.
  103216. */
  103217. lowerRadiusLimit: Nullable<number>;
  103218. /**
  103219. * Maximum allowed distance of the camera to the target (The camera can not get further).
  103220. * This can help limiting how the Camera is able to move in the scene.
  103221. */
  103222. upperRadiusLimit: Nullable<number>;
  103223. /**
  103224. * Defines the current inertia value used during panning of the camera along the X axis.
  103225. */
  103226. inertialPanningX: number;
  103227. /**
  103228. * Defines the current inertia value used during panning of the camera along the Y axis.
  103229. */
  103230. inertialPanningY: number;
  103231. /**
  103232. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  103233. * Basically if your fingers moves away from more than this distance you will be considered
  103234. * in pinch mode.
  103235. */
  103236. pinchToPanMaxDistance: number;
  103237. /**
  103238. * Defines the maximum distance the camera can pan.
  103239. * This could help keeping the cammera always in your scene.
  103240. */
  103241. panningDistanceLimit: Nullable<number>;
  103242. /**
  103243. * Defines the target of the camera before paning.
  103244. */
  103245. panningOriginTarget: Vector3;
  103246. /**
  103247. * Defines the value of the inertia used during panning.
  103248. * 0 would mean stop inertia and one would mean no decelleration at all.
  103249. */
  103250. panningInertia: number;
  103251. /**
  103252. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  103253. */
  103254. angularSensibilityX: number;
  103255. /**
  103256. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  103257. */
  103258. angularSensibilityY: number;
  103259. /**
  103260. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  103261. */
  103262. pinchPrecision: number;
  103263. /**
  103264. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  103265. * It will be used instead of pinchDeltaPrecision if different from 0.
  103266. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103267. */
  103268. pinchDeltaPercentage: number;
  103269. /**
  103270. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  103271. */
  103272. panningSensibility: number;
  103273. /**
  103274. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  103275. */
  103276. keysUp: number[];
  103277. /**
  103278. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  103279. */
  103280. keysDown: number[];
  103281. /**
  103282. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  103283. */
  103284. keysLeft: number[];
  103285. /**
  103286. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  103287. */
  103288. keysRight: number[];
  103289. /**
  103290. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  103291. */
  103292. wheelPrecision: number;
  103293. /**
  103294. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  103295. * It will be used instead of pinchDeltaPrecision if different from 0.
  103296. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  103297. */
  103298. wheelDeltaPercentage: number;
  103299. /**
  103300. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  103301. */
  103302. zoomOnFactor: number;
  103303. /**
  103304. * Defines a screen offset for the camera position.
  103305. */
  103306. targetScreenOffset: Vector2;
  103307. /**
  103308. * Allows the camera to be completely reversed.
  103309. * If false the camera can not arrive upside down.
  103310. */
  103311. allowUpsideDown: boolean;
  103312. /**
  103313. * Define if double tap/click is used to restore the previously saved state of the camera.
  103314. */
  103315. useInputToRestoreState: boolean;
  103316. /** @hidden */
  103317. _viewMatrix: Matrix;
  103318. /** @hidden */
  103319. _useCtrlForPanning: boolean;
  103320. /** @hidden */
  103321. _panningMouseButton: number;
  103322. /**
  103323. * Defines the input associated to the camera.
  103324. */
  103325. inputs: ArcRotateCameraInputsManager;
  103326. /** @hidden */
  103327. _reset: () => void;
  103328. /**
  103329. * Defines the allowed panning axis.
  103330. */
  103331. panningAxis: Vector3;
  103332. protected _localDirection: Vector3;
  103333. protected _transformedDirection: Vector3;
  103334. private _bouncingBehavior;
  103335. /**
  103336. * Gets the bouncing behavior of the camera if it has been enabled.
  103337. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103338. */
  103339. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  103340. /**
  103341. * Defines if the bouncing behavior of the camera is enabled on the camera.
  103342. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  103343. */
  103344. useBouncingBehavior: boolean;
  103345. private _framingBehavior;
  103346. /**
  103347. * Gets the framing behavior of the camera if it has been enabled.
  103348. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103349. */
  103350. readonly framingBehavior: Nullable<FramingBehavior>;
  103351. /**
  103352. * Defines if the framing behavior of the camera is enabled on the camera.
  103353. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  103354. */
  103355. useFramingBehavior: boolean;
  103356. private _autoRotationBehavior;
  103357. /**
  103358. * Gets the auto rotation behavior of the camera if it has been enabled.
  103359. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103360. */
  103361. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  103362. /**
  103363. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  103364. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103365. */
  103366. useAutoRotationBehavior: boolean;
  103367. /**
  103368. * Observable triggered when the mesh target has been changed on the camera.
  103369. */
  103370. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  103371. /**
  103372. * Event raised when the camera is colliding with a mesh.
  103373. */
  103374. onCollide: (collidedMesh: AbstractMesh) => void;
  103375. /**
  103376. * Defines whether the camera should check collision with the objects oh the scene.
  103377. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  103378. */
  103379. checkCollisions: boolean;
  103380. /**
  103381. * Defines the collision radius of the camera.
  103382. * This simulates a sphere around the camera.
  103383. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  103384. */
  103385. collisionRadius: Vector3;
  103386. protected _collider: Collider;
  103387. protected _previousPosition: Vector3;
  103388. protected _collisionVelocity: Vector3;
  103389. protected _newPosition: Vector3;
  103390. protected _previousAlpha: number;
  103391. protected _previousBeta: number;
  103392. protected _previousRadius: number;
  103393. protected _collisionTriggered: boolean;
  103394. protected _targetBoundingCenter: Nullable<Vector3>;
  103395. private _computationVector;
  103396. /**
  103397. * Instantiates a new ArcRotateCamera in a given scene
  103398. * @param name Defines the name of the camera
  103399. * @param alpha Defines the camera rotation along the logitudinal axis
  103400. * @param beta Defines the camera rotation along the latitudinal axis
  103401. * @param radius Defines the camera distance from its target
  103402. * @param target Defines the camera target
  103403. * @param scene Defines the scene the camera belongs to
  103404. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  103405. */
  103406. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  103407. /** @hidden */
  103408. _initCache(): void;
  103409. /** @hidden */
  103410. _updateCache(ignoreParentClass?: boolean): void;
  103411. protected _getTargetPosition(): Vector3;
  103412. private _storedAlpha;
  103413. private _storedBeta;
  103414. private _storedRadius;
  103415. private _storedTarget;
  103416. private _storedTargetScreenOffset;
  103417. /**
  103418. * Stores the current state of the camera (alpha, beta, radius and target)
  103419. * @returns the camera itself
  103420. */
  103421. storeState(): Camera;
  103422. /**
  103423. * @hidden
  103424. * Restored camera state. You must call storeState() first
  103425. */
  103426. _restoreStateValues(): boolean;
  103427. /** @hidden */
  103428. _isSynchronizedViewMatrix(): boolean;
  103429. /**
  103430. * Attached controls to the current camera.
  103431. * @param element Defines the element the controls should be listened from
  103432. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  103433. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  103434. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  103435. */
  103436. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  103437. /**
  103438. * Detach the current controls from the camera.
  103439. * The camera will stop reacting to inputs.
  103440. * @param element Defines the element to stop listening the inputs from
  103441. */
  103442. detachControl(element: HTMLElement): void;
  103443. /** @hidden */
  103444. _checkInputs(): void;
  103445. protected _checkLimits(): void;
  103446. /**
  103447. * Rebuilds angles (alpha, beta) and radius from the give position and target
  103448. */
  103449. rebuildAnglesAndRadius(): void;
  103450. /**
  103451. * Use a position to define the current camera related information like alpha, beta and radius
  103452. * @param position Defines the position to set the camera at
  103453. */
  103454. setPosition(position: Vector3): void;
  103455. /**
  103456. * Defines the target the camera should look at.
  103457. * This will automatically adapt alpha beta and radius to fit within the new target.
  103458. * @param target Defines the new target as a Vector or a mesh
  103459. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  103460. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  103461. */
  103462. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  103463. /** @hidden */
  103464. _getViewMatrix(): Matrix;
  103465. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  103466. /**
  103467. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  103468. * @param meshes Defines the mesh to zoom on
  103469. * @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)
  103470. */
  103471. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  103472. /**
  103473. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  103474. * The target will be changed but the radius
  103475. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  103476. * @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)
  103477. */
  103478. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  103479. min: Vector3;
  103480. max: Vector3;
  103481. distance: number;
  103482. }, doNotUpdateMaxZ?: boolean): void;
  103483. /**
  103484. * @override
  103485. * Override Camera.createRigCamera
  103486. */
  103487. createRigCamera(name: string, cameraIndex: number): Camera;
  103488. /**
  103489. * @hidden
  103490. * @override
  103491. * Override Camera._updateRigCameras
  103492. */
  103493. _updateRigCameras(): void;
  103494. /**
  103495. * Destroy the camera and release the current resources hold by it.
  103496. */
  103497. dispose(): void;
  103498. /**
  103499. * Gets the current object class name.
  103500. * @return the class name
  103501. */
  103502. getClassName(): string;
  103503. }
  103504. }
  103505. declare module BABYLON {
  103506. /**
  103507. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  103508. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  103509. */
  103510. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  103511. /**
  103512. * Gets the name of the behavior.
  103513. */
  103514. readonly name: string;
  103515. private _zoomStopsAnimation;
  103516. private _idleRotationSpeed;
  103517. private _idleRotationWaitTime;
  103518. private _idleRotationSpinupTime;
  103519. /**
  103520. * Sets the flag that indicates if user zooming should stop animation.
  103521. */
  103522. /**
  103523. * Gets the flag that indicates if user zooming should stop animation.
  103524. */
  103525. zoomStopsAnimation: boolean;
  103526. /**
  103527. * Sets the default speed at which the camera rotates around the model.
  103528. */
  103529. /**
  103530. * Gets the default speed at which the camera rotates around the model.
  103531. */
  103532. idleRotationSpeed: number;
  103533. /**
  103534. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  103535. */
  103536. /**
  103537. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  103538. */
  103539. idleRotationWaitTime: number;
  103540. /**
  103541. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103542. */
  103543. /**
  103544. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  103545. */
  103546. idleRotationSpinupTime: number;
  103547. /**
  103548. * Gets a value indicating if the camera is currently rotating because of this behavior
  103549. */
  103550. readonly rotationInProgress: boolean;
  103551. private _onPrePointerObservableObserver;
  103552. private _onAfterCheckInputsObserver;
  103553. private _attachedCamera;
  103554. private _isPointerDown;
  103555. private _lastFrameTime;
  103556. private _lastInteractionTime;
  103557. private _cameraRotationSpeed;
  103558. /**
  103559. * Initializes the behavior.
  103560. */
  103561. init(): void;
  103562. /**
  103563. * Attaches the behavior to its arc rotate camera.
  103564. * @param camera Defines the camera to attach the behavior to
  103565. */
  103566. attach(camera: ArcRotateCamera): void;
  103567. /**
  103568. * Detaches the behavior from its current arc rotate camera.
  103569. */
  103570. detach(): void;
  103571. /**
  103572. * Returns true if user is scrolling.
  103573. * @return true if user is scrolling.
  103574. */
  103575. private _userIsZooming;
  103576. private _lastFrameRadius;
  103577. private _shouldAnimationStopForInteraction;
  103578. /**
  103579. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  103580. */
  103581. private _applyUserInteraction;
  103582. private _userIsMoving;
  103583. }
  103584. }
  103585. declare module BABYLON {
  103586. /**
  103587. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  103588. */
  103589. export class AttachToBoxBehavior implements Behavior<Mesh> {
  103590. private ui;
  103591. /**
  103592. * The name of the behavior
  103593. */
  103594. name: string;
  103595. /**
  103596. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  103597. */
  103598. distanceAwayFromFace: number;
  103599. /**
  103600. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  103601. */
  103602. distanceAwayFromBottomOfFace: number;
  103603. private _faceVectors;
  103604. private _target;
  103605. private _scene;
  103606. private _onRenderObserver;
  103607. private _tmpMatrix;
  103608. private _tmpVector;
  103609. /**
  103610. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  103611. * @param ui The transform node that should be attched to the mesh
  103612. */
  103613. constructor(ui: TransformNode);
  103614. /**
  103615. * Initializes the behavior
  103616. */
  103617. init(): void;
  103618. private _closestFace;
  103619. private _zeroVector;
  103620. private _lookAtTmpMatrix;
  103621. private _lookAtToRef;
  103622. /**
  103623. * Attaches the AttachToBoxBehavior to the passed in mesh
  103624. * @param target The mesh that the specified node will be attached to
  103625. */
  103626. attach(target: Mesh): void;
  103627. /**
  103628. * Detaches the behavior from the mesh
  103629. */
  103630. detach(): void;
  103631. }
  103632. }
  103633. declare module BABYLON {
  103634. /**
  103635. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  103636. */
  103637. export class FadeInOutBehavior implements Behavior<Mesh> {
  103638. /**
  103639. * Time in milliseconds to delay before fading in (Default: 0)
  103640. */
  103641. delay: number;
  103642. /**
  103643. * Time in milliseconds for the mesh to fade in (Default: 300)
  103644. */
  103645. fadeInTime: number;
  103646. private _millisecondsPerFrame;
  103647. private _hovered;
  103648. private _hoverValue;
  103649. private _ownerNode;
  103650. /**
  103651. * Instatiates the FadeInOutBehavior
  103652. */
  103653. constructor();
  103654. /**
  103655. * The name of the behavior
  103656. */
  103657. readonly name: string;
  103658. /**
  103659. * Initializes the behavior
  103660. */
  103661. init(): void;
  103662. /**
  103663. * Attaches the fade behavior on the passed in mesh
  103664. * @param ownerNode The mesh that will be faded in/out once attached
  103665. */
  103666. attach(ownerNode: Mesh): void;
  103667. /**
  103668. * Detaches the behavior from the mesh
  103669. */
  103670. detach(): void;
  103671. /**
  103672. * Triggers the mesh to begin fading in or out
  103673. * @param value if the object should fade in or out (true to fade in)
  103674. */
  103675. fadeIn(value: boolean): void;
  103676. private _update;
  103677. private _setAllVisibility;
  103678. }
  103679. }
  103680. declare module BABYLON {
  103681. /**
  103682. * Class containing a set of static utilities functions for managing Pivots
  103683. * @hidden
  103684. */
  103685. export class PivotTools {
  103686. private static _PivotCached;
  103687. private static _OldPivotPoint;
  103688. private static _PivotTranslation;
  103689. private static _PivotTmpVector;
  103690. /** @hidden */
  103691. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  103692. /** @hidden */
  103693. static _RestorePivotPoint(mesh: AbstractMesh): void;
  103694. }
  103695. }
  103696. declare module BABYLON {
  103697. /**
  103698. * Class containing static functions to help procedurally build meshes
  103699. */
  103700. export class PlaneBuilder {
  103701. /**
  103702. * Creates a plane mesh
  103703. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  103704. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  103705. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  103706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  103707. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  103708. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  103709. * @param name defines the name of the mesh
  103710. * @param options defines the options used to create the mesh
  103711. * @param scene defines the hosting scene
  103712. * @returns the plane mesh
  103713. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  103714. */
  103715. static CreatePlane(name: string, options: {
  103716. size?: number;
  103717. width?: number;
  103718. height?: number;
  103719. sideOrientation?: number;
  103720. frontUVs?: Vector4;
  103721. backUVs?: Vector4;
  103722. updatable?: boolean;
  103723. sourcePlane?: Plane;
  103724. }, scene?: Nullable<Scene>): Mesh;
  103725. }
  103726. }
  103727. declare module BABYLON {
  103728. /**
  103729. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  103730. */
  103731. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  103732. private static _AnyMouseID;
  103733. /**
  103734. * Abstract mesh the behavior is set on
  103735. */
  103736. attachedNode: AbstractMesh;
  103737. private _dragPlane;
  103738. private _scene;
  103739. private _pointerObserver;
  103740. private _beforeRenderObserver;
  103741. private static _planeScene;
  103742. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  103743. /**
  103744. * 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)
  103745. */
  103746. maxDragAngle: number;
  103747. /**
  103748. * @hidden
  103749. */
  103750. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  103751. /**
  103752. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103753. */
  103754. currentDraggingPointerID: number;
  103755. /**
  103756. * The last position where the pointer hit the drag plane in world space
  103757. */
  103758. lastDragPosition: Vector3;
  103759. /**
  103760. * If the behavior is currently in a dragging state
  103761. */
  103762. dragging: boolean;
  103763. /**
  103764. * 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)
  103765. */
  103766. dragDeltaRatio: number;
  103767. /**
  103768. * If the drag plane orientation should be updated during the dragging (Default: true)
  103769. */
  103770. updateDragPlane: boolean;
  103771. private _debugMode;
  103772. private _moving;
  103773. /**
  103774. * Fires each time the attached mesh is dragged with the pointer
  103775. * * delta between last drag position and current drag position in world space
  103776. * * dragDistance along the drag axis
  103777. * * dragPlaneNormal normal of the current drag plane used during the drag
  103778. * * dragPlanePoint in world space where the drag intersects the drag plane
  103779. */
  103780. onDragObservable: Observable<{
  103781. delta: Vector3;
  103782. dragPlanePoint: Vector3;
  103783. dragPlaneNormal: Vector3;
  103784. dragDistance: number;
  103785. pointerId: number;
  103786. }>;
  103787. /**
  103788. * Fires each time a drag begins (eg. mouse down on mesh)
  103789. */
  103790. onDragStartObservable: Observable<{
  103791. dragPlanePoint: Vector3;
  103792. pointerId: number;
  103793. }>;
  103794. /**
  103795. * Fires each time a drag ends (eg. mouse release after drag)
  103796. */
  103797. onDragEndObservable: Observable<{
  103798. dragPlanePoint: Vector3;
  103799. pointerId: number;
  103800. }>;
  103801. /**
  103802. * If the attached mesh should be moved when dragged
  103803. */
  103804. moveAttached: boolean;
  103805. /**
  103806. * If the drag behavior will react to drag events (Default: true)
  103807. */
  103808. enabled: boolean;
  103809. /**
  103810. * If pointer events should start and release the drag (Default: true)
  103811. */
  103812. startAndReleaseDragOnPointerEvents: boolean;
  103813. /**
  103814. * If camera controls should be detached during the drag
  103815. */
  103816. detachCameraControls: boolean;
  103817. /**
  103818. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  103819. */
  103820. useObjectOrienationForDragging: boolean;
  103821. private _options;
  103822. /**
  103823. * Creates a pointer drag behavior that can be attached to a mesh
  103824. * @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)
  103825. */
  103826. constructor(options?: {
  103827. dragAxis?: Vector3;
  103828. dragPlaneNormal?: Vector3;
  103829. });
  103830. /**
  103831. * Predicate to determine if it is valid to move the object to a new position when it is moved
  103832. */
  103833. validateDrag: (targetPosition: Vector3) => boolean;
  103834. /**
  103835. * The name of the behavior
  103836. */
  103837. readonly name: string;
  103838. /**
  103839. * Initializes the behavior
  103840. */
  103841. init(): void;
  103842. private _tmpVector;
  103843. private _alternatePickedPoint;
  103844. private _worldDragAxis;
  103845. private _targetPosition;
  103846. private _attachedElement;
  103847. /**
  103848. * Attaches the drag behavior the passed in mesh
  103849. * @param ownerNode The mesh that will be dragged around once attached
  103850. * @param predicate Predicate to use for pick filtering
  103851. */
  103852. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  103853. /**
  103854. * Force relase the drag action by code.
  103855. */
  103856. releaseDrag(): void;
  103857. private _startDragRay;
  103858. private _lastPointerRay;
  103859. /**
  103860. * Simulates the start of a pointer drag event on the behavior
  103861. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  103862. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  103863. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  103864. */
  103865. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  103866. private _startDrag;
  103867. private _dragDelta;
  103868. private _moveDrag;
  103869. private _pickWithRayOnDragPlane;
  103870. private _pointA;
  103871. private _pointB;
  103872. private _pointC;
  103873. private _lineA;
  103874. private _lineB;
  103875. private _localAxis;
  103876. private _lookAt;
  103877. private _updateDragPlanePosition;
  103878. /**
  103879. * Detaches the behavior from the mesh
  103880. */
  103881. detach(): void;
  103882. }
  103883. }
  103884. declare module BABYLON {
  103885. /**
  103886. * A behavior that when attached to a mesh will allow the mesh to be scaled
  103887. */
  103888. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  103889. private _dragBehaviorA;
  103890. private _dragBehaviorB;
  103891. private _startDistance;
  103892. private _initialScale;
  103893. private _targetScale;
  103894. private _ownerNode;
  103895. private _sceneRenderObserver;
  103896. /**
  103897. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  103898. */
  103899. constructor();
  103900. /**
  103901. * The name of the behavior
  103902. */
  103903. readonly name: string;
  103904. /**
  103905. * Initializes the behavior
  103906. */
  103907. init(): void;
  103908. private _getCurrentDistance;
  103909. /**
  103910. * Attaches the scale behavior the passed in mesh
  103911. * @param ownerNode The mesh that will be scaled around once attached
  103912. */
  103913. attach(ownerNode: Mesh): void;
  103914. /**
  103915. * Detaches the behavior from the mesh
  103916. */
  103917. detach(): void;
  103918. }
  103919. }
  103920. declare module BABYLON {
  103921. /**
  103922. * 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
  103923. */
  103924. export class SixDofDragBehavior implements Behavior<Mesh> {
  103925. private static _virtualScene;
  103926. private _ownerNode;
  103927. private _sceneRenderObserver;
  103928. private _scene;
  103929. private _targetPosition;
  103930. private _virtualOriginMesh;
  103931. private _virtualDragMesh;
  103932. private _pointerObserver;
  103933. private _moving;
  103934. private _startingOrientation;
  103935. /**
  103936. * 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)
  103937. */
  103938. private zDragFactor;
  103939. /**
  103940. * If the object should rotate to face the drag origin
  103941. */
  103942. rotateDraggedObject: boolean;
  103943. /**
  103944. * If the behavior is currently in a dragging state
  103945. */
  103946. dragging: boolean;
  103947. /**
  103948. * 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)
  103949. */
  103950. dragDeltaRatio: number;
  103951. /**
  103952. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  103953. */
  103954. currentDraggingPointerID: number;
  103955. /**
  103956. * If camera controls should be detached during the drag
  103957. */
  103958. detachCameraControls: boolean;
  103959. /**
  103960. * Fires each time a drag starts
  103961. */
  103962. onDragStartObservable: Observable<{}>;
  103963. /**
  103964. * Fires each time a drag ends (eg. mouse release after drag)
  103965. */
  103966. onDragEndObservable: Observable<{}>;
  103967. /**
  103968. * 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
  103969. */
  103970. constructor();
  103971. /**
  103972. * The name of the behavior
  103973. */
  103974. readonly name: string;
  103975. /**
  103976. * Initializes the behavior
  103977. */
  103978. init(): void;
  103979. /**
  103980. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  103981. */
  103982. private readonly _pointerCamera;
  103983. /**
  103984. * Attaches the scale behavior the passed in mesh
  103985. * @param ownerNode The mesh that will be scaled around once attached
  103986. */
  103987. attach(ownerNode: Mesh): void;
  103988. /**
  103989. * Detaches the behavior from the mesh
  103990. */
  103991. detach(): void;
  103992. }
  103993. }
  103994. declare module BABYLON {
  103995. /**
  103996. * Class used to apply inverse kinematics to bones
  103997. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  103998. */
  103999. export class BoneIKController {
  104000. private static _tmpVecs;
  104001. private static _tmpQuat;
  104002. private static _tmpMats;
  104003. /**
  104004. * Gets or sets the target mesh
  104005. */
  104006. targetMesh: AbstractMesh;
  104007. /** Gets or sets the mesh used as pole */
  104008. poleTargetMesh: AbstractMesh;
  104009. /**
  104010. * Gets or sets the bone used as pole
  104011. */
  104012. poleTargetBone: Nullable<Bone>;
  104013. /**
  104014. * Gets or sets the target position
  104015. */
  104016. targetPosition: Vector3;
  104017. /**
  104018. * Gets or sets the pole target position
  104019. */
  104020. poleTargetPosition: Vector3;
  104021. /**
  104022. * Gets or sets the pole target local offset
  104023. */
  104024. poleTargetLocalOffset: Vector3;
  104025. /**
  104026. * Gets or sets the pole angle
  104027. */
  104028. poleAngle: number;
  104029. /**
  104030. * Gets or sets the mesh associated with the controller
  104031. */
  104032. mesh: AbstractMesh;
  104033. /**
  104034. * 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)
  104035. */
  104036. slerpAmount: number;
  104037. private _bone1Quat;
  104038. private _bone1Mat;
  104039. private _bone2Ang;
  104040. private _bone1;
  104041. private _bone2;
  104042. private _bone1Length;
  104043. private _bone2Length;
  104044. private _maxAngle;
  104045. private _maxReach;
  104046. private _rightHandedSystem;
  104047. private _bendAxis;
  104048. private _slerping;
  104049. private _adjustRoll;
  104050. /**
  104051. * Gets or sets maximum allowed angle
  104052. */
  104053. maxAngle: number;
  104054. /**
  104055. * Creates a new BoneIKController
  104056. * @param mesh defines the mesh to control
  104057. * @param bone defines the bone to control
  104058. * @param options defines options to set up the controller
  104059. */
  104060. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  104061. targetMesh?: AbstractMesh;
  104062. poleTargetMesh?: AbstractMesh;
  104063. poleTargetBone?: Bone;
  104064. poleTargetLocalOffset?: Vector3;
  104065. poleAngle?: number;
  104066. bendAxis?: Vector3;
  104067. maxAngle?: number;
  104068. slerpAmount?: number;
  104069. });
  104070. private _setMaxAngle;
  104071. /**
  104072. * Force the controller to update the bones
  104073. */
  104074. update(): void;
  104075. }
  104076. }
  104077. declare module BABYLON {
  104078. /**
  104079. * Class used to make a bone look toward a point in space
  104080. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  104081. */
  104082. export class BoneLookController {
  104083. private static _tmpVecs;
  104084. private static _tmpQuat;
  104085. private static _tmpMats;
  104086. /**
  104087. * The target Vector3 that the bone will look at
  104088. */
  104089. target: Vector3;
  104090. /**
  104091. * The mesh that the bone is attached to
  104092. */
  104093. mesh: AbstractMesh;
  104094. /**
  104095. * The bone that will be looking to the target
  104096. */
  104097. bone: Bone;
  104098. /**
  104099. * The up axis of the coordinate system that is used when the bone is rotated
  104100. */
  104101. upAxis: Vector3;
  104102. /**
  104103. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  104104. */
  104105. upAxisSpace: Space;
  104106. /**
  104107. * Used to make an adjustment to the yaw of the bone
  104108. */
  104109. adjustYaw: number;
  104110. /**
  104111. * Used to make an adjustment to the pitch of the bone
  104112. */
  104113. adjustPitch: number;
  104114. /**
  104115. * Used to make an adjustment to the roll of the bone
  104116. */
  104117. adjustRoll: number;
  104118. /**
  104119. * 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)
  104120. */
  104121. slerpAmount: number;
  104122. private _minYaw;
  104123. private _maxYaw;
  104124. private _minPitch;
  104125. private _maxPitch;
  104126. private _minYawSin;
  104127. private _minYawCos;
  104128. private _maxYawSin;
  104129. private _maxYawCos;
  104130. private _midYawConstraint;
  104131. private _minPitchTan;
  104132. private _maxPitchTan;
  104133. private _boneQuat;
  104134. private _slerping;
  104135. private _transformYawPitch;
  104136. private _transformYawPitchInv;
  104137. private _firstFrameSkipped;
  104138. private _yawRange;
  104139. private _fowardAxis;
  104140. /**
  104141. * Gets or sets the minimum yaw angle that the bone can look to
  104142. */
  104143. minYaw: number;
  104144. /**
  104145. * Gets or sets the maximum yaw angle that the bone can look to
  104146. */
  104147. maxYaw: number;
  104148. /**
  104149. * Gets or sets the minimum pitch angle that the bone can look to
  104150. */
  104151. minPitch: number;
  104152. /**
  104153. * Gets or sets the maximum pitch angle that the bone can look to
  104154. */
  104155. maxPitch: number;
  104156. /**
  104157. * Create a BoneLookController
  104158. * @param mesh the mesh that the bone belongs to
  104159. * @param bone the bone that will be looking to the target
  104160. * @param target the target Vector3 to look at
  104161. * @param options optional settings:
  104162. * * maxYaw: the maximum angle the bone will yaw to
  104163. * * minYaw: the minimum angle the bone will yaw to
  104164. * * maxPitch: the maximum angle the bone will pitch to
  104165. * * minPitch: the minimum angle the bone will yaw to
  104166. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  104167. * * upAxis: the up axis of the coordinate system
  104168. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  104169. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  104170. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  104171. * * adjustYaw: used to make an adjustment to the yaw of the bone
  104172. * * adjustPitch: used to make an adjustment to the pitch of the bone
  104173. * * adjustRoll: used to make an adjustment to the roll of the bone
  104174. **/
  104175. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  104176. maxYaw?: number;
  104177. minYaw?: number;
  104178. maxPitch?: number;
  104179. minPitch?: number;
  104180. slerpAmount?: number;
  104181. upAxis?: Vector3;
  104182. upAxisSpace?: Space;
  104183. yawAxis?: Vector3;
  104184. pitchAxis?: Vector3;
  104185. adjustYaw?: number;
  104186. adjustPitch?: number;
  104187. adjustRoll?: number;
  104188. });
  104189. /**
  104190. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  104191. */
  104192. update(): void;
  104193. private _getAngleDiff;
  104194. private _getAngleBetween;
  104195. private _isAngleBetween;
  104196. }
  104197. }
  104198. declare module BABYLON {
  104199. /**
  104200. * Manage the gamepad inputs to control an arc rotate camera.
  104201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104202. */
  104203. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  104204. /**
  104205. * Defines the camera the input is attached to.
  104206. */
  104207. camera: ArcRotateCamera;
  104208. /**
  104209. * Defines the gamepad the input is gathering event from.
  104210. */
  104211. gamepad: Nullable<Gamepad>;
  104212. /**
  104213. * Defines the gamepad rotation sensiblity.
  104214. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  104215. */
  104216. gamepadRotationSensibility: number;
  104217. /**
  104218. * Defines the gamepad move sensiblity.
  104219. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  104220. */
  104221. gamepadMoveSensibility: number;
  104222. private _onGamepadConnectedObserver;
  104223. private _onGamepadDisconnectedObserver;
  104224. /**
  104225. * Attach the input controls to a specific dom element to get the input from.
  104226. * @param element Defines the element the controls should be listened from
  104227. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104228. */
  104229. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104230. /**
  104231. * Detach the current controls from the specified dom element.
  104232. * @param element Defines the element to stop listening the inputs from
  104233. */
  104234. detachControl(element: Nullable<HTMLElement>): void;
  104235. /**
  104236. * Update the current camera state depending on the inputs that have been used this frame.
  104237. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104238. */
  104239. checkInputs(): void;
  104240. /**
  104241. * Gets the class name of the current intput.
  104242. * @returns the class name
  104243. */
  104244. getClassName(): string;
  104245. /**
  104246. * Get the friendly name associated with the input class.
  104247. * @returns the input friendly name
  104248. */
  104249. getSimpleName(): string;
  104250. }
  104251. }
  104252. declare module BABYLON {
  104253. interface ArcRotateCameraInputsManager {
  104254. /**
  104255. * Add orientation input support to the input manager.
  104256. * @returns the current input manager
  104257. */
  104258. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  104259. }
  104260. /**
  104261. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  104262. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104263. */
  104264. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  104265. /**
  104266. * Defines the camera the input is attached to.
  104267. */
  104268. camera: ArcRotateCamera;
  104269. /**
  104270. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  104271. */
  104272. alphaCorrection: number;
  104273. /**
  104274. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  104275. */
  104276. gammaCorrection: number;
  104277. private _alpha;
  104278. private _gamma;
  104279. private _dirty;
  104280. private _deviceOrientationHandler;
  104281. /**
  104282. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  104283. */
  104284. constructor();
  104285. /**
  104286. * Attach the input controls to a specific dom element to get the input from.
  104287. * @param element Defines the element the controls should be listened from
  104288. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104289. */
  104290. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104291. /** @hidden */
  104292. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  104293. /**
  104294. * Update the current camera state depending on the inputs that have been used this frame.
  104295. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104296. */
  104297. checkInputs(): void;
  104298. /**
  104299. * Detach the current controls from the specified dom element.
  104300. * @param element Defines the element to stop listening the inputs from
  104301. */
  104302. detachControl(element: Nullable<HTMLElement>): void;
  104303. /**
  104304. * Gets the class name of the current intput.
  104305. * @returns the class name
  104306. */
  104307. getClassName(): string;
  104308. /**
  104309. * Get the friendly name associated with the input class.
  104310. * @returns the input friendly name
  104311. */
  104312. getSimpleName(): string;
  104313. }
  104314. }
  104315. declare module BABYLON {
  104316. /**
  104317. * Listen to mouse events to control the camera.
  104318. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104319. */
  104320. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  104321. /**
  104322. * Defines the camera the input is attached to.
  104323. */
  104324. camera: FlyCamera;
  104325. /**
  104326. * Defines if touch is enabled. (Default is true.)
  104327. */
  104328. touchEnabled: boolean;
  104329. /**
  104330. * Defines the buttons associated with the input to handle camera rotation.
  104331. */
  104332. buttons: number[];
  104333. /**
  104334. * Assign buttons for Yaw control.
  104335. */
  104336. buttonsYaw: number[];
  104337. /**
  104338. * Assign buttons for Pitch control.
  104339. */
  104340. buttonsPitch: number[];
  104341. /**
  104342. * Assign buttons for Roll control.
  104343. */
  104344. buttonsRoll: number[];
  104345. /**
  104346. * Detect if any button is being pressed while mouse is moved.
  104347. * -1 = Mouse locked.
  104348. * 0 = Left button.
  104349. * 1 = Middle Button.
  104350. * 2 = Right Button.
  104351. */
  104352. activeButton: number;
  104353. /**
  104354. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  104355. * Higher values reduce its sensitivity.
  104356. */
  104357. angularSensibility: number;
  104358. private _mousemoveCallback;
  104359. private _observer;
  104360. private _rollObserver;
  104361. private previousPosition;
  104362. private noPreventDefault;
  104363. private element;
  104364. /**
  104365. * Listen to mouse events to control the camera.
  104366. * @param touchEnabled Define if touch is enabled. (Default is true.)
  104367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104368. */
  104369. constructor(touchEnabled?: boolean);
  104370. /**
  104371. * Attach the mouse control to the HTML DOM element.
  104372. * @param element Defines the element that listens to the input events.
  104373. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  104374. */
  104375. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104376. /**
  104377. * Detach the current controls from the specified dom element.
  104378. * @param element Defines the element to stop listening the inputs from
  104379. */
  104380. detachControl(element: Nullable<HTMLElement>): void;
  104381. /**
  104382. * Gets the class name of the current input.
  104383. * @returns the class name.
  104384. */
  104385. getClassName(): string;
  104386. /**
  104387. * Get the friendly name associated with the input class.
  104388. * @returns the input's friendly name.
  104389. */
  104390. getSimpleName(): string;
  104391. private _pointerInput;
  104392. private _onMouseMove;
  104393. /**
  104394. * Rotate camera by mouse offset.
  104395. */
  104396. private rotateCamera;
  104397. }
  104398. }
  104399. declare module BABYLON {
  104400. /**
  104401. * Default Inputs manager for the FlyCamera.
  104402. * It groups all the default supported inputs for ease of use.
  104403. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104404. */
  104405. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  104406. /**
  104407. * Instantiates a new FlyCameraInputsManager.
  104408. * @param camera Defines the camera the inputs belong to.
  104409. */
  104410. constructor(camera: FlyCamera);
  104411. /**
  104412. * Add keyboard input support to the input manager.
  104413. * @returns the new FlyCameraKeyboardMoveInput().
  104414. */
  104415. addKeyboard(): FlyCameraInputsManager;
  104416. /**
  104417. * Add mouse input support to the input manager.
  104418. * @param touchEnabled Enable touch screen support.
  104419. * @returns the new FlyCameraMouseInput().
  104420. */
  104421. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  104422. }
  104423. }
  104424. declare module BABYLON {
  104425. /**
  104426. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104427. * such as in a 3D Space Shooter or a Flight Simulator.
  104428. */
  104429. export class FlyCamera extends TargetCamera {
  104430. /**
  104431. * Define the collision ellipsoid of the camera.
  104432. * This is helpful for simulating a camera body, like a player's body.
  104433. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  104434. */
  104435. ellipsoid: Vector3;
  104436. /**
  104437. * Define an offset for the position of the ellipsoid around the camera.
  104438. * This can be helpful if the camera is attached away from the player's body center,
  104439. * such as at its head.
  104440. */
  104441. ellipsoidOffset: Vector3;
  104442. /**
  104443. * Enable or disable collisions of the camera with the rest of the scene objects.
  104444. */
  104445. checkCollisions: boolean;
  104446. /**
  104447. * Enable or disable gravity on the camera.
  104448. */
  104449. applyGravity: boolean;
  104450. /**
  104451. * Define the current direction the camera is moving to.
  104452. */
  104453. cameraDirection: Vector3;
  104454. /**
  104455. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  104456. * This overrides and empties cameraRotation.
  104457. */
  104458. rotationQuaternion: Quaternion;
  104459. /**
  104460. * Track Roll to maintain the wanted Rolling when looking around.
  104461. */
  104462. _trackRoll: number;
  104463. /**
  104464. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  104465. */
  104466. rollCorrect: number;
  104467. /**
  104468. * Mimic a banked turn, Rolling the camera when Yawing.
  104469. * It's recommended to use rollCorrect = 10 for faster banking correction.
  104470. */
  104471. bankedTurn: boolean;
  104472. /**
  104473. * Limit in radians for how much Roll banking will add. (Default: 90°)
  104474. */
  104475. bankedTurnLimit: number;
  104476. /**
  104477. * Value of 0 disables the banked Roll.
  104478. * Value of 1 is equal to the Yaw angle in radians.
  104479. */
  104480. bankedTurnMultiplier: number;
  104481. /**
  104482. * The inputs manager loads all the input sources, such as keyboard and mouse.
  104483. */
  104484. inputs: FlyCameraInputsManager;
  104485. /**
  104486. * Gets the input sensibility for mouse input.
  104487. * Higher values reduce sensitivity.
  104488. */
  104489. /**
  104490. * Sets the input sensibility for a mouse input.
  104491. * Higher values reduce sensitivity.
  104492. */
  104493. angularSensibility: number;
  104494. /**
  104495. * Get the keys for camera movement forward.
  104496. */
  104497. /**
  104498. * Set the keys for camera movement forward.
  104499. */
  104500. keysForward: number[];
  104501. /**
  104502. * Get the keys for camera movement backward.
  104503. */
  104504. keysBackward: number[];
  104505. /**
  104506. * Get the keys for camera movement up.
  104507. */
  104508. /**
  104509. * Set the keys for camera movement up.
  104510. */
  104511. keysUp: number[];
  104512. /**
  104513. * Get the keys for camera movement down.
  104514. */
  104515. /**
  104516. * Set the keys for camera movement down.
  104517. */
  104518. keysDown: number[];
  104519. /**
  104520. * Get the keys for camera movement left.
  104521. */
  104522. /**
  104523. * Set the keys for camera movement left.
  104524. */
  104525. keysLeft: number[];
  104526. /**
  104527. * Set the keys for camera movement right.
  104528. */
  104529. /**
  104530. * Set the keys for camera movement right.
  104531. */
  104532. keysRight: number[];
  104533. /**
  104534. * Event raised when the camera collides with a mesh in the scene.
  104535. */
  104536. onCollide: (collidedMesh: AbstractMesh) => void;
  104537. private _collider;
  104538. private _needMoveForGravity;
  104539. private _oldPosition;
  104540. private _diffPosition;
  104541. private _newPosition;
  104542. /** @hidden */
  104543. _localDirection: Vector3;
  104544. /** @hidden */
  104545. _transformedDirection: Vector3;
  104546. /**
  104547. * Instantiates a FlyCamera.
  104548. * This is a flying camera, designed for 3D movement and rotation in all directions,
  104549. * such as in a 3D Space Shooter or a Flight Simulator.
  104550. * @param name Define the name of the camera in the scene.
  104551. * @param position Define the starting position of the camera in the scene.
  104552. * @param scene Define the scene the camera belongs to.
  104553. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  104554. */
  104555. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  104556. /**
  104557. * Attach a control to the HTML DOM element.
  104558. * @param element Defines the element that listens to the input events.
  104559. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  104560. */
  104561. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104562. /**
  104563. * Detach a control from the HTML DOM element.
  104564. * The camera will stop reacting to that input.
  104565. * @param element Defines the element that listens to the input events.
  104566. */
  104567. detachControl(element: HTMLElement): void;
  104568. private _collisionMask;
  104569. /**
  104570. * Get the mask that the camera ignores in collision events.
  104571. */
  104572. /**
  104573. * Set the mask that the camera ignores in collision events.
  104574. */
  104575. collisionMask: number;
  104576. /** @hidden */
  104577. _collideWithWorld(displacement: Vector3): void;
  104578. /** @hidden */
  104579. private _onCollisionPositionChange;
  104580. /** @hidden */
  104581. _checkInputs(): void;
  104582. /** @hidden */
  104583. _decideIfNeedsToMove(): boolean;
  104584. /** @hidden */
  104585. _updatePosition(): void;
  104586. /**
  104587. * Restore the Roll to its target value at the rate specified.
  104588. * @param rate - Higher means slower restoring.
  104589. * @hidden
  104590. */
  104591. restoreRoll(rate: number): void;
  104592. /**
  104593. * Destroy the camera and release the current resources held by it.
  104594. */
  104595. dispose(): void;
  104596. /**
  104597. * Get the current object class name.
  104598. * @returns the class name.
  104599. */
  104600. getClassName(): string;
  104601. }
  104602. }
  104603. declare module BABYLON {
  104604. /**
  104605. * Listen to keyboard events to control the camera.
  104606. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104607. */
  104608. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  104609. /**
  104610. * Defines the camera the input is attached to.
  104611. */
  104612. camera: FlyCamera;
  104613. /**
  104614. * The list of keyboard keys used to control the forward move of the camera.
  104615. */
  104616. keysForward: number[];
  104617. /**
  104618. * The list of keyboard keys used to control the backward move of the camera.
  104619. */
  104620. keysBackward: number[];
  104621. /**
  104622. * The list of keyboard keys used to control the forward move of the camera.
  104623. */
  104624. keysUp: number[];
  104625. /**
  104626. * The list of keyboard keys used to control the backward move of the camera.
  104627. */
  104628. keysDown: number[];
  104629. /**
  104630. * The list of keyboard keys used to control the right strafe move of the camera.
  104631. */
  104632. keysRight: number[];
  104633. /**
  104634. * The list of keyboard keys used to control the left strafe move of the camera.
  104635. */
  104636. keysLeft: number[];
  104637. private _keys;
  104638. private _onCanvasBlurObserver;
  104639. private _onKeyboardObserver;
  104640. private _engine;
  104641. private _scene;
  104642. /**
  104643. * Attach the input controls to a specific dom element to get the input from.
  104644. * @param element Defines the element the controls should be listened from
  104645. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104646. */
  104647. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104648. /**
  104649. * Detach the current controls from the specified dom element.
  104650. * @param element Defines the element to stop listening the inputs from
  104651. */
  104652. detachControl(element: Nullable<HTMLElement>): void;
  104653. /**
  104654. * Gets the class name of the current intput.
  104655. * @returns the class name
  104656. */
  104657. getClassName(): string;
  104658. /** @hidden */
  104659. _onLostFocus(e: FocusEvent): void;
  104660. /**
  104661. * Get the friendly name associated with the input class.
  104662. * @returns the input friendly name
  104663. */
  104664. getSimpleName(): string;
  104665. /**
  104666. * Update the current camera state depending on the inputs that have been used this frame.
  104667. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  104668. */
  104669. checkInputs(): void;
  104670. }
  104671. }
  104672. declare module BABYLON {
  104673. /**
  104674. * Manage the mouse wheel inputs to control a follow camera.
  104675. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104676. */
  104677. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  104678. /**
  104679. * Defines the camera the input is attached to.
  104680. */
  104681. camera: FollowCamera;
  104682. /**
  104683. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  104684. */
  104685. axisControlRadius: boolean;
  104686. /**
  104687. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  104688. */
  104689. axisControlHeight: boolean;
  104690. /**
  104691. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  104692. */
  104693. axisControlRotation: boolean;
  104694. /**
  104695. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  104696. * relation to mouseWheel events.
  104697. */
  104698. wheelPrecision: number;
  104699. /**
  104700. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  104701. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  104702. */
  104703. wheelDeltaPercentage: number;
  104704. private _wheel;
  104705. private _observer;
  104706. /**
  104707. * Attach the input controls to a specific dom element to get the input from.
  104708. * @param element Defines the element the controls should be listened from
  104709. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104710. */
  104711. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104712. /**
  104713. * Detach the current controls from the specified dom element.
  104714. * @param element Defines the element to stop listening the inputs from
  104715. */
  104716. detachControl(element: Nullable<HTMLElement>): void;
  104717. /**
  104718. * Gets the class name of the current intput.
  104719. * @returns the class name
  104720. */
  104721. getClassName(): string;
  104722. /**
  104723. * Get the friendly name associated with the input class.
  104724. * @returns the input friendly name
  104725. */
  104726. getSimpleName(): string;
  104727. }
  104728. }
  104729. declare module BABYLON {
  104730. /**
  104731. * Manage the pointers inputs to control an follow camera.
  104732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104733. */
  104734. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  104735. /**
  104736. * Defines the camera the input is attached to.
  104737. */
  104738. camera: FollowCamera;
  104739. /**
  104740. * Gets the class name of the current input.
  104741. * @returns the class name
  104742. */
  104743. getClassName(): string;
  104744. /**
  104745. * Defines the pointer angular sensibility along the X axis or how fast is
  104746. * the camera rotating.
  104747. * A negative number will reverse the axis direction.
  104748. */
  104749. angularSensibilityX: number;
  104750. /**
  104751. * Defines the pointer angular sensibility along the Y axis or how fast is
  104752. * the camera rotating.
  104753. * A negative number will reverse the axis direction.
  104754. */
  104755. angularSensibilityY: number;
  104756. /**
  104757. * Defines the pointer pinch precision or how fast is the camera zooming.
  104758. * A negative number will reverse the axis direction.
  104759. */
  104760. pinchPrecision: number;
  104761. /**
  104762. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  104763. * from 0.
  104764. * It defines the percentage of current camera.radius to use as delta when
  104765. * pinch zoom is used.
  104766. */
  104767. pinchDeltaPercentage: number;
  104768. /**
  104769. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  104770. */
  104771. axisXControlRadius: boolean;
  104772. /**
  104773. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  104774. */
  104775. axisXControlHeight: boolean;
  104776. /**
  104777. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  104778. */
  104779. axisXControlRotation: boolean;
  104780. /**
  104781. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  104782. */
  104783. axisYControlRadius: boolean;
  104784. /**
  104785. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  104786. */
  104787. axisYControlHeight: boolean;
  104788. /**
  104789. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  104790. */
  104791. axisYControlRotation: boolean;
  104792. /**
  104793. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  104794. */
  104795. axisPinchControlRadius: boolean;
  104796. /**
  104797. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  104798. */
  104799. axisPinchControlHeight: boolean;
  104800. /**
  104801. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  104802. */
  104803. axisPinchControlRotation: boolean;
  104804. /**
  104805. * Log error messages if basic misconfiguration has occurred.
  104806. */
  104807. warningEnable: boolean;
  104808. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  104809. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  104810. private _warningCounter;
  104811. private _warning;
  104812. }
  104813. }
  104814. declare module BABYLON {
  104815. /**
  104816. * Default Inputs manager for the FollowCamera.
  104817. * It groups all the default supported inputs for ease of use.
  104818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104819. */
  104820. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  104821. /**
  104822. * Instantiates a new FollowCameraInputsManager.
  104823. * @param camera Defines the camera the inputs belong to
  104824. */
  104825. constructor(camera: FollowCamera);
  104826. /**
  104827. * Add keyboard input support to the input manager.
  104828. * @returns the current input manager
  104829. */
  104830. addKeyboard(): FollowCameraInputsManager;
  104831. /**
  104832. * Add mouse wheel input support to the input manager.
  104833. * @returns the current input manager
  104834. */
  104835. addMouseWheel(): FollowCameraInputsManager;
  104836. /**
  104837. * Add pointers input support to the input manager.
  104838. * @returns the current input manager
  104839. */
  104840. addPointers(): FollowCameraInputsManager;
  104841. /**
  104842. * Add orientation input support to the input manager.
  104843. * @returns the current input manager
  104844. */
  104845. addVRDeviceOrientation(): FollowCameraInputsManager;
  104846. }
  104847. }
  104848. declare module BABYLON {
  104849. /**
  104850. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  104851. * an arc rotate version arcFollowCamera are available.
  104852. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104853. */
  104854. export class FollowCamera extends TargetCamera {
  104855. /**
  104856. * Distance the follow camera should follow an object at
  104857. */
  104858. radius: number;
  104859. /**
  104860. * Minimum allowed distance of the camera to the axis of rotation
  104861. * (The camera can not get closer).
  104862. * This can help limiting how the Camera is able to move in the scene.
  104863. */
  104864. lowerRadiusLimit: Nullable<number>;
  104865. /**
  104866. * Maximum allowed distance of the camera to the axis of rotation
  104867. * (The camera can not get further).
  104868. * This can help limiting how the Camera is able to move in the scene.
  104869. */
  104870. upperRadiusLimit: Nullable<number>;
  104871. /**
  104872. * Define a rotation offset between the camera and the object it follows
  104873. */
  104874. rotationOffset: number;
  104875. /**
  104876. * Minimum allowed angle to camera position relative to target object.
  104877. * This can help limiting how the Camera is able to move in the scene.
  104878. */
  104879. lowerRotationOffsetLimit: Nullable<number>;
  104880. /**
  104881. * Maximum allowed angle to camera position relative to target object.
  104882. * This can help limiting how the Camera is able to move in the scene.
  104883. */
  104884. upperRotationOffsetLimit: Nullable<number>;
  104885. /**
  104886. * Define a height offset between the camera and the object it follows.
  104887. * It can help following an object from the top (like a car chaing a plane)
  104888. */
  104889. heightOffset: number;
  104890. /**
  104891. * Minimum allowed height of camera position relative to target object.
  104892. * This can help limiting how the Camera is able to move in the scene.
  104893. */
  104894. lowerHeightOffsetLimit: Nullable<number>;
  104895. /**
  104896. * Maximum allowed height of camera position relative to target object.
  104897. * This can help limiting how the Camera is able to move in the scene.
  104898. */
  104899. upperHeightOffsetLimit: Nullable<number>;
  104900. /**
  104901. * Define how fast the camera can accelerate to follow it s target.
  104902. */
  104903. cameraAcceleration: number;
  104904. /**
  104905. * Define the speed limit of the camera following an object.
  104906. */
  104907. maxCameraSpeed: number;
  104908. /**
  104909. * Define the target of the camera.
  104910. */
  104911. lockedTarget: Nullable<AbstractMesh>;
  104912. /**
  104913. * Defines the input associated with the camera.
  104914. */
  104915. inputs: FollowCameraInputsManager;
  104916. /**
  104917. * Instantiates the follow camera.
  104918. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104919. * @param name Define the name of the camera in the scene
  104920. * @param position Define the position of the camera
  104921. * @param scene Define the scene the camera belong to
  104922. * @param lockedTarget Define the target of the camera
  104923. */
  104924. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  104925. private _follow;
  104926. /**
  104927. * Attached controls to the current camera.
  104928. * @param element Defines the element the controls should be listened from
  104929. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  104930. */
  104931. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  104932. /**
  104933. * Detach the current controls from the camera.
  104934. * The camera will stop reacting to inputs.
  104935. * @param element Defines the element to stop listening the inputs from
  104936. */
  104937. detachControl(element: HTMLElement): void;
  104938. /** @hidden */
  104939. _checkInputs(): void;
  104940. private _checkLimits;
  104941. /**
  104942. * Gets the camera class name.
  104943. * @returns the class name
  104944. */
  104945. getClassName(): string;
  104946. }
  104947. /**
  104948. * Arc Rotate version of the follow camera.
  104949. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  104950. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104951. */
  104952. export class ArcFollowCamera extends TargetCamera {
  104953. /** The longitudinal angle of the camera */
  104954. alpha: number;
  104955. /** The latitudinal angle of the camera */
  104956. beta: number;
  104957. /** The radius of the camera from its target */
  104958. radius: number;
  104959. /** Define the camera target (the messh it should follow) */
  104960. target: Nullable<AbstractMesh>;
  104961. private _cartesianCoordinates;
  104962. /**
  104963. * Instantiates a new ArcFollowCamera
  104964. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  104965. * @param name Define the name of the camera
  104966. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  104967. * @param beta Define the rotation angle of the camera around the elevation axis
  104968. * @param radius Define the radius of the camera from its target point
  104969. * @param target Define the target of the camera
  104970. * @param scene Define the scene the camera belongs to
  104971. */
  104972. constructor(name: string,
  104973. /** The longitudinal angle of the camera */
  104974. alpha: number,
  104975. /** The latitudinal angle of the camera */
  104976. beta: number,
  104977. /** The radius of the camera from its target */
  104978. radius: number,
  104979. /** Define the camera target (the messh it should follow) */
  104980. target: Nullable<AbstractMesh>, scene: Scene);
  104981. private _follow;
  104982. /** @hidden */
  104983. _checkInputs(): void;
  104984. /**
  104985. * Returns the class name of the object.
  104986. * It is mostly used internally for serialization purposes.
  104987. */
  104988. getClassName(): string;
  104989. }
  104990. }
  104991. declare module BABYLON {
  104992. /**
  104993. * Manage the keyboard inputs to control the movement of a follow camera.
  104994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  104995. */
  104996. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  104997. /**
  104998. * Defines the camera the input is attached to.
  104999. */
  105000. camera: FollowCamera;
  105001. /**
  105002. * Defines the list of key codes associated with the up action (increase heightOffset)
  105003. */
  105004. keysHeightOffsetIncr: number[];
  105005. /**
  105006. * Defines the list of key codes associated with the down action (decrease heightOffset)
  105007. */
  105008. keysHeightOffsetDecr: number[];
  105009. /**
  105010. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  105011. */
  105012. keysHeightOffsetModifierAlt: boolean;
  105013. /**
  105014. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  105015. */
  105016. keysHeightOffsetModifierCtrl: boolean;
  105017. /**
  105018. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  105019. */
  105020. keysHeightOffsetModifierShift: boolean;
  105021. /**
  105022. * Defines the list of key codes associated with the left action (increase rotationOffset)
  105023. */
  105024. keysRotationOffsetIncr: number[];
  105025. /**
  105026. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  105027. */
  105028. keysRotationOffsetDecr: number[];
  105029. /**
  105030. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  105031. */
  105032. keysRotationOffsetModifierAlt: boolean;
  105033. /**
  105034. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  105035. */
  105036. keysRotationOffsetModifierCtrl: boolean;
  105037. /**
  105038. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  105039. */
  105040. keysRotationOffsetModifierShift: boolean;
  105041. /**
  105042. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  105043. */
  105044. keysRadiusIncr: number[];
  105045. /**
  105046. * Defines the list of key codes associated with the zoom-out action (increase radius)
  105047. */
  105048. keysRadiusDecr: number[];
  105049. /**
  105050. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  105051. */
  105052. keysRadiusModifierAlt: boolean;
  105053. /**
  105054. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  105055. */
  105056. keysRadiusModifierCtrl: boolean;
  105057. /**
  105058. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  105059. */
  105060. keysRadiusModifierShift: boolean;
  105061. /**
  105062. * Defines the rate of change of heightOffset.
  105063. */
  105064. heightSensibility: number;
  105065. /**
  105066. * Defines the rate of change of rotationOffset.
  105067. */
  105068. rotationSensibility: number;
  105069. /**
  105070. * Defines the rate of change of radius.
  105071. */
  105072. radiusSensibility: number;
  105073. private _keys;
  105074. private _ctrlPressed;
  105075. private _altPressed;
  105076. private _shiftPressed;
  105077. private _onCanvasBlurObserver;
  105078. private _onKeyboardObserver;
  105079. private _engine;
  105080. private _scene;
  105081. /**
  105082. * Attach the input controls to a specific dom element to get the input from.
  105083. * @param element Defines the element the controls should be listened from
  105084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105085. */
  105086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105087. /**
  105088. * Detach the current controls from the specified dom element.
  105089. * @param element Defines the element to stop listening the inputs from
  105090. */
  105091. detachControl(element: Nullable<HTMLElement>): void;
  105092. /**
  105093. * Update the current camera state depending on the inputs that have been used this frame.
  105094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105095. */
  105096. checkInputs(): void;
  105097. /**
  105098. * Gets the class name of the current input.
  105099. * @returns the class name
  105100. */
  105101. getClassName(): string;
  105102. /**
  105103. * Get the friendly name associated with the input class.
  105104. * @returns the input friendly name
  105105. */
  105106. getSimpleName(): string;
  105107. /**
  105108. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105109. * allow modification of the heightOffset value.
  105110. */
  105111. private _modifierHeightOffset;
  105112. /**
  105113. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105114. * allow modification of the rotationOffset value.
  105115. */
  105116. private _modifierRotationOffset;
  105117. /**
  105118. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  105119. * allow modification of the radius value.
  105120. */
  105121. private _modifierRadius;
  105122. }
  105123. }
  105124. declare module BABYLON {
  105125. interface FreeCameraInputsManager {
  105126. /**
  105127. * @hidden
  105128. */
  105129. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  105130. /**
  105131. * Add orientation input support to the input manager.
  105132. * @returns the current input manager
  105133. */
  105134. addDeviceOrientation(): FreeCameraInputsManager;
  105135. }
  105136. /**
  105137. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  105138. * Screen rotation is taken into account.
  105139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105140. */
  105141. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  105142. private _camera;
  105143. private _screenOrientationAngle;
  105144. private _constantTranform;
  105145. private _screenQuaternion;
  105146. private _alpha;
  105147. private _beta;
  105148. private _gamma;
  105149. /**
  105150. * Can be used to detect if a device orientation sensor is availible on a device
  105151. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  105152. * @returns a promise that will resolve on orientation change
  105153. */
  105154. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  105155. /**
  105156. * @hidden
  105157. */
  105158. _onDeviceOrientationChangedObservable: Observable<void>;
  105159. /**
  105160. * Instantiates a new input
  105161. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105162. */
  105163. constructor();
  105164. /**
  105165. * Define the camera controlled by the input.
  105166. */
  105167. camera: FreeCamera;
  105168. /**
  105169. * Attach the input controls to a specific dom element to get the input from.
  105170. * @param element Defines the element the controls should be listened from
  105171. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105172. */
  105173. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105174. private _orientationChanged;
  105175. private _deviceOrientation;
  105176. /**
  105177. * Detach the current controls from the specified dom element.
  105178. * @param element Defines the element to stop listening the inputs from
  105179. */
  105180. detachControl(element: Nullable<HTMLElement>): void;
  105181. /**
  105182. * Update the current camera state depending on the inputs that have been used this frame.
  105183. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105184. */
  105185. checkInputs(): void;
  105186. /**
  105187. * Gets the class name of the current intput.
  105188. * @returns the class name
  105189. */
  105190. getClassName(): string;
  105191. /**
  105192. * Get the friendly name associated with the input class.
  105193. * @returns the input friendly name
  105194. */
  105195. getSimpleName(): string;
  105196. }
  105197. }
  105198. declare module BABYLON {
  105199. /**
  105200. * Manage the gamepad inputs to control a free camera.
  105201. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105202. */
  105203. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  105204. /**
  105205. * Define the camera the input is attached to.
  105206. */
  105207. camera: FreeCamera;
  105208. /**
  105209. * Define the Gamepad controlling the input
  105210. */
  105211. gamepad: Nullable<Gamepad>;
  105212. /**
  105213. * Defines the gamepad rotation sensiblity.
  105214. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  105215. */
  105216. gamepadAngularSensibility: number;
  105217. /**
  105218. * Defines the gamepad move sensiblity.
  105219. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  105220. */
  105221. gamepadMoveSensibility: number;
  105222. private _onGamepadConnectedObserver;
  105223. private _onGamepadDisconnectedObserver;
  105224. private _cameraTransform;
  105225. private _deltaTransform;
  105226. private _vector3;
  105227. private _vector2;
  105228. /**
  105229. * Attach the input controls to a specific dom element to get the input from.
  105230. * @param element Defines the element the controls should be listened from
  105231. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105232. */
  105233. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105234. /**
  105235. * Detach the current controls from the specified dom element.
  105236. * @param element Defines the element to stop listening the inputs from
  105237. */
  105238. detachControl(element: Nullable<HTMLElement>): void;
  105239. /**
  105240. * Update the current camera state depending on the inputs that have been used this frame.
  105241. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105242. */
  105243. checkInputs(): void;
  105244. /**
  105245. * Gets the class name of the current intput.
  105246. * @returns the class name
  105247. */
  105248. getClassName(): string;
  105249. /**
  105250. * Get the friendly name associated with the input class.
  105251. * @returns the input friendly name
  105252. */
  105253. getSimpleName(): string;
  105254. }
  105255. }
  105256. declare module BABYLON {
  105257. /**
  105258. * Defines the potential axis of a Joystick
  105259. */
  105260. export enum JoystickAxis {
  105261. /** X axis */
  105262. X = 0,
  105263. /** Y axis */
  105264. Y = 1,
  105265. /** Z axis */
  105266. Z = 2
  105267. }
  105268. /**
  105269. * Class used to define virtual joystick (used in touch mode)
  105270. */
  105271. export class VirtualJoystick {
  105272. /**
  105273. * Gets or sets a boolean indicating that left and right values must be inverted
  105274. */
  105275. reverseLeftRight: boolean;
  105276. /**
  105277. * Gets or sets a boolean indicating that up and down values must be inverted
  105278. */
  105279. reverseUpDown: boolean;
  105280. /**
  105281. * Gets the offset value for the position (ie. the change of the position value)
  105282. */
  105283. deltaPosition: Vector3;
  105284. /**
  105285. * Gets a boolean indicating if the virtual joystick was pressed
  105286. */
  105287. pressed: boolean;
  105288. /**
  105289. * Canvas the virtual joystick will render onto, default z-index of this is 5
  105290. */
  105291. static Canvas: Nullable<HTMLCanvasElement>;
  105292. private static _globalJoystickIndex;
  105293. private static vjCanvasContext;
  105294. private static vjCanvasWidth;
  105295. private static vjCanvasHeight;
  105296. private static halfWidth;
  105297. private _action;
  105298. private _axisTargetedByLeftAndRight;
  105299. private _axisTargetedByUpAndDown;
  105300. private _joystickSensibility;
  105301. private _inversedSensibility;
  105302. private _joystickPointerID;
  105303. private _joystickColor;
  105304. private _joystickPointerPos;
  105305. private _joystickPreviousPointerPos;
  105306. private _joystickPointerStartPos;
  105307. private _deltaJoystickVector;
  105308. private _leftJoystick;
  105309. private _touches;
  105310. private _onPointerDownHandlerRef;
  105311. private _onPointerMoveHandlerRef;
  105312. private _onPointerUpHandlerRef;
  105313. private _onResize;
  105314. /**
  105315. * Creates a new virtual joystick
  105316. * @param leftJoystick defines that the joystick is for left hand (false by default)
  105317. */
  105318. constructor(leftJoystick?: boolean);
  105319. /**
  105320. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  105321. * @param newJoystickSensibility defines the new sensibility
  105322. */
  105323. setJoystickSensibility(newJoystickSensibility: number): void;
  105324. private _onPointerDown;
  105325. private _onPointerMove;
  105326. private _onPointerUp;
  105327. /**
  105328. * Change the color of the virtual joystick
  105329. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  105330. */
  105331. setJoystickColor(newColor: string): void;
  105332. /**
  105333. * Defines a callback to call when the joystick is touched
  105334. * @param action defines the callback
  105335. */
  105336. setActionOnTouch(action: () => any): void;
  105337. /**
  105338. * Defines which axis you'd like to control for left & right
  105339. * @param axis defines the axis to use
  105340. */
  105341. setAxisForLeftRight(axis: JoystickAxis): void;
  105342. /**
  105343. * Defines which axis you'd like to control for up & down
  105344. * @param axis defines the axis to use
  105345. */
  105346. setAxisForUpDown(axis: JoystickAxis): void;
  105347. private _drawVirtualJoystick;
  105348. /**
  105349. * Release internal HTML canvas
  105350. */
  105351. releaseCanvas(): void;
  105352. }
  105353. }
  105354. declare module BABYLON {
  105355. interface FreeCameraInputsManager {
  105356. /**
  105357. * Add virtual joystick input support to the input manager.
  105358. * @returns the current input manager
  105359. */
  105360. addVirtualJoystick(): FreeCameraInputsManager;
  105361. }
  105362. /**
  105363. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  105364. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  105365. */
  105366. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  105367. /**
  105368. * Defines the camera the input is attached to.
  105369. */
  105370. camera: FreeCamera;
  105371. private _leftjoystick;
  105372. private _rightjoystick;
  105373. /**
  105374. * Gets the left stick of the virtual joystick.
  105375. * @returns The virtual Joystick
  105376. */
  105377. getLeftJoystick(): VirtualJoystick;
  105378. /**
  105379. * Gets the right stick of the virtual joystick.
  105380. * @returns The virtual Joystick
  105381. */
  105382. getRightJoystick(): VirtualJoystick;
  105383. /**
  105384. * Update the current camera state depending on the inputs that have been used this frame.
  105385. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  105386. */
  105387. checkInputs(): void;
  105388. /**
  105389. * Attach the input controls to a specific dom element to get the input from.
  105390. * @param element Defines the element the controls should be listened from
  105391. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  105392. */
  105393. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  105394. /**
  105395. * Detach the current controls from the specified dom element.
  105396. * @param element Defines the element to stop listening the inputs from
  105397. */
  105398. detachControl(element: Nullable<HTMLElement>): void;
  105399. /**
  105400. * Gets the class name of the current intput.
  105401. * @returns the class name
  105402. */
  105403. getClassName(): string;
  105404. /**
  105405. * Get the friendly name associated with the input class.
  105406. * @returns the input friendly name
  105407. */
  105408. getSimpleName(): string;
  105409. }
  105410. }
  105411. declare module BABYLON {
  105412. /**
  105413. * This represents a FPS type of camera controlled by touch.
  105414. * This is like a universal camera minus the Gamepad controls.
  105415. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105416. */
  105417. export class TouchCamera extends FreeCamera {
  105418. /**
  105419. * Defines the touch sensibility for rotation.
  105420. * The higher the faster.
  105421. */
  105422. touchAngularSensibility: number;
  105423. /**
  105424. * Defines the touch sensibility for move.
  105425. * The higher the faster.
  105426. */
  105427. touchMoveSensibility: number;
  105428. /**
  105429. * Instantiates a new touch camera.
  105430. * This represents a FPS type of camera controlled by touch.
  105431. * This is like a universal camera minus the Gamepad controls.
  105432. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  105433. * @param name Define the name of the camera in the scene
  105434. * @param position Define the start position of the camera in the scene
  105435. * @param scene Define the scene the camera belongs to
  105436. */
  105437. constructor(name: string, position: Vector3, scene: Scene);
  105438. /**
  105439. * Gets the current object class name.
  105440. * @return the class name
  105441. */
  105442. getClassName(): string;
  105443. /** @hidden */
  105444. _setupInputs(): void;
  105445. }
  105446. }
  105447. declare module BABYLON {
  105448. /**
  105449. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  105450. * being tilted forward or back and left or right.
  105451. */
  105452. export class DeviceOrientationCamera extends FreeCamera {
  105453. private _initialQuaternion;
  105454. private _quaternionCache;
  105455. private _tmpDragQuaternion;
  105456. private _disablePointerInputWhenUsingDeviceOrientation;
  105457. /**
  105458. * Creates a new device orientation camera
  105459. * @param name The name of the camera
  105460. * @param position The start position camera
  105461. * @param scene The scene the camera belongs to
  105462. */
  105463. constructor(name: string, position: Vector3, scene: Scene);
  105464. /**
  105465. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  105466. */
  105467. disablePointerInputWhenUsingDeviceOrientation: boolean;
  105468. private _dragFactor;
  105469. /**
  105470. * Enabled turning on the y axis when the orientation sensor is active
  105471. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  105472. */
  105473. enableHorizontalDragging(dragFactor?: number): void;
  105474. /**
  105475. * Gets the current instance class name ("DeviceOrientationCamera").
  105476. * This helps avoiding instanceof at run time.
  105477. * @returns the class name
  105478. */
  105479. getClassName(): string;
  105480. /**
  105481. * @hidden
  105482. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  105483. */
  105484. _checkInputs(): void;
  105485. /**
  105486. * Reset the camera to its default orientation on the specified axis only.
  105487. * @param axis The axis to reset
  105488. */
  105489. resetToCurrentRotation(axis?: Axis): void;
  105490. }
  105491. }
  105492. declare module BABYLON {
  105493. /**
  105494. * Defines supported buttons for XBox360 compatible gamepads
  105495. */
  105496. export enum Xbox360Button {
  105497. /** A */
  105498. A = 0,
  105499. /** B */
  105500. B = 1,
  105501. /** X */
  105502. X = 2,
  105503. /** Y */
  105504. Y = 3,
  105505. /** Start */
  105506. Start = 4,
  105507. /** Back */
  105508. Back = 5,
  105509. /** Left button */
  105510. LB = 6,
  105511. /** Right button */
  105512. RB = 7,
  105513. /** Left stick */
  105514. LeftStick = 8,
  105515. /** Right stick */
  105516. RightStick = 9
  105517. }
  105518. /** Defines values for XBox360 DPad */
  105519. export enum Xbox360Dpad {
  105520. /** Up */
  105521. Up = 0,
  105522. /** Down */
  105523. Down = 1,
  105524. /** Left */
  105525. Left = 2,
  105526. /** Right */
  105527. Right = 3
  105528. }
  105529. /**
  105530. * Defines a XBox360 gamepad
  105531. */
  105532. export class Xbox360Pad extends Gamepad {
  105533. private _leftTrigger;
  105534. private _rightTrigger;
  105535. private _onlefttriggerchanged;
  105536. private _onrighttriggerchanged;
  105537. private _onbuttondown;
  105538. private _onbuttonup;
  105539. private _ondpaddown;
  105540. private _ondpadup;
  105541. /** Observable raised when a button is pressed */
  105542. onButtonDownObservable: Observable<Xbox360Button>;
  105543. /** Observable raised when a button is released */
  105544. onButtonUpObservable: Observable<Xbox360Button>;
  105545. /** Observable raised when a pad is pressed */
  105546. onPadDownObservable: Observable<Xbox360Dpad>;
  105547. /** Observable raised when a pad is released */
  105548. onPadUpObservable: Observable<Xbox360Dpad>;
  105549. private _buttonA;
  105550. private _buttonB;
  105551. private _buttonX;
  105552. private _buttonY;
  105553. private _buttonBack;
  105554. private _buttonStart;
  105555. private _buttonLB;
  105556. private _buttonRB;
  105557. private _buttonLeftStick;
  105558. private _buttonRightStick;
  105559. private _dPadUp;
  105560. private _dPadDown;
  105561. private _dPadLeft;
  105562. private _dPadRight;
  105563. private _isXboxOnePad;
  105564. /**
  105565. * Creates a new XBox360 gamepad object
  105566. * @param id defines the id of this gamepad
  105567. * @param index defines its index
  105568. * @param gamepad defines the internal HTML gamepad object
  105569. * @param xboxOne defines if it is a XBox One gamepad
  105570. */
  105571. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  105572. /**
  105573. * Defines the callback to call when left trigger is pressed
  105574. * @param callback defines the callback to use
  105575. */
  105576. onlefttriggerchanged(callback: (value: number) => void): void;
  105577. /**
  105578. * Defines the callback to call when right trigger is pressed
  105579. * @param callback defines the callback to use
  105580. */
  105581. onrighttriggerchanged(callback: (value: number) => void): void;
  105582. /**
  105583. * Gets the left trigger value
  105584. */
  105585. /**
  105586. * Sets the left trigger value
  105587. */
  105588. leftTrigger: number;
  105589. /**
  105590. * Gets the right trigger value
  105591. */
  105592. /**
  105593. * Sets the right trigger value
  105594. */
  105595. rightTrigger: number;
  105596. /**
  105597. * Defines the callback to call when a button is pressed
  105598. * @param callback defines the callback to use
  105599. */
  105600. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  105601. /**
  105602. * Defines the callback to call when a button is released
  105603. * @param callback defines the callback to use
  105604. */
  105605. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  105606. /**
  105607. * Defines the callback to call when a pad is pressed
  105608. * @param callback defines the callback to use
  105609. */
  105610. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  105611. /**
  105612. * Defines the callback to call when a pad is released
  105613. * @param callback defines the callback to use
  105614. */
  105615. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  105616. private _setButtonValue;
  105617. private _setDPadValue;
  105618. /**
  105619. * Gets the value of the `A` button
  105620. */
  105621. /**
  105622. * Sets the value of the `A` button
  105623. */
  105624. buttonA: number;
  105625. /**
  105626. * Gets the value of the `B` button
  105627. */
  105628. /**
  105629. * Sets the value of the `B` button
  105630. */
  105631. buttonB: number;
  105632. /**
  105633. * Gets the value of the `X` button
  105634. */
  105635. /**
  105636. * Sets the value of the `X` button
  105637. */
  105638. buttonX: number;
  105639. /**
  105640. * Gets the value of the `Y` button
  105641. */
  105642. /**
  105643. * Sets the value of the `Y` button
  105644. */
  105645. buttonY: number;
  105646. /**
  105647. * Gets the value of the `Start` button
  105648. */
  105649. /**
  105650. * Sets the value of the `Start` button
  105651. */
  105652. buttonStart: number;
  105653. /**
  105654. * Gets the value of the `Back` button
  105655. */
  105656. /**
  105657. * Sets the value of the `Back` button
  105658. */
  105659. buttonBack: number;
  105660. /**
  105661. * Gets the value of the `Left` button
  105662. */
  105663. /**
  105664. * Sets the value of the `Left` button
  105665. */
  105666. buttonLB: number;
  105667. /**
  105668. * Gets the value of the `Right` button
  105669. */
  105670. /**
  105671. * Sets the value of the `Right` button
  105672. */
  105673. buttonRB: number;
  105674. /**
  105675. * Gets the value of the Left joystick
  105676. */
  105677. /**
  105678. * Sets the value of the Left joystick
  105679. */
  105680. buttonLeftStick: number;
  105681. /**
  105682. * Gets the value of the Right joystick
  105683. */
  105684. /**
  105685. * Sets the value of the Right joystick
  105686. */
  105687. buttonRightStick: number;
  105688. /**
  105689. * Gets the value of D-pad up
  105690. */
  105691. /**
  105692. * Sets the value of D-pad up
  105693. */
  105694. dPadUp: number;
  105695. /**
  105696. * Gets the value of D-pad down
  105697. */
  105698. /**
  105699. * Sets the value of D-pad down
  105700. */
  105701. dPadDown: number;
  105702. /**
  105703. * Gets the value of D-pad left
  105704. */
  105705. /**
  105706. * Sets the value of D-pad left
  105707. */
  105708. dPadLeft: number;
  105709. /**
  105710. * Gets the value of D-pad right
  105711. */
  105712. /**
  105713. * Sets the value of D-pad right
  105714. */
  105715. dPadRight: number;
  105716. /**
  105717. * Force the gamepad to synchronize with device values
  105718. */
  105719. update(): void;
  105720. /**
  105721. * Disposes the gamepad
  105722. */
  105723. dispose(): void;
  105724. }
  105725. }
  105726. declare module BABYLON {
  105727. /**
  105728. * Defines supported buttons for DualShock compatible gamepads
  105729. */
  105730. export enum DualShockButton {
  105731. /** Cross */
  105732. Cross = 0,
  105733. /** Circle */
  105734. Circle = 1,
  105735. /** Square */
  105736. Square = 2,
  105737. /** Triangle */
  105738. Triangle = 3,
  105739. /** Options */
  105740. Options = 4,
  105741. /** Share */
  105742. Share = 5,
  105743. /** L1 */
  105744. L1 = 6,
  105745. /** R1 */
  105746. R1 = 7,
  105747. /** Left stick */
  105748. LeftStick = 8,
  105749. /** Right stick */
  105750. RightStick = 9
  105751. }
  105752. /** Defines values for DualShock DPad */
  105753. export enum DualShockDpad {
  105754. /** Up */
  105755. Up = 0,
  105756. /** Down */
  105757. Down = 1,
  105758. /** Left */
  105759. Left = 2,
  105760. /** Right */
  105761. Right = 3
  105762. }
  105763. /**
  105764. * Defines a DualShock gamepad
  105765. */
  105766. export class DualShockPad extends Gamepad {
  105767. private _leftTrigger;
  105768. private _rightTrigger;
  105769. private _onlefttriggerchanged;
  105770. private _onrighttriggerchanged;
  105771. private _onbuttondown;
  105772. private _onbuttonup;
  105773. private _ondpaddown;
  105774. private _ondpadup;
  105775. /** Observable raised when a button is pressed */
  105776. onButtonDownObservable: Observable<DualShockButton>;
  105777. /** Observable raised when a button is released */
  105778. onButtonUpObservable: Observable<DualShockButton>;
  105779. /** Observable raised when a pad is pressed */
  105780. onPadDownObservable: Observable<DualShockDpad>;
  105781. /** Observable raised when a pad is released */
  105782. onPadUpObservable: Observable<DualShockDpad>;
  105783. private _buttonCross;
  105784. private _buttonCircle;
  105785. private _buttonSquare;
  105786. private _buttonTriangle;
  105787. private _buttonShare;
  105788. private _buttonOptions;
  105789. private _buttonL1;
  105790. private _buttonR1;
  105791. private _buttonLeftStick;
  105792. private _buttonRightStick;
  105793. private _dPadUp;
  105794. private _dPadDown;
  105795. private _dPadLeft;
  105796. private _dPadRight;
  105797. /**
  105798. * Creates a new DualShock gamepad object
  105799. * @param id defines the id of this gamepad
  105800. * @param index defines its index
  105801. * @param gamepad defines the internal HTML gamepad object
  105802. */
  105803. constructor(id: string, index: number, gamepad: any);
  105804. /**
  105805. * Defines the callback to call when left trigger is pressed
  105806. * @param callback defines the callback to use
  105807. */
  105808. onlefttriggerchanged(callback: (value: number) => void): void;
  105809. /**
  105810. * Defines the callback to call when right trigger is pressed
  105811. * @param callback defines the callback to use
  105812. */
  105813. onrighttriggerchanged(callback: (value: number) => void): void;
  105814. /**
  105815. * Gets the left trigger value
  105816. */
  105817. /**
  105818. * Sets the left trigger value
  105819. */
  105820. leftTrigger: number;
  105821. /**
  105822. * Gets the right trigger value
  105823. */
  105824. /**
  105825. * Sets the right trigger value
  105826. */
  105827. rightTrigger: number;
  105828. /**
  105829. * Defines the callback to call when a button is pressed
  105830. * @param callback defines the callback to use
  105831. */
  105832. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  105833. /**
  105834. * Defines the callback to call when a button is released
  105835. * @param callback defines the callback to use
  105836. */
  105837. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  105838. /**
  105839. * Defines the callback to call when a pad is pressed
  105840. * @param callback defines the callback to use
  105841. */
  105842. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  105843. /**
  105844. * Defines the callback to call when a pad is released
  105845. * @param callback defines the callback to use
  105846. */
  105847. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  105848. private _setButtonValue;
  105849. private _setDPadValue;
  105850. /**
  105851. * Gets the value of the `Cross` button
  105852. */
  105853. /**
  105854. * Sets the value of the `Cross` button
  105855. */
  105856. buttonCross: number;
  105857. /**
  105858. * Gets the value of the `Circle` button
  105859. */
  105860. /**
  105861. * Sets the value of the `Circle` button
  105862. */
  105863. buttonCircle: number;
  105864. /**
  105865. * Gets the value of the `Square` button
  105866. */
  105867. /**
  105868. * Sets the value of the `Square` button
  105869. */
  105870. buttonSquare: number;
  105871. /**
  105872. * Gets the value of the `Triangle` button
  105873. */
  105874. /**
  105875. * Sets the value of the `Triangle` button
  105876. */
  105877. buttonTriangle: number;
  105878. /**
  105879. * Gets the value of the `Options` button
  105880. */
  105881. /**
  105882. * Sets the value of the `Options` button
  105883. */
  105884. buttonOptions: number;
  105885. /**
  105886. * Gets the value of the `Share` button
  105887. */
  105888. /**
  105889. * Sets the value of the `Share` button
  105890. */
  105891. buttonShare: number;
  105892. /**
  105893. * Gets the value of the `L1` button
  105894. */
  105895. /**
  105896. * Sets the value of the `L1` button
  105897. */
  105898. buttonL1: number;
  105899. /**
  105900. * Gets the value of the `R1` button
  105901. */
  105902. /**
  105903. * Sets the value of the `R1` button
  105904. */
  105905. buttonR1: number;
  105906. /**
  105907. * Gets the value of the Left joystick
  105908. */
  105909. /**
  105910. * Sets the value of the Left joystick
  105911. */
  105912. buttonLeftStick: number;
  105913. /**
  105914. * Gets the value of the Right joystick
  105915. */
  105916. /**
  105917. * Sets the value of the Right joystick
  105918. */
  105919. buttonRightStick: number;
  105920. /**
  105921. * Gets the value of D-pad up
  105922. */
  105923. /**
  105924. * Sets the value of D-pad up
  105925. */
  105926. dPadUp: number;
  105927. /**
  105928. * Gets the value of D-pad down
  105929. */
  105930. /**
  105931. * Sets the value of D-pad down
  105932. */
  105933. dPadDown: number;
  105934. /**
  105935. * Gets the value of D-pad left
  105936. */
  105937. /**
  105938. * Sets the value of D-pad left
  105939. */
  105940. dPadLeft: number;
  105941. /**
  105942. * Gets the value of D-pad right
  105943. */
  105944. /**
  105945. * Sets the value of D-pad right
  105946. */
  105947. dPadRight: number;
  105948. /**
  105949. * Force the gamepad to synchronize with device values
  105950. */
  105951. update(): void;
  105952. /**
  105953. * Disposes the gamepad
  105954. */
  105955. dispose(): void;
  105956. }
  105957. }
  105958. declare module BABYLON {
  105959. /**
  105960. * Manager for handling gamepads
  105961. */
  105962. export class GamepadManager {
  105963. private _scene?;
  105964. private _babylonGamepads;
  105965. private _oneGamepadConnected;
  105966. /** @hidden */
  105967. _isMonitoring: boolean;
  105968. private _gamepadEventSupported;
  105969. private _gamepadSupport;
  105970. /**
  105971. * observable to be triggered when the gamepad controller has been connected
  105972. */
  105973. onGamepadConnectedObservable: Observable<Gamepad>;
  105974. /**
  105975. * observable to be triggered when the gamepad controller has been disconnected
  105976. */
  105977. onGamepadDisconnectedObservable: Observable<Gamepad>;
  105978. private _onGamepadConnectedEvent;
  105979. private _onGamepadDisconnectedEvent;
  105980. /**
  105981. * Initializes the gamepad manager
  105982. * @param _scene BabylonJS scene
  105983. */
  105984. constructor(_scene?: Scene | undefined);
  105985. /**
  105986. * The gamepads in the game pad manager
  105987. */
  105988. readonly gamepads: Gamepad[];
  105989. /**
  105990. * Get the gamepad controllers based on type
  105991. * @param type The type of gamepad controller
  105992. * @returns Nullable gamepad
  105993. */
  105994. getGamepadByType(type?: number): Nullable<Gamepad>;
  105995. /**
  105996. * Disposes the gamepad manager
  105997. */
  105998. dispose(): void;
  105999. private _addNewGamepad;
  106000. private _startMonitoringGamepads;
  106001. private _stopMonitoringGamepads;
  106002. /** @hidden */
  106003. _checkGamepadsStatus(): void;
  106004. private _updateGamepadObjects;
  106005. }
  106006. }
  106007. declare module BABYLON {
  106008. interface Scene {
  106009. /** @hidden */
  106010. _gamepadManager: Nullable<GamepadManager>;
  106011. /**
  106012. * Gets the gamepad manager associated with the scene
  106013. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  106014. */
  106015. gamepadManager: GamepadManager;
  106016. }
  106017. /**
  106018. * Interface representing a free camera inputs manager
  106019. */
  106020. interface FreeCameraInputsManager {
  106021. /**
  106022. * Adds gamepad input support to the FreeCameraInputsManager.
  106023. * @returns the FreeCameraInputsManager
  106024. */
  106025. addGamepad(): FreeCameraInputsManager;
  106026. }
  106027. /**
  106028. * Interface representing an arc rotate camera inputs manager
  106029. */
  106030. interface ArcRotateCameraInputsManager {
  106031. /**
  106032. * Adds gamepad input support to the ArcRotateCamera InputManager.
  106033. * @returns the camera inputs manager
  106034. */
  106035. addGamepad(): ArcRotateCameraInputsManager;
  106036. }
  106037. /**
  106038. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  106039. */
  106040. export class GamepadSystemSceneComponent implements ISceneComponent {
  106041. /**
  106042. * The component name helpfull to identify the component in the list of scene components.
  106043. */
  106044. readonly name: string;
  106045. /**
  106046. * The scene the component belongs to.
  106047. */
  106048. scene: Scene;
  106049. /**
  106050. * Creates a new instance of the component for the given scene
  106051. * @param scene Defines the scene to register the component in
  106052. */
  106053. constructor(scene: Scene);
  106054. /**
  106055. * Registers the component in a given scene
  106056. */
  106057. register(): void;
  106058. /**
  106059. * Rebuilds the elements related to this component in case of
  106060. * context lost for instance.
  106061. */
  106062. rebuild(): void;
  106063. /**
  106064. * Disposes the component and the associated ressources
  106065. */
  106066. dispose(): void;
  106067. private _beforeCameraUpdate;
  106068. }
  106069. }
  106070. declare module BABYLON {
  106071. /**
  106072. * 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,
  106073. * which still works and will still be found in many Playgrounds.
  106074. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106075. */
  106076. export class UniversalCamera extends TouchCamera {
  106077. /**
  106078. * Defines the gamepad rotation sensiblity.
  106079. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  106080. */
  106081. gamepadAngularSensibility: number;
  106082. /**
  106083. * Defines the gamepad move sensiblity.
  106084. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  106085. */
  106086. gamepadMoveSensibility: number;
  106087. /**
  106088. * 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,
  106089. * which still works and will still be found in many Playgrounds.
  106090. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106091. * @param name Define the name of the camera in the scene
  106092. * @param position Define the start position of the camera in the scene
  106093. * @param scene Define the scene the camera belongs to
  106094. */
  106095. constructor(name: string, position: Vector3, scene: Scene);
  106096. /**
  106097. * Gets the current object class name.
  106098. * @return the class name
  106099. */
  106100. getClassName(): string;
  106101. }
  106102. }
  106103. declare module BABYLON {
  106104. /**
  106105. * This represents a FPS type of camera. This is only here for back compat purpose.
  106106. * Please use the UniversalCamera instead as both are identical.
  106107. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106108. */
  106109. export class GamepadCamera extends UniversalCamera {
  106110. /**
  106111. * Instantiates a new Gamepad Camera
  106112. * This represents a FPS type of camera. This is only here for back compat purpose.
  106113. * Please use the UniversalCamera instead as both are identical.
  106114. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  106115. * @param name Define the name of the camera in the scene
  106116. * @param position Define the start position of the camera in the scene
  106117. * @param scene Define the scene the camera belongs to
  106118. */
  106119. constructor(name: string, position: Vector3, scene: Scene);
  106120. /**
  106121. * Gets the current object class name.
  106122. * @return the class name
  106123. */
  106124. getClassName(): string;
  106125. }
  106126. }
  106127. declare module BABYLON {
  106128. /** @hidden */
  106129. export var passPixelShader: {
  106130. name: string;
  106131. shader: string;
  106132. };
  106133. }
  106134. declare module BABYLON {
  106135. /** @hidden */
  106136. export var passCubePixelShader: {
  106137. name: string;
  106138. shader: string;
  106139. };
  106140. }
  106141. declare module BABYLON {
  106142. /**
  106143. * PassPostProcess which produces an output the same as it's input
  106144. */
  106145. export class PassPostProcess extends PostProcess {
  106146. /**
  106147. * Creates the PassPostProcess
  106148. * @param name The name of the effect.
  106149. * @param options The required width/height ratio to downsize to before computing the render pass.
  106150. * @param camera The camera to apply the render pass to.
  106151. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106152. * @param engine The engine which the post process will be applied. (default: current engine)
  106153. * @param reusable If the post process can be reused on the same frame. (default: false)
  106154. * @param textureType The type of texture to be used when performing the post processing.
  106155. * @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)
  106156. */
  106157. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106158. }
  106159. /**
  106160. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  106161. */
  106162. export class PassCubePostProcess extends PostProcess {
  106163. private _face;
  106164. /**
  106165. * Gets or sets the cube face to display.
  106166. * * 0 is +X
  106167. * * 1 is -X
  106168. * * 2 is +Y
  106169. * * 3 is -Y
  106170. * * 4 is +Z
  106171. * * 5 is -Z
  106172. */
  106173. face: number;
  106174. /**
  106175. * Creates the PassCubePostProcess
  106176. * @param name The name of the effect.
  106177. * @param options The required width/height ratio to downsize to before computing the render pass.
  106178. * @param camera The camera to apply the render pass to.
  106179. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106180. * @param engine The engine which the post process will be applied. (default: current engine)
  106181. * @param reusable If the post process can be reused on the same frame. (default: false)
  106182. * @param textureType The type of texture to be used when performing the post processing.
  106183. * @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)
  106184. */
  106185. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  106186. }
  106187. }
  106188. declare module BABYLON {
  106189. /** @hidden */
  106190. export var anaglyphPixelShader: {
  106191. name: string;
  106192. shader: string;
  106193. };
  106194. }
  106195. declare module BABYLON {
  106196. /**
  106197. * Postprocess used to generate anaglyphic rendering
  106198. */
  106199. export class AnaglyphPostProcess extends PostProcess {
  106200. private _passedProcess;
  106201. /**
  106202. * Creates a new AnaglyphPostProcess
  106203. * @param name defines postprocess name
  106204. * @param options defines creation options or target ratio scale
  106205. * @param rigCameras defines cameras using this postprocess
  106206. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  106207. * @param engine defines hosting engine
  106208. * @param reusable defines if the postprocess will be reused multiple times per frame
  106209. */
  106210. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  106211. }
  106212. }
  106213. declare module BABYLON {
  106214. /**
  106215. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  106216. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106217. */
  106218. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  106219. /**
  106220. * Creates a new AnaglyphArcRotateCamera
  106221. * @param name defines camera name
  106222. * @param alpha defines alpha angle (in radians)
  106223. * @param beta defines beta angle (in radians)
  106224. * @param radius defines radius
  106225. * @param target defines camera target
  106226. * @param interaxialDistance defines distance between each color axis
  106227. * @param scene defines the hosting scene
  106228. */
  106229. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  106230. /**
  106231. * Gets camera class name
  106232. * @returns AnaglyphArcRotateCamera
  106233. */
  106234. getClassName(): string;
  106235. }
  106236. }
  106237. declare module BABYLON {
  106238. /**
  106239. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  106240. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106241. */
  106242. export class AnaglyphFreeCamera extends FreeCamera {
  106243. /**
  106244. * Creates a new AnaglyphFreeCamera
  106245. * @param name defines camera name
  106246. * @param position defines initial position
  106247. * @param interaxialDistance defines distance between each color axis
  106248. * @param scene defines the hosting scene
  106249. */
  106250. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106251. /**
  106252. * Gets camera class name
  106253. * @returns AnaglyphFreeCamera
  106254. */
  106255. getClassName(): string;
  106256. }
  106257. }
  106258. declare module BABYLON {
  106259. /**
  106260. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  106261. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106262. */
  106263. export class AnaglyphGamepadCamera extends GamepadCamera {
  106264. /**
  106265. * Creates a new AnaglyphGamepadCamera
  106266. * @param name defines camera name
  106267. * @param position defines initial position
  106268. * @param interaxialDistance defines distance between each color axis
  106269. * @param scene defines the hosting scene
  106270. */
  106271. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106272. /**
  106273. * Gets camera class name
  106274. * @returns AnaglyphGamepadCamera
  106275. */
  106276. getClassName(): string;
  106277. }
  106278. }
  106279. declare module BABYLON {
  106280. /**
  106281. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  106282. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  106283. */
  106284. export class AnaglyphUniversalCamera extends UniversalCamera {
  106285. /**
  106286. * Creates a new AnaglyphUniversalCamera
  106287. * @param name defines camera name
  106288. * @param position defines initial position
  106289. * @param interaxialDistance defines distance between each color axis
  106290. * @param scene defines the hosting scene
  106291. */
  106292. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  106293. /**
  106294. * Gets camera class name
  106295. * @returns AnaglyphUniversalCamera
  106296. */
  106297. getClassName(): string;
  106298. }
  106299. }
  106300. declare module BABYLON {
  106301. /** @hidden */
  106302. export var stereoscopicInterlacePixelShader: {
  106303. name: string;
  106304. shader: string;
  106305. };
  106306. }
  106307. declare module BABYLON {
  106308. /**
  106309. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  106310. */
  106311. export class StereoscopicInterlacePostProcess extends PostProcess {
  106312. private _stepSize;
  106313. private _passedProcess;
  106314. /**
  106315. * Initializes a StereoscopicInterlacePostProcess
  106316. * @param name The name of the effect.
  106317. * @param rigCameras The rig cameras to be appled to the post process
  106318. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  106319. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  106320. * @param engine The engine which the post process will be applied. (default: current engine)
  106321. * @param reusable If the post process can be reused on the same frame. (default: false)
  106322. */
  106323. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  106324. }
  106325. }
  106326. declare module BABYLON {
  106327. /**
  106328. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  106329. * @see http://doc.babylonjs.com/features/cameras
  106330. */
  106331. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  106332. /**
  106333. * Creates a new StereoscopicArcRotateCamera
  106334. * @param name defines camera name
  106335. * @param alpha defines alpha angle (in radians)
  106336. * @param beta defines beta angle (in radians)
  106337. * @param radius defines radius
  106338. * @param target defines camera target
  106339. * @param interaxialDistance defines distance between each color axis
  106340. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106341. * @param scene defines the hosting scene
  106342. */
  106343. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106344. /**
  106345. * Gets camera class name
  106346. * @returns StereoscopicArcRotateCamera
  106347. */
  106348. getClassName(): string;
  106349. }
  106350. }
  106351. declare module BABYLON {
  106352. /**
  106353. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  106354. * @see http://doc.babylonjs.com/features/cameras
  106355. */
  106356. export class StereoscopicFreeCamera extends FreeCamera {
  106357. /**
  106358. * Creates a new StereoscopicFreeCamera
  106359. * @param name defines camera name
  106360. * @param position defines initial position
  106361. * @param interaxialDistance defines distance between each color axis
  106362. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106363. * @param scene defines the hosting scene
  106364. */
  106365. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106366. /**
  106367. * Gets camera class name
  106368. * @returns StereoscopicFreeCamera
  106369. */
  106370. getClassName(): string;
  106371. }
  106372. }
  106373. declare module BABYLON {
  106374. /**
  106375. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  106376. * @see http://doc.babylonjs.com/features/cameras
  106377. */
  106378. export class StereoscopicGamepadCamera extends GamepadCamera {
  106379. /**
  106380. * Creates a new StereoscopicGamepadCamera
  106381. * @param name defines camera name
  106382. * @param position defines initial position
  106383. * @param interaxialDistance defines distance between each color axis
  106384. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106385. * @param scene defines the hosting scene
  106386. */
  106387. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106388. /**
  106389. * Gets camera class name
  106390. * @returns StereoscopicGamepadCamera
  106391. */
  106392. getClassName(): string;
  106393. }
  106394. }
  106395. declare module BABYLON {
  106396. /**
  106397. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  106398. * @see http://doc.babylonjs.com/features/cameras
  106399. */
  106400. export class StereoscopicUniversalCamera extends UniversalCamera {
  106401. /**
  106402. * Creates a new StereoscopicUniversalCamera
  106403. * @param name defines camera name
  106404. * @param position defines initial position
  106405. * @param interaxialDistance defines distance between each color axis
  106406. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  106407. * @param scene defines the hosting scene
  106408. */
  106409. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  106410. /**
  106411. * Gets camera class name
  106412. * @returns StereoscopicUniversalCamera
  106413. */
  106414. getClassName(): string;
  106415. }
  106416. }
  106417. declare module BABYLON {
  106418. /**
  106419. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  106420. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106421. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106422. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106423. */
  106424. export class VirtualJoysticksCamera extends FreeCamera {
  106425. /**
  106426. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  106427. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  106428. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  106429. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  106430. * @param name Define the name of the camera in the scene
  106431. * @param position Define the start position of the camera in the scene
  106432. * @param scene Define the scene the camera belongs to
  106433. */
  106434. constructor(name: string, position: Vector3, scene: Scene);
  106435. /**
  106436. * Gets the current object class name.
  106437. * @return the class name
  106438. */
  106439. getClassName(): string;
  106440. }
  106441. }
  106442. declare module BABYLON {
  106443. /**
  106444. * This represents all the required metrics to create a VR camera.
  106445. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  106446. */
  106447. export class VRCameraMetrics {
  106448. /**
  106449. * Define the horizontal resolution off the screen.
  106450. */
  106451. hResolution: number;
  106452. /**
  106453. * Define the vertical resolution off the screen.
  106454. */
  106455. vResolution: number;
  106456. /**
  106457. * Define the horizontal screen size.
  106458. */
  106459. hScreenSize: number;
  106460. /**
  106461. * Define the vertical screen size.
  106462. */
  106463. vScreenSize: number;
  106464. /**
  106465. * Define the vertical screen center position.
  106466. */
  106467. vScreenCenter: number;
  106468. /**
  106469. * Define the distance of the eyes to the screen.
  106470. */
  106471. eyeToScreenDistance: number;
  106472. /**
  106473. * Define the distance between both lenses
  106474. */
  106475. lensSeparationDistance: number;
  106476. /**
  106477. * Define the distance between both viewer's eyes.
  106478. */
  106479. interpupillaryDistance: number;
  106480. /**
  106481. * Define the distortion factor of the VR postprocess.
  106482. * Please, touch with care.
  106483. */
  106484. distortionK: number[];
  106485. /**
  106486. * Define the chromatic aberration correction factors for the VR post process.
  106487. */
  106488. chromaAbCorrection: number[];
  106489. /**
  106490. * Define the scale factor of the post process.
  106491. * The smaller the better but the slower.
  106492. */
  106493. postProcessScaleFactor: number;
  106494. /**
  106495. * Define an offset for the lens center.
  106496. */
  106497. lensCenterOffset: number;
  106498. /**
  106499. * Define if the current vr camera should compensate the distortion of the lense or not.
  106500. */
  106501. compensateDistortion: boolean;
  106502. /**
  106503. * Defines if multiview should be enabled when rendering (Default: false)
  106504. */
  106505. multiviewEnabled: boolean;
  106506. /**
  106507. * Gets the rendering aspect ratio based on the provided resolutions.
  106508. */
  106509. readonly aspectRatio: number;
  106510. /**
  106511. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  106512. */
  106513. readonly aspectRatioFov: number;
  106514. /**
  106515. * @hidden
  106516. */
  106517. readonly leftHMatrix: Matrix;
  106518. /**
  106519. * @hidden
  106520. */
  106521. readonly rightHMatrix: Matrix;
  106522. /**
  106523. * @hidden
  106524. */
  106525. readonly leftPreViewMatrix: Matrix;
  106526. /**
  106527. * @hidden
  106528. */
  106529. readonly rightPreViewMatrix: Matrix;
  106530. /**
  106531. * Get the default VRMetrics based on the most generic setup.
  106532. * @returns the default vr metrics
  106533. */
  106534. static GetDefault(): VRCameraMetrics;
  106535. }
  106536. }
  106537. declare module BABYLON {
  106538. /** @hidden */
  106539. export var vrDistortionCorrectionPixelShader: {
  106540. name: string;
  106541. shader: string;
  106542. };
  106543. }
  106544. declare module BABYLON {
  106545. /**
  106546. * VRDistortionCorrectionPostProcess used for mobile VR
  106547. */
  106548. export class VRDistortionCorrectionPostProcess extends PostProcess {
  106549. private _isRightEye;
  106550. private _distortionFactors;
  106551. private _postProcessScaleFactor;
  106552. private _lensCenterOffset;
  106553. private _scaleIn;
  106554. private _scaleFactor;
  106555. private _lensCenter;
  106556. /**
  106557. * Initializes the VRDistortionCorrectionPostProcess
  106558. * @param name The name of the effect.
  106559. * @param camera The camera to apply the render pass to.
  106560. * @param isRightEye If this is for the right eye distortion
  106561. * @param vrMetrics All the required metrics for the VR camera
  106562. */
  106563. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  106564. }
  106565. }
  106566. declare module BABYLON {
  106567. /**
  106568. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  106569. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106570. */
  106571. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  106572. /**
  106573. * Creates a new VRDeviceOrientationArcRotateCamera
  106574. * @param name defines camera name
  106575. * @param alpha defines the camera rotation along the logitudinal axis
  106576. * @param beta defines the camera rotation along the latitudinal axis
  106577. * @param radius defines the camera distance from its target
  106578. * @param target defines the camera target
  106579. * @param scene defines the scene the camera belongs to
  106580. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106581. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106582. */
  106583. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106584. /**
  106585. * Gets camera class name
  106586. * @returns VRDeviceOrientationArcRotateCamera
  106587. */
  106588. getClassName(): string;
  106589. }
  106590. }
  106591. declare module BABYLON {
  106592. /**
  106593. * Camera used to simulate VR rendering (based on FreeCamera)
  106594. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106595. */
  106596. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  106597. /**
  106598. * Creates a new VRDeviceOrientationFreeCamera
  106599. * @param name defines camera name
  106600. * @param position defines the start position of the camera
  106601. * @param scene defines the scene the camera belongs to
  106602. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106603. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106604. */
  106605. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106606. /**
  106607. * Gets camera class name
  106608. * @returns VRDeviceOrientationFreeCamera
  106609. */
  106610. getClassName(): string;
  106611. }
  106612. }
  106613. declare module BABYLON {
  106614. /**
  106615. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  106616. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  106617. */
  106618. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  106619. /**
  106620. * Creates a new VRDeviceOrientationGamepadCamera
  106621. * @param name defines camera name
  106622. * @param position defines the start position of the camera
  106623. * @param scene defines the scene the camera belongs to
  106624. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  106625. * @param vrCameraMetrics defines the vr metrics associated to the camera
  106626. */
  106627. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  106628. /**
  106629. * Gets camera class name
  106630. * @returns VRDeviceOrientationGamepadCamera
  106631. */
  106632. getClassName(): string;
  106633. }
  106634. }
  106635. declare module BABYLON {
  106636. /**
  106637. * Base class of materials working in push mode in babylon JS
  106638. * @hidden
  106639. */
  106640. export class PushMaterial extends Material {
  106641. protected _activeEffect: Effect;
  106642. protected _normalMatrix: Matrix;
  106643. /**
  106644. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  106645. * This means that the material can keep using a previous shader while a new one is being compiled.
  106646. * This is mostly used when shader parallel compilation is supported (true by default)
  106647. */
  106648. allowShaderHotSwapping: boolean;
  106649. constructor(name: string, scene: Scene);
  106650. getEffect(): Effect;
  106651. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  106652. /**
  106653. * Binds the given world matrix to the active effect
  106654. *
  106655. * @param world the matrix to bind
  106656. */
  106657. bindOnlyWorldMatrix(world: Matrix): void;
  106658. /**
  106659. * Binds the given normal matrix to the active effect
  106660. *
  106661. * @param normalMatrix the matrix to bind
  106662. */
  106663. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  106664. bind(world: Matrix, mesh?: Mesh): void;
  106665. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  106666. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  106667. }
  106668. }
  106669. declare module BABYLON {
  106670. /**
  106671. * This groups all the flags used to control the materials channel.
  106672. */
  106673. export class MaterialFlags {
  106674. private static _DiffuseTextureEnabled;
  106675. /**
  106676. * Are diffuse textures enabled in the application.
  106677. */
  106678. static DiffuseTextureEnabled: boolean;
  106679. private static _AmbientTextureEnabled;
  106680. /**
  106681. * Are ambient textures enabled in the application.
  106682. */
  106683. static AmbientTextureEnabled: boolean;
  106684. private static _OpacityTextureEnabled;
  106685. /**
  106686. * Are opacity textures enabled in the application.
  106687. */
  106688. static OpacityTextureEnabled: boolean;
  106689. private static _ReflectionTextureEnabled;
  106690. /**
  106691. * Are reflection textures enabled in the application.
  106692. */
  106693. static ReflectionTextureEnabled: boolean;
  106694. private static _EmissiveTextureEnabled;
  106695. /**
  106696. * Are emissive textures enabled in the application.
  106697. */
  106698. static EmissiveTextureEnabled: boolean;
  106699. private static _SpecularTextureEnabled;
  106700. /**
  106701. * Are specular textures enabled in the application.
  106702. */
  106703. static SpecularTextureEnabled: boolean;
  106704. private static _BumpTextureEnabled;
  106705. /**
  106706. * Are bump textures enabled in the application.
  106707. */
  106708. static BumpTextureEnabled: boolean;
  106709. private static _LightmapTextureEnabled;
  106710. /**
  106711. * Are lightmap textures enabled in the application.
  106712. */
  106713. static LightmapTextureEnabled: boolean;
  106714. private static _RefractionTextureEnabled;
  106715. /**
  106716. * Are refraction textures enabled in the application.
  106717. */
  106718. static RefractionTextureEnabled: boolean;
  106719. private static _ColorGradingTextureEnabled;
  106720. /**
  106721. * Are color grading textures enabled in the application.
  106722. */
  106723. static ColorGradingTextureEnabled: boolean;
  106724. private static _FresnelEnabled;
  106725. /**
  106726. * Are fresnels enabled in the application.
  106727. */
  106728. static FresnelEnabled: boolean;
  106729. private static _ClearCoatTextureEnabled;
  106730. /**
  106731. * Are clear coat textures enabled in the application.
  106732. */
  106733. static ClearCoatTextureEnabled: boolean;
  106734. private static _ClearCoatBumpTextureEnabled;
  106735. /**
  106736. * Are clear coat bump textures enabled in the application.
  106737. */
  106738. static ClearCoatBumpTextureEnabled: boolean;
  106739. private static _ClearCoatTintTextureEnabled;
  106740. /**
  106741. * Are clear coat tint textures enabled in the application.
  106742. */
  106743. static ClearCoatTintTextureEnabled: boolean;
  106744. private static _SheenTextureEnabled;
  106745. /**
  106746. * Are sheen textures enabled in the application.
  106747. */
  106748. static SheenTextureEnabled: boolean;
  106749. private static _AnisotropicTextureEnabled;
  106750. /**
  106751. * Are anisotropic textures enabled in the application.
  106752. */
  106753. static AnisotropicTextureEnabled: boolean;
  106754. private static _ThicknessTextureEnabled;
  106755. /**
  106756. * Are thickness textures enabled in the application.
  106757. */
  106758. static ThicknessTextureEnabled: boolean;
  106759. }
  106760. }
  106761. declare module BABYLON {
  106762. /** @hidden */
  106763. export var defaultFragmentDeclaration: {
  106764. name: string;
  106765. shader: string;
  106766. };
  106767. }
  106768. declare module BABYLON {
  106769. /** @hidden */
  106770. export var defaultUboDeclaration: {
  106771. name: string;
  106772. shader: string;
  106773. };
  106774. }
  106775. declare module BABYLON {
  106776. /** @hidden */
  106777. export var lightFragmentDeclaration: {
  106778. name: string;
  106779. shader: string;
  106780. };
  106781. }
  106782. declare module BABYLON {
  106783. /** @hidden */
  106784. export var lightUboDeclaration: {
  106785. name: string;
  106786. shader: string;
  106787. };
  106788. }
  106789. declare module BABYLON {
  106790. /** @hidden */
  106791. export var lightsFragmentFunctions: {
  106792. name: string;
  106793. shader: string;
  106794. };
  106795. }
  106796. declare module BABYLON {
  106797. /** @hidden */
  106798. export var shadowsFragmentFunctions: {
  106799. name: string;
  106800. shader: string;
  106801. };
  106802. }
  106803. declare module BABYLON {
  106804. /** @hidden */
  106805. export var fresnelFunction: {
  106806. name: string;
  106807. shader: string;
  106808. };
  106809. }
  106810. declare module BABYLON {
  106811. /** @hidden */
  106812. export var reflectionFunction: {
  106813. name: string;
  106814. shader: string;
  106815. };
  106816. }
  106817. declare module BABYLON {
  106818. /** @hidden */
  106819. export var bumpFragmentFunctions: {
  106820. name: string;
  106821. shader: string;
  106822. };
  106823. }
  106824. declare module BABYLON {
  106825. /** @hidden */
  106826. export var logDepthDeclaration: {
  106827. name: string;
  106828. shader: string;
  106829. };
  106830. }
  106831. declare module BABYLON {
  106832. /** @hidden */
  106833. export var bumpFragment: {
  106834. name: string;
  106835. shader: string;
  106836. };
  106837. }
  106838. declare module BABYLON {
  106839. /** @hidden */
  106840. export var depthPrePass: {
  106841. name: string;
  106842. shader: string;
  106843. };
  106844. }
  106845. declare module BABYLON {
  106846. /** @hidden */
  106847. export var lightFragment: {
  106848. name: string;
  106849. shader: string;
  106850. };
  106851. }
  106852. declare module BABYLON {
  106853. /** @hidden */
  106854. export var logDepthFragment: {
  106855. name: string;
  106856. shader: string;
  106857. };
  106858. }
  106859. declare module BABYLON {
  106860. /** @hidden */
  106861. export var defaultPixelShader: {
  106862. name: string;
  106863. shader: string;
  106864. };
  106865. }
  106866. declare module BABYLON {
  106867. /** @hidden */
  106868. export var defaultVertexDeclaration: {
  106869. name: string;
  106870. shader: string;
  106871. };
  106872. }
  106873. declare module BABYLON {
  106874. /** @hidden */
  106875. export var bumpVertexDeclaration: {
  106876. name: string;
  106877. shader: string;
  106878. };
  106879. }
  106880. declare module BABYLON {
  106881. /** @hidden */
  106882. export var bumpVertex: {
  106883. name: string;
  106884. shader: string;
  106885. };
  106886. }
  106887. declare module BABYLON {
  106888. /** @hidden */
  106889. export var fogVertex: {
  106890. name: string;
  106891. shader: string;
  106892. };
  106893. }
  106894. declare module BABYLON {
  106895. /** @hidden */
  106896. export var shadowsVertex: {
  106897. name: string;
  106898. shader: string;
  106899. };
  106900. }
  106901. declare module BABYLON {
  106902. /** @hidden */
  106903. export var pointCloudVertex: {
  106904. name: string;
  106905. shader: string;
  106906. };
  106907. }
  106908. declare module BABYLON {
  106909. /** @hidden */
  106910. export var logDepthVertex: {
  106911. name: string;
  106912. shader: string;
  106913. };
  106914. }
  106915. declare module BABYLON {
  106916. /** @hidden */
  106917. export var defaultVertexShader: {
  106918. name: string;
  106919. shader: string;
  106920. };
  106921. }
  106922. declare module BABYLON {
  106923. /** @hidden */
  106924. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  106925. MAINUV1: boolean;
  106926. MAINUV2: boolean;
  106927. DIFFUSE: boolean;
  106928. DIFFUSEDIRECTUV: number;
  106929. AMBIENT: boolean;
  106930. AMBIENTDIRECTUV: number;
  106931. OPACITY: boolean;
  106932. OPACITYDIRECTUV: number;
  106933. OPACITYRGB: boolean;
  106934. REFLECTION: boolean;
  106935. EMISSIVE: boolean;
  106936. EMISSIVEDIRECTUV: number;
  106937. SPECULAR: boolean;
  106938. SPECULARDIRECTUV: number;
  106939. BUMP: boolean;
  106940. BUMPDIRECTUV: number;
  106941. PARALLAX: boolean;
  106942. PARALLAXOCCLUSION: boolean;
  106943. SPECULAROVERALPHA: boolean;
  106944. CLIPPLANE: boolean;
  106945. CLIPPLANE2: boolean;
  106946. CLIPPLANE3: boolean;
  106947. CLIPPLANE4: boolean;
  106948. ALPHATEST: boolean;
  106949. DEPTHPREPASS: boolean;
  106950. ALPHAFROMDIFFUSE: boolean;
  106951. POINTSIZE: boolean;
  106952. FOG: boolean;
  106953. SPECULARTERM: boolean;
  106954. DIFFUSEFRESNEL: boolean;
  106955. OPACITYFRESNEL: boolean;
  106956. REFLECTIONFRESNEL: boolean;
  106957. REFRACTIONFRESNEL: boolean;
  106958. EMISSIVEFRESNEL: boolean;
  106959. FRESNEL: boolean;
  106960. NORMAL: boolean;
  106961. UV1: boolean;
  106962. UV2: boolean;
  106963. VERTEXCOLOR: boolean;
  106964. VERTEXALPHA: boolean;
  106965. NUM_BONE_INFLUENCERS: number;
  106966. BonesPerMesh: number;
  106967. BONETEXTURE: boolean;
  106968. INSTANCES: boolean;
  106969. GLOSSINESS: boolean;
  106970. ROUGHNESS: boolean;
  106971. EMISSIVEASILLUMINATION: boolean;
  106972. LINKEMISSIVEWITHDIFFUSE: boolean;
  106973. REFLECTIONFRESNELFROMSPECULAR: boolean;
  106974. LIGHTMAP: boolean;
  106975. LIGHTMAPDIRECTUV: number;
  106976. OBJECTSPACE_NORMALMAP: boolean;
  106977. USELIGHTMAPASSHADOWMAP: boolean;
  106978. REFLECTIONMAP_3D: boolean;
  106979. REFLECTIONMAP_SPHERICAL: boolean;
  106980. REFLECTIONMAP_PLANAR: boolean;
  106981. REFLECTIONMAP_CUBIC: boolean;
  106982. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  106983. REFLECTIONMAP_PROJECTION: boolean;
  106984. REFLECTIONMAP_SKYBOX: boolean;
  106985. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  106986. REFLECTIONMAP_EXPLICIT: boolean;
  106987. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  106988. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  106989. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  106990. INVERTCUBICMAP: boolean;
  106991. LOGARITHMICDEPTH: boolean;
  106992. REFRACTION: boolean;
  106993. REFRACTIONMAP_3D: boolean;
  106994. REFLECTIONOVERALPHA: boolean;
  106995. TWOSIDEDLIGHTING: boolean;
  106996. SHADOWFLOAT: boolean;
  106997. MORPHTARGETS: boolean;
  106998. MORPHTARGETS_NORMAL: boolean;
  106999. MORPHTARGETS_TANGENT: boolean;
  107000. MORPHTARGETS_UV: boolean;
  107001. NUM_MORPH_INFLUENCERS: number;
  107002. NONUNIFORMSCALING: boolean;
  107003. PREMULTIPLYALPHA: boolean;
  107004. IMAGEPROCESSING: boolean;
  107005. VIGNETTE: boolean;
  107006. VIGNETTEBLENDMODEMULTIPLY: boolean;
  107007. VIGNETTEBLENDMODEOPAQUE: boolean;
  107008. TONEMAPPING: boolean;
  107009. TONEMAPPING_ACES: boolean;
  107010. CONTRAST: boolean;
  107011. COLORCURVES: boolean;
  107012. COLORGRADING: boolean;
  107013. COLORGRADING3D: boolean;
  107014. SAMPLER3DGREENDEPTH: boolean;
  107015. SAMPLER3DBGRMAP: boolean;
  107016. IMAGEPROCESSINGPOSTPROCESS: boolean;
  107017. MULTIVIEW: boolean;
  107018. /**
  107019. * If the reflection texture on this material is in linear color space
  107020. * @hidden
  107021. */
  107022. IS_REFLECTION_LINEAR: boolean;
  107023. /**
  107024. * If the refraction texture on this material is in linear color space
  107025. * @hidden
  107026. */
  107027. IS_REFRACTION_LINEAR: boolean;
  107028. EXPOSURE: boolean;
  107029. constructor();
  107030. setReflectionMode(modeToEnable: string): void;
  107031. }
  107032. /**
  107033. * This is the default material used in Babylon. It is the best trade off between quality
  107034. * and performances.
  107035. * @see http://doc.babylonjs.com/babylon101/materials
  107036. */
  107037. export class StandardMaterial extends PushMaterial {
  107038. private _diffuseTexture;
  107039. /**
  107040. * The basic texture of the material as viewed under a light.
  107041. */
  107042. diffuseTexture: Nullable<BaseTexture>;
  107043. private _ambientTexture;
  107044. /**
  107045. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  107046. */
  107047. ambientTexture: Nullable<BaseTexture>;
  107048. private _opacityTexture;
  107049. /**
  107050. * Define the transparency of the material from a texture.
  107051. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  107052. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  107053. */
  107054. opacityTexture: Nullable<BaseTexture>;
  107055. private _reflectionTexture;
  107056. /**
  107057. * Define the texture used to display the reflection.
  107058. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107059. */
  107060. reflectionTexture: Nullable<BaseTexture>;
  107061. private _emissiveTexture;
  107062. /**
  107063. * Define texture of the material as if self lit.
  107064. * This will be mixed in the final result even in the absence of light.
  107065. */
  107066. emissiveTexture: Nullable<BaseTexture>;
  107067. private _specularTexture;
  107068. /**
  107069. * Define how the color and intensity of the highlight given by the light in the material.
  107070. */
  107071. specularTexture: Nullable<BaseTexture>;
  107072. private _bumpTexture;
  107073. /**
  107074. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  107075. * 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.
  107076. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  107077. */
  107078. bumpTexture: Nullable<BaseTexture>;
  107079. private _lightmapTexture;
  107080. /**
  107081. * Complex lighting can be computationally expensive to compute at runtime.
  107082. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  107083. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  107084. */
  107085. lightmapTexture: Nullable<BaseTexture>;
  107086. private _refractionTexture;
  107087. /**
  107088. * Define the texture used to display the refraction.
  107089. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107090. */
  107091. refractionTexture: Nullable<BaseTexture>;
  107092. /**
  107093. * The color of the material lit by the environmental background lighting.
  107094. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  107095. */
  107096. ambientColor: Color3;
  107097. /**
  107098. * The basic color of the material as viewed under a light.
  107099. */
  107100. diffuseColor: Color3;
  107101. /**
  107102. * Define how the color and intensity of the highlight given by the light in the material.
  107103. */
  107104. specularColor: Color3;
  107105. /**
  107106. * Define the color of the material as if self lit.
  107107. * This will be mixed in the final result even in the absence of light.
  107108. */
  107109. emissiveColor: Color3;
  107110. /**
  107111. * Defines how sharp are the highlights in the material.
  107112. * The bigger the value the sharper giving a more glossy feeling to the result.
  107113. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  107114. */
  107115. specularPower: number;
  107116. private _useAlphaFromDiffuseTexture;
  107117. /**
  107118. * Does the transparency come from the diffuse texture alpha channel.
  107119. */
  107120. useAlphaFromDiffuseTexture: boolean;
  107121. private _useEmissiveAsIllumination;
  107122. /**
  107123. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  107124. */
  107125. useEmissiveAsIllumination: boolean;
  107126. private _linkEmissiveWithDiffuse;
  107127. /**
  107128. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  107129. * the emissive level when the final color is close to one.
  107130. */
  107131. linkEmissiveWithDiffuse: boolean;
  107132. private _useSpecularOverAlpha;
  107133. /**
  107134. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  107135. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  107136. */
  107137. useSpecularOverAlpha: boolean;
  107138. private _useReflectionOverAlpha;
  107139. /**
  107140. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  107141. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  107142. */
  107143. useReflectionOverAlpha: boolean;
  107144. private _disableLighting;
  107145. /**
  107146. * Does lights from the scene impacts this material.
  107147. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  107148. */
  107149. disableLighting: boolean;
  107150. private _useObjectSpaceNormalMap;
  107151. /**
  107152. * Allows using an object space normal map (instead of tangent space).
  107153. */
  107154. useObjectSpaceNormalMap: boolean;
  107155. private _useParallax;
  107156. /**
  107157. * Is parallax enabled or not.
  107158. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107159. */
  107160. useParallax: boolean;
  107161. private _useParallaxOcclusion;
  107162. /**
  107163. * Is parallax occlusion enabled or not.
  107164. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  107165. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  107166. */
  107167. useParallaxOcclusion: boolean;
  107168. /**
  107169. * 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.
  107170. */
  107171. parallaxScaleBias: number;
  107172. private _roughness;
  107173. /**
  107174. * Helps to define how blurry the reflections should appears in the material.
  107175. */
  107176. roughness: number;
  107177. /**
  107178. * In case of refraction, define the value of the index of refraction.
  107179. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107180. */
  107181. indexOfRefraction: number;
  107182. /**
  107183. * Invert the refraction texture alongside the y axis.
  107184. * It can be useful with procedural textures or probe for instance.
  107185. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  107186. */
  107187. invertRefractionY: boolean;
  107188. /**
  107189. * Defines the alpha limits in alpha test mode.
  107190. */
  107191. alphaCutOff: number;
  107192. private _useLightmapAsShadowmap;
  107193. /**
  107194. * In case of light mapping, define whether the map contains light or shadow informations.
  107195. */
  107196. useLightmapAsShadowmap: boolean;
  107197. private _diffuseFresnelParameters;
  107198. /**
  107199. * Define the diffuse fresnel parameters of the material.
  107200. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107201. */
  107202. diffuseFresnelParameters: FresnelParameters;
  107203. private _opacityFresnelParameters;
  107204. /**
  107205. * Define the opacity fresnel parameters of the material.
  107206. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107207. */
  107208. opacityFresnelParameters: FresnelParameters;
  107209. private _reflectionFresnelParameters;
  107210. /**
  107211. * Define the reflection fresnel parameters of the material.
  107212. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107213. */
  107214. reflectionFresnelParameters: FresnelParameters;
  107215. private _refractionFresnelParameters;
  107216. /**
  107217. * Define the refraction fresnel parameters of the material.
  107218. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107219. */
  107220. refractionFresnelParameters: FresnelParameters;
  107221. private _emissiveFresnelParameters;
  107222. /**
  107223. * Define the emissive fresnel parameters of the material.
  107224. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107225. */
  107226. emissiveFresnelParameters: FresnelParameters;
  107227. private _useReflectionFresnelFromSpecular;
  107228. /**
  107229. * If true automatically deducts the fresnels values from the material specularity.
  107230. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  107231. */
  107232. useReflectionFresnelFromSpecular: boolean;
  107233. private _useGlossinessFromSpecularMapAlpha;
  107234. /**
  107235. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  107236. */
  107237. useGlossinessFromSpecularMapAlpha: boolean;
  107238. private _maxSimultaneousLights;
  107239. /**
  107240. * Defines the maximum number of lights that can be used in the material
  107241. */
  107242. maxSimultaneousLights: number;
  107243. private _invertNormalMapX;
  107244. /**
  107245. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  107246. */
  107247. invertNormalMapX: boolean;
  107248. private _invertNormalMapY;
  107249. /**
  107250. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  107251. */
  107252. invertNormalMapY: boolean;
  107253. private _twoSidedLighting;
  107254. /**
  107255. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  107256. */
  107257. twoSidedLighting: boolean;
  107258. /**
  107259. * Default configuration related to image processing available in the standard Material.
  107260. */
  107261. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107262. /**
  107263. * Gets the image processing configuration used either in this material.
  107264. */
  107265. /**
  107266. * Sets the Default image processing configuration used either in the this material.
  107267. *
  107268. * If sets to null, the scene one is in use.
  107269. */
  107270. imageProcessingConfiguration: ImageProcessingConfiguration;
  107271. /**
  107272. * Keep track of the image processing observer to allow dispose and replace.
  107273. */
  107274. private _imageProcessingObserver;
  107275. /**
  107276. * Attaches a new image processing configuration to the Standard Material.
  107277. * @param configuration
  107278. */
  107279. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  107280. /**
  107281. * Gets wether the color curves effect is enabled.
  107282. */
  107283. /**
  107284. * Sets wether the color curves effect is enabled.
  107285. */
  107286. cameraColorCurvesEnabled: boolean;
  107287. /**
  107288. * Gets wether the color grading effect is enabled.
  107289. */
  107290. /**
  107291. * Gets wether the color grading effect is enabled.
  107292. */
  107293. cameraColorGradingEnabled: boolean;
  107294. /**
  107295. * Gets wether tonemapping is enabled or not.
  107296. */
  107297. /**
  107298. * Sets wether tonemapping is enabled or not
  107299. */
  107300. cameraToneMappingEnabled: boolean;
  107301. /**
  107302. * The camera exposure used on this material.
  107303. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107304. * This corresponds to a photographic exposure.
  107305. */
  107306. /**
  107307. * The camera exposure used on this material.
  107308. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  107309. * This corresponds to a photographic exposure.
  107310. */
  107311. cameraExposure: number;
  107312. /**
  107313. * Gets The camera contrast used on this material.
  107314. */
  107315. /**
  107316. * Sets The camera contrast used on this material.
  107317. */
  107318. cameraContrast: number;
  107319. /**
  107320. * Gets the Color Grading 2D Lookup Texture.
  107321. */
  107322. /**
  107323. * Sets the Color Grading 2D Lookup Texture.
  107324. */
  107325. cameraColorGradingTexture: Nullable<BaseTexture>;
  107326. /**
  107327. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107328. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107329. * 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;
  107330. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107331. */
  107332. /**
  107333. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  107334. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  107335. * 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;
  107336. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  107337. */
  107338. cameraColorCurves: Nullable<ColorCurves>;
  107339. /**
  107340. * Custom callback helping to override the default shader used in the material.
  107341. */
  107342. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  107343. protected _renderTargets: SmartArray<RenderTargetTexture>;
  107344. protected _worldViewProjectionMatrix: Matrix;
  107345. protected _globalAmbientColor: Color3;
  107346. protected _useLogarithmicDepth: boolean;
  107347. protected _rebuildInParallel: boolean;
  107348. /**
  107349. * Instantiates a new standard material.
  107350. * This is the default material used in Babylon. It is the best trade off between quality
  107351. * and performances.
  107352. * @see http://doc.babylonjs.com/babylon101/materials
  107353. * @param name Define the name of the material in the scene
  107354. * @param scene Define the scene the material belong to
  107355. */
  107356. constructor(name: string, scene: Scene);
  107357. /**
  107358. * Gets a boolean indicating that current material needs to register RTT
  107359. */
  107360. readonly hasRenderTargetTextures: boolean;
  107361. /**
  107362. * Gets the current class name of the material e.g. "StandardMaterial"
  107363. * Mainly use in serialization.
  107364. * @returns the class name
  107365. */
  107366. getClassName(): string;
  107367. /**
  107368. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  107369. * You can try switching to logarithmic depth.
  107370. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  107371. */
  107372. useLogarithmicDepth: boolean;
  107373. /**
  107374. * Specifies if the material will require alpha blending
  107375. * @returns a boolean specifying if alpha blending is needed
  107376. */
  107377. needAlphaBlending(): boolean;
  107378. /**
  107379. * Specifies if this material should be rendered in alpha test mode
  107380. * @returns a boolean specifying if an alpha test is needed.
  107381. */
  107382. needAlphaTesting(): boolean;
  107383. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  107384. /**
  107385. * Get the texture used for alpha test purpose.
  107386. * @returns the diffuse texture in case of the standard material.
  107387. */
  107388. getAlphaTestTexture(): Nullable<BaseTexture>;
  107389. /**
  107390. * Get if the submesh is ready to be used and all its information available.
  107391. * Child classes can use it to update shaders
  107392. * @param mesh defines the mesh to check
  107393. * @param subMesh defines which submesh to check
  107394. * @param useInstances specifies that instances should be used
  107395. * @returns a boolean indicating that the submesh is ready or not
  107396. */
  107397. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  107398. /**
  107399. * Builds the material UBO layouts.
  107400. * Used internally during the effect preparation.
  107401. */
  107402. buildUniformLayout(): void;
  107403. /**
  107404. * Unbinds the material from the mesh
  107405. */
  107406. unbind(): void;
  107407. /**
  107408. * Binds the submesh to this material by preparing the effect and shader to draw
  107409. * @param world defines the world transformation matrix
  107410. * @param mesh defines the mesh containing the submesh
  107411. * @param subMesh defines the submesh to bind the material to
  107412. */
  107413. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  107414. /**
  107415. * Get the list of animatables in the material.
  107416. * @returns the list of animatables object used in the material
  107417. */
  107418. getAnimatables(): IAnimatable[];
  107419. /**
  107420. * Gets the active textures from the material
  107421. * @returns an array of textures
  107422. */
  107423. getActiveTextures(): BaseTexture[];
  107424. /**
  107425. * Specifies if the material uses a texture
  107426. * @param texture defines the texture to check against the material
  107427. * @returns a boolean specifying if the material uses the texture
  107428. */
  107429. hasTexture(texture: BaseTexture): boolean;
  107430. /**
  107431. * Disposes the material
  107432. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  107433. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  107434. */
  107435. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  107436. /**
  107437. * Makes a duplicate of the material, and gives it a new name
  107438. * @param name defines the new name for the duplicated material
  107439. * @returns the cloned material
  107440. */
  107441. clone(name: string): StandardMaterial;
  107442. /**
  107443. * Serializes this material in a JSON representation
  107444. * @returns the serialized material object
  107445. */
  107446. serialize(): any;
  107447. /**
  107448. * Creates a standard material from parsed material data
  107449. * @param source defines the JSON representation of the material
  107450. * @param scene defines the hosting scene
  107451. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  107452. * @returns a new standard material
  107453. */
  107454. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  107455. /**
  107456. * Are diffuse textures enabled in the application.
  107457. */
  107458. static DiffuseTextureEnabled: boolean;
  107459. /**
  107460. * Are ambient textures enabled in the application.
  107461. */
  107462. static AmbientTextureEnabled: boolean;
  107463. /**
  107464. * Are opacity textures enabled in the application.
  107465. */
  107466. static OpacityTextureEnabled: boolean;
  107467. /**
  107468. * Are reflection textures enabled in the application.
  107469. */
  107470. static ReflectionTextureEnabled: boolean;
  107471. /**
  107472. * Are emissive textures enabled in the application.
  107473. */
  107474. static EmissiveTextureEnabled: boolean;
  107475. /**
  107476. * Are specular textures enabled in the application.
  107477. */
  107478. static SpecularTextureEnabled: boolean;
  107479. /**
  107480. * Are bump textures enabled in the application.
  107481. */
  107482. static BumpTextureEnabled: boolean;
  107483. /**
  107484. * Are lightmap textures enabled in the application.
  107485. */
  107486. static LightmapTextureEnabled: boolean;
  107487. /**
  107488. * Are refraction textures enabled in the application.
  107489. */
  107490. static RefractionTextureEnabled: boolean;
  107491. /**
  107492. * Are color grading textures enabled in the application.
  107493. */
  107494. static ColorGradingTextureEnabled: boolean;
  107495. /**
  107496. * Are fresnels enabled in the application.
  107497. */
  107498. static FresnelEnabled: boolean;
  107499. }
  107500. }
  107501. declare module BABYLON {
  107502. /** @hidden */
  107503. export var imageProcessingPixelShader: {
  107504. name: string;
  107505. shader: string;
  107506. };
  107507. }
  107508. declare module BABYLON {
  107509. /**
  107510. * ImageProcessingPostProcess
  107511. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  107512. */
  107513. export class ImageProcessingPostProcess extends PostProcess {
  107514. /**
  107515. * Default configuration related to image processing available in the PBR Material.
  107516. */
  107517. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  107518. /**
  107519. * Gets the image processing configuration used either in this material.
  107520. */
  107521. /**
  107522. * Sets the Default image processing configuration used either in the this material.
  107523. *
  107524. * If sets to null, the scene one is in use.
  107525. */
  107526. imageProcessingConfiguration: ImageProcessingConfiguration;
  107527. /**
  107528. * Keep track of the image processing observer to allow dispose and replace.
  107529. */
  107530. private _imageProcessingObserver;
  107531. /**
  107532. * Attaches a new image processing configuration to the PBR Material.
  107533. * @param configuration
  107534. */
  107535. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  107536. /**
  107537. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107538. */
  107539. /**
  107540. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  107541. */
  107542. colorCurves: Nullable<ColorCurves>;
  107543. /**
  107544. * Gets wether the color curves effect is enabled.
  107545. */
  107546. /**
  107547. * Sets wether the color curves effect is enabled.
  107548. */
  107549. colorCurvesEnabled: boolean;
  107550. /**
  107551. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107552. */
  107553. /**
  107554. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  107555. */
  107556. colorGradingTexture: Nullable<BaseTexture>;
  107557. /**
  107558. * Gets wether the color grading effect is enabled.
  107559. */
  107560. /**
  107561. * Gets wether the color grading effect is enabled.
  107562. */
  107563. colorGradingEnabled: boolean;
  107564. /**
  107565. * Gets exposure used in the effect.
  107566. */
  107567. /**
  107568. * Sets exposure used in the effect.
  107569. */
  107570. exposure: number;
  107571. /**
  107572. * Gets wether tonemapping is enabled or not.
  107573. */
  107574. /**
  107575. * Sets wether tonemapping is enabled or not
  107576. */
  107577. toneMappingEnabled: boolean;
  107578. /**
  107579. * Gets the type of tone mapping effect.
  107580. */
  107581. /**
  107582. * Sets the type of tone mapping effect.
  107583. */
  107584. toneMappingType: number;
  107585. /**
  107586. * Gets contrast used in the effect.
  107587. */
  107588. /**
  107589. * Sets contrast used in the effect.
  107590. */
  107591. contrast: number;
  107592. /**
  107593. * Gets Vignette stretch size.
  107594. */
  107595. /**
  107596. * Sets Vignette stretch size.
  107597. */
  107598. vignetteStretch: number;
  107599. /**
  107600. * Gets Vignette centre X Offset.
  107601. */
  107602. /**
  107603. * Sets Vignette centre X Offset.
  107604. */
  107605. vignetteCentreX: number;
  107606. /**
  107607. * Gets Vignette centre Y Offset.
  107608. */
  107609. /**
  107610. * Sets Vignette centre Y Offset.
  107611. */
  107612. vignetteCentreY: number;
  107613. /**
  107614. * Gets Vignette weight or intensity of the vignette effect.
  107615. */
  107616. /**
  107617. * Sets Vignette weight or intensity of the vignette effect.
  107618. */
  107619. vignetteWeight: number;
  107620. /**
  107621. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107622. * if vignetteEnabled is set to true.
  107623. */
  107624. /**
  107625. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  107626. * if vignetteEnabled is set to true.
  107627. */
  107628. vignetteColor: Color4;
  107629. /**
  107630. * Gets Camera field of view used by the Vignette effect.
  107631. */
  107632. /**
  107633. * Sets Camera field of view used by the Vignette effect.
  107634. */
  107635. vignetteCameraFov: number;
  107636. /**
  107637. * Gets the vignette blend mode allowing different kind of effect.
  107638. */
  107639. /**
  107640. * Sets the vignette blend mode allowing different kind of effect.
  107641. */
  107642. vignetteBlendMode: number;
  107643. /**
  107644. * Gets wether the vignette effect is enabled.
  107645. */
  107646. /**
  107647. * Sets wether the vignette effect is enabled.
  107648. */
  107649. vignetteEnabled: boolean;
  107650. private _fromLinearSpace;
  107651. /**
  107652. * Gets wether the input of the processing is in Gamma or Linear Space.
  107653. */
  107654. /**
  107655. * Sets wether the input of the processing is in Gamma or Linear Space.
  107656. */
  107657. fromLinearSpace: boolean;
  107658. /**
  107659. * Defines cache preventing GC.
  107660. */
  107661. private _defines;
  107662. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  107663. /**
  107664. * "ImageProcessingPostProcess"
  107665. * @returns "ImageProcessingPostProcess"
  107666. */
  107667. getClassName(): string;
  107668. protected _updateParameters(): void;
  107669. dispose(camera?: Camera): void;
  107670. }
  107671. }
  107672. declare module BABYLON {
  107673. /**
  107674. * Class containing static functions to help procedurally build meshes
  107675. */
  107676. export class GroundBuilder {
  107677. /**
  107678. * Creates a ground mesh
  107679. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  107680. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  107681. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107682. * @param name defines the name of the mesh
  107683. * @param options defines the options used to create the mesh
  107684. * @param scene defines the hosting scene
  107685. * @returns the ground mesh
  107686. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  107687. */
  107688. static CreateGround(name: string, options: {
  107689. width?: number;
  107690. height?: number;
  107691. subdivisions?: number;
  107692. subdivisionsX?: number;
  107693. subdivisionsY?: number;
  107694. updatable?: boolean;
  107695. }, scene: any): Mesh;
  107696. /**
  107697. * Creates a tiled ground mesh
  107698. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  107699. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  107700. * * 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
  107701. * * 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
  107702. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107703. * @param name defines the name of the mesh
  107704. * @param options defines the options used to create the mesh
  107705. * @param scene defines the hosting scene
  107706. * @returns the tiled ground mesh
  107707. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  107708. */
  107709. static CreateTiledGround(name: string, options: {
  107710. xmin: number;
  107711. zmin: number;
  107712. xmax: number;
  107713. zmax: number;
  107714. subdivisions?: {
  107715. w: number;
  107716. h: number;
  107717. };
  107718. precision?: {
  107719. w: number;
  107720. h: number;
  107721. };
  107722. updatable?: boolean;
  107723. }, scene?: Nullable<Scene>): Mesh;
  107724. /**
  107725. * Creates a ground mesh from a height map
  107726. * * The parameter `url` sets the URL of the height map image resource.
  107727. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  107728. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  107729. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  107730. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  107731. * * 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.
  107732. * * 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).
  107733. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  107734. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107735. * @param name defines the name of the mesh
  107736. * @param url defines the url to the height map
  107737. * @param options defines the options used to create the mesh
  107738. * @param scene defines the hosting scene
  107739. * @returns the ground mesh
  107740. * @see https://doc.babylonjs.com/babylon101/height_map
  107741. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  107742. */
  107743. static CreateGroundFromHeightMap(name: string, url: string, options: {
  107744. width?: number;
  107745. height?: number;
  107746. subdivisions?: number;
  107747. minHeight?: number;
  107748. maxHeight?: number;
  107749. colorFilter?: Color3;
  107750. alphaFilter?: number;
  107751. updatable?: boolean;
  107752. onReady?: (mesh: GroundMesh) => void;
  107753. }, scene?: Nullable<Scene>): GroundMesh;
  107754. }
  107755. }
  107756. declare module BABYLON {
  107757. /**
  107758. * Class containing static functions to help procedurally build meshes
  107759. */
  107760. export class TorusBuilder {
  107761. /**
  107762. * Creates a torus mesh
  107763. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  107764. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  107765. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  107766. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107767. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107768. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107769. * @param name defines the name of the mesh
  107770. * @param options defines the options used to create the mesh
  107771. * @param scene defines the hosting scene
  107772. * @returns the torus mesh
  107773. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  107774. */
  107775. static CreateTorus(name: string, options: {
  107776. diameter?: number;
  107777. thickness?: number;
  107778. tessellation?: number;
  107779. updatable?: boolean;
  107780. sideOrientation?: number;
  107781. frontUVs?: Vector4;
  107782. backUVs?: Vector4;
  107783. }, scene: any): Mesh;
  107784. }
  107785. }
  107786. declare module BABYLON {
  107787. /**
  107788. * Class containing static functions to help procedurally build meshes
  107789. */
  107790. export class CylinderBuilder {
  107791. /**
  107792. * Creates a cylinder or a cone mesh
  107793. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  107794. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  107795. * * 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.
  107796. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  107797. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  107798. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  107799. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  107800. * * 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).
  107801. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  107802. * * 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).
  107803. * * 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
  107804. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  107805. * * 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
  107806. * * 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.
  107807. * * If `enclose` is false, a ring surface is one element.
  107808. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  107809. * * 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
  107810. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107811. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107812. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107813. * @param name defines the name of the mesh
  107814. * @param options defines the options used to create the mesh
  107815. * @param scene defines the hosting scene
  107816. * @returns the cylinder mesh
  107817. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  107818. */
  107819. static CreateCylinder(name: string, options: {
  107820. height?: number;
  107821. diameterTop?: number;
  107822. diameterBottom?: number;
  107823. diameter?: number;
  107824. tessellation?: number;
  107825. subdivisions?: number;
  107826. arc?: number;
  107827. faceColors?: Color4[];
  107828. faceUV?: Vector4[];
  107829. updatable?: boolean;
  107830. hasRings?: boolean;
  107831. enclose?: boolean;
  107832. cap?: number;
  107833. sideOrientation?: number;
  107834. frontUVs?: Vector4;
  107835. backUVs?: Vector4;
  107836. }, scene: any): Mesh;
  107837. }
  107838. }
  107839. declare module BABYLON {
  107840. /**
  107841. * Options to modify the vr teleportation behavior.
  107842. */
  107843. export interface VRTeleportationOptions {
  107844. /**
  107845. * The name of the mesh which should be used as the teleportation floor. (default: null)
  107846. */
  107847. floorMeshName?: string;
  107848. /**
  107849. * A list of meshes to be used as the teleportation floor. (default: empty)
  107850. */
  107851. floorMeshes?: Mesh[];
  107852. }
  107853. /**
  107854. * Options to modify the vr experience helper's behavior.
  107855. */
  107856. export interface VRExperienceHelperOptions extends WebVROptions {
  107857. /**
  107858. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  107859. */
  107860. createDeviceOrientationCamera?: boolean;
  107861. /**
  107862. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  107863. */
  107864. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  107865. /**
  107866. * Uses the main button on the controller to toggle the laser casted. (default: true)
  107867. */
  107868. laserToggle?: boolean;
  107869. /**
  107870. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  107871. */
  107872. floorMeshes?: Mesh[];
  107873. /**
  107874. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  107875. */
  107876. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  107877. }
  107878. /**
  107879. * Event containing information after VR has been entered
  107880. */
  107881. export class OnAfterEnteringVRObservableEvent {
  107882. /**
  107883. * If entering vr was successful
  107884. */
  107885. success: boolean;
  107886. }
  107887. /**
  107888. * Helps to quickly add VR support to an existing scene.
  107889. * See http://doc.babylonjs.com/how_to/webvr_helper
  107890. */
  107891. export class VRExperienceHelper {
  107892. /** Options to modify the vr experience helper's behavior. */
  107893. webVROptions: VRExperienceHelperOptions;
  107894. private _scene;
  107895. private _position;
  107896. private _btnVR;
  107897. private _btnVRDisplayed;
  107898. private _webVRsupported;
  107899. private _webVRready;
  107900. private _webVRrequesting;
  107901. private _webVRpresenting;
  107902. private _hasEnteredVR;
  107903. private _fullscreenVRpresenting;
  107904. private _canvas;
  107905. private _webVRCamera;
  107906. private _vrDeviceOrientationCamera;
  107907. private _deviceOrientationCamera;
  107908. private _existingCamera;
  107909. private _onKeyDown;
  107910. private _onVrDisplayPresentChange;
  107911. private _onVRDisplayChanged;
  107912. private _onVRRequestPresentStart;
  107913. private _onVRRequestPresentComplete;
  107914. /**
  107915. * 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)
  107916. */
  107917. enableGazeEvenWhenNoPointerLock: boolean;
  107918. /**
  107919. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  107920. */
  107921. exitVROnDoubleTap: boolean;
  107922. /**
  107923. * Observable raised right before entering VR.
  107924. */
  107925. onEnteringVRObservable: Observable<VRExperienceHelper>;
  107926. /**
  107927. * Observable raised when entering VR has completed.
  107928. */
  107929. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  107930. /**
  107931. * Observable raised when exiting VR.
  107932. */
  107933. onExitingVRObservable: Observable<VRExperienceHelper>;
  107934. /**
  107935. * Observable raised when controller mesh is loaded.
  107936. */
  107937. onControllerMeshLoadedObservable: Observable<WebVRController>;
  107938. /** Return this.onEnteringVRObservable
  107939. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  107940. */
  107941. readonly onEnteringVR: Observable<VRExperienceHelper>;
  107942. /** Return this.onExitingVRObservable
  107943. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  107944. */
  107945. readonly onExitingVR: Observable<VRExperienceHelper>;
  107946. /** Return this.onControllerMeshLoadedObservable
  107947. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  107948. */
  107949. readonly onControllerMeshLoaded: Observable<WebVRController>;
  107950. private _rayLength;
  107951. private _useCustomVRButton;
  107952. private _teleportationRequested;
  107953. private _teleportActive;
  107954. private _floorMeshName;
  107955. private _floorMeshesCollection;
  107956. private _rotationAllowed;
  107957. private _teleportBackwardsVector;
  107958. private _teleportationTarget;
  107959. private _isDefaultTeleportationTarget;
  107960. private _postProcessMove;
  107961. private _teleportationFillColor;
  107962. private _teleportationBorderColor;
  107963. private _rotationAngle;
  107964. private _haloCenter;
  107965. private _cameraGazer;
  107966. private _padSensibilityUp;
  107967. private _padSensibilityDown;
  107968. private _leftController;
  107969. private _rightController;
  107970. /**
  107971. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  107972. */
  107973. onNewMeshSelected: Observable<AbstractMesh>;
  107974. /**
  107975. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  107976. * This observable will provide the mesh and the controller used to select the mesh
  107977. */
  107978. onMeshSelectedWithController: Observable<{
  107979. mesh: AbstractMesh;
  107980. controller: WebVRController;
  107981. }>;
  107982. /**
  107983. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  107984. */
  107985. onNewMeshPicked: Observable<PickingInfo>;
  107986. private _circleEase;
  107987. /**
  107988. * Observable raised before camera teleportation
  107989. */
  107990. onBeforeCameraTeleport: Observable<Vector3>;
  107991. /**
  107992. * Observable raised after camera teleportation
  107993. */
  107994. onAfterCameraTeleport: Observable<Vector3>;
  107995. /**
  107996. * Observable raised when current selected mesh gets unselected
  107997. */
  107998. onSelectedMeshUnselected: Observable<AbstractMesh>;
  107999. private _raySelectionPredicate;
  108000. /**
  108001. * To be optionaly changed by user to define custom ray selection
  108002. */
  108003. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  108004. /**
  108005. * To be optionaly changed by user to define custom selection logic (after ray selection)
  108006. */
  108007. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  108008. /**
  108009. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  108010. */
  108011. teleportationEnabled: boolean;
  108012. private _defaultHeight;
  108013. private _teleportationInitialized;
  108014. private _interactionsEnabled;
  108015. private _interactionsRequested;
  108016. private _displayGaze;
  108017. private _displayLaserPointer;
  108018. /**
  108019. * The mesh used to display where the user is going to teleport.
  108020. */
  108021. /**
  108022. * Sets the mesh to be used to display where the user is going to teleport.
  108023. */
  108024. teleportationTarget: Mesh;
  108025. /**
  108026. * 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
  108027. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  108028. * See http://doc.babylonjs.com/resources/baking_transformations
  108029. */
  108030. gazeTrackerMesh: Mesh;
  108031. /**
  108032. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  108033. */
  108034. updateGazeTrackerScale: boolean;
  108035. /**
  108036. * If the gaze trackers color should be updated when selecting meshes
  108037. */
  108038. updateGazeTrackerColor: boolean;
  108039. /**
  108040. * If the controller laser color should be updated when selecting meshes
  108041. */
  108042. updateControllerLaserColor: boolean;
  108043. /**
  108044. * The gaze tracking mesh corresponding to the left controller
  108045. */
  108046. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  108047. /**
  108048. * The gaze tracking mesh corresponding to the right controller
  108049. */
  108050. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  108051. /**
  108052. * If the ray of the gaze should be displayed.
  108053. */
  108054. /**
  108055. * Sets if the ray of the gaze should be displayed.
  108056. */
  108057. displayGaze: boolean;
  108058. /**
  108059. * If the ray of the LaserPointer should be displayed.
  108060. */
  108061. /**
  108062. * Sets if the ray of the LaserPointer should be displayed.
  108063. */
  108064. displayLaserPointer: boolean;
  108065. /**
  108066. * The deviceOrientationCamera used as the camera when not in VR.
  108067. */
  108068. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  108069. /**
  108070. * Based on the current WebVR support, returns the current VR camera used.
  108071. */
  108072. readonly currentVRCamera: Nullable<Camera>;
  108073. /**
  108074. * The webVRCamera which is used when in VR.
  108075. */
  108076. readonly webVRCamera: WebVRFreeCamera;
  108077. /**
  108078. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  108079. */
  108080. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  108081. /**
  108082. * The html button that is used to trigger entering into VR.
  108083. */
  108084. readonly vrButton: Nullable<HTMLButtonElement>;
  108085. private readonly _teleportationRequestInitiated;
  108086. /**
  108087. * Defines wether or not Pointer lock should be requested when switching to
  108088. * full screen.
  108089. */
  108090. requestPointerLockOnFullScreen: boolean;
  108091. /**
  108092. * Instantiates a VRExperienceHelper.
  108093. * Helps to quickly add VR support to an existing scene.
  108094. * @param scene The scene the VRExperienceHelper belongs to.
  108095. * @param webVROptions Options to modify the vr experience helper's behavior.
  108096. */
  108097. constructor(scene: Scene,
  108098. /** Options to modify the vr experience helper's behavior. */
  108099. webVROptions?: VRExperienceHelperOptions);
  108100. private _onDefaultMeshLoaded;
  108101. private _onResize;
  108102. private _onFullscreenChange;
  108103. /**
  108104. * Gets a value indicating if we are currently in VR mode.
  108105. */
  108106. readonly isInVRMode: boolean;
  108107. private onVrDisplayPresentChange;
  108108. private onVRDisplayChanged;
  108109. private moveButtonToBottomRight;
  108110. private displayVRButton;
  108111. private updateButtonVisibility;
  108112. private _cachedAngularSensibility;
  108113. /**
  108114. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  108115. * Otherwise, will use the fullscreen API.
  108116. */
  108117. enterVR(): void;
  108118. /**
  108119. * Attempt to exit VR, or fullscreen.
  108120. */
  108121. exitVR(): void;
  108122. /**
  108123. * The position of the vr experience helper.
  108124. */
  108125. /**
  108126. * Sets the position of the vr experience helper.
  108127. */
  108128. position: Vector3;
  108129. /**
  108130. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  108131. */
  108132. enableInteractions(): void;
  108133. private readonly _noControllerIsActive;
  108134. private beforeRender;
  108135. private _isTeleportationFloor;
  108136. /**
  108137. * Adds a floor mesh to be used for teleportation.
  108138. * @param floorMesh the mesh to be used for teleportation.
  108139. */
  108140. addFloorMesh(floorMesh: Mesh): void;
  108141. /**
  108142. * Removes a floor mesh from being used for teleportation.
  108143. * @param floorMesh the mesh to be removed.
  108144. */
  108145. removeFloorMesh(floorMesh: Mesh): void;
  108146. /**
  108147. * Enables interactions and teleportation using the VR controllers and gaze.
  108148. * @param vrTeleportationOptions options to modify teleportation behavior.
  108149. */
  108150. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  108151. private _onNewGamepadConnected;
  108152. private _tryEnableInteractionOnController;
  108153. private _onNewGamepadDisconnected;
  108154. private _enableInteractionOnController;
  108155. private _checkTeleportWithRay;
  108156. private _checkRotate;
  108157. private _checkTeleportBackwards;
  108158. private _enableTeleportationOnController;
  108159. private _createTeleportationCircles;
  108160. private _displayTeleportationTarget;
  108161. private _hideTeleportationTarget;
  108162. private _rotateCamera;
  108163. private _moveTeleportationSelectorTo;
  108164. private _workingVector;
  108165. private _workingQuaternion;
  108166. private _workingMatrix;
  108167. /**
  108168. * Teleports the users feet to the desired location
  108169. * @param location The location where the user's feet should be placed
  108170. */
  108171. teleportCamera(location: Vector3): void;
  108172. private _convertNormalToDirectionOfRay;
  108173. private _castRayAndSelectObject;
  108174. private _notifySelectedMeshUnselected;
  108175. /**
  108176. * Sets the color of the laser ray from the vr controllers.
  108177. * @param color new color for the ray.
  108178. */
  108179. changeLaserColor(color: Color3): void;
  108180. /**
  108181. * Sets the color of the ray from the vr headsets gaze.
  108182. * @param color new color for the ray.
  108183. */
  108184. changeGazeColor(color: Color3): void;
  108185. /**
  108186. * Exits VR and disposes of the vr experience helper
  108187. */
  108188. dispose(): void;
  108189. /**
  108190. * Gets the name of the VRExperienceHelper class
  108191. * @returns "VRExperienceHelper"
  108192. */
  108193. getClassName(): string;
  108194. }
  108195. }
  108196. declare module BABYLON {
  108197. /**
  108198. * Manages an XRSession to work with Babylon's engine
  108199. * @see https://doc.babylonjs.com/how_to/webxr
  108200. */
  108201. export class WebXRSessionManager implements IDisposable {
  108202. private scene;
  108203. /**
  108204. * Fires every time a new xrFrame arrives which can be used to update the camera
  108205. */
  108206. onXRFrameObservable: Observable<any>;
  108207. /**
  108208. * Fires when the xr session is ended either by the device or manually done
  108209. */
  108210. onXRSessionEnded: Observable<any>;
  108211. /**
  108212. * Underlying xr session
  108213. */
  108214. session: XRSession;
  108215. /**
  108216. * Type of reference space used when creating the session
  108217. */
  108218. referenceSpace: XRReferenceSpace;
  108219. /** @hidden */
  108220. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  108221. /**
  108222. * Current XR frame
  108223. */
  108224. currentFrame: Nullable<XRFrame>;
  108225. private _xrNavigator;
  108226. private baseLayer;
  108227. /**
  108228. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  108229. * @param scene The scene which the session should be created for
  108230. */
  108231. constructor(scene: Scene);
  108232. /**
  108233. * Initializes the manager
  108234. * After initialization enterXR can be called to start an XR session
  108235. * @returns Promise which resolves after it is initialized
  108236. */
  108237. initializeAsync(): Promise<void>;
  108238. /**
  108239. * Initializes an xr session
  108240. * @param xrSessionMode mode to initialize
  108241. * @returns a promise which will resolve once the session has been initialized
  108242. */
  108243. initializeSessionAsync(xrSessionMode: XRSessionMode): any;
  108244. /**
  108245. * Sets the reference space on the xr session
  108246. * @param referenceSpace space to set
  108247. * @returns a promise that will resolve once the reference space has been set
  108248. */
  108249. setReferenceSpaceAsync(referenceSpace: XRReferenceSpaceType): Promise<void>;
  108250. /**
  108251. * Updates the render state of the session
  108252. * @param state state to set
  108253. * @returns a promise that resolves once the render state has been updated
  108254. */
  108255. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  108256. /**
  108257. * Starts rendering to the xr layer
  108258. * @returns a promise that will resolve once rendering has started
  108259. */
  108260. startRenderingToXRAsync(): Promise<void>;
  108261. /**
  108262. * Stops the xrSession and restores the renderloop
  108263. * @returns Promise which resolves after it exits XR
  108264. */
  108265. exitXRAsync(): Promise<unknown>;
  108266. /**
  108267. * Checks if a session would be supported for the creation options specified
  108268. * @param sessionMode session mode to check if supported eg. immersive-vr
  108269. * @returns true if supported
  108270. */
  108271. supportsSessionAsync(sessionMode: XRSessionMode): any;
  108272. /**
  108273. * @hidden
  108274. * Converts the render layer of xrSession to a render target
  108275. * @param session session to create render target for
  108276. * @param scene scene the new render target should be created for
  108277. */
  108278. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene, baseLayer: XRWebGLLayer): RenderTargetTexture;
  108279. /**
  108280. * Disposes of the session manager
  108281. */
  108282. dispose(): void;
  108283. }
  108284. }
  108285. declare module BABYLON {
  108286. /**
  108287. * WebXR Camera which holds the views for the xrSession
  108288. * @see https://doc.babylonjs.com/how_to/webxr
  108289. */
  108290. export class WebXRCamera extends FreeCamera {
  108291. private static _TmpMatrix;
  108292. /**
  108293. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  108294. * @param name the name of the camera
  108295. * @param scene the scene to add the camera to
  108296. */
  108297. constructor(name: string, scene: Scene);
  108298. private _updateNumberOfRigCameras;
  108299. /** @hidden */
  108300. _updateForDualEyeDebugging(pupilDistance?: number): void;
  108301. /**
  108302. * Updates the cameras position from the current pose information of the XR session
  108303. * @param xrSessionManager the session containing pose information
  108304. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  108305. */
  108306. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  108307. }
  108308. }
  108309. declare module BABYLON {
  108310. /**
  108311. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  108312. */
  108313. export class WebXRManagedOutputCanvas implements IDisposable {
  108314. private helper;
  108315. private _canvas;
  108316. /**
  108317. * xrpresent context of the canvas which can be used to display/mirror xr content
  108318. */
  108319. canvasContext: WebGLRenderingContext;
  108320. /**
  108321. * xr layer for the canvas
  108322. */
  108323. xrLayer: Nullable<XRWebGLLayer>;
  108324. /**
  108325. * Initializes the xr layer for the session
  108326. * @param xrSession xr session
  108327. * @returns a promise that will resolve once the XR Layer has been created
  108328. */
  108329. initializeXRLayerAsync(xrSession: any): any;
  108330. /**
  108331. * Initializes the canvas to be added/removed upon entering/exiting xr
  108332. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  108333. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  108334. */
  108335. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  108336. /**
  108337. * Disposes of the object
  108338. */
  108339. dispose(): void;
  108340. private _setManagedOutputCanvas;
  108341. private _addCanvas;
  108342. private _removeCanvas;
  108343. }
  108344. }
  108345. declare module BABYLON {
  108346. /**
  108347. * States of the webXR experience
  108348. */
  108349. export enum WebXRState {
  108350. /**
  108351. * Transitioning to being in XR mode
  108352. */
  108353. ENTERING_XR = 0,
  108354. /**
  108355. * Transitioning to non XR mode
  108356. */
  108357. EXITING_XR = 1,
  108358. /**
  108359. * In XR mode and presenting
  108360. */
  108361. IN_XR = 2,
  108362. /**
  108363. * Not entered XR mode
  108364. */
  108365. NOT_IN_XR = 3
  108366. }
  108367. /**
  108368. * Base set of functionality needed to create an XR experince (WebXRSessionManager, Camera, StateManagement, etc.)
  108369. * @see https://doc.babylonjs.com/how_to/webxr
  108370. */
  108371. export class WebXRExperienceHelper implements IDisposable {
  108372. private scene;
  108373. /**
  108374. * 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
  108375. */
  108376. container: AbstractMesh;
  108377. /**
  108378. * Camera used to render xr content
  108379. */
  108380. camera: WebXRCamera;
  108381. /**
  108382. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  108383. */
  108384. state: WebXRState;
  108385. private _setState;
  108386. private static _TmpVector;
  108387. /**
  108388. * Fires when the state of the experience helper has changed
  108389. */
  108390. onStateChangedObservable: Observable<WebXRState>;
  108391. /** Session manager used to keep track of xr session */
  108392. sessionManager: WebXRSessionManager;
  108393. private _nonVRCamera;
  108394. private _originalSceneAutoClear;
  108395. private _supported;
  108396. /**
  108397. * Creates the experience helper
  108398. * @param scene the scene to attach the experience helper to
  108399. * @returns a promise for the experience helper
  108400. */
  108401. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  108402. /**
  108403. * Creates a WebXRExperienceHelper
  108404. * @param scene The scene the helper should be created in
  108405. */
  108406. private constructor();
  108407. /**
  108408. * Exits XR mode and returns the scene to its original state
  108409. * @returns promise that resolves after xr mode has exited
  108410. */
  108411. exitXRAsync(): Promise<unknown>;
  108412. /**
  108413. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  108414. * @param sessionCreationOptions options for the XR session
  108415. * @param referenceSpaceType frame of reference of the XR session
  108416. * @param outputCanvas the output canvas that will be used to enter XR mode
  108417. * @returns promise that resolves after xr mode has entered
  108418. */
  108419. enterXRAsync(sessionCreationOptions: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, outputCanvas: WebXRManagedOutputCanvas): any;
  108420. /**
  108421. * Updates the global position of the camera by moving the camera's container
  108422. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  108423. * @param position The desired global position of the camera
  108424. */
  108425. setPositionOfCameraUsingContainer(position: Vector3): void;
  108426. /**
  108427. * Rotates the xr camera by rotating the camera's container around the camera's position
  108428. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  108429. * @param rotation the desired quaternion rotation to apply to the camera
  108430. */
  108431. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  108432. /**
  108433. * Disposes of the experience helper
  108434. */
  108435. dispose(): void;
  108436. }
  108437. }
  108438. declare module BABYLON {
  108439. /**
  108440. * Button which can be used to enter a different mode of XR
  108441. */
  108442. export class WebXREnterExitUIButton {
  108443. /** button element */
  108444. element: HTMLElement;
  108445. /** XR initialization options for the button */
  108446. sessionMode: XRSessionMode;
  108447. /** Reference space type */
  108448. referenceSpaceType: XRReferenceSpaceType;
  108449. /**
  108450. * Creates a WebXREnterExitUIButton
  108451. * @param element button element
  108452. * @param sessionMode XR initialization session mode
  108453. * @param referenceSpaceType the type of reference space to be used
  108454. */
  108455. constructor(
  108456. /** button element */
  108457. element: HTMLElement,
  108458. /** XR initialization options for the button */
  108459. sessionMode: XRSessionMode,
  108460. /** Reference space type */
  108461. referenceSpaceType: XRReferenceSpaceType);
  108462. /**
  108463. * Overwritable function which can be used to update the button's visuals when the state changes
  108464. * @param activeButton the current active button in the UI
  108465. */
  108466. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  108467. }
  108468. /**
  108469. * Options to create the webXR UI
  108470. */
  108471. export class WebXREnterExitUIOptions {
  108472. /**
  108473. * Context to enter xr with
  108474. */
  108475. webXRManagedOutputCanvas?: Nullable<WebXRManagedOutputCanvas>;
  108476. /**
  108477. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  108478. */
  108479. customButtons?: Array<WebXREnterExitUIButton>;
  108480. }
  108481. /**
  108482. * UI to allow the user to enter/exit XR mode
  108483. */
  108484. export class WebXREnterExitUI implements IDisposable {
  108485. private scene;
  108486. private _overlay;
  108487. private _buttons;
  108488. private _activeButton;
  108489. /**
  108490. * Fired every time the active button is changed.
  108491. *
  108492. * When xr is entered via a button that launches xr that button will be the callback parameter
  108493. *
  108494. * When exiting xr the callback parameter will be null)
  108495. */
  108496. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  108497. /**
  108498. * Creates UI to allow the user to enter/exit XR mode
  108499. * @param scene the scene to add the ui to
  108500. * @param helper the xr experience helper to enter/exit xr with
  108501. * @param options options to configure the UI
  108502. * @returns the created ui
  108503. */
  108504. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  108505. private constructor();
  108506. private _updateButtons;
  108507. /**
  108508. * Disposes of the object
  108509. */
  108510. dispose(): void;
  108511. }
  108512. }
  108513. declare module BABYLON {
  108514. /**
  108515. * Represents an XR input
  108516. */
  108517. export class WebXRController {
  108518. private scene;
  108519. /** The underlying input source for the controller */
  108520. inputSource: XRInputSource;
  108521. private parentContainer;
  108522. /**
  108523. * 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
  108524. */
  108525. grip?: AbstractMesh;
  108526. /**
  108527. * Pointer which can be used to select objects or attach a visible laser to
  108528. */
  108529. pointer: AbstractMesh;
  108530. /**
  108531. * Event that fires when the controller is removed/disposed
  108532. */
  108533. onDisposeObservable: Observable<{}>;
  108534. private _tmpMatrix;
  108535. private _tmpQuaternion;
  108536. private _tmpVector;
  108537. /**
  108538. * Creates the controller
  108539. * @see https://doc.babylonjs.com/how_to/webxr
  108540. * @param scene the scene which the controller should be associated to
  108541. * @param inputSource the underlying input source for the controller
  108542. * @param parentContainer parent that the controller meshes should be children of
  108543. */
  108544. constructor(scene: Scene,
  108545. /** The underlying input source for the controller */
  108546. inputSource: XRInputSource, parentContainer?: Nullable<AbstractMesh>);
  108547. /**
  108548. * Updates the controller pose based on the given XRFrame
  108549. * @param xrFrame xr frame to update the pose with
  108550. * @param referenceSpace reference space to use
  108551. */
  108552. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  108553. /**
  108554. * Gets a world space ray coming from the controller
  108555. * @param result the resulting ray
  108556. */
  108557. getWorldPointerRayToRef(result: Ray): void;
  108558. /**
  108559. * Disposes of the object
  108560. */
  108561. dispose(): void;
  108562. }
  108563. }
  108564. declare module BABYLON {
  108565. /**
  108566. * XR input used to track XR inputs such as controllers/rays
  108567. */
  108568. export class WebXRInput implements IDisposable {
  108569. /**
  108570. * Base experience the input listens to
  108571. */
  108572. baseExperience: WebXRExperienceHelper;
  108573. /**
  108574. * XR controllers being tracked
  108575. */
  108576. controllers: Array<WebXRController>;
  108577. private _frameObserver;
  108578. private _stateObserver;
  108579. /**
  108580. * Event when a controller has been connected/added
  108581. */
  108582. onControllerAddedObservable: Observable<WebXRController>;
  108583. /**
  108584. * Event when a controller has been removed/disconnected
  108585. */
  108586. onControllerRemovedObservable: Observable<WebXRController>;
  108587. /**
  108588. * Initializes the WebXRInput
  108589. * @param baseExperience experience helper which the input should be created for
  108590. */
  108591. constructor(
  108592. /**
  108593. * Base experience the input listens to
  108594. */
  108595. baseExperience: WebXRExperienceHelper);
  108596. private _onInputSourcesChange;
  108597. private _addAndRemoveControllers;
  108598. /**
  108599. * Disposes of the object
  108600. */
  108601. dispose(): void;
  108602. }
  108603. }
  108604. declare module BABYLON {
  108605. /**
  108606. * Enables teleportation
  108607. */
  108608. export class WebXRControllerTeleportation {
  108609. private _teleportationFillColor;
  108610. private _teleportationBorderColor;
  108611. private _tmpRay;
  108612. private _tmpVector;
  108613. /**
  108614. * Creates a WebXRControllerTeleportation
  108615. * @param input input manager to add teleportation to
  108616. * @param floorMeshes floormeshes which can be teleported to
  108617. */
  108618. constructor(input: WebXRInput, floorMeshes?: Array<AbstractMesh>);
  108619. }
  108620. }
  108621. declare module BABYLON {
  108622. /**
  108623. * Handles pointer input automatically for the pointer of XR controllers
  108624. */
  108625. export class WebXRControllerPointerSelection {
  108626. private static _idCounter;
  108627. private _tmpRay;
  108628. /**
  108629. * Creates a WebXRControllerPointerSelection
  108630. * @param input input manager to setup pointer selection
  108631. */
  108632. constructor(input: WebXRInput);
  108633. private _convertNormalToDirectionOfRay;
  108634. private _updatePointerDistance;
  108635. }
  108636. }
  108637. declare module BABYLON {
  108638. /**
  108639. * Class used to represent data loading progression
  108640. */
  108641. export class SceneLoaderProgressEvent {
  108642. /** defines if data length to load can be evaluated */
  108643. readonly lengthComputable: boolean;
  108644. /** defines the loaded data length */
  108645. readonly loaded: number;
  108646. /** defines the data length to load */
  108647. readonly total: number;
  108648. /**
  108649. * Create a new progress event
  108650. * @param lengthComputable defines if data length to load can be evaluated
  108651. * @param loaded defines the loaded data length
  108652. * @param total defines the data length to load
  108653. */
  108654. constructor(
  108655. /** defines if data length to load can be evaluated */
  108656. lengthComputable: boolean,
  108657. /** defines the loaded data length */
  108658. loaded: number,
  108659. /** defines the data length to load */
  108660. total: number);
  108661. /**
  108662. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  108663. * @param event defines the source event
  108664. * @returns a new SceneLoaderProgressEvent
  108665. */
  108666. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  108667. }
  108668. /**
  108669. * Interface used by SceneLoader plugins to define supported file extensions
  108670. */
  108671. export interface ISceneLoaderPluginExtensions {
  108672. /**
  108673. * Defines the list of supported extensions
  108674. */
  108675. [extension: string]: {
  108676. isBinary: boolean;
  108677. };
  108678. }
  108679. /**
  108680. * Interface used by SceneLoader plugin factory
  108681. */
  108682. export interface ISceneLoaderPluginFactory {
  108683. /**
  108684. * Defines the name of the factory
  108685. */
  108686. name: string;
  108687. /**
  108688. * Function called to create a new plugin
  108689. * @return the new plugin
  108690. */
  108691. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  108692. /**
  108693. * Boolean indicating if the plugin can direct load specific data
  108694. */
  108695. canDirectLoad?: (data: string) => boolean;
  108696. }
  108697. /**
  108698. * Interface used to define a SceneLoader plugin
  108699. */
  108700. export interface ISceneLoaderPlugin {
  108701. /**
  108702. * The friendly name of this plugin.
  108703. */
  108704. name: string;
  108705. /**
  108706. * The file extensions supported by this plugin.
  108707. */
  108708. extensions: string | ISceneLoaderPluginExtensions;
  108709. /**
  108710. * Import meshes into a scene.
  108711. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108712. * @param scene The scene to import into
  108713. * @param data The data to import
  108714. * @param rootUrl The root url for scene and resources
  108715. * @param meshes The meshes array to import into
  108716. * @param particleSystems The particle systems array to import into
  108717. * @param skeletons The skeletons array to import into
  108718. * @param onError The callback when import fails
  108719. * @returns True if successful or false otherwise
  108720. */
  108721. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  108722. /**
  108723. * Load into a scene.
  108724. * @param scene The scene to load into
  108725. * @param data The data to import
  108726. * @param rootUrl The root url for scene and resources
  108727. * @param onError The callback when import fails
  108728. * @returns true if successful or false otherwise
  108729. */
  108730. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  108731. /**
  108732. * The callback that returns true if the data can be directly loaded.
  108733. */
  108734. canDirectLoad?: (data: string) => boolean;
  108735. /**
  108736. * The callback that allows custom handling of the root url based on the response url.
  108737. */
  108738. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108739. /**
  108740. * Load into an asset container.
  108741. * @param scene The scene to load into
  108742. * @param data The data to import
  108743. * @param rootUrl The root url for scene and resources
  108744. * @param onError The callback when import fails
  108745. * @returns The loaded asset container
  108746. */
  108747. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  108748. }
  108749. /**
  108750. * Interface used to define an async SceneLoader plugin
  108751. */
  108752. export interface ISceneLoaderPluginAsync {
  108753. /**
  108754. * The friendly name of this plugin.
  108755. */
  108756. name: string;
  108757. /**
  108758. * The file extensions supported by this plugin.
  108759. */
  108760. extensions: string | ISceneLoaderPluginExtensions;
  108761. /**
  108762. * Import meshes into a scene.
  108763. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108764. * @param scene The scene to import into
  108765. * @param data The data to import
  108766. * @param rootUrl The root url for scene and resources
  108767. * @param onProgress The callback when the load progresses
  108768. * @param fileName Defines the name of the file to load
  108769. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  108770. */
  108771. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  108772. meshes: AbstractMesh[];
  108773. particleSystems: IParticleSystem[];
  108774. skeletons: Skeleton[];
  108775. animationGroups: AnimationGroup[];
  108776. }>;
  108777. /**
  108778. * Load into a scene.
  108779. * @param scene The scene to load into
  108780. * @param data The data to import
  108781. * @param rootUrl The root url for scene and resources
  108782. * @param onProgress The callback when the load progresses
  108783. * @param fileName Defines the name of the file to load
  108784. * @returns Nothing
  108785. */
  108786. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  108787. /**
  108788. * The callback that returns true if the data can be directly loaded.
  108789. */
  108790. canDirectLoad?: (data: string) => boolean;
  108791. /**
  108792. * The callback that allows custom handling of the root url based on the response url.
  108793. */
  108794. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  108795. /**
  108796. * Load into an asset container.
  108797. * @param scene The scene to load into
  108798. * @param data The data to import
  108799. * @param rootUrl The root url for scene and resources
  108800. * @param onProgress The callback when the load progresses
  108801. * @param fileName Defines the name of the file to load
  108802. * @returns The loaded asset container
  108803. */
  108804. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  108805. }
  108806. /**
  108807. * Class used to load scene from various file formats using registered plugins
  108808. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  108809. */
  108810. export class SceneLoader {
  108811. /**
  108812. * No logging while loading
  108813. */
  108814. static readonly NO_LOGGING: number;
  108815. /**
  108816. * Minimal logging while loading
  108817. */
  108818. static readonly MINIMAL_LOGGING: number;
  108819. /**
  108820. * Summary logging while loading
  108821. */
  108822. static readonly SUMMARY_LOGGING: number;
  108823. /**
  108824. * Detailled logging while loading
  108825. */
  108826. static readonly DETAILED_LOGGING: number;
  108827. /**
  108828. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  108829. */
  108830. static ForceFullSceneLoadingForIncremental: boolean;
  108831. /**
  108832. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  108833. */
  108834. static ShowLoadingScreen: boolean;
  108835. /**
  108836. * Defines the current logging level (while loading the scene)
  108837. * @ignorenaming
  108838. */
  108839. static loggingLevel: number;
  108840. /**
  108841. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  108842. */
  108843. static CleanBoneMatrixWeights: boolean;
  108844. /**
  108845. * Event raised when a plugin is used to load a scene
  108846. */
  108847. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  108848. private static _registeredPlugins;
  108849. private static _getDefaultPlugin;
  108850. private static _getPluginForExtension;
  108851. private static _getPluginForDirectLoad;
  108852. private static _getPluginForFilename;
  108853. private static _getDirectLoad;
  108854. private static _loadData;
  108855. private static _getFileInfo;
  108856. /**
  108857. * Gets a plugin that can load the given extension
  108858. * @param extension defines the extension to load
  108859. * @returns a plugin or null if none works
  108860. */
  108861. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  108862. /**
  108863. * Gets a boolean indicating that the given extension can be loaded
  108864. * @param extension defines the extension to load
  108865. * @returns true if the extension is supported
  108866. */
  108867. static IsPluginForExtensionAvailable(extension: string): boolean;
  108868. /**
  108869. * Adds a new plugin to the list of registered plugins
  108870. * @param plugin defines the plugin to add
  108871. */
  108872. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  108873. /**
  108874. * Import meshes into a scene
  108875. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108876. * @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)
  108877. * @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)
  108878. * @param scene the instance of BABYLON.Scene to append to
  108879. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  108880. * @param onProgress a callback with a progress event for each file being loaded
  108881. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108882. * @param pluginExtension the extension used to determine the plugin
  108883. * @returns The loaded plugin
  108884. */
  108885. 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>;
  108886. /**
  108887. * Import meshes into a scene
  108888. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  108889. * @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)
  108890. * @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)
  108891. * @param scene the instance of BABYLON.Scene to append to
  108892. * @param onProgress a callback with a progress event for each file being loaded
  108893. * @param pluginExtension the extension used to determine the plugin
  108894. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  108895. */
  108896. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  108897. meshes: AbstractMesh[];
  108898. particleSystems: IParticleSystem[];
  108899. skeletons: Skeleton[];
  108900. animationGroups: AnimationGroup[];
  108901. }>;
  108902. /**
  108903. * Load a scene
  108904. * @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)
  108905. * @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)
  108906. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108907. * @param onSuccess a callback with the scene when import succeeds
  108908. * @param onProgress a callback with a progress event for each file being loaded
  108909. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108910. * @param pluginExtension the extension used to determine the plugin
  108911. * @returns The loaded plugin
  108912. */
  108913. 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>;
  108914. /**
  108915. * Load a scene
  108916. * @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)
  108917. * @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)
  108918. * @param engine is the instance of BABYLON.Engine to use to create the scene
  108919. * @param onProgress a callback with a progress event for each file being loaded
  108920. * @param pluginExtension the extension used to determine the plugin
  108921. * @returns The loaded scene
  108922. */
  108923. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108924. /**
  108925. * Append a scene
  108926. * @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)
  108927. * @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)
  108928. * @param scene is the instance of BABYLON.Scene to append to
  108929. * @param onSuccess a callback with the scene when import succeeds
  108930. * @param onProgress a callback with a progress event for each file being loaded
  108931. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108932. * @param pluginExtension the extension used to determine the plugin
  108933. * @returns The loaded plugin
  108934. */
  108935. 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>;
  108936. /**
  108937. * Append a scene
  108938. * @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)
  108939. * @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)
  108940. * @param scene is the instance of BABYLON.Scene to append to
  108941. * @param onProgress a callback with a progress event for each file being loaded
  108942. * @param pluginExtension the extension used to determine the plugin
  108943. * @returns The given scene
  108944. */
  108945. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  108946. /**
  108947. * Load a scene into an asset container
  108948. * @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)
  108949. * @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)
  108950. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  108951. * @param onSuccess a callback with the scene when import succeeds
  108952. * @param onProgress a callback with a progress event for each file being loaded
  108953. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  108954. * @param pluginExtension the extension used to determine the plugin
  108955. * @returns The loaded plugin
  108956. */
  108957. 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>;
  108958. /**
  108959. * Load a scene into an asset container
  108960. * @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)
  108961. * @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)
  108962. * @param scene is the instance of Scene to append to
  108963. * @param onProgress a callback with a progress event for each file being loaded
  108964. * @param pluginExtension the extension used to determine the plugin
  108965. * @returns The loaded asset container
  108966. */
  108967. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  108968. }
  108969. }
  108970. declare module BABYLON {
  108971. /**
  108972. * Generic Controller
  108973. */
  108974. export class GenericController extends WebVRController {
  108975. /**
  108976. * Base Url for the controller model.
  108977. */
  108978. static readonly MODEL_BASE_URL: string;
  108979. /**
  108980. * File name for the controller model.
  108981. */
  108982. static readonly MODEL_FILENAME: string;
  108983. /**
  108984. * Creates a new GenericController from a gamepad
  108985. * @param vrGamepad the gamepad that the controller should be created from
  108986. */
  108987. constructor(vrGamepad: any);
  108988. /**
  108989. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  108990. * @param scene scene in which to add meshes
  108991. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  108992. */
  108993. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  108994. /**
  108995. * Called once for each button that changed state since the last frame
  108996. * @param buttonIdx Which button index changed
  108997. * @param state New state of the button
  108998. * @param changes Which properties on the state changed since last frame
  108999. */
  109000. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109001. }
  109002. }
  109003. declare module BABYLON {
  109004. /**
  109005. * Defines the WindowsMotionController object that the state of the windows motion controller
  109006. */
  109007. export class WindowsMotionController extends WebVRController {
  109008. /**
  109009. * The base url used to load the left and right controller models
  109010. */
  109011. static MODEL_BASE_URL: string;
  109012. /**
  109013. * The name of the left controller model file
  109014. */
  109015. static MODEL_LEFT_FILENAME: string;
  109016. /**
  109017. * The name of the right controller model file
  109018. */
  109019. static MODEL_RIGHT_FILENAME: string;
  109020. /**
  109021. * The controller name prefix for this controller type
  109022. */
  109023. static readonly GAMEPAD_ID_PREFIX: string;
  109024. /**
  109025. * The controller id pattern for this controller type
  109026. */
  109027. private static readonly GAMEPAD_ID_PATTERN;
  109028. private _loadedMeshInfo;
  109029. private readonly _mapping;
  109030. /**
  109031. * Fired when the trackpad on this controller is clicked
  109032. */
  109033. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  109034. /**
  109035. * Fired when the trackpad on this controller is modified
  109036. */
  109037. onTrackpadValuesChangedObservable: Observable<StickValues>;
  109038. /**
  109039. * The current x and y values of this controller's trackpad
  109040. */
  109041. trackpad: StickValues;
  109042. /**
  109043. * Creates a new WindowsMotionController from a gamepad
  109044. * @param vrGamepad the gamepad that the controller should be created from
  109045. */
  109046. constructor(vrGamepad: any);
  109047. /**
  109048. * Fired when the trigger on this controller is modified
  109049. */
  109050. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109051. /**
  109052. * Fired when the menu button on this controller is modified
  109053. */
  109054. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109055. /**
  109056. * Fired when the grip button on this controller is modified
  109057. */
  109058. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109059. /**
  109060. * Fired when the thumbstick button on this controller is modified
  109061. */
  109062. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109063. /**
  109064. * Fired when the touchpad button on this controller is modified
  109065. */
  109066. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109067. /**
  109068. * Fired when the touchpad values on this controller are modified
  109069. */
  109070. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  109071. private _updateTrackpad;
  109072. /**
  109073. * Called once per frame by the engine.
  109074. */
  109075. update(): void;
  109076. /**
  109077. * Called once for each button that changed state since the last frame
  109078. * @param buttonIdx Which button index changed
  109079. * @param state New state of the button
  109080. * @param changes Which properties on the state changed since last frame
  109081. */
  109082. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109083. /**
  109084. * Moves the buttons on the controller mesh based on their current state
  109085. * @param buttonName the name of the button to move
  109086. * @param buttonValue the value of the button which determines the buttons new position
  109087. */
  109088. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  109089. /**
  109090. * Moves the axis on the controller mesh based on its current state
  109091. * @param axis the index of the axis
  109092. * @param axisValue the value of the axis which determines the meshes new position
  109093. * @hidden
  109094. */
  109095. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  109096. /**
  109097. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109098. * @param scene scene in which to add meshes
  109099. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109100. */
  109101. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  109102. /**
  109103. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  109104. * can be transformed by button presses and axes values, based on this._mapping.
  109105. *
  109106. * @param scene scene in which the meshes exist
  109107. * @param meshes list of meshes that make up the controller model to process
  109108. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  109109. */
  109110. private processModel;
  109111. private createMeshInfo;
  109112. /**
  109113. * Gets the ray of the controller in the direction the controller is pointing
  109114. * @param length the length the resulting ray should be
  109115. * @returns a ray in the direction the controller is pointing
  109116. */
  109117. getForwardRay(length?: number): Ray;
  109118. /**
  109119. * Disposes of the controller
  109120. */
  109121. dispose(): void;
  109122. }
  109123. }
  109124. declare module BABYLON {
  109125. /**
  109126. * Oculus Touch Controller
  109127. */
  109128. export class OculusTouchController extends WebVRController {
  109129. /**
  109130. * Base Url for the controller model.
  109131. */
  109132. static MODEL_BASE_URL: string;
  109133. /**
  109134. * File name for the left controller model.
  109135. */
  109136. static MODEL_LEFT_FILENAME: string;
  109137. /**
  109138. * File name for the right controller model.
  109139. */
  109140. static MODEL_RIGHT_FILENAME: string;
  109141. /**
  109142. * Base Url for the Quest controller model.
  109143. */
  109144. static QUEST_MODEL_BASE_URL: string;
  109145. /**
  109146. * @hidden
  109147. * If the controllers are running on a device that needs the updated Quest controller models
  109148. */
  109149. static _IsQuest: boolean;
  109150. /**
  109151. * Fired when the secondary trigger on this controller is modified
  109152. */
  109153. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  109154. /**
  109155. * Fired when the thumb rest on this controller is modified
  109156. */
  109157. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  109158. /**
  109159. * Creates a new OculusTouchController from a gamepad
  109160. * @param vrGamepad the gamepad that the controller should be created from
  109161. */
  109162. constructor(vrGamepad: any);
  109163. /**
  109164. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109165. * @param scene scene in which to add meshes
  109166. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109167. */
  109168. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109169. /**
  109170. * Fired when the A button on this controller is modified
  109171. */
  109172. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109173. /**
  109174. * Fired when the B button on this controller is modified
  109175. */
  109176. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109177. /**
  109178. * Fired when the X button on this controller is modified
  109179. */
  109180. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109181. /**
  109182. * Fired when the Y button on this controller is modified
  109183. */
  109184. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109185. /**
  109186. * Called once for each button that changed state since the last frame
  109187. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  109188. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  109189. * 2) secondary trigger (same)
  109190. * 3) A (right) X (left), touch, pressed = value
  109191. * 4) B / Y
  109192. * 5) thumb rest
  109193. * @param buttonIdx Which button index changed
  109194. * @param state New state of the button
  109195. * @param changes Which properties on the state changed since last frame
  109196. */
  109197. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109198. }
  109199. }
  109200. declare module BABYLON {
  109201. /**
  109202. * Vive Controller
  109203. */
  109204. export class ViveController extends WebVRController {
  109205. /**
  109206. * Base Url for the controller model.
  109207. */
  109208. static MODEL_BASE_URL: string;
  109209. /**
  109210. * File name for the controller model.
  109211. */
  109212. static MODEL_FILENAME: string;
  109213. /**
  109214. * Creates a new ViveController from a gamepad
  109215. * @param vrGamepad the gamepad that the controller should be created from
  109216. */
  109217. constructor(vrGamepad: any);
  109218. /**
  109219. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  109220. * @param scene scene in which to add meshes
  109221. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  109222. */
  109223. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  109224. /**
  109225. * Fired when the left button on this controller is modified
  109226. */
  109227. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109228. /**
  109229. * Fired when the right button on this controller is modified
  109230. */
  109231. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109232. /**
  109233. * Fired when the menu button on this controller is modified
  109234. */
  109235. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  109236. /**
  109237. * Called once for each button that changed state since the last frame
  109238. * Vive mapping:
  109239. * 0: touchpad
  109240. * 1: trigger
  109241. * 2: left AND right buttons
  109242. * 3: menu button
  109243. * @param buttonIdx Which button index changed
  109244. * @param state New state of the button
  109245. * @param changes Which properties on the state changed since last frame
  109246. */
  109247. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  109248. }
  109249. }
  109250. declare module BABYLON {
  109251. /**
  109252. * Loads a controller model and adds it as a child of the WebXRControllers grip when the controller is created
  109253. */
  109254. export class WebXRControllerModelLoader {
  109255. /**
  109256. * Creates the WebXRControllerModelLoader
  109257. * @param input xr input that creates the controllers
  109258. */
  109259. constructor(input: WebXRInput);
  109260. }
  109261. }
  109262. declare module BABYLON {
  109263. /**
  109264. * Contains an array of blocks representing the octree
  109265. */
  109266. export interface IOctreeContainer<T> {
  109267. /**
  109268. * Blocks within the octree
  109269. */
  109270. blocks: Array<OctreeBlock<T>>;
  109271. }
  109272. /**
  109273. * Class used to store a cell in an octree
  109274. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109275. */
  109276. export class OctreeBlock<T> {
  109277. /**
  109278. * Gets the content of the current block
  109279. */
  109280. entries: T[];
  109281. /**
  109282. * Gets the list of block children
  109283. */
  109284. blocks: Array<OctreeBlock<T>>;
  109285. private _depth;
  109286. private _maxDepth;
  109287. private _capacity;
  109288. private _minPoint;
  109289. private _maxPoint;
  109290. private _boundingVectors;
  109291. private _creationFunc;
  109292. /**
  109293. * Creates a new block
  109294. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  109295. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  109296. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109297. * @param depth defines the current depth of this block in the octree
  109298. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  109299. * @param creationFunc defines a callback to call when an element is added to the block
  109300. */
  109301. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  109302. /**
  109303. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  109304. */
  109305. readonly capacity: number;
  109306. /**
  109307. * Gets the minimum vector (in world space) of the block's bounding box
  109308. */
  109309. readonly minPoint: Vector3;
  109310. /**
  109311. * Gets the maximum vector (in world space) of the block's bounding box
  109312. */
  109313. readonly maxPoint: Vector3;
  109314. /**
  109315. * Add a new element to this block
  109316. * @param entry defines the element to add
  109317. */
  109318. addEntry(entry: T): void;
  109319. /**
  109320. * Remove an element from this block
  109321. * @param entry defines the element to remove
  109322. */
  109323. removeEntry(entry: T): void;
  109324. /**
  109325. * Add an array of elements to this block
  109326. * @param entries defines the array of elements to add
  109327. */
  109328. addEntries(entries: T[]): void;
  109329. /**
  109330. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  109331. * @param frustumPlanes defines the frustum planes to test
  109332. * @param selection defines the array to store current content if selection is positive
  109333. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109334. */
  109335. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109336. /**
  109337. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  109338. * @param sphereCenter defines the bounding sphere center
  109339. * @param sphereRadius defines the bounding sphere radius
  109340. * @param selection defines the array to store current content if selection is positive
  109341. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109342. */
  109343. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  109344. /**
  109345. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  109346. * @param ray defines the ray to test with
  109347. * @param selection defines the array to store current content if selection is positive
  109348. */
  109349. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  109350. /**
  109351. * Subdivide the content into child blocks (this block will then be empty)
  109352. */
  109353. createInnerBlocks(): void;
  109354. /**
  109355. * @hidden
  109356. */
  109357. 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;
  109358. }
  109359. }
  109360. declare module BABYLON {
  109361. /**
  109362. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  109363. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109364. */
  109365. export class Octree<T> {
  109366. /** 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.) */
  109367. maxDepth: number;
  109368. /**
  109369. * Blocks within the octree containing objects
  109370. */
  109371. blocks: Array<OctreeBlock<T>>;
  109372. /**
  109373. * Content stored in the octree
  109374. */
  109375. dynamicContent: T[];
  109376. private _maxBlockCapacity;
  109377. private _selectionContent;
  109378. private _creationFunc;
  109379. /**
  109380. * Creates a octree
  109381. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109382. * @param creationFunc function to be used to instatiate the octree
  109383. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  109384. * @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.)
  109385. */
  109386. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  109387. /** 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.) */
  109388. maxDepth?: number);
  109389. /**
  109390. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  109391. * @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);
  109392. * @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);
  109393. * @param entries meshes to be added to the octree blocks
  109394. */
  109395. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  109396. /**
  109397. * Adds a mesh to the octree
  109398. * @param entry Mesh to add to the octree
  109399. */
  109400. addMesh(entry: T): void;
  109401. /**
  109402. * Remove an element from the octree
  109403. * @param entry defines the element to remove
  109404. */
  109405. removeMesh(entry: T): void;
  109406. /**
  109407. * Selects an array of meshes within the frustum
  109408. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  109409. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  109410. * @returns array of meshes within the frustum
  109411. */
  109412. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  109413. /**
  109414. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  109415. * @param sphereCenter defines the bounding sphere center
  109416. * @param sphereRadius defines the bounding sphere radius
  109417. * @param allowDuplicate defines if the selection array can contains duplicated entries
  109418. * @returns an array of objects that intersect the sphere
  109419. */
  109420. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  109421. /**
  109422. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  109423. * @param ray defines the ray to test with
  109424. * @returns array of intersected objects
  109425. */
  109426. intersectsRay(ray: Ray): SmartArray<T>;
  109427. /**
  109428. * Adds a mesh into the octree block if it intersects the block
  109429. */
  109430. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  109431. /**
  109432. * Adds a submesh into the octree block if it intersects the block
  109433. */
  109434. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  109435. }
  109436. }
  109437. declare module BABYLON {
  109438. interface Scene {
  109439. /**
  109440. * @hidden
  109441. * Backing Filed
  109442. */
  109443. _selectionOctree: Octree<AbstractMesh>;
  109444. /**
  109445. * Gets the octree used to boost mesh selection (picking)
  109446. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109447. */
  109448. selectionOctree: Octree<AbstractMesh>;
  109449. /**
  109450. * Creates or updates the octree used to boost selection (picking)
  109451. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109452. * @param maxCapacity defines the maximum capacity per leaf
  109453. * @param maxDepth defines the maximum depth of the octree
  109454. * @returns an octree of AbstractMesh
  109455. */
  109456. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  109457. }
  109458. interface AbstractMesh {
  109459. /**
  109460. * @hidden
  109461. * Backing Field
  109462. */
  109463. _submeshesOctree: Octree<SubMesh>;
  109464. /**
  109465. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  109466. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  109467. * @param maxCapacity defines the maximum size of each block (64 by default)
  109468. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  109469. * @returns the new octree
  109470. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  109471. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  109472. */
  109473. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  109474. }
  109475. /**
  109476. * Defines the octree scene component responsible to manage any octrees
  109477. * in a given scene.
  109478. */
  109479. export class OctreeSceneComponent {
  109480. /**
  109481. * The component name help to identify the component in the list of scene components.
  109482. */
  109483. readonly name: string;
  109484. /**
  109485. * The scene the component belongs to.
  109486. */
  109487. scene: Scene;
  109488. /**
  109489. * Indicates if the meshes have been checked to make sure they are isEnabled()
  109490. */
  109491. readonly checksIsEnabled: boolean;
  109492. /**
  109493. * Creates a new instance of the component for the given scene
  109494. * @param scene Defines the scene to register the component in
  109495. */
  109496. constructor(scene: Scene);
  109497. /**
  109498. * Registers the component in a given scene
  109499. */
  109500. register(): void;
  109501. /**
  109502. * Return the list of active meshes
  109503. * @returns the list of active meshes
  109504. */
  109505. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  109506. /**
  109507. * Return the list of active sub meshes
  109508. * @param mesh The mesh to get the candidates sub meshes from
  109509. * @returns the list of active sub meshes
  109510. */
  109511. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  109512. private _tempRay;
  109513. /**
  109514. * Return the list of sub meshes intersecting with a given local ray
  109515. * @param mesh defines the mesh to find the submesh for
  109516. * @param localRay defines the ray in local space
  109517. * @returns the list of intersecting sub meshes
  109518. */
  109519. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  109520. /**
  109521. * Return the list of sub meshes colliding with a collider
  109522. * @param mesh defines the mesh to find the submesh for
  109523. * @param collider defines the collider to evaluate the collision against
  109524. * @returns the list of colliding sub meshes
  109525. */
  109526. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  109527. /**
  109528. * Rebuilds the elements related to this component in case of
  109529. * context lost for instance.
  109530. */
  109531. rebuild(): void;
  109532. /**
  109533. * Disposes the component and the associated ressources.
  109534. */
  109535. dispose(): void;
  109536. }
  109537. }
  109538. declare module BABYLON {
  109539. /**
  109540. * Renders a layer on top of an existing scene
  109541. */
  109542. export class UtilityLayerRenderer implements IDisposable {
  109543. /** the original scene that will be rendered on top of */
  109544. originalScene: Scene;
  109545. private _pointerCaptures;
  109546. private _lastPointerEvents;
  109547. private static _DefaultUtilityLayer;
  109548. private static _DefaultKeepDepthUtilityLayer;
  109549. private _sharedGizmoLight;
  109550. private _renderCamera;
  109551. /**
  109552. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  109553. * @returns the camera that is used when rendering the utility layer
  109554. */
  109555. getRenderCamera(): Nullable<Camera>;
  109556. /**
  109557. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  109558. * @param cam the camera that should be used when rendering the utility layer
  109559. */
  109560. setRenderCamera(cam: Nullable<Camera>): void;
  109561. /**
  109562. * @hidden
  109563. * Light which used by gizmos to get light shading
  109564. */
  109565. _getSharedGizmoLight(): HemisphericLight;
  109566. /**
  109567. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  109568. */
  109569. pickUtilitySceneFirst: boolean;
  109570. /**
  109571. * 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)
  109572. */
  109573. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  109574. /**
  109575. * 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)
  109576. */
  109577. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  109578. /**
  109579. * The scene that is rendered on top of the original scene
  109580. */
  109581. utilityLayerScene: Scene;
  109582. /**
  109583. * If the utility layer should automatically be rendered on top of existing scene
  109584. */
  109585. shouldRender: boolean;
  109586. /**
  109587. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  109588. */
  109589. onlyCheckPointerDownEvents: boolean;
  109590. /**
  109591. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  109592. */
  109593. processAllEvents: boolean;
  109594. /**
  109595. * Observable raised when the pointer move from the utility layer scene to the main scene
  109596. */
  109597. onPointerOutObservable: Observable<number>;
  109598. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  109599. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  109600. private _afterRenderObserver;
  109601. private _sceneDisposeObserver;
  109602. private _originalPointerObserver;
  109603. /**
  109604. * Instantiates a UtilityLayerRenderer
  109605. * @param originalScene the original scene that will be rendered on top of
  109606. * @param handleEvents boolean indicating if the utility layer should handle events
  109607. */
  109608. constructor(
  109609. /** the original scene that will be rendered on top of */
  109610. originalScene: Scene, handleEvents?: boolean);
  109611. private _notifyObservers;
  109612. /**
  109613. * Renders the utility layers scene on top of the original scene
  109614. */
  109615. render(): void;
  109616. /**
  109617. * Disposes of the renderer
  109618. */
  109619. dispose(): void;
  109620. private _updateCamera;
  109621. }
  109622. }
  109623. declare module BABYLON {
  109624. /**
  109625. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  109626. */
  109627. export class Gizmo implements IDisposable {
  109628. /** The utility layer the gizmo will be added to */
  109629. gizmoLayer: UtilityLayerRenderer;
  109630. /**
  109631. * The root mesh of the gizmo
  109632. */
  109633. _rootMesh: Mesh;
  109634. private _attachedMesh;
  109635. /**
  109636. * Ratio for the scale of the gizmo (Default: 1)
  109637. */
  109638. scaleRatio: number;
  109639. /**
  109640. * If a custom mesh has been set (Default: false)
  109641. */
  109642. protected _customMeshSet: boolean;
  109643. /**
  109644. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  109645. * * When set, interactions will be enabled
  109646. */
  109647. attachedMesh: Nullable<AbstractMesh>;
  109648. /**
  109649. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  109650. * @param mesh The mesh to replace the default mesh of the gizmo
  109651. */
  109652. setCustomMesh(mesh: Mesh): void;
  109653. /**
  109654. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  109655. */
  109656. updateGizmoRotationToMatchAttachedMesh: boolean;
  109657. /**
  109658. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  109659. */
  109660. updateGizmoPositionToMatchAttachedMesh: boolean;
  109661. /**
  109662. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  109663. */
  109664. updateScale: boolean;
  109665. protected _interactionsEnabled: boolean;
  109666. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109667. private _beforeRenderObserver;
  109668. private _tempVector;
  109669. /**
  109670. * Creates a gizmo
  109671. * @param gizmoLayer The utility layer the gizmo will be added to
  109672. */
  109673. constructor(
  109674. /** The utility layer the gizmo will be added to */
  109675. gizmoLayer?: UtilityLayerRenderer);
  109676. /**
  109677. * Updates the gizmo to match the attached mesh's position/rotation
  109678. */
  109679. protected _update(): void;
  109680. /**
  109681. * Disposes of the gizmo
  109682. */
  109683. dispose(): void;
  109684. }
  109685. }
  109686. declare module BABYLON {
  109687. /**
  109688. * Single plane drag gizmo
  109689. */
  109690. export class PlaneDragGizmo extends Gizmo {
  109691. /**
  109692. * Drag behavior responsible for the gizmos dragging interactions
  109693. */
  109694. dragBehavior: PointerDragBehavior;
  109695. private _pointerObserver;
  109696. /**
  109697. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109698. */
  109699. snapDistance: number;
  109700. /**
  109701. * Event that fires each time the gizmo snaps to a new location.
  109702. * * snapDistance is the the change in distance
  109703. */
  109704. onSnapObservable: Observable<{
  109705. snapDistance: number;
  109706. }>;
  109707. private _plane;
  109708. private _coloredMaterial;
  109709. private _hoverMaterial;
  109710. private _isEnabled;
  109711. private _parent;
  109712. /** @hidden */
  109713. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  109714. /** @hidden */
  109715. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109716. /**
  109717. * Creates a PlaneDragGizmo
  109718. * @param gizmoLayer The utility layer the gizmo will be added to
  109719. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  109720. * @param color The color of the gizmo
  109721. */
  109722. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109723. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109724. /**
  109725. * If the gizmo is enabled
  109726. */
  109727. isEnabled: boolean;
  109728. /**
  109729. * Disposes of the gizmo
  109730. */
  109731. dispose(): void;
  109732. }
  109733. }
  109734. declare module BABYLON {
  109735. /**
  109736. * Gizmo that enables dragging a mesh along 3 axis
  109737. */
  109738. export class PositionGizmo extends Gizmo {
  109739. /**
  109740. * Internal gizmo used for interactions on the x axis
  109741. */
  109742. xGizmo: AxisDragGizmo;
  109743. /**
  109744. * Internal gizmo used for interactions on the y axis
  109745. */
  109746. yGizmo: AxisDragGizmo;
  109747. /**
  109748. * Internal gizmo used for interactions on the z axis
  109749. */
  109750. zGizmo: AxisDragGizmo;
  109751. /**
  109752. * Internal gizmo used for interactions on the yz plane
  109753. */
  109754. xPlaneGizmo: PlaneDragGizmo;
  109755. /**
  109756. * Internal gizmo used for interactions on the xz plane
  109757. */
  109758. yPlaneGizmo: PlaneDragGizmo;
  109759. /**
  109760. * Internal gizmo used for interactions on the xy plane
  109761. */
  109762. zPlaneGizmo: PlaneDragGizmo;
  109763. /**
  109764. * private variables
  109765. */
  109766. private _meshAttached;
  109767. private _updateGizmoRotationToMatchAttachedMesh;
  109768. private _snapDistance;
  109769. private _scaleRatio;
  109770. /** Fires an event when any of it's sub gizmos are dragged */
  109771. onDragStartObservable: Observable<unknown>;
  109772. /** Fires an event when any of it's sub gizmos are released from dragging */
  109773. onDragEndObservable: Observable<unknown>;
  109774. /**
  109775. * If set to true, planar drag is enabled
  109776. */
  109777. private _planarGizmoEnabled;
  109778. attachedMesh: Nullable<AbstractMesh>;
  109779. /**
  109780. * Creates a PositionGizmo
  109781. * @param gizmoLayer The utility layer the gizmo will be added to
  109782. */
  109783. constructor(gizmoLayer?: UtilityLayerRenderer);
  109784. /**
  109785. * If the planar drag gizmo is enabled
  109786. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  109787. */
  109788. planarGizmoEnabled: boolean;
  109789. updateGizmoRotationToMatchAttachedMesh: boolean;
  109790. /**
  109791. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109792. */
  109793. snapDistance: number;
  109794. /**
  109795. * Ratio for the scale of the gizmo (Default: 1)
  109796. */
  109797. scaleRatio: number;
  109798. /**
  109799. * Disposes of the gizmo
  109800. */
  109801. dispose(): void;
  109802. /**
  109803. * CustomMeshes are not supported by this gizmo
  109804. * @param mesh The mesh to replace the default mesh of the gizmo
  109805. */
  109806. setCustomMesh(mesh: Mesh): void;
  109807. }
  109808. }
  109809. declare module BABYLON {
  109810. /**
  109811. * Single axis drag gizmo
  109812. */
  109813. export class AxisDragGizmo extends Gizmo {
  109814. /**
  109815. * Drag behavior responsible for the gizmos dragging interactions
  109816. */
  109817. dragBehavior: PointerDragBehavior;
  109818. private _pointerObserver;
  109819. /**
  109820. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  109821. */
  109822. snapDistance: number;
  109823. /**
  109824. * Event that fires each time the gizmo snaps to a new location.
  109825. * * snapDistance is the the change in distance
  109826. */
  109827. onSnapObservable: Observable<{
  109828. snapDistance: number;
  109829. }>;
  109830. private _isEnabled;
  109831. private _parent;
  109832. private _arrow;
  109833. private _coloredMaterial;
  109834. private _hoverMaterial;
  109835. /** @hidden */
  109836. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  109837. /** @hidden */
  109838. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  109839. /**
  109840. * Creates an AxisDragGizmo
  109841. * @param gizmoLayer The utility layer the gizmo will be added to
  109842. * @param dragAxis The axis which the gizmo will be able to drag on
  109843. * @param color The color of the gizmo
  109844. */
  109845. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  109846. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  109847. /**
  109848. * If the gizmo is enabled
  109849. */
  109850. isEnabled: boolean;
  109851. /**
  109852. * Disposes of the gizmo
  109853. */
  109854. dispose(): void;
  109855. }
  109856. }
  109857. declare module BABYLON.Debug {
  109858. /**
  109859. * The Axes viewer will show 3 axes in a specific point in space
  109860. */
  109861. export class AxesViewer {
  109862. private _xAxis;
  109863. private _yAxis;
  109864. private _zAxis;
  109865. private _scaleLinesFactor;
  109866. private _instanced;
  109867. /**
  109868. * Gets the hosting scene
  109869. */
  109870. scene: Scene;
  109871. /**
  109872. * Gets or sets a number used to scale line length
  109873. */
  109874. scaleLines: number;
  109875. /** Gets the node hierarchy used to render x-axis */
  109876. readonly xAxis: TransformNode;
  109877. /** Gets the node hierarchy used to render y-axis */
  109878. readonly yAxis: TransformNode;
  109879. /** Gets the node hierarchy used to render z-axis */
  109880. readonly zAxis: TransformNode;
  109881. /**
  109882. * Creates a new AxesViewer
  109883. * @param scene defines the hosting scene
  109884. * @param scaleLines defines a number used to scale line length (1 by default)
  109885. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  109886. * @param xAxis defines the node hierarchy used to render the x-axis
  109887. * @param yAxis defines the node hierarchy used to render the y-axis
  109888. * @param zAxis defines the node hierarchy used to render the z-axis
  109889. */
  109890. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  109891. /**
  109892. * Force the viewer to update
  109893. * @param position defines the position of the viewer
  109894. * @param xaxis defines the x axis of the viewer
  109895. * @param yaxis defines the y axis of the viewer
  109896. * @param zaxis defines the z axis of the viewer
  109897. */
  109898. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  109899. /**
  109900. * Creates an instance of this axes viewer.
  109901. * @returns a new axes viewer with instanced meshes
  109902. */
  109903. createInstance(): AxesViewer;
  109904. /** Releases resources */
  109905. dispose(): void;
  109906. private static _SetRenderingGroupId;
  109907. }
  109908. }
  109909. declare module BABYLON.Debug {
  109910. /**
  109911. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  109912. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  109913. */
  109914. export class BoneAxesViewer extends AxesViewer {
  109915. /**
  109916. * Gets or sets the target mesh where to display the axes viewer
  109917. */
  109918. mesh: Nullable<Mesh>;
  109919. /**
  109920. * Gets or sets the target bone where to display the axes viewer
  109921. */
  109922. bone: Nullable<Bone>;
  109923. /** Gets current position */
  109924. pos: Vector3;
  109925. /** Gets direction of X axis */
  109926. xaxis: Vector3;
  109927. /** Gets direction of Y axis */
  109928. yaxis: Vector3;
  109929. /** Gets direction of Z axis */
  109930. zaxis: Vector3;
  109931. /**
  109932. * Creates a new BoneAxesViewer
  109933. * @param scene defines the hosting scene
  109934. * @param bone defines the target bone
  109935. * @param mesh defines the target mesh
  109936. * @param scaleLines defines a scaling factor for line length (1 by default)
  109937. */
  109938. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  109939. /**
  109940. * Force the viewer to update
  109941. */
  109942. update(): void;
  109943. /** Releases resources */
  109944. dispose(): void;
  109945. }
  109946. }
  109947. declare module BABYLON {
  109948. /**
  109949. * Interface used to define scene explorer extensibility option
  109950. */
  109951. export interface IExplorerExtensibilityOption {
  109952. /**
  109953. * Define the option label
  109954. */
  109955. label: string;
  109956. /**
  109957. * Defines the action to execute on click
  109958. */
  109959. action: (entity: any) => void;
  109960. }
  109961. /**
  109962. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  109963. */
  109964. export interface IExplorerExtensibilityGroup {
  109965. /**
  109966. * Defines a predicate to test if a given type mut be extended
  109967. */
  109968. predicate: (entity: any) => boolean;
  109969. /**
  109970. * Gets the list of options added to a type
  109971. */
  109972. entries: IExplorerExtensibilityOption[];
  109973. }
  109974. /**
  109975. * Interface used to define the options to use to create the Inspector
  109976. */
  109977. export interface IInspectorOptions {
  109978. /**
  109979. * Display in overlay mode (default: false)
  109980. */
  109981. overlay?: boolean;
  109982. /**
  109983. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  109984. */
  109985. globalRoot?: HTMLElement;
  109986. /**
  109987. * Display the Scene explorer
  109988. */
  109989. showExplorer?: boolean;
  109990. /**
  109991. * Display the property inspector
  109992. */
  109993. showInspector?: boolean;
  109994. /**
  109995. * Display in embed mode (both panes on the right)
  109996. */
  109997. embedMode?: boolean;
  109998. /**
  109999. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  110000. */
  110001. handleResize?: boolean;
  110002. /**
  110003. * Allow the panes to popup (default: true)
  110004. */
  110005. enablePopup?: boolean;
  110006. /**
  110007. * Allow the panes to be closed by users (default: true)
  110008. */
  110009. enableClose?: boolean;
  110010. /**
  110011. * Optional list of extensibility entries
  110012. */
  110013. explorerExtensibility?: IExplorerExtensibilityGroup[];
  110014. /**
  110015. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  110016. */
  110017. inspectorURL?: string;
  110018. }
  110019. interface Scene {
  110020. /**
  110021. * @hidden
  110022. * Backing field
  110023. */
  110024. _debugLayer: DebugLayer;
  110025. /**
  110026. * Gets the debug layer (aka Inspector) associated with the scene
  110027. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110028. */
  110029. debugLayer: DebugLayer;
  110030. }
  110031. /**
  110032. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110033. * what is happening in your scene
  110034. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110035. */
  110036. export class DebugLayer {
  110037. /**
  110038. * Define the url to get the inspector script from.
  110039. * By default it uses the babylonjs CDN.
  110040. * @ignoreNaming
  110041. */
  110042. static InspectorURL: string;
  110043. private _scene;
  110044. private BJSINSPECTOR;
  110045. private _onPropertyChangedObservable?;
  110046. /**
  110047. * Observable triggered when a property is changed through the inspector.
  110048. */
  110049. readonly onPropertyChangedObservable: any;
  110050. /**
  110051. * Instantiates a new debug layer.
  110052. * The debug layer (aka Inspector) is the go to tool in order to better understand
  110053. * what is happening in your scene
  110054. * @see http://doc.babylonjs.com/features/playground_debuglayer
  110055. * @param scene Defines the scene to inspect
  110056. */
  110057. constructor(scene: Scene);
  110058. /** Creates the inspector window. */
  110059. private _createInspector;
  110060. /**
  110061. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  110062. * @param entity defines the entity to select
  110063. * @param lineContainerTitle defines the specific block to highlight
  110064. */
  110065. select(entity: any, lineContainerTitle?: string): void;
  110066. /** Get the inspector from bundle or global */
  110067. private _getGlobalInspector;
  110068. /**
  110069. * Get if the inspector is visible or not.
  110070. * @returns true if visible otherwise, false
  110071. */
  110072. isVisible(): boolean;
  110073. /**
  110074. * Hide the inspector and close its window.
  110075. */
  110076. hide(): void;
  110077. /**
  110078. * Launch the debugLayer.
  110079. * @param config Define the configuration of the inspector
  110080. * @return a promise fulfilled when the debug layer is visible
  110081. */
  110082. show(config?: IInspectorOptions): Promise<DebugLayer>;
  110083. }
  110084. }
  110085. declare module BABYLON {
  110086. /**
  110087. * Class containing static functions to help procedurally build meshes
  110088. */
  110089. export class BoxBuilder {
  110090. /**
  110091. * Creates a box mesh
  110092. * * The parameter `size` sets the size (float) of each box side (default 1)
  110093. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  110094. * * 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)
  110095. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110096. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110097. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110098. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110099. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  110100. * @param name defines the name of the mesh
  110101. * @param options defines the options used to create the mesh
  110102. * @param scene defines the hosting scene
  110103. * @returns the box mesh
  110104. */
  110105. static CreateBox(name: string, options: {
  110106. size?: number;
  110107. width?: number;
  110108. height?: number;
  110109. depth?: number;
  110110. faceUV?: Vector4[];
  110111. faceColors?: Color4[];
  110112. sideOrientation?: number;
  110113. frontUVs?: Vector4;
  110114. backUVs?: Vector4;
  110115. wrap?: boolean;
  110116. topBaseAt?: number;
  110117. bottomBaseAt?: number;
  110118. updatable?: boolean;
  110119. }, scene?: Nullable<Scene>): Mesh;
  110120. }
  110121. }
  110122. declare module BABYLON {
  110123. /**
  110124. * Class containing static functions to help procedurally build meshes
  110125. */
  110126. export class SphereBuilder {
  110127. /**
  110128. * Creates a sphere mesh
  110129. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  110130. * * 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`)
  110131. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  110132. * * 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
  110133. * * 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)
  110134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110137. * @param name defines the name of the mesh
  110138. * @param options defines the options used to create the mesh
  110139. * @param scene defines the hosting scene
  110140. * @returns the sphere mesh
  110141. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  110142. */
  110143. static CreateSphere(name: string, options: {
  110144. segments?: number;
  110145. diameter?: number;
  110146. diameterX?: number;
  110147. diameterY?: number;
  110148. diameterZ?: number;
  110149. arc?: number;
  110150. slice?: number;
  110151. sideOrientation?: number;
  110152. frontUVs?: Vector4;
  110153. backUVs?: Vector4;
  110154. updatable?: boolean;
  110155. }, scene?: Nullable<Scene>): Mesh;
  110156. }
  110157. }
  110158. declare module BABYLON.Debug {
  110159. /**
  110160. * Used to show the physics impostor around the specific mesh
  110161. */
  110162. export class PhysicsViewer {
  110163. /** @hidden */
  110164. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  110165. /** @hidden */
  110166. protected _meshes: Array<Nullable<AbstractMesh>>;
  110167. /** @hidden */
  110168. protected _scene: Nullable<Scene>;
  110169. /** @hidden */
  110170. protected _numMeshes: number;
  110171. /** @hidden */
  110172. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  110173. private _renderFunction;
  110174. private _utilityLayer;
  110175. private _debugBoxMesh;
  110176. private _debugSphereMesh;
  110177. private _debugCylinderMesh;
  110178. private _debugMaterial;
  110179. private _debugMeshMeshes;
  110180. /**
  110181. * Creates a new PhysicsViewer
  110182. * @param scene defines the hosting scene
  110183. */
  110184. constructor(scene: Scene);
  110185. /** @hidden */
  110186. protected _updateDebugMeshes(): void;
  110187. /**
  110188. * Renders a specified physic impostor
  110189. * @param impostor defines the impostor to render
  110190. * @param targetMesh defines the mesh represented by the impostor
  110191. * @returns the new debug mesh used to render the impostor
  110192. */
  110193. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  110194. /**
  110195. * Hides a specified physic impostor
  110196. * @param impostor defines the impostor to hide
  110197. */
  110198. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  110199. private _getDebugMaterial;
  110200. private _getDebugBoxMesh;
  110201. private _getDebugSphereMesh;
  110202. private _getDebugCylinderMesh;
  110203. private _getDebugMeshMesh;
  110204. private _getDebugMesh;
  110205. /** Releases all resources */
  110206. dispose(): void;
  110207. }
  110208. }
  110209. declare module BABYLON {
  110210. /**
  110211. * Class containing static functions to help procedurally build meshes
  110212. */
  110213. export class LinesBuilder {
  110214. /**
  110215. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  110216. * * 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
  110217. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  110218. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  110219. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  110220. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  110221. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  110222. * * 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
  110223. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  110224. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110225. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  110226. * @param name defines the name of the new line system
  110227. * @param options defines the options used to create the line system
  110228. * @param scene defines the hosting scene
  110229. * @returns a new line system mesh
  110230. */
  110231. static CreateLineSystem(name: string, options: {
  110232. lines: Vector3[][];
  110233. updatable?: boolean;
  110234. instance?: Nullable<LinesMesh>;
  110235. colors?: Nullable<Color4[][]>;
  110236. useVertexAlpha?: boolean;
  110237. }, scene: Nullable<Scene>): LinesMesh;
  110238. /**
  110239. * Creates a line mesh
  110240. * 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
  110241. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110242. * * The parameter `points` is an array successive Vector3
  110243. * * 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
  110244. * * The optional parameter `colors` is an array of successive Color4, one per line point
  110245. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  110246. * * When updating an instance, remember that only point positions can change, not the number of points
  110247. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110248. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  110249. * @param name defines the name of the new line system
  110250. * @param options defines the options used to create the line system
  110251. * @param scene defines the hosting scene
  110252. * @returns a new line mesh
  110253. */
  110254. static CreateLines(name: string, options: {
  110255. points: Vector3[];
  110256. updatable?: boolean;
  110257. instance?: Nullable<LinesMesh>;
  110258. colors?: Color4[];
  110259. useVertexAlpha?: boolean;
  110260. }, scene?: Nullable<Scene>): LinesMesh;
  110261. /**
  110262. * Creates a dashed line mesh
  110263. * * 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
  110264. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  110265. * * The parameter `points` is an array successive Vector3
  110266. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  110267. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  110268. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  110269. * * 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
  110270. * * When updating an instance, remember that only point positions can change, not the number of points
  110271. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110272. * @param name defines the name of the mesh
  110273. * @param options defines the options used to create the mesh
  110274. * @param scene defines the hosting scene
  110275. * @returns the dashed line mesh
  110276. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  110277. */
  110278. static CreateDashedLines(name: string, options: {
  110279. points: Vector3[];
  110280. dashSize?: number;
  110281. gapSize?: number;
  110282. dashNb?: number;
  110283. updatable?: boolean;
  110284. instance?: LinesMesh;
  110285. }, scene?: Nullable<Scene>): LinesMesh;
  110286. }
  110287. }
  110288. declare module BABYLON {
  110289. /**
  110290. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110291. * in order to better appreciate the issue one might have.
  110292. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110293. */
  110294. export class RayHelper {
  110295. /**
  110296. * Defines the ray we are currently tryin to visualize.
  110297. */
  110298. ray: Nullable<Ray>;
  110299. private _renderPoints;
  110300. private _renderLine;
  110301. private _renderFunction;
  110302. private _scene;
  110303. private _updateToMeshFunction;
  110304. private _attachedToMesh;
  110305. private _meshSpaceDirection;
  110306. private _meshSpaceOrigin;
  110307. /**
  110308. * Helper function to create a colored helper in a scene in one line.
  110309. * @param ray Defines the ray we are currently tryin to visualize
  110310. * @param scene Defines the scene the ray is used in
  110311. * @param color Defines the color we want to see the ray in
  110312. * @returns The newly created ray helper.
  110313. */
  110314. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  110315. /**
  110316. * Instantiate a new ray helper.
  110317. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  110318. * in order to better appreciate the issue one might have.
  110319. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  110320. * @param ray Defines the ray we are currently tryin to visualize
  110321. */
  110322. constructor(ray: Ray);
  110323. /**
  110324. * Shows the ray we are willing to debug.
  110325. * @param scene Defines the scene the ray needs to be rendered in
  110326. * @param color Defines the color the ray needs to be rendered in
  110327. */
  110328. show(scene: Scene, color?: Color3): void;
  110329. /**
  110330. * Hides the ray we are debugging.
  110331. */
  110332. hide(): void;
  110333. private _render;
  110334. /**
  110335. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  110336. * @param mesh Defines the mesh we want the helper attached to
  110337. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  110338. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  110339. * @param length Defines the length of the ray
  110340. */
  110341. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  110342. /**
  110343. * Detach the ray helper from the mesh it has previously been attached to.
  110344. */
  110345. detachFromMesh(): void;
  110346. private _updateToMesh;
  110347. /**
  110348. * Dispose the helper and release its associated resources.
  110349. */
  110350. dispose(): void;
  110351. }
  110352. }
  110353. declare module BABYLON.Debug {
  110354. /**
  110355. * Class used to render a debug view of a given skeleton
  110356. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  110357. */
  110358. export class SkeletonViewer {
  110359. /** defines the skeleton to render */
  110360. skeleton: Skeleton;
  110361. /** defines the mesh attached to the skeleton */
  110362. mesh: AbstractMesh;
  110363. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110364. autoUpdateBonesMatrices: boolean;
  110365. /** defines the rendering group id to use with the viewer */
  110366. renderingGroupId: number;
  110367. /** Gets or sets the color used to render the skeleton */
  110368. color: Color3;
  110369. private _scene;
  110370. private _debugLines;
  110371. private _debugMesh;
  110372. private _isEnabled;
  110373. private _renderFunction;
  110374. private _utilityLayer;
  110375. /**
  110376. * Returns the mesh used to render the bones
  110377. */
  110378. readonly debugMesh: Nullable<LinesMesh>;
  110379. /**
  110380. * Creates a new SkeletonViewer
  110381. * @param skeleton defines the skeleton to render
  110382. * @param mesh defines the mesh attached to the skeleton
  110383. * @param scene defines the hosting scene
  110384. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  110385. * @param renderingGroupId defines the rendering group id to use with the viewer
  110386. */
  110387. constructor(
  110388. /** defines the skeleton to render */
  110389. skeleton: Skeleton,
  110390. /** defines the mesh attached to the skeleton */
  110391. mesh: AbstractMesh, scene: Scene,
  110392. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  110393. autoUpdateBonesMatrices?: boolean,
  110394. /** defines the rendering group id to use with the viewer */
  110395. renderingGroupId?: number);
  110396. /** Gets or sets a boolean indicating if the viewer is enabled */
  110397. isEnabled: boolean;
  110398. private _getBonePosition;
  110399. private _getLinesForBonesWithLength;
  110400. private _getLinesForBonesNoLength;
  110401. /** Update the viewer to sync with current skeleton state */
  110402. update(): void;
  110403. /** Release associated resources */
  110404. dispose(): void;
  110405. }
  110406. }
  110407. declare module BABYLON {
  110408. /**
  110409. * Options to create the null engine
  110410. */
  110411. export class NullEngineOptions {
  110412. /**
  110413. * Render width (Default: 512)
  110414. */
  110415. renderWidth: number;
  110416. /**
  110417. * Render height (Default: 256)
  110418. */
  110419. renderHeight: number;
  110420. /**
  110421. * Texture size (Default: 512)
  110422. */
  110423. textureSize: number;
  110424. /**
  110425. * If delta time between frames should be constant
  110426. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110427. */
  110428. deterministicLockstep: boolean;
  110429. /**
  110430. * Maximum about of steps between frames (Default: 4)
  110431. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110432. */
  110433. lockstepMaxSteps: number;
  110434. }
  110435. /**
  110436. * The null engine class provides support for headless version of babylon.js.
  110437. * This can be used in server side scenario or for testing purposes
  110438. */
  110439. export class NullEngine extends Engine {
  110440. private _options;
  110441. /**
  110442. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  110443. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110444. * @returns true if engine is in deterministic lock step mode
  110445. */
  110446. isDeterministicLockStep(): boolean;
  110447. /**
  110448. * Gets the max steps when engine is running in deterministic lock step
  110449. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110450. * @returns the max steps
  110451. */
  110452. getLockstepMaxSteps(): number;
  110453. /**
  110454. * Gets the current hardware scaling level.
  110455. * By default the hardware scaling level is computed from the window device ratio.
  110456. * 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.
  110457. * @returns a number indicating the current hardware scaling level
  110458. */
  110459. getHardwareScalingLevel(): number;
  110460. constructor(options?: NullEngineOptions);
  110461. /**
  110462. * Creates a vertex buffer
  110463. * @param vertices the data for the vertex buffer
  110464. * @returns the new WebGL static buffer
  110465. */
  110466. createVertexBuffer(vertices: FloatArray): DataBuffer;
  110467. /**
  110468. * Creates a new index buffer
  110469. * @param indices defines the content of the index buffer
  110470. * @param updatable defines if the index buffer must be updatable
  110471. * @returns a new webGL buffer
  110472. */
  110473. createIndexBuffer(indices: IndicesArray): DataBuffer;
  110474. /**
  110475. * Clear the current render buffer or the current render target (if any is set up)
  110476. * @param color defines the color to use
  110477. * @param backBuffer defines if the back buffer must be cleared
  110478. * @param depth defines if the depth buffer must be cleared
  110479. * @param stencil defines if the stencil buffer must be cleared
  110480. */
  110481. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  110482. /**
  110483. * Gets the current render width
  110484. * @param useScreen defines if screen size must be used (or the current render target if any)
  110485. * @returns a number defining the current render width
  110486. */
  110487. getRenderWidth(useScreen?: boolean): number;
  110488. /**
  110489. * Gets the current render height
  110490. * @param useScreen defines if screen size must be used (or the current render target if any)
  110491. * @returns a number defining the current render height
  110492. */
  110493. getRenderHeight(useScreen?: boolean): number;
  110494. /**
  110495. * Set the WebGL's viewport
  110496. * @param viewport defines the viewport element to be used
  110497. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  110498. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  110499. */
  110500. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  110501. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  110502. /**
  110503. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  110504. * @param pipelineContext defines the pipeline context to use
  110505. * @param uniformsNames defines the list of uniform names
  110506. * @returns an array of webGL uniform locations
  110507. */
  110508. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  110509. /**
  110510. * Gets the lsit of active attributes for a given webGL program
  110511. * @param pipelineContext defines the pipeline context to use
  110512. * @param attributesNames defines the list of attribute names to get
  110513. * @returns an array of indices indicating the offset of each attribute
  110514. */
  110515. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  110516. /**
  110517. * Binds an effect to the webGL context
  110518. * @param effect defines the effect to bind
  110519. */
  110520. bindSamplers(effect: Effect): void;
  110521. /**
  110522. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  110523. * @param effect defines the effect to activate
  110524. */
  110525. enableEffect(effect: Effect): void;
  110526. /**
  110527. * Set various states to the webGL context
  110528. * @param culling defines backface culling state
  110529. * @param zOffset defines the value to apply to zOffset (0 by default)
  110530. * @param force defines if states must be applied even if cache is up to date
  110531. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  110532. */
  110533. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  110534. /**
  110535. * Set the value of an uniform to an array of int32
  110536. * @param uniform defines the webGL uniform location where to store the value
  110537. * @param array defines the array of int32 to store
  110538. */
  110539. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  110540. /**
  110541. * Set the value of an uniform to an array of int32 (stored as vec2)
  110542. * @param uniform defines the webGL uniform location where to store the value
  110543. * @param array defines the array of int32 to store
  110544. */
  110545. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  110546. /**
  110547. * Set the value of an uniform to an array of int32 (stored as vec3)
  110548. * @param uniform defines the webGL uniform location where to store the value
  110549. * @param array defines the array of int32 to store
  110550. */
  110551. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  110552. /**
  110553. * Set the value of an uniform to an array of int32 (stored as vec4)
  110554. * @param uniform defines the webGL uniform location where to store the value
  110555. * @param array defines the array of int32 to store
  110556. */
  110557. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  110558. /**
  110559. * Set the value of an uniform to an array of float32
  110560. * @param uniform defines the webGL uniform location where to store the value
  110561. * @param array defines the array of float32 to store
  110562. */
  110563. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  110564. /**
  110565. * Set the value of an uniform to an array of float32 (stored as vec2)
  110566. * @param uniform defines the webGL uniform location where to store the value
  110567. * @param array defines the array of float32 to store
  110568. */
  110569. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  110570. /**
  110571. * Set the value of an uniform to an array of float32 (stored as vec3)
  110572. * @param uniform defines the webGL uniform location where to store the value
  110573. * @param array defines the array of float32 to store
  110574. */
  110575. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  110576. /**
  110577. * Set the value of an uniform to an array of float32 (stored as vec4)
  110578. * @param uniform defines the webGL uniform location where to store the value
  110579. * @param array defines the array of float32 to store
  110580. */
  110581. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  110582. /**
  110583. * Set the value of an uniform to an array of number
  110584. * @param uniform defines the webGL uniform location where to store the value
  110585. * @param array defines the array of number to store
  110586. */
  110587. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  110588. /**
  110589. * Set the value of an uniform to an array of number (stored as vec2)
  110590. * @param uniform defines the webGL uniform location where to store the value
  110591. * @param array defines the array of number to store
  110592. */
  110593. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  110594. /**
  110595. * Set the value of an uniform to an array of number (stored as vec3)
  110596. * @param uniform defines the webGL uniform location where to store the value
  110597. * @param array defines the array of number to store
  110598. */
  110599. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  110600. /**
  110601. * Set the value of an uniform to an array of number (stored as vec4)
  110602. * @param uniform defines the webGL uniform location where to store the value
  110603. * @param array defines the array of number to store
  110604. */
  110605. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  110606. /**
  110607. * Set the value of an uniform to an array of float32 (stored as matrices)
  110608. * @param uniform defines the webGL uniform location where to store the value
  110609. * @param matrices defines the array of float32 to store
  110610. */
  110611. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  110612. /**
  110613. * Set the value of an uniform to a matrix (3x3)
  110614. * @param uniform defines the webGL uniform location where to store the value
  110615. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  110616. */
  110617. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110618. /**
  110619. * Set the value of an uniform to a matrix (2x2)
  110620. * @param uniform defines the webGL uniform location where to store the value
  110621. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  110622. */
  110623. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  110624. /**
  110625. * Set the value of an uniform to a number (float)
  110626. * @param uniform defines the webGL uniform location where to store the value
  110627. * @param value defines the float number to store
  110628. */
  110629. setFloat(uniform: WebGLUniformLocation, value: number): void;
  110630. /**
  110631. * Set the value of an uniform to a vec2
  110632. * @param uniform defines the webGL uniform location where to store the value
  110633. * @param x defines the 1st component of the value
  110634. * @param y defines the 2nd component of the value
  110635. */
  110636. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  110637. /**
  110638. * Set the value of an uniform to a vec3
  110639. * @param uniform defines the webGL uniform location where to store the value
  110640. * @param x defines the 1st component of the value
  110641. * @param y defines the 2nd component of the value
  110642. * @param z defines the 3rd component of the value
  110643. */
  110644. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  110645. /**
  110646. * Set the value of an uniform to a boolean
  110647. * @param uniform defines the webGL uniform location where to store the value
  110648. * @param bool defines the boolean to store
  110649. */
  110650. setBool(uniform: WebGLUniformLocation, bool: number): void;
  110651. /**
  110652. * Set the value of an uniform to a vec4
  110653. * @param uniform defines the webGL uniform location where to store the value
  110654. * @param x defines the 1st component of the value
  110655. * @param y defines the 2nd component of the value
  110656. * @param z defines the 3rd component of the value
  110657. * @param w defines the 4th component of the value
  110658. */
  110659. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  110660. /**
  110661. * Sets the current alpha mode
  110662. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  110663. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  110664. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  110665. */
  110666. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  110667. /**
  110668. * Bind webGl buffers directly to the webGL context
  110669. * @param vertexBuffers defines the vertex buffer to bind
  110670. * @param indexBuffer defines the index buffer to bind
  110671. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  110672. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  110673. * @param effect defines the effect associated with the vertex buffer
  110674. */
  110675. bindBuffers(vertexBuffers: {
  110676. [key: string]: VertexBuffer;
  110677. }, indexBuffer: DataBuffer, effect: Effect): void;
  110678. /**
  110679. * Force the entire cache to be cleared
  110680. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  110681. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  110682. */
  110683. wipeCaches(bruteForce?: boolean): void;
  110684. /**
  110685. * Send a draw order
  110686. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  110687. * @param indexStart defines the starting index
  110688. * @param indexCount defines the number of index to draw
  110689. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110690. */
  110691. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  110692. /**
  110693. * Draw a list of indexed primitives
  110694. * @param fillMode defines the primitive to use
  110695. * @param indexStart defines the starting index
  110696. * @param indexCount defines the number of index to draw
  110697. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110698. */
  110699. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  110700. /**
  110701. * Draw a list of unindexed primitives
  110702. * @param fillMode defines the primitive to use
  110703. * @param verticesStart defines the index of first vertex to draw
  110704. * @param verticesCount defines the count of vertices to draw
  110705. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  110706. */
  110707. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  110708. /** @hidden */
  110709. _createTexture(): WebGLTexture;
  110710. /** @hidden */
  110711. _releaseTexture(texture: InternalTexture): void;
  110712. /**
  110713. * Usually called from Texture.ts.
  110714. * Passed information to create a WebGLTexture
  110715. * @param urlArg defines a value which contains one of the following:
  110716. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  110717. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  110718. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  110719. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  110720. * @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)
  110721. * @param scene needed for loading to the correct scene
  110722. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  110723. * @param onLoad optional callback to be called upon successful completion
  110724. * @param onError optional callback to be called upon failure
  110725. * @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
  110726. * @param fallBack an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  110727. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  110728. * @param forcedExtension defines the extension to use to pick the right loader
  110729. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  110730. * @returns a InternalTexture for assignment back into BABYLON.Texture
  110731. */
  110732. 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;
  110733. /**
  110734. * Creates a new render target texture
  110735. * @param size defines the size of the texture
  110736. * @param options defines the options used to create the texture
  110737. * @returns a new render target texture stored in an InternalTexture
  110738. */
  110739. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  110740. /**
  110741. * Update the sampling mode of a given texture
  110742. * @param samplingMode defines the required sampling mode
  110743. * @param texture defines the texture to update
  110744. */
  110745. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  110746. /**
  110747. * Binds the frame buffer to the specified texture.
  110748. * @param texture The texture to render to or null for the default canvas
  110749. * @param faceIndex The face of the texture to render to in case of cube texture
  110750. * @param requiredWidth The width of the target to render to
  110751. * @param requiredHeight The height of the target to render to
  110752. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  110753. * @param depthStencilTexture The depth stencil texture to use to render
  110754. * @param lodLevel defines le lod level to bind to the frame buffer
  110755. */
  110756. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  110757. /**
  110758. * Unbind the current render target texture from the webGL context
  110759. * @param texture defines the render target texture to unbind
  110760. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  110761. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  110762. */
  110763. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  110764. /**
  110765. * Creates a dynamic vertex buffer
  110766. * @param vertices the data for the dynamic vertex buffer
  110767. * @returns the new WebGL dynamic buffer
  110768. */
  110769. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  110770. /**
  110771. * Update the content of a dynamic texture
  110772. * @param texture defines the texture to update
  110773. * @param canvas defines the canvas containing the source
  110774. * @param invertY defines if data must be stored with Y axis inverted
  110775. * @param premulAlpha defines if alpha is stored as premultiplied
  110776. * @param format defines the format of the data
  110777. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  110778. */
  110779. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  110780. /**
  110781. * Gets a boolean indicating if all created effects are ready
  110782. * @returns true if all effects are ready
  110783. */
  110784. areAllEffectsReady(): boolean;
  110785. /**
  110786. * @hidden
  110787. * Get the current error code of the webGL context
  110788. * @returns the error code
  110789. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  110790. */
  110791. getError(): number;
  110792. /** @hidden */
  110793. _getUnpackAlignement(): number;
  110794. /** @hidden */
  110795. _unpackFlipY(value: boolean): void;
  110796. /**
  110797. * Update a dynamic index buffer
  110798. * @param indexBuffer defines the target index buffer
  110799. * @param indices defines the data to update
  110800. * @param offset defines the offset in the target index buffer where update should start
  110801. */
  110802. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  110803. /**
  110804. * Updates a dynamic vertex buffer.
  110805. * @param vertexBuffer the vertex buffer to update
  110806. * @param vertices the data used to update the vertex buffer
  110807. * @param byteOffset the byte offset of the data (optional)
  110808. * @param byteLength the byte length of the data (optional)
  110809. */
  110810. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  110811. /** @hidden */
  110812. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  110813. /** @hidden */
  110814. _bindTexture(channel: number, texture: InternalTexture): void;
  110815. protected _deleteBuffer(buffer: WebGLBuffer): void;
  110816. /**
  110817. * 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
  110818. */
  110819. releaseEffects(): void;
  110820. displayLoadingUI(): void;
  110821. hideLoadingUI(): void;
  110822. /** @hidden */
  110823. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110824. /** @hidden */
  110825. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110826. /** @hidden */
  110827. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  110828. /** @hidden */
  110829. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  110830. }
  110831. }
  110832. declare module BABYLON {
  110833. /** @hidden */
  110834. export class _OcclusionDataStorage {
  110835. /** @hidden */
  110836. occlusionInternalRetryCounter: number;
  110837. /** @hidden */
  110838. isOcclusionQueryInProgress: boolean;
  110839. /** @hidden */
  110840. isOccluded: boolean;
  110841. /** @hidden */
  110842. occlusionRetryCount: number;
  110843. /** @hidden */
  110844. occlusionType: number;
  110845. /** @hidden */
  110846. occlusionQueryAlgorithmType: number;
  110847. }
  110848. interface Engine {
  110849. /**
  110850. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  110851. * @return the new query
  110852. */
  110853. createQuery(): WebGLQuery;
  110854. /**
  110855. * Delete and release a webGL query
  110856. * @param query defines the query to delete
  110857. * @return the current engine
  110858. */
  110859. deleteQuery(query: WebGLQuery): Engine;
  110860. /**
  110861. * Check if a given query has resolved and got its value
  110862. * @param query defines the query to check
  110863. * @returns true if the query got its value
  110864. */
  110865. isQueryResultAvailable(query: WebGLQuery): boolean;
  110866. /**
  110867. * Gets the value of a given query
  110868. * @param query defines the query to check
  110869. * @returns the value of the query
  110870. */
  110871. getQueryResult(query: WebGLQuery): number;
  110872. /**
  110873. * Initiates an occlusion query
  110874. * @param algorithmType defines the algorithm to use
  110875. * @param query defines the query to use
  110876. * @returns the current engine
  110877. * @see http://doc.babylonjs.com/features/occlusionquery
  110878. */
  110879. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  110880. /**
  110881. * Ends an occlusion query
  110882. * @see http://doc.babylonjs.com/features/occlusionquery
  110883. * @param algorithmType defines the algorithm to use
  110884. * @returns the current engine
  110885. */
  110886. endOcclusionQuery(algorithmType: number): Engine;
  110887. /**
  110888. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  110889. * Please note that only one query can be issued at a time
  110890. * @returns a time token used to track the time span
  110891. */
  110892. startTimeQuery(): Nullable<_TimeToken>;
  110893. /**
  110894. * Ends a time query
  110895. * @param token defines the token used to measure the time span
  110896. * @returns the time spent (in ns)
  110897. */
  110898. endTimeQuery(token: _TimeToken): int;
  110899. /** @hidden */
  110900. _currentNonTimestampToken: Nullable<_TimeToken>;
  110901. /** @hidden */
  110902. _createTimeQuery(): WebGLQuery;
  110903. /** @hidden */
  110904. _deleteTimeQuery(query: WebGLQuery): void;
  110905. /** @hidden */
  110906. _getGlAlgorithmType(algorithmType: number): number;
  110907. /** @hidden */
  110908. _getTimeQueryResult(query: WebGLQuery): any;
  110909. /** @hidden */
  110910. _getTimeQueryAvailability(query: WebGLQuery): any;
  110911. }
  110912. interface AbstractMesh {
  110913. /**
  110914. * Backing filed
  110915. * @hidden
  110916. */
  110917. __occlusionDataStorage: _OcclusionDataStorage;
  110918. /**
  110919. * Access property
  110920. * @hidden
  110921. */
  110922. _occlusionDataStorage: _OcclusionDataStorage;
  110923. /**
  110924. * 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.
  110925. * The default value is -1 which means don't break the query and wait till the result
  110926. * @see http://doc.babylonjs.com/features/occlusionquery
  110927. */
  110928. occlusionRetryCount: number;
  110929. /**
  110930. * 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:
  110931. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  110932. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  110933. * * 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.
  110934. * @see http://doc.babylonjs.com/features/occlusionquery
  110935. */
  110936. occlusionType: number;
  110937. /**
  110938. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  110939. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  110940. * * 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.
  110941. * @see http://doc.babylonjs.com/features/occlusionquery
  110942. */
  110943. occlusionQueryAlgorithmType: number;
  110944. /**
  110945. * 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
  110946. * @see http://doc.babylonjs.com/features/occlusionquery
  110947. */
  110948. isOccluded: boolean;
  110949. /**
  110950. * Flag to check the progress status of the query
  110951. * @see http://doc.babylonjs.com/features/occlusionquery
  110952. */
  110953. isOcclusionQueryInProgress: boolean;
  110954. }
  110955. }
  110956. declare module BABYLON {
  110957. /** @hidden */
  110958. export var _forceTransformFeedbackToBundle: boolean;
  110959. interface Engine {
  110960. /**
  110961. * Creates a webGL transform feedback object
  110962. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  110963. * @returns the webGL transform feedback object
  110964. */
  110965. createTransformFeedback(): WebGLTransformFeedback;
  110966. /**
  110967. * Delete a webGL transform feedback object
  110968. * @param value defines the webGL transform feedback object to delete
  110969. */
  110970. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  110971. /**
  110972. * Bind a webGL transform feedback object to the webgl context
  110973. * @param value defines the webGL transform feedback object to bind
  110974. */
  110975. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  110976. /**
  110977. * Begins a transform feedback operation
  110978. * @param usePoints defines if points or triangles must be used
  110979. */
  110980. beginTransformFeedback(usePoints: boolean): void;
  110981. /**
  110982. * Ends a transform feedback operation
  110983. */
  110984. endTransformFeedback(): void;
  110985. /**
  110986. * Specify the varyings to use with transform feedback
  110987. * @param program defines the associated webGL program
  110988. * @param value defines the list of strings representing the varying names
  110989. */
  110990. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  110991. /**
  110992. * Bind a webGL buffer for a transform feedback operation
  110993. * @param value defines the webGL buffer to bind
  110994. */
  110995. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  110996. }
  110997. }
  110998. declare module BABYLON {
  110999. /**
  111000. * Creation options of the multi render target texture.
  111001. */
  111002. export interface IMultiRenderTargetOptions {
  111003. /**
  111004. * Define if the texture needs to create mip maps after render.
  111005. */
  111006. generateMipMaps?: boolean;
  111007. /**
  111008. * Define the types of all the draw buffers we want to create
  111009. */
  111010. types?: number[];
  111011. /**
  111012. * Define the sampling modes of all the draw buffers we want to create
  111013. */
  111014. samplingModes?: number[];
  111015. /**
  111016. * Define if a depth buffer is required
  111017. */
  111018. generateDepthBuffer?: boolean;
  111019. /**
  111020. * Define if a stencil buffer is required
  111021. */
  111022. generateStencilBuffer?: boolean;
  111023. /**
  111024. * Define if a depth texture is required instead of a depth buffer
  111025. */
  111026. generateDepthTexture?: boolean;
  111027. /**
  111028. * Define the number of desired draw buffers
  111029. */
  111030. textureCount?: number;
  111031. /**
  111032. * Define if aspect ratio should be adapted to the texture or stay the scene one
  111033. */
  111034. doNotChangeAspectRatio?: boolean;
  111035. /**
  111036. * Define the default type of the buffers we are creating
  111037. */
  111038. defaultType?: number;
  111039. }
  111040. /**
  111041. * A multi render target, like a render target provides the ability to render to a texture.
  111042. * Unlike the render target, it can render to several draw buffers in one draw.
  111043. * This is specially interesting in deferred rendering or for any effects requiring more than
  111044. * just one color from a single pass.
  111045. */
  111046. export class MultiRenderTarget extends RenderTargetTexture {
  111047. private _internalTextures;
  111048. private _textures;
  111049. private _multiRenderTargetOptions;
  111050. /**
  111051. * Get if draw buffers are currently supported by the used hardware and browser.
  111052. */
  111053. readonly isSupported: boolean;
  111054. /**
  111055. * Get the list of textures generated by the multi render target.
  111056. */
  111057. readonly textures: Texture[];
  111058. /**
  111059. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  111060. */
  111061. readonly depthTexture: Texture;
  111062. /**
  111063. * Set the wrapping mode on U of all the textures we are rendering to.
  111064. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111065. */
  111066. wrapU: number;
  111067. /**
  111068. * Set the wrapping mode on V of all the textures we are rendering to.
  111069. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  111070. */
  111071. wrapV: number;
  111072. /**
  111073. * Instantiate a new multi render target texture.
  111074. * A multi render target, like a render target provides the ability to render to a texture.
  111075. * Unlike the render target, it can render to several draw buffers in one draw.
  111076. * This is specially interesting in deferred rendering or for any effects requiring more than
  111077. * just one color from a single pass.
  111078. * @param name Define the name of the texture
  111079. * @param size Define the size of the buffers to render to
  111080. * @param count Define the number of target we are rendering into
  111081. * @param scene Define the scene the texture belongs to
  111082. * @param options Define the options used to create the multi render target
  111083. */
  111084. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  111085. /** @hidden */
  111086. _rebuild(): void;
  111087. private _createInternalTextures;
  111088. private _createTextures;
  111089. /**
  111090. * Define the number of samples used if MSAA is enabled.
  111091. */
  111092. samples: number;
  111093. /**
  111094. * Resize all the textures in the multi render target.
  111095. * Be carrefull as it will recreate all the data in the new texture.
  111096. * @param size Define the new size
  111097. */
  111098. resize(size: any): void;
  111099. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  111100. /**
  111101. * Dispose the render targets and their associated resources
  111102. */
  111103. dispose(): void;
  111104. /**
  111105. * Release all the underlying texture used as draw buffers.
  111106. */
  111107. releaseInternalTextures(): void;
  111108. }
  111109. }
  111110. declare module BABYLON {
  111111. interface ThinEngine {
  111112. /**
  111113. * Unbind a list of render target textures from the webGL context
  111114. * This is used only when drawBuffer extension or webGL2 are active
  111115. * @param textures defines the render target textures to unbind
  111116. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  111117. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  111118. */
  111119. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  111120. /**
  111121. * Create a multi render target texture
  111122. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  111123. * @param size defines the size of the texture
  111124. * @param options defines the creation options
  111125. * @returns the cube texture as an InternalTexture
  111126. */
  111127. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  111128. /**
  111129. * Update the sample count for a given multiple render target texture
  111130. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  111131. * @param textures defines the textures to update
  111132. * @param samples defines the sample count to set
  111133. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  111134. */
  111135. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  111136. }
  111137. }
  111138. declare module BABYLON {
  111139. /** @hidden */
  111140. export var rgbdEncodePixelShader: {
  111141. name: string;
  111142. shader: string;
  111143. };
  111144. }
  111145. declare module BABYLON {
  111146. /** @hidden */
  111147. export var rgbdDecodePixelShader: {
  111148. name: string;
  111149. shader: string;
  111150. };
  111151. }
  111152. declare module BABYLON {
  111153. /**
  111154. * Raw texture data and descriptor sufficient for WebGL texture upload
  111155. */
  111156. export interface EnvironmentTextureInfo {
  111157. /**
  111158. * Version of the environment map
  111159. */
  111160. version: number;
  111161. /**
  111162. * Width of image
  111163. */
  111164. width: number;
  111165. /**
  111166. * Irradiance information stored in the file.
  111167. */
  111168. irradiance: any;
  111169. /**
  111170. * Specular information stored in the file.
  111171. */
  111172. specular: any;
  111173. }
  111174. /**
  111175. * Defines One Image in the file. It requires only the position in the file
  111176. * as well as the length.
  111177. */
  111178. interface BufferImageData {
  111179. /**
  111180. * Length of the image data.
  111181. */
  111182. length: number;
  111183. /**
  111184. * Position of the data from the null terminator delimiting the end of the JSON.
  111185. */
  111186. position: number;
  111187. }
  111188. /**
  111189. * Defines the specular data enclosed in the file.
  111190. * This corresponds to the version 1 of the data.
  111191. */
  111192. export interface EnvironmentTextureSpecularInfoV1 {
  111193. /**
  111194. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  111195. */
  111196. specularDataPosition?: number;
  111197. /**
  111198. * This contains all the images data needed to reconstruct the cubemap.
  111199. */
  111200. mipmaps: Array<BufferImageData>;
  111201. /**
  111202. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  111203. */
  111204. lodGenerationScale: number;
  111205. }
  111206. /**
  111207. * Sets of helpers addressing the serialization and deserialization of environment texture
  111208. * stored in a BabylonJS env file.
  111209. * Those files are usually stored as .env files.
  111210. */
  111211. export class EnvironmentTextureTools {
  111212. /**
  111213. * Magic number identifying the env file.
  111214. */
  111215. private static _MagicBytes;
  111216. /**
  111217. * Gets the environment info from an env file.
  111218. * @param data The array buffer containing the .env bytes.
  111219. * @returns the environment file info (the json header) if successfully parsed.
  111220. */
  111221. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  111222. /**
  111223. * Creates an environment texture from a loaded cube texture.
  111224. * @param texture defines the cube texture to convert in env file
  111225. * @return a promise containing the environment data if succesfull.
  111226. */
  111227. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  111228. /**
  111229. * Creates a JSON representation of the spherical data.
  111230. * @param texture defines the texture containing the polynomials
  111231. * @return the JSON representation of the spherical info
  111232. */
  111233. private static _CreateEnvTextureIrradiance;
  111234. /**
  111235. * Creates the ArrayBufferViews used for initializing environment texture image data.
  111236. * @param arrayBuffer the underlying ArrayBuffer to which the views refer
  111237. * @param info parameters that determine what views will be created for accessing the underlying buffer
  111238. * @return the views described by info providing access to the underlying buffer
  111239. */
  111240. static CreateImageDataArrayBufferViews(arrayBuffer: any, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  111241. /**
  111242. * Uploads the texture info contained in the env file to the GPU.
  111243. * @param texture defines the internal texture to upload to
  111244. * @param arrayBuffer defines the buffer cotaining the data to load
  111245. * @param info defines the texture info retrieved through the GetEnvInfo method
  111246. * @returns a promise
  111247. */
  111248. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  111249. /**
  111250. * Uploads the levels of image data to the GPU.
  111251. * @param texture defines the internal texture to upload to
  111252. * @param imageData defines the array buffer views of image data [mipmap][face]
  111253. * @returns a promise
  111254. */
  111255. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  111256. /**
  111257. * Uploads spherical polynomials information to the texture.
  111258. * @param texture defines the texture we are trying to upload the information to
  111259. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  111260. */
  111261. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  111262. /** @hidden */
  111263. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  111264. }
  111265. }
  111266. declare module BABYLON {
  111267. /**
  111268. * Contains position and normal vectors for a vertex
  111269. */
  111270. export class PositionNormalVertex {
  111271. /** the position of the vertex (defaut: 0,0,0) */
  111272. position: Vector3;
  111273. /** the normal of the vertex (defaut: 0,1,0) */
  111274. normal: Vector3;
  111275. /**
  111276. * Creates a PositionNormalVertex
  111277. * @param position the position of the vertex (defaut: 0,0,0)
  111278. * @param normal the normal of the vertex (defaut: 0,1,0)
  111279. */
  111280. constructor(
  111281. /** the position of the vertex (defaut: 0,0,0) */
  111282. position?: Vector3,
  111283. /** the normal of the vertex (defaut: 0,1,0) */
  111284. normal?: Vector3);
  111285. /**
  111286. * Clones the PositionNormalVertex
  111287. * @returns the cloned PositionNormalVertex
  111288. */
  111289. clone(): PositionNormalVertex;
  111290. }
  111291. /**
  111292. * Contains position, normal and uv vectors for a vertex
  111293. */
  111294. export class PositionNormalTextureVertex {
  111295. /** the position of the vertex (defaut: 0,0,0) */
  111296. position: Vector3;
  111297. /** the normal of the vertex (defaut: 0,1,0) */
  111298. normal: Vector3;
  111299. /** the uv of the vertex (default: 0,0) */
  111300. uv: Vector2;
  111301. /**
  111302. * Creates a PositionNormalTextureVertex
  111303. * @param position the position of the vertex (defaut: 0,0,0)
  111304. * @param normal the normal of the vertex (defaut: 0,1,0)
  111305. * @param uv the uv of the vertex (default: 0,0)
  111306. */
  111307. constructor(
  111308. /** the position of the vertex (defaut: 0,0,0) */
  111309. position?: Vector3,
  111310. /** the normal of the vertex (defaut: 0,1,0) */
  111311. normal?: Vector3,
  111312. /** the uv of the vertex (default: 0,0) */
  111313. uv?: Vector2);
  111314. /**
  111315. * Clones the PositionNormalTextureVertex
  111316. * @returns the cloned PositionNormalTextureVertex
  111317. */
  111318. clone(): PositionNormalTextureVertex;
  111319. }
  111320. }
  111321. declare module BABYLON {
  111322. /** @hidden */
  111323. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  111324. private _genericAttributeLocation;
  111325. private _varyingLocationCount;
  111326. private _varyingLocationMap;
  111327. private _replacements;
  111328. private _textureCount;
  111329. private _uniforms;
  111330. lineProcessor(line: string): string;
  111331. attributeProcessor(attribute: string): string;
  111332. varyingProcessor(varying: string, isFragment: boolean): string;
  111333. uniformProcessor(uniform: string): string;
  111334. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  111335. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  111336. }
  111337. }
  111338. declare module BABYLON {
  111339. /**
  111340. * Container for accessors for natively-stored mesh data buffers.
  111341. */
  111342. class NativeDataBuffer extends DataBuffer {
  111343. /**
  111344. * Accessor value used to identify/retrieve a natively-stored index buffer.
  111345. */
  111346. nativeIndexBuffer?: any;
  111347. /**
  111348. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  111349. */
  111350. nativeVertexBuffer?: any;
  111351. }
  111352. /** @hidden */
  111353. export class NativeEngine extends Engine {
  111354. private readonly _native;
  111355. getHardwareScalingLevel(): number;
  111356. constructor();
  111357. /**
  111358. * Can be used to override the current requestAnimationFrame requester.
  111359. * @hidden
  111360. */
  111361. protected _queueNewFrame(bindedRenderFunction: any, requester: any): number;
  111362. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  111363. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  111364. createVertexBuffer(data: DataArray): NativeDataBuffer;
  111365. recordVertexArrayObject(vertexBuffers: {
  111366. [key: string]: VertexBuffer;
  111367. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  111368. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111369. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  111370. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  111371. /**
  111372. * Draw a list of indexed primitives
  111373. * @param fillMode defines the primitive to use
  111374. * @param indexStart defines the starting index
  111375. * @param indexCount defines the number of index to draw
  111376. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111377. */
  111378. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  111379. /**
  111380. * Draw a list of unindexed primitives
  111381. * @param fillMode defines the primitive to use
  111382. * @param verticesStart defines the index of first vertex to draw
  111383. * @param verticesCount defines the count of vertices to draw
  111384. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  111385. */
  111386. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  111387. createPipelineContext(): IPipelineContext;
  111388. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  111389. /** @hidden */
  111390. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  111391. /** @hidden */
  111392. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  111393. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111394. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  111395. protected _setProgram(program: WebGLProgram): void;
  111396. _releaseEffect(effect: Effect): void;
  111397. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  111398. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  111399. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  111400. bindSamplers(effect: Effect): void;
  111401. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  111402. getRenderWidth(useScreen?: boolean): number;
  111403. getRenderHeight(useScreen?: boolean): number;
  111404. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  111405. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  111406. /**
  111407. * Set the z offset to apply to current rendering
  111408. * @param value defines the offset to apply
  111409. */
  111410. setZOffset(value: number): void;
  111411. /**
  111412. * Gets the current value of the zOffset
  111413. * @returns the current zOffset state
  111414. */
  111415. getZOffset(): number;
  111416. /**
  111417. * Enable or disable depth buffering
  111418. * @param enable defines the state to set
  111419. */
  111420. setDepthBuffer(enable: boolean): void;
  111421. /**
  111422. * Gets a boolean indicating if depth writing is enabled
  111423. * @returns the current depth writing state
  111424. */
  111425. getDepthWrite(): boolean;
  111426. /**
  111427. * Enable or disable depth writing
  111428. * @param enable defines the state to set
  111429. */
  111430. setDepthWrite(enable: boolean): void;
  111431. /**
  111432. * Enable or disable color writing
  111433. * @param enable defines the state to set
  111434. */
  111435. setColorWrite(enable: boolean): void;
  111436. /**
  111437. * Gets a boolean indicating if color writing is enabled
  111438. * @returns the current color writing state
  111439. */
  111440. getColorWrite(): boolean;
  111441. /**
  111442. * Sets alpha constants used by some alpha blending modes
  111443. * @param r defines the red component
  111444. * @param g defines the green component
  111445. * @param b defines the blue component
  111446. * @param a defines the alpha component
  111447. */
  111448. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  111449. /**
  111450. * Sets the current alpha mode
  111451. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  111452. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  111453. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111454. */
  111455. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  111456. /**
  111457. * Gets the current alpha mode
  111458. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  111459. * @returns the current alpha mode
  111460. */
  111461. getAlphaMode(): number;
  111462. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  111463. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  111464. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  111465. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  111466. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  111467. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  111468. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  111469. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  111470. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  111471. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  111472. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  111473. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  111474. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  111475. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111476. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  111477. setFloat(uniform: WebGLUniformLocation, value: number): void;
  111478. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  111479. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  111480. setBool(uniform: WebGLUniformLocation, bool: number): void;
  111481. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  111482. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  111483. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  111484. wipeCaches(bruteForce?: boolean): void;
  111485. _createTexture(): WebGLTexture;
  111486. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  111487. /**
  111488. * Usually called from BABYLON.Texture.ts.
  111489. * Passed information to create a WebGLTexture
  111490. * @param urlArg defines a value which contains one of the following:
  111491. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  111492. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  111493. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  111494. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  111495. * @param invertY when true, image is flipped when loaded. You probably want true. Ignored for compressed textures. Must be flipped in the file
  111496. * @param scene needed for loading to the correct scene
  111497. * @param samplingMode mode with should be used sample / access the texture (Default: BABYLON.Texture.TRILINEAR_SAMPLINGMODE)
  111498. * @param onLoad optional callback to be called upon successful completion
  111499. * @param onError optional callback to be called upon failure
  111500. * @param buffer a source of a file previously fetched as either a base64 string, an ArrayBuffer (compressed or image format), or a Blob
  111501. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  111502. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  111503. * @param forcedExtension defines the extension to use to pick the right loader
  111504. * @returns a InternalTexture for assignment back into BABYLON.Texture
  111505. */
  111506. 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;
  111507. /**
  111508. * Creates a cube texture
  111509. * @param rootUrl defines the url where the files to load is located
  111510. * @param scene defines the current scene
  111511. * @param files defines the list of files to load (1 per face)
  111512. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  111513. * @param onLoad defines an optional callback raised when the texture is loaded
  111514. * @param onError defines an optional callback raised if there is an issue to load the texture
  111515. * @param format defines the format of the data
  111516. * @param forcedExtension defines the extension to use to pick the right loader
  111517. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  111518. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  111519. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  111520. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  111521. * @returns the cube texture as an InternalTexture
  111522. */
  111523. 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;
  111524. private _getSamplingFilter;
  111525. private static _GetNativeTextureFormat;
  111526. createRenderTargetTexture(size: number | {
  111527. width: number;
  111528. height: number;
  111529. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  111530. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  111531. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  111532. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  111533. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  111534. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  111535. /**
  111536. * Updates a dynamic vertex buffer.
  111537. * @param vertexBuffer the vertex buffer to update
  111538. * @param data the data used to update the vertex buffer
  111539. * @param byteOffset the byte offset of the data (optional)
  111540. * @param byteLength the byte length of the data (optional)
  111541. */
  111542. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  111543. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  111544. private _updateAnisotropicLevel;
  111545. private _getAddressMode;
  111546. /** @hidden */
  111547. _bindTexture(channel: number, texture: InternalTexture): void;
  111548. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  111549. releaseEffects(): void;
  111550. /** @hidden */
  111551. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111552. /** @hidden */
  111553. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111554. /** @hidden */
  111555. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  111556. /** @hidden */
  111557. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  111558. }
  111559. }
  111560. declare module BABYLON {
  111561. /**
  111562. * Gather the list of clipboard event types as constants.
  111563. */
  111564. export class ClipboardEventTypes {
  111565. /**
  111566. * The clipboard event is fired when a copy command is active (pressed).
  111567. */
  111568. static readonly COPY: number;
  111569. /**
  111570. * The clipboard event is fired when a cut command is active (pressed).
  111571. */
  111572. static readonly CUT: number;
  111573. /**
  111574. * The clipboard event is fired when a paste command is active (pressed).
  111575. */
  111576. static readonly PASTE: number;
  111577. }
  111578. /**
  111579. * This class is used to store clipboard related info for the onClipboardObservable event.
  111580. */
  111581. export class ClipboardInfo {
  111582. /**
  111583. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111584. */
  111585. type: number;
  111586. /**
  111587. * Defines the related dom event
  111588. */
  111589. event: ClipboardEvent;
  111590. /**
  111591. *Creates an instance of ClipboardInfo.
  111592. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  111593. * @param event Defines the related dom event
  111594. */
  111595. constructor(
  111596. /**
  111597. * Defines the type of event (BABYLON.ClipboardEventTypes)
  111598. */
  111599. type: number,
  111600. /**
  111601. * Defines the related dom event
  111602. */
  111603. event: ClipboardEvent);
  111604. /**
  111605. * Get the clipboard event's type from the keycode.
  111606. * @param keyCode Defines the keyCode for the current keyboard event.
  111607. * @return {number}
  111608. */
  111609. static GetTypeFromCharacter(keyCode: number): number;
  111610. }
  111611. }
  111612. declare module BABYLON {
  111613. /**
  111614. * Google Daydream controller
  111615. */
  111616. export class DaydreamController extends WebVRController {
  111617. /**
  111618. * Base Url for the controller model.
  111619. */
  111620. static MODEL_BASE_URL: string;
  111621. /**
  111622. * File name for the controller model.
  111623. */
  111624. static MODEL_FILENAME: string;
  111625. /**
  111626. * Gamepad Id prefix used to identify Daydream Controller.
  111627. */
  111628. static readonly GAMEPAD_ID_PREFIX: string;
  111629. /**
  111630. * Creates a new DaydreamController from a gamepad
  111631. * @param vrGamepad the gamepad that the controller should be created from
  111632. */
  111633. constructor(vrGamepad: any);
  111634. /**
  111635. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111636. * @param scene scene in which to add meshes
  111637. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111638. */
  111639. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111640. /**
  111641. * Called once for each button that changed state since the last frame
  111642. * @param buttonIdx Which button index changed
  111643. * @param state New state of the button
  111644. * @param changes Which properties on the state changed since last frame
  111645. */
  111646. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111647. }
  111648. }
  111649. declare module BABYLON {
  111650. /**
  111651. * Gear VR Controller
  111652. */
  111653. export class GearVRController extends WebVRController {
  111654. /**
  111655. * Base Url for the controller model.
  111656. */
  111657. static MODEL_BASE_URL: string;
  111658. /**
  111659. * File name for the controller model.
  111660. */
  111661. static MODEL_FILENAME: string;
  111662. /**
  111663. * Gamepad Id prefix used to identify this controller.
  111664. */
  111665. static readonly GAMEPAD_ID_PREFIX: string;
  111666. private readonly _buttonIndexToObservableNameMap;
  111667. /**
  111668. * Creates a new GearVRController from a gamepad
  111669. * @param vrGamepad the gamepad that the controller should be created from
  111670. */
  111671. constructor(vrGamepad: any);
  111672. /**
  111673. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  111674. * @param scene scene in which to add meshes
  111675. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  111676. */
  111677. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  111678. /**
  111679. * Called once for each button that changed state since the last frame
  111680. * @param buttonIdx Which button index changed
  111681. * @param state New state of the button
  111682. * @param changes Which properties on the state changed since last frame
  111683. */
  111684. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  111685. }
  111686. }
  111687. declare module BABYLON {
  111688. /**
  111689. * Class containing static functions to help procedurally build meshes
  111690. */
  111691. export class PolyhedronBuilder {
  111692. /**
  111693. * Creates a polyhedron mesh
  111694. * * 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
  111695. * * The parameter `size` (positive float, default 1) sets the polygon size
  111696. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  111697. * * 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`
  111698. * * 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
  111699. * * 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)`)
  111700. * * 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
  111701. * * 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
  111702. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  111703. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  111704. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  111705. * @param name defines the name of the mesh
  111706. * @param options defines the options used to create the mesh
  111707. * @param scene defines the hosting scene
  111708. * @returns the polyhedron mesh
  111709. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  111710. */
  111711. static CreatePolyhedron(name: string, options: {
  111712. type?: number;
  111713. size?: number;
  111714. sizeX?: number;
  111715. sizeY?: number;
  111716. sizeZ?: number;
  111717. custom?: any;
  111718. faceUV?: Vector4[];
  111719. faceColors?: Color4[];
  111720. flat?: boolean;
  111721. updatable?: boolean;
  111722. sideOrientation?: number;
  111723. frontUVs?: Vector4;
  111724. backUVs?: Vector4;
  111725. }, scene?: Nullable<Scene>): Mesh;
  111726. }
  111727. }
  111728. declare module BABYLON {
  111729. /**
  111730. * Gizmo that enables scaling a mesh along 3 axis
  111731. */
  111732. export class ScaleGizmo extends Gizmo {
  111733. /**
  111734. * Internal gizmo used for interactions on the x axis
  111735. */
  111736. xGizmo: AxisScaleGizmo;
  111737. /**
  111738. * Internal gizmo used for interactions on the y axis
  111739. */
  111740. yGizmo: AxisScaleGizmo;
  111741. /**
  111742. * Internal gizmo used for interactions on the z axis
  111743. */
  111744. zGizmo: AxisScaleGizmo;
  111745. /**
  111746. * Internal gizmo used to scale all axis equally
  111747. */
  111748. uniformScaleGizmo: AxisScaleGizmo;
  111749. private _meshAttached;
  111750. private _updateGizmoRotationToMatchAttachedMesh;
  111751. private _snapDistance;
  111752. private _scaleRatio;
  111753. private _uniformScalingMesh;
  111754. private _octahedron;
  111755. /** Fires an event when any of it's sub gizmos are dragged */
  111756. onDragStartObservable: Observable<unknown>;
  111757. /** Fires an event when any of it's sub gizmos are released from dragging */
  111758. onDragEndObservable: Observable<unknown>;
  111759. attachedMesh: Nullable<AbstractMesh>;
  111760. /**
  111761. * Creates a ScaleGizmo
  111762. * @param gizmoLayer The utility layer the gizmo will be added to
  111763. */
  111764. constructor(gizmoLayer?: UtilityLayerRenderer);
  111765. updateGizmoRotationToMatchAttachedMesh: boolean;
  111766. /**
  111767. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111768. */
  111769. snapDistance: number;
  111770. /**
  111771. * Ratio for the scale of the gizmo (Default: 1)
  111772. */
  111773. scaleRatio: number;
  111774. /**
  111775. * Disposes of the gizmo
  111776. */
  111777. dispose(): void;
  111778. }
  111779. }
  111780. declare module BABYLON {
  111781. /**
  111782. * Single axis scale gizmo
  111783. */
  111784. export class AxisScaleGizmo extends Gizmo {
  111785. /**
  111786. * Drag behavior responsible for the gizmos dragging interactions
  111787. */
  111788. dragBehavior: PointerDragBehavior;
  111789. private _pointerObserver;
  111790. /**
  111791. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  111792. */
  111793. snapDistance: number;
  111794. /**
  111795. * Event that fires each time the gizmo snaps to a new location.
  111796. * * snapDistance is the the change in distance
  111797. */
  111798. onSnapObservable: Observable<{
  111799. snapDistance: number;
  111800. }>;
  111801. /**
  111802. * If the scaling operation should be done on all axis (default: false)
  111803. */
  111804. uniformScaling: boolean;
  111805. private _isEnabled;
  111806. private _parent;
  111807. private _arrow;
  111808. private _coloredMaterial;
  111809. private _hoverMaterial;
  111810. /**
  111811. * Creates an AxisScaleGizmo
  111812. * @param gizmoLayer The utility layer the gizmo will be added to
  111813. * @param dragAxis The axis which the gizmo will be able to scale on
  111814. * @param color The color of the gizmo
  111815. */
  111816. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  111817. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111818. /**
  111819. * If the gizmo is enabled
  111820. */
  111821. isEnabled: boolean;
  111822. /**
  111823. * Disposes of the gizmo
  111824. */
  111825. dispose(): void;
  111826. /**
  111827. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  111828. * @param mesh The mesh to replace the default mesh of the gizmo
  111829. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  111830. */
  111831. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  111832. }
  111833. }
  111834. declare module BABYLON {
  111835. /**
  111836. * Bounding box gizmo
  111837. */
  111838. export class BoundingBoxGizmo extends Gizmo {
  111839. private _lineBoundingBox;
  111840. private _rotateSpheresParent;
  111841. private _scaleBoxesParent;
  111842. private _boundingDimensions;
  111843. private _renderObserver;
  111844. private _pointerObserver;
  111845. private _scaleDragSpeed;
  111846. private _tmpQuaternion;
  111847. private _tmpVector;
  111848. private _tmpRotationMatrix;
  111849. /**
  111850. * 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)
  111851. */
  111852. ignoreChildren: boolean;
  111853. /**
  111854. * 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)
  111855. */
  111856. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  111857. /**
  111858. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  111859. */
  111860. rotationSphereSize: number;
  111861. /**
  111862. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  111863. */
  111864. scaleBoxSize: number;
  111865. /**
  111866. * 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)
  111867. */
  111868. fixedDragMeshScreenSize: boolean;
  111869. /**
  111870. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  111871. */
  111872. fixedDragMeshScreenSizeDistanceFactor: number;
  111873. /**
  111874. * Fired when a rotation sphere or scale box is dragged
  111875. */
  111876. onDragStartObservable: Observable<{}>;
  111877. /**
  111878. * Fired when a scale box is dragged
  111879. */
  111880. onScaleBoxDragObservable: Observable<{}>;
  111881. /**
  111882. * Fired when a scale box drag is ended
  111883. */
  111884. onScaleBoxDragEndObservable: Observable<{}>;
  111885. /**
  111886. * Fired when a rotation sphere is dragged
  111887. */
  111888. onRotationSphereDragObservable: Observable<{}>;
  111889. /**
  111890. * Fired when a rotation sphere drag is ended
  111891. */
  111892. onRotationSphereDragEndObservable: Observable<{}>;
  111893. /**
  111894. * 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)
  111895. */
  111896. scalePivot: Nullable<Vector3>;
  111897. /**
  111898. * Mesh used as a pivot to rotate the attached mesh
  111899. */
  111900. private _anchorMesh;
  111901. private _existingMeshScale;
  111902. private _dragMesh;
  111903. private pointerDragBehavior;
  111904. private coloredMaterial;
  111905. private hoverColoredMaterial;
  111906. /**
  111907. * Sets the color of the bounding box gizmo
  111908. * @param color the color to set
  111909. */
  111910. setColor(color: Color3): void;
  111911. /**
  111912. * Creates an BoundingBoxGizmo
  111913. * @param gizmoLayer The utility layer the gizmo will be added to
  111914. * @param color The color of the gizmo
  111915. */
  111916. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  111917. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111918. private _selectNode;
  111919. /**
  111920. * Updates the bounding box information for the Gizmo
  111921. */
  111922. updateBoundingBox(): void;
  111923. private _updateRotationSpheres;
  111924. private _updateScaleBoxes;
  111925. /**
  111926. * Enables rotation on the specified axis and disables rotation on the others
  111927. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  111928. */
  111929. setEnabledRotationAxis(axis: string): void;
  111930. /**
  111931. * Enables/disables scaling
  111932. * @param enable if scaling should be enabled
  111933. */
  111934. setEnabledScaling(enable: boolean): void;
  111935. private _updateDummy;
  111936. /**
  111937. * Enables a pointer drag behavior on the bounding box of the gizmo
  111938. */
  111939. enableDragBehavior(): void;
  111940. /**
  111941. * Disposes of the gizmo
  111942. */
  111943. dispose(): void;
  111944. /**
  111945. * 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)
  111946. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  111947. * @returns the bounding box mesh with the passed in mesh as a child
  111948. */
  111949. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  111950. /**
  111951. * CustomMeshes are not supported by this gizmo
  111952. * @param mesh The mesh to replace the default mesh of the gizmo
  111953. */
  111954. setCustomMesh(mesh: Mesh): void;
  111955. }
  111956. }
  111957. declare module BABYLON {
  111958. /**
  111959. * Single plane rotation gizmo
  111960. */
  111961. export class PlaneRotationGizmo extends Gizmo {
  111962. /**
  111963. * Drag behavior responsible for the gizmos dragging interactions
  111964. */
  111965. dragBehavior: PointerDragBehavior;
  111966. private _pointerObserver;
  111967. /**
  111968. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  111969. */
  111970. snapDistance: number;
  111971. /**
  111972. * Event that fires each time the gizmo snaps to a new location.
  111973. * * snapDistance is the the change in distance
  111974. */
  111975. onSnapObservable: Observable<{
  111976. snapDistance: number;
  111977. }>;
  111978. private _isEnabled;
  111979. private _parent;
  111980. /**
  111981. * Creates a PlaneRotationGizmo
  111982. * @param gizmoLayer The utility layer the gizmo will be added to
  111983. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  111984. * @param color The color of the gizmo
  111985. * @param tessellation Amount of tessellation to be used when creating rotation circles
  111986. * @param useEulerRotation Use and update Euler angle instead of quaternion
  111987. */
  111988. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  111989. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  111990. /**
  111991. * If the gizmo is enabled
  111992. */
  111993. isEnabled: boolean;
  111994. /**
  111995. * Disposes of the gizmo
  111996. */
  111997. dispose(): void;
  111998. }
  111999. }
  112000. declare module BABYLON {
  112001. /**
  112002. * Gizmo that enables rotating a mesh along 3 axis
  112003. */
  112004. export class RotationGizmo extends Gizmo {
  112005. /**
  112006. * Internal gizmo used for interactions on the x axis
  112007. */
  112008. xGizmo: PlaneRotationGizmo;
  112009. /**
  112010. * Internal gizmo used for interactions on the y axis
  112011. */
  112012. yGizmo: PlaneRotationGizmo;
  112013. /**
  112014. * Internal gizmo used for interactions on the z axis
  112015. */
  112016. zGizmo: PlaneRotationGizmo;
  112017. /** Fires an event when any of it's sub gizmos are dragged */
  112018. onDragStartObservable: Observable<unknown>;
  112019. /** Fires an event when any of it's sub gizmos are released from dragging */
  112020. onDragEndObservable: Observable<unknown>;
  112021. private _meshAttached;
  112022. attachedMesh: Nullable<AbstractMesh>;
  112023. /**
  112024. * Creates a RotationGizmo
  112025. * @param gizmoLayer The utility layer the gizmo will be added to
  112026. * @param tessellation Amount of tessellation to be used when creating rotation circles
  112027. * @param useEulerRotation Use and update Euler angle instead of quaternion
  112028. */
  112029. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  112030. updateGizmoRotationToMatchAttachedMesh: boolean;
  112031. /**
  112032. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  112033. */
  112034. snapDistance: number;
  112035. /**
  112036. * Ratio for the scale of the gizmo (Default: 1)
  112037. */
  112038. scaleRatio: number;
  112039. /**
  112040. * Disposes of the gizmo
  112041. */
  112042. dispose(): void;
  112043. /**
  112044. * CustomMeshes are not supported by this gizmo
  112045. * @param mesh The mesh to replace the default mesh of the gizmo
  112046. */
  112047. setCustomMesh(mesh: Mesh): void;
  112048. }
  112049. }
  112050. declare module BABYLON {
  112051. /**
  112052. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  112053. */
  112054. export class GizmoManager implements IDisposable {
  112055. private scene;
  112056. /**
  112057. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  112058. */
  112059. gizmos: {
  112060. positionGizmo: Nullable<PositionGizmo>;
  112061. rotationGizmo: Nullable<RotationGizmo>;
  112062. scaleGizmo: Nullable<ScaleGizmo>;
  112063. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  112064. };
  112065. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  112066. clearGizmoOnEmptyPointerEvent: boolean;
  112067. /** Fires an event when the manager is attached to a mesh */
  112068. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  112069. private _gizmosEnabled;
  112070. private _pointerObserver;
  112071. private _attachedMesh;
  112072. private _boundingBoxColor;
  112073. private _defaultUtilityLayer;
  112074. private _defaultKeepDepthUtilityLayer;
  112075. /**
  112076. * When bounding box gizmo is enabled, this can be used to track drag/end events
  112077. */
  112078. boundingBoxDragBehavior: SixDofDragBehavior;
  112079. /**
  112080. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  112081. */
  112082. attachableMeshes: Nullable<Array<AbstractMesh>>;
  112083. /**
  112084. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  112085. */
  112086. usePointerToAttachGizmos: boolean;
  112087. /**
  112088. * Utility layer that the bounding box gizmo belongs to
  112089. */
  112090. readonly keepDepthUtilityLayer: UtilityLayerRenderer;
  112091. /**
  112092. * Utility layer that all gizmos besides bounding box belong to
  112093. */
  112094. readonly utilityLayer: UtilityLayerRenderer;
  112095. /**
  112096. * Instatiates a gizmo manager
  112097. * @param scene the scene to overlay the gizmos on top of
  112098. */
  112099. constructor(scene: Scene);
  112100. /**
  112101. * Attaches a set of gizmos to the specified mesh
  112102. * @param mesh The mesh the gizmo's should be attached to
  112103. */
  112104. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  112105. /**
  112106. * If the position gizmo is enabled
  112107. */
  112108. positionGizmoEnabled: boolean;
  112109. /**
  112110. * If the rotation gizmo is enabled
  112111. */
  112112. rotationGizmoEnabled: boolean;
  112113. /**
  112114. * If the scale gizmo is enabled
  112115. */
  112116. scaleGizmoEnabled: boolean;
  112117. /**
  112118. * If the boundingBox gizmo is enabled
  112119. */
  112120. boundingBoxGizmoEnabled: boolean;
  112121. /**
  112122. * Disposes of the gizmo manager
  112123. */
  112124. dispose(): void;
  112125. }
  112126. }
  112127. declare module BABYLON {
  112128. /**
  112129. * A directional light is defined by a direction (what a surprise!).
  112130. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  112131. * 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.
  112132. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112133. */
  112134. export class DirectionalLight extends ShadowLight {
  112135. private _shadowFrustumSize;
  112136. /**
  112137. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  112138. */
  112139. /**
  112140. * Specifies a fix frustum size for the shadow generation.
  112141. */
  112142. shadowFrustumSize: number;
  112143. private _shadowOrthoScale;
  112144. /**
  112145. * Gets the shadow projection scale against the optimal computed one.
  112146. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112147. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112148. */
  112149. /**
  112150. * Sets the shadow projection scale against the optimal computed one.
  112151. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  112152. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  112153. */
  112154. shadowOrthoScale: number;
  112155. /**
  112156. * Automatically compute the projection matrix to best fit (including all the casters)
  112157. * on each frame.
  112158. */
  112159. autoUpdateExtends: boolean;
  112160. private _orthoLeft;
  112161. private _orthoRight;
  112162. private _orthoTop;
  112163. private _orthoBottom;
  112164. /**
  112165. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  112166. * The directional light is emitted from everywhere in the given direction.
  112167. * It can cast shadows.
  112168. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112169. * @param name The friendly name of the light
  112170. * @param direction The direction of the light
  112171. * @param scene The scene the light belongs to
  112172. */
  112173. constructor(name: string, direction: Vector3, scene: Scene);
  112174. /**
  112175. * Returns the string "DirectionalLight".
  112176. * @return The class name
  112177. */
  112178. getClassName(): string;
  112179. /**
  112180. * Returns the integer 1.
  112181. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112182. */
  112183. getTypeID(): number;
  112184. /**
  112185. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  112186. * Returns the DirectionalLight Shadow projection matrix.
  112187. */
  112188. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112189. /**
  112190. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  112191. * Returns the DirectionalLight Shadow projection matrix.
  112192. */
  112193. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  112194. /**
  112195. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  112196. * Returns the DirectionalLight Shadow projection matrix.
  112197. */
  112198. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112199. protected _buildUniformLayout(): void;
  112200. /**
  112201. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  112202. * @param effect The effect to update
  112203. * @param lightIndex The index of the light in the effect to update
  112204. * @returns The directional light
  112205. */
  112206. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  112207. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  112208. /**
  112209. * Gets the minZ used for shadow according to both the scene and the light.
  112210. *
  112211. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112212. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112213. * @param activeCamera The camera we are returning the min for
  112214. * @returns the depth min z
  112215. */
  112216. getDepthMinZ(activeCamera: Camera): number;
  112217. /**
  112218. * Gets the maxZ used for shadow according to both the scene and the light.
  112219. *
  112220. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  112221. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  112222. * @param activeCamera The camera we are returning the max for
  112223. * @returns the depth max z
  112224. */
  112225. getDepthMaxZ(activeCamera: Camera): number;
  112226. /**
  112227. * Prepares the list of defines specific to the light type.
  112228. * @param defines the list of defines
  112229. * @param lightIndex defines the index of the light for the effect
  112230. */
  112231. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112232. }
  112233. }
  112234. declare module BABYLON {
  112235. /**
  112236. * Class containing static functions to help procedurally build meshes
  112237. */
  112238. export class HemisphereBuilder {
  112239. /**
  112240. * Creates a hemisphere mesh
  112241. * @param name defines the name of the mesh
  112242. * @param options defines the options used to create the mesh
  112243. * @param scene defines the hosting scene
  112244. * @returns the hemisphere mesh
  112245. */
  112246. static CreateHemisphere(name: string, options: {
  112247. segments?: number;
  112248. diameter?: number;
  112249. sideOrientation?: number;
  112250. }, scene: any): Mesh;
  112251. }
  112252. }
  112253. declare module BABYLON {
  112254. /**
  112255. * A spot light is defined by a position, a direction, an angle, and an exponent.
  112256. * These values define a cone of light starting from the position, emitting toward the direction.
  112257. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  112258. * and the exponent defines the speed of the decay of the light with distance (reach).
  112259. * Documentation: https://doc.babylonjs.com/babylon101/lights
  112260. */
  112261. export class SpotLight extends ShadowLight {
  112262. private _angle;
  112263. private _innerAngle;
  112264. private _cosHalfAngle;
  112265. private _lightAngleScale;
  112266. private _lightAngleOffset;
  112267. /**
  112268. * Gets the cone angle of the spot light in Radians.
  112269. */
  112270. /**
  112271. * Sets the cone angle of the spot light in Radians.
  112272. */
  112273. angle: number;
  112274. /**
  112275. * Only used in gltf falloff mode, this defines the angle where
  112276. * the directional falloff will start before cutting at angle which could be seen
  112277. * as outer angle.
  112278. */
  112279. /**
  112280. * Only used in gltf falloff mode, this defines the angle where
  112281. * the directional falloff will start before cutting at angle which could be seen
  112282. * as outer angle.
  112283. */
  112284. innerAngle: number;
  112285. private _shadowAngleScale;
  112286. /**
  112287. * Allows scaling the angle of the light for shadow generation only.
  112288. */
  112289. /**
  112290. * Allows scaling the angle of the light for shadow generation only.
  112291. */
  112292. shadowAngleScale: number;
  112293. /**
  112294. * The light decay speed with the distance from the emission spot.
  112295. */
  112296. exponent: number;
  112297. private _projectionTextureMatrix;
  112298. /**
  112299. * Allows reading the projecton texture
  112300. */
  112301. readonly projectionTextureMatrix: Matrix;
  112302. protected _projectionTextureLightNear: number;
  112303. /**
  112304. * Gets the near clip of the Spotlight for texture projection.
  112305. */
  112306. /**
  112307. * Sets the near clip of the Spotlight for texture projection.
  112308. */
  112309. projectionTextureLightNear: number;
  112310. protected _projectionTextureLightFar: number;
  112311. /**
  112312. * Gets the far clip of the Spotlight for texture projection.
  112313. */
  112314. /**
  112315. * Sets the far clip of the Spotlight for texture projection.
  112316. */
  112317. projectionTextureLightFar: number;
  112318. protected _projectionTextureUpDirection: Vector3;
  112319. /**
  112320. * Gets the Up vector of the Spotlight for texture projection.
  112321. */
  112322. /**
  112323. * Sets the Up vector of the Spotlight for texture projection.
  112324. */
  112325. projectionTextureUpDirection: Vector3;
  112326. private _projectionTexture;
  112327. /**
  112328. * Gets the projection texture of the light.
  112329. */
  112330. /**
  112331. * Sets the projection texture of the light.
  112332. */
  112333. projectionTexture: Nullable<BaseTexture>;
  112334. private _projectionTextureViewLightDirty;
  112335. private _projectionTextureProjectionLightDirty;
  112336. private _projectionTextureDirty;
  112337. private _projectionTextureViewTargetVector;
  112338. private _projectionTextureViewLightMatrix;
  112339. private _projectionTextureProjectionLightMatrix;
  112340. private _projectionTextureScalingMatrix;
  112341. /**
  112342. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  112343. * It can cast shadows.
  112344. * Documentation : https://doc.babylonjs.com/babylon101/lights
  112345. * @param name The light friendly name
  112346. * @param position The position of the spot light in the scene
  112347. * @param direction The direction of the light in the scene
  112348. * @param angle The cone angle of the light in Radians
  112349. * @param exponent The light decay speed with the distance from the emission spot
  112350. * @param scene The scene the lights belongs to
  112351. */
  112352. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  112353. /**
  112354. * Returns the string "SpotLight".
  112355. * @returns the class name
  112356. */
  112357. getClassName(): string;
  112358. /**
  112359. * Returns the integer 2.
  112360. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  112361. */
  112362. getTypeID(): number;
  112363. /**
  112364. * Overrides the direction setter to recompute the projection texture view light Matrix.
  112365. */
  112366. protected _setDirection(value: Vector3): void;
  112367. /**
  112368. * Overrides the position setter to recompute the projection texture view light Matrix.
  112369. */
  112370. protected _setPosition(value: Vector3): void;
  112371. /**
  112372. * 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.
  112373. * Returns the SpotLight.
  112374. */
  112375. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  112376. protected _computeProjectionTextureViewLightMatrix(): void;
  112377. protected _computeProjectionTextureProjectionLightMatrix(): void;
  112378. /**
  112379. * Main function for light texture projection matrix computing.
  112380. */
  112381. protected _computeProjectionTextureMatrix(): void;
  112382. protected _buildUniformLayout(): void;
  112383. private _computeAngleValues;
  112384. /**
  112385. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  112386. * @param effect The effect to update
  112387. * @param lightIndex The index of the light in the effect to update
  112388. * @returns The spot light
  112389. */
  112390. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  112391. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  112392. /**
  112393. * Disposes the light and the associated resources.
  112394. */
  112395. dispose(): void;
  112396. /**
  112397. * Prepares the list of defines specific to the light type.
  112398. * @param defines the list of defines
  112399. * @param lightIndex defines the index of the light for the effect
  112400. */
  112401. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  112402. }
  112403. }
  112404. declare module BABYLON {
  112405. /**
  112406. * Gizmo that enables viewing a light
  112407. */
  112408. export class LightGizmo extends Gizmo {
  112409. private _lightMesh;
  112410. private _material;
  112411. private cachedPosition;
  112412. private cachedForward;
  112413. /**
  112414. * Creates a LightGizmo
  112415. * @param gizmoLayer The utility layer the gizmo will be added to
  112416. */
  112417. constructor(gizmoLayer?: UtilityLayerRenderer);
  112418. private _light;
  112419. /**
  112420. * The light that the gizmo is attached to
  112421. */
  112422. light: Nullable<Light>;
  112423. /**
  112424. * Gets the material used to render the light gizmo
  112425. */
  112426. readonly material: StandardMaterial;
  112427. /**
  112428. * @hidden
  112429. * Updates the gizmo to match the attached mesh's position/rotation
  112430. */
  112431. protected _update(): void;
  112432. private static _Scale;
  112433. /**
  112434. * Creates the lines for a light mesh
  112435. */
  112436. private static _createLightLines;
  112437. /**
  112438. * Disposes of the light gizmo
  112439. */
  112440. dispose(): void;
  112441. private static _CreateHemisphericLightMesh;
  112442. private static _CreatePointLightMesh;
  112443. private static _CreateSpotLightMesh;
  112444. private static _CreateDirectionalLightMesh;
  112445. }
  112446. }
  112447. declare module BABYLON {
  112448. /** @hidden */
  112449. export var backgroundFragmentDeclaration: {
  112450. name: string;
  112451. shader: string;
  112452. };
  112453. }
  112454. declare module BABYLON {
  112455. /** @hidden */
  112456. export var backgroundUboDeclaration: {
  112457. name: string;
  112458. shader: string;
  112459. };
  112460. }
  112461. declare module BABYLON {
  112462. /** @hidden */
  112463. export var backgroundPixelShader: {
  112464. name: string;
  112465. shader: string;
  112466. };
  112467. }
  112468. declare module BABYLON {
  112469. /** @hidden */
  112470. export var backgroundVertexDeclaration: {
  112471. name: string;
  112472. shader: string;
  112473. };
  112474. }
  112475. declare module BABYLON {
  112476. /** @hidden */
  112477. export var backgroundVertexShader: {
  112478. name: string;
  112479. shader: string;
  112480. };
  112481. }
  112482. declare module BABYLON {
  112483. /**
  112484. * Background material used to create an efficient environement around your scene.
  112485. */
  112486. export class BackgroundMaterial extends PushMaterial {
  112487. /**
  112488. * Standard reflectance value at parallel view angle.
  112489. */
  112490. static StandardReflectance0: number;
  112491. /**
  112492. * Standard reflectance value at grazing angle.
  112493. */
  112494. static StandardReflectance90: number;
  112495. protected _primaryColor: Color3;
  112496. /**
  112497. * Key light Color (multiply against the environement texture)
  112498. */
  112499. primaryColor: Color3;
  112500. protected __perceptualColor: Nullable<Color3>;
  112501. /**
  112502. * Experimental Internal Use Only.
  112503. *
  112504. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  112505. * This acts as a helper to set the primary color to a more "human friendly" value.
  112506. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  112507. * output color as close as possible from the chosen value.
  112508. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  112509. * part of lighting setup.)
  112510. */
  112511. _perceptualColor: Nullable<Color3>;
  112512. protected _primaryColorShadowLevel: float;
  112513. /**
  112514. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  112515. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  112516. */
  112517. primaryColorShadowLevel: float;
  112518. protected _primaryColorHighlightLevel: float;
  112519. /**
  112520. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  112521. * The primary color is used at the level chosen to define what the white area would look.
  112522. */
  112523. primaryColorHighlightLevel: float;
  112524. protected _reflectionTexture: Nullable<BaseTexture>;
  112525. /**
  112526. * Reflection Texture used in the material.
  112527. * Should be author in a specific way for the best result (refer to the documentation).
  112528. */
  112529. reflectionTexture: Nullable<BaseTexture>;
  112530. protected _reflectionBlur: float;
  112531. /**
  112532. * Reflection Texture level of blur.
  112533. *
  112534. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  112535. * texture twice.
  112536. */
  112537. reflectionBlur: float;
  112538. protected _diffuseTexture: Nullable<BaseTexture>;
  112539. /**
  112540. * Diffuse Texture used in the material.
  112541. * Should be author in a specific way for the best result (refer to the documentation).
  112542. */
  112543. diffuseTexture: Nullable<BaseTexture>;
  112544. protected _shadowLights: Nullable<IShadowLight[]>;
  112545. /**
  112546. * Specify the list of lights casting shadow on the material.
  112547. * All scene shadow lights will be included if null.
  112548. */
  112549. shadowLights: Nullable<IShadowLight[]>;
  112550. protected _shadowLevel: float;
  112551. /**
  112552. * Helps adjusting the shadow to a softer level if required.
  112553. * 0 means black shadows and 1 means no shadows.
  112554. */
  112555. shadowLevel: float;
  112556. protected _sceneCenter: Vector3;
  112557. /**
  112558. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  112559. * It is usually zero but might be interesting to modify according to your setup.
  112560. */
  112561. sceneCenter: Vector3;
  112562. protected _opacityFresnel: boolean;
  112563. /**
  112564. * This helps specifying that the material is falling off to the sky box at grazing angle.
  112565. * This helps ensuring a nice transition when the camera goes under the ground.
  112566. */
  112567. opacityFresnel: boolean;
  112568. protected _reflectionFresnel: boolean;
  112569. /**
  112570. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  112571. * This helps adding a mirror texture on the ground.
  112572. */
  112573. reflectionFresnel: boolean;
  112574. protected _reflectionFalloffDistance: number;
  112575. /**
  112576. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  112577. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  112578. */
  112579. reflectionFalloffDistance: number;
  112580. protected _reflectionAmount: number;
  112581. /**
  112582. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  112583. */
  112584. reflectionAmount: number;
  112585. protected _reflectionReflectance0: number;
  112586. /**
  112587. * This specifies the weight of the reflection at grazing angle.
  112588. */
  112589. reflectionReflectance0: number;
  112590. protected _reflectionReflectance90: number;
  112591. /**
  112592. * This specifies the weight of the reflection at a perpendicular point of view.
  112593. */
  112594. reflectionReflectance90: number;
  112595. /**
  112596. * Sets the reflection reflectance fresnel values according to the default standard
  112597. * empirically know to work well :-)
  112598. */
  112599. reflectionStandardFresnelWeight: number;
  112600. protected _useRGBColor: boolean;
  112601. /**
  112602. * Helps to directly use the maps channels instead of their level.
  112603. */
  112604. useRGBColor: boolean;
  112605. protected _enableNoise: boolean;
  112606. /**
  112607. * This helps reducing the banding effect that could occur on the background.
  112608. */
  112609. enableNoise: boolean;
  112610. /**
  112611. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  112612. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  112613. * Recommended to be keep at 1.0 except for special cases.
  112614. */
  112615. fovMultiplier: number;
  112616. private _fovMultiplier;
  112617. /**
  112618. * Enable the FOV adjustment feature controlled by fovMultiplier.
  112619. */
  112620. useEquirectangularFOV: boolean;
  112621. private _maxSimultaneousLights;
  112622. /**
  112623. * Number of Simultaneous lights allowed on the material.
  112624. */
  112625. maxSimultaneousLights: int;
  112626. /**
  112627. * Default configuration related to image processing available in the Background Material.
  112628. */
  112629. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  112630. /**
  112631. * Keep track of the image processing observer to allow dispose and replace.
  112632. */
  112633. private _imageProcessingObserver;
  112634. /**
  112635. * Attaches a new image processing configuration to the PBR Material.
  112636. * @param configuration (if null the scene configuration will be use)
  112637. */
  112638. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  112639. /**
  112640. * Gets the image processing configuration used either in this material.
  112641. */
  112642. /**
  112643. * Sets the Default image processing configuration used either in the this material.
  112644. *
  112645. * If sets to null, the scene one is in use.
  112646. */
  112647. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  112648. /**
  112649. * Gets wether the color curves effect is enabled.
  112650. */
  112651. /**
  112652. * Sets wether the color curves effect is enabled.
  112653. */
  112654. cameraColorCurvesEnabled: boolean;
  112655. /**
  112656. * Gets wether the color grading effect is enabled.
  112657. */
  112658. /**
  112659. * Gets wether the color grading effect is enabled.
  112660. */
  112661. cameraColorGradingEnabled: boolean;
  112662. /**
  112663. * Gets wether tonemapping is enabled or not.
  112664. */
  112665. /**
  112666. * Sets wether tonemapping is enabled or not
  112667. */
  112668. cameraToneMappingEnabled: boolean;
  112669. /**
  112670. * The camera exposure used on this material.
  112671. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112672. * This corresponds to a photographic exposure.
  112673. */
  112674. /**
  112675. * The camera exposure used on this material.
  112676. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  112677. * This corresponds to a photographic exposure.
  112678. */
  112679. cameraExposure: float;
  112680. /**
  112681. * Gets The camera contrast used on this material.
  112682. */
  112683. /**
  112684. * Sets The camera contrast used on this material.
  112685. */
  112686. cameraContrast: float;
  112687. /**
  112688. * Gets the Color Grading 2D Lookup Texture.
  112689. */
  112690. /**
  112691. * Sets the Color Grading 2D Lookup Texture.
  112692. */
  112693. cameraColorGradingTexture: Nullable<BaseTexture>;
  112694. /**
  112695. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112696. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112697. * 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;
  112698. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112699. */
  112700. /**
  112701. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  112702. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  112703. * 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;
  112704. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  112705. */
  112706. cameraColorCurves: Nullable<ColorCurves>;
  112707. /**
  112708. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  112709. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  112710. */
  112711. switchToBGR: boolean;
  112712. private _renderTargets;
  112713. private _reflectionControls;
  112714. private _white;
  112715. private _primaryShadowColor;
  112716. private _primaryHighlightColor;
  112717. /**
  112718. * Instantiates a Background Material in the given scene
  112719. * @param name The friendly name of the material
  112720. * @param scene The scene to add the material to
  112721. */
  112722. constructor(name: string, scene: Scene);
  112723. /**
  112724. * Gets a boolean indicating that current material needs to register RTT
  112725. */
  112726. readonly hasRenderTargetTextures: boolean;
  112727. /**
  112728. * The entire material has been created in order to prevent overdraw.
  112729. * @returns false
  112730. */
  112731. needAlphaTesting(): boolean;
  112732. /**
  112733. * The entire material has been created in order to prevent overdraw.
  112734. * @returns true if blending is enable
  112735. */
  112736. needAlphaBlending(): boolean;
  112737. /**
  112738. * Checks wether the material is ready to be rendered for a given mesh.
  112739. * @param mesh The mesh to render
  112740. * @param subMesh The submesh to check against
  112741. * @param useInstances Specify wether or not the material is used with instances
  112742. * @returns true if all the dependencies are ready (Textures, Effects...)
  112743. */
  112744. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  112745. /**
  112746. * Compute the primary color according to the chosen perceptual color.
  112747. */
  112748. private _computePrimaryColorFromPerceptualColor;
  112749. /**
  112750. * Compute the highlights and shadow colors according to their chosen levels.
  112751. */
  112752. private _computePrimaryColors;
  112753. /**
  112754. * Build the uniform buffer used in the material.
  112755. */
  112756. buildUniformLayout(): void;
  112757. /**
  112758. * Unbind the material.
  112759. */
  112760. unbind(): void;
  112761. /**
  112762. * Bind only the world matrix to the material.
  112763. * @param world The world matrix to bind.
  112764. */
  112765. bindOnlyWorldMatrix(world: Matrix): void;
  112766. /**
  112767. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  112768. * @param world The world matrix to bind.
  112769. * @param subMesh The submesh to bind for.
  112770. */
  112771. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  112772. /**
  112773. * Checks to see if a texture is used in the material.
  112774. * @param texture - Base texture to use.
  112775. * @returns - Boolean specifying if a texture is used in the material.
  112776. */
  112777. hasTexture(texture: BaseTexture): boolean;
  112778. /**
  112779. * Dispose the material.
  112780. * @param forceDisposeEffect Force disposal of the associated effect.
  112781. * @param forceDisposeTextures Force disposal of the associated textures.
  112782. */
  112783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  112784. /**
  112785. * Clones the material.
  112786. * @param name The cloned name.
  112787. * @returns The cloned material.
  112788. */
  112789. clone(name: string): BackgroundMaterial;
  112790. /**
  112791. * Serializes the current material to its JSON representation.
  112792. * @returns The JSON representation.
  112793. */
  112794. serialize(): any;
  112795. /**
  112796. * Gets the class name of the material
  112797. * @returns "BackgroundMaterial"
  112798. */
  112799. getClassName(): string;
  112800. /**
  112801. * Parse a JSON input to create back a background material.
  112802. * @param source The JSON data to parse
  112803. * @param scene The scene to create the parsed material in
  112804. * @param rootUrl The root url of the assets the material depends upon
  112805. * @returns the instantiated BackgroundMaterial.
  112806. */
  112807. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  112808. }
  112809. }
  112810. declare module BABYLON {
  112811. /**
  112812. * Represents the different options available during the creation of
  112813. * a Environment helper.
  112814. *
  112815. * This can control the default ground, skybox and image processing setup of your scene.
  112816. */
  112817. export interface IEnvironmentHelperOptions {
  112818. /**
  112819. * Specifies wether or not to create a ground.
  112820. * True by default.
  112821. */
  112822. createGround: boolean;
  112823. /**
  112824. * Specifies the ground size.
  112825. * 15 by default.
  112826. */
  112827. groundSize: number;
  112828. /**
  112829. * The texture used on the ground for the main color.
  112830. * Comes from the BabylonJS CDN by default.
  112831. *
  112832. * Remarks: Can be either a texture or a url.
  112833. */
  112834. groundTexture: string | BaseTexture;
  112835. /**
  112836. * The color mixed in the ground texture by default.
  112837. * BabylonJS clearColor by default.
  112838. */
  112839. groundColor: Color3;
  112840. /**
  112841. * Specifies the ground opacity.
  112842. * 1 by default.
  112843. */
  112844. groundOpacity: number;
  112845. /**
  112846. * Enables the ground to receive shadows.
  112847. * True by default.
  112848. */
  112849. enableGroundShadow: boolean;
  112850. /**
  112851. * Helps preventing the shadow to be fully black on the ground.
  112852. * 0.5 by default.
  112853. */
  112854. groundShadowLevel: number;
  112855. /**
  112856. * Creates a mirror texture attach to the ground.
  112857. * false by default.
  112858. */
  112859. enableGroundMirror: boolean;
  112860. /**
  112861. * Specifies the ground mirror size ratio.
  112862. * 0.3 by default as the default kernel is 64.
  112863. */
  112864. groundMirrorSizeRatio: number;
  112865. /**
  112866. * Specifies the ground mirror blur kernel size.
  112867. * 64 by default.
  112868. */
  112869. groundMirrorBlurKernel: number;
  112870. /**
  112871. * Specifies the ground mirror visibility amount.
  112872. * 1 by default
  112873. */
  112874. groundMirrorAmount: number;
  112875. /**
  112876. * Specifies the ground mirror reflectance weight.
  112877. * This uses the standard weight of the background material to setup the fresnel effect
  112878. * of the mirror.
  112879. * 1 by default.
  112880. */
  112881. groundMirrorFresnelWeight: number;
  112882. /**
  112883. * Specifies the ground mirror Falloff distance.
  112884. * This can helps reducing the size of the reflection.
  112885. * 0 by Default.
  112886. */
  112887. groundMirrorFallOffDistance: number;
  112888. /**
  112889. * Specifies the ground mirror texture type.
  112890. * Unsigned Int by Default.
  112891. */
  112892. groundMirrorTextureType: number;
  112893. /**
  112894. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  112895. * the shown objects.
  112896. */
  112897. groundYBias: number;
  112898. /**
  112899. * Specifies wether or not to create a skybox.
  112900. * True by default.
  112901. */
  112902. createSkybox: boolean;
  112903. /**
  112904. * Specifies the skybox size.
  112905. * 20 by default.
  112906. */
  112907. skyboxSize: number;
  112908. /**
  112909. * The texture used on the skybox for the main color.
  112910. * Comes from the BabylonJS CDN by default.
  112911. *
  112912. * Remarks: Can be either a texture or a url.
  112913. */
  112914. skyboxTexture: string | BaseTexture;
  112915. /**
  112916. * The color mixed in the skybox texture by default.
  112917. * BabylonJS clearColor by default.
  112918. */
  112919. skyboxColor: Color3;
  112920. /**
  112921. * The background rotation around the Y axis of the scene.
  112922. * This helps aligning the key lights of your scene with the background.
  112923. * 0 by default.
  112924. */
  112925. backgroundYRotation: number;
  112926. /**
  112927. * Compute automatically the size of the elements to best fit with the scene.
  112928. */
  112929. sizeAuto: boolean;
  112930. /**
  112931. * Default position of the rootMesh if autoSize is not true.
  112932. */
  112933. rootPosition: Vector3;
  112934. /**
  112935. * Sets up the image processing in the scene.
  112936. * true by default.
  112937. */
  112938. setupImageProcessing: boolean;
  112939. /**
  112940. * The texture used as your environment texture in the scene.
  112941. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  112942. *
  112943. * Remarks: Can be either a texture or a url.
  112944. */
  112945. environmentTexture: string | BaseTexture;
  112946. /**
  112947. * The value of the exposure to apply to the scene.
  112948. * 0.6 by default if setupImageProcessing is true.
  112949. */
  112950. cameraExposure: number;
  112951. /**
  112952. * The value of the contrast to apply to the scene.
  112953. * 1.6 by default if setupImageProcessing is true.
  112954. */
  112955. cameraContrast: number;
  112956. /**
  112957. * Specifies wether or not tonemapping should be enabled in the scene.
  112958. * true by default if setupImageProcessing is true.
  112959. */
  112960. toneMappingEnabled: boolean;
  112961. }
  112962. /**
  112963. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  112964. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  112965. * It also helps with the default setup of your imageProcessing configuration.
  112966. */
  112967. export class EnvironmentHelper {
  112968. /**
  112969. * Default ground texture URL.
  112970. */
  112971. private static _groundTextureCDNUrl;
  112972. /**
  112973. * Default skybox texture URL.
  112974. */
  112975. private static _skyboxTextureCDNUrl;
  112976. /**
  112977. * Default environment texture URL.
  112978. */
  112979. private static _environmentTextureCDNUrl;
  112980. /**
  112981. * Creates the default options for the helper.
  112982. */
  112983. private static _getDefaultOptions;
  112984. private _rootMesh;
  112985. /**
  112986. * Gets the root mesh created by the helper.
  112987. */
  112988. readonly rootMesh: Mesh;
  112989. private _skybox;
  112990. /**
  112991. * Gets the skybox created by the helper.
  112992. */
  112993. readonly skybox: Nullable<Mesh>;
  112994. private _skyboxTexture;
  112995. /**
  112996. * Gets the skybox texture created by the helper.
  112997. */
  112998. readonly skyboxTexture: Nullable<BaseTexture>;
  112999. private _skyboxMaterial;
  113000. /**
  113001. * Gets the skybox material created by the helper.
  113002. */
  113003. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  113004. private _ground;
  113005. /**
  113006. * Gets the ground mesh created by the helper.
  113007. */
  113008. readonly ground: Nullable<Mesh>;
  113009. private _groundTexture;
  113010. /**
  113011. * Gets the ground texture created by the helper.
  113012. */
  113013. readonly groundTexture: Nullable<BaseTexture>;
  113014. private _groundMirror;
  113015. /**
  113016. * Gets the ground mirror created by the helper.
  113017. */
  113018. readonly groundMirror: Nullable<MirrorTexture>;
  113019. /**
  113020. * Gets the ground mirror render list to helps pushing the meshes
  113021. * you wish in the ground reflection.
  113022. */
  113023. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  113024. private _groundMaterial;
  113025. /**
  113026. * Gets the ground material created by the helper.
  113027. */
  113028. readonly groundMaterial: Nullable<BackgroundMaterial>;
  113029. /**
  113030. * Stores the creation options.
  113031. */
  113032. private readonly _scene;
  113033. private _options;
  113034. /**
  113035. * This observable will be notified with any error during the creation of the environment,
  113036. * mainly texture creation errors.
  113037. */
  113038. onErrorObservable: Observable<{
  113039. message?: string;
  113040. exception?: any;
  113041. }>;
  113042. /**
  113043. * constructor
  113044. * @param options Defines the options we want to customize the helper
  113045. * @param scene The scene to add the material to
  113046. */
  113047. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  113048. /**
  113049. * Updates the background according to the new options
  113050. * @param options
  113051. */
  113052. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  113053. /**
  113054. * Sets the primary color of all the available elements.
  113055. * @param color the main color to affect to the ground and the background
  113056. */
  113057. setMainColor(color: Color3): void;
  113058. /**
  113059. * Setup the image processing according to the specified options.
  113060. */
  113061. private _setupImageProcessing;
  113062. /**
  113063. * Setup the environment texture according to the specified options.
  113064. */
  113065. private _setupEnvironmentTexture;
  113066. /**
  113067. * Setup the background according to the specified options.
  113068. */
  113069. private _setupBackground;
  113070. /**
  113071. * Get the scene sizes according to the setup.
  113072. */
  113073. private _getSceneSize;
  113074. /**
  113075. * Setup the ground according to the specified options.
  113076. */
  113077. private _setupGround;
  113078. /**
  113079. * Setup the ground material according to the specified options.
  113080. */
  113081. private _setupGroundMaterial;
  113082. /**
  113083. * Setup the ground diffuse texture according to the specified options.
  113084. */
  113085. private _setupGroundDiffuseTexture;
  113086. /**
  113087. * Setup the ground mirror texture according to the specified options.
  113088. */
  113089. private _setupGroundMirrorTexture;
  113090. /**
  113091. * Setup the ground to receive the mirror texture.
  113092. */
  113093. private _setupMirrorInGroundMaterial;
  113094. /**
  113095. * Setup the skybox according to the specified options.
  113096. */
  113097. private _setupSkybox;
  113098. /**
  113099. * Setup the skybox material according to the specified options.
  113100. */
  113101. private _setupSkyboxMaterial;
  113102. /**
  113103. * Setup the skybox reflection texture according to the specified options.
  113104. */
  113105. private _setupSkyboxReflectionTexture;
  113106. private _errorHandler;
  113107. /**
  113108. * Dispose all the elements created by the Helper.
  113109. */
  113110. dispose(): void;
  113111. }
  113112. }
  113113. declare module BABYLON {
  113114. /**
  113115. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  113116. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  113117. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  113118. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  113119. */
  113120. export class PhotoDome extends TransformNode {
  113121. /**
  113122. * Define the image as a Monoscopic panoramic 360 image.
  113123. */
  113124. static readonly MODE_MONOSCOPIC: number;
  113125. /**
  113126. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113127. */
  113128. static readonly MODE_TOPBOTTOM: number;
  113129. /**
  113130. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113131. */
  113132. static readonly MODE_SIDEBYSIDE: number;
  113133. private _useDirectMapping;
  113134. /**
  113135. * The texture being displayed on the sphere
  113136. */
  113137. protected _photoTexture: Texture;
  113138. /**
  113139. * Gets or sets the texture being displayed on the sphere
  113140. */
  113141. photoTexture: Texture;
  113142. /**
  113143. * Observable raised when an error occured while loading the 360 image
  113144. */
  113145. onLoadErrorObservable: Observable<string>;
  113146. /**
  113147. * The skybox material
  113148. */
  113149. protected _material: BackgroundMaterial;
  113150. /**
  113151. * The surface used for the skybox
  113152. */
  113153. protected _mesh: Mesh;
  113154. /**
  113155. * Gets the mesh used for the skybox.
  113156. */
  113157. readonly mesh: Mesh;
  113158. /**
  113159. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  113160. * Also see the options.resolution property.
  113161. */
  113162. fovMultiplier: number;
  113163. private _imageMode;
  113164. /**
  113165. * Gets or set the current video mode for the video. It can be:
  113166. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  113167. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  113168. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  113169. */
  113170. imageMode: number;
  113171. /**
  113172. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  113173. * @param name Element's name, child elements will append suffixes for their own names.
  113174. * @param urlsOfPhoto defines the url of the photo to display
  113175. * @param options defines an object containing optional or exposed sub element properties
  113176. * @param onError defines a callback called when an error occured while loading the texture
  113177. */
  113178. constructor(name: string, urlOfPhoto: string, options: {
  113179. resolution?: number;
  113180. size?: number;
  113181. useDirectMapping?: boolean;
  113182. faceForward?: boolean;
  113183. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  113184. private _onBeforeCameraRenderObserver;
  113185. private _changeImageMode;
  113186. /**
  113187. * Releases resources associated with this node.
  113188. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113189. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113190. */
  113191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113192. }
  113193. }
  113194. declare module BABYLON {
  113195. /**
  113196. * Class used to host RGBD texture specific utilities
  113197. */
  113198. export class RGBDTextureTools {
  113199. /**
  113200. * Expand the RGBD Texture from RGBD to Half Float if possible.
  113201. * @param texture the texture to expand.
  113202. */
  113203. static ExpandRGBDTexture(texture: Texture): void;
  113204. }
  113205. }
  113206. declare module BABYLON {
  113207. /**
  113208. * Class used to host texture specific utilities
  113209. */
  113210. export class BRDFTextureTools {
  113211. /**
  113212. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  113213. * @param scene defines the hosting scene
  113214. * @returns the environment BRDF texture
  113215. */
  113216. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  113217. private static _environmentBRDFBase64Texture;
  113218. }
  113219. }
  113220. declare module BABYLON {
  113221. /**
  113222. * @hidden
  113223. */
  113224. export interface IMaterialClearCoatDefines {
  113225. CLEARCOAT: boolean;
  113226. CLEARCOAT_DEFAULTIOR: boolean;
  113227. CLEARCOAT_TEXTURE: boolean;
  113228. CLEARCOAT_TEXTUREDIRECTUV: number;
  113229. CLEARCOAT_BUMP: boolean;
  113230. CLEARCOAT_BUMPDIRECTUV: number;
  113231. CLEARCOAT_TINT: boolean;
  113232. CLEARCOAT_TINT_TEXTURE: boolean;
  113233. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  113234. /** @hidden */
  113235. _areTexturesDirty: boolean;
  113236. }
  113237. /**
  113238. * Define the code related to the clear coat parameters of the pbr material.
  113239. */
  113240. export class PBRClearCoatConfiguration {
  113241. /**
  113242. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113243. * The default fits with a polyurethane material.
  113244. */
  113245. private static readonly _DefaultIndexOfRefraction;
  113246. private _isEnabled;
  113247. /**
  113248. * Defines if the clear coat is enabled in the material.
  113249. */
  113250. isEnabled: boolean;
  113251. /**
  113252. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  113253. */
  113254. intensity: number;
  113255. /**
  113256. * Defines the clear coat layer roughness.
  113257. */
  113258. roughness: number;
  113259. private _indexOfRefraction;
  113260. /**
  113261. * Defines the index of refraction of the clear coat.
  113262. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  113263. * The default fits with a polyurethane material.
  113264. * Changing the default value is more performance intensive.
  113265. */
  113266. indexOfRefraction: number;
  113267. private _texture;
  113268. /**
  113269. * Stores the clear coat values in a texture.
  113270. */
  113271. texture: Nullable<BaseTexture>;
  113272. private _bumpTexture;
  113273. /**
  113274. * Define the clear coat specific bump texture.
  113275. */
  113276. bumpTexture: Nullable<BaseTexture>;
  113277. private _isTintEnabled;
  113278. /**
  113279. * Defines if the clear coat tint is enabled in the material.
  113280. */
  113281. isTintEnabled: boolean;
  113282. /**
  113283. * Defines the clear coat tint of the material.
  113284. * This is only use if tint is enabled
  113285. */
  113286. tintColor: Color3;
  113287. /**
  113288. * Defines the distance at which the tint color should be found in the
  113289. * clear coat media.
  113290. * This is only use if tint is enabled
  113291. */
  113292. tintColorAtDistance: number;
  113293. /**
  113294. * Defines the clear coat layer thickness.
  113295. * This is only use if tint is enabled
  113296. */
  113297. tintThickness: number;
  113298. private _tintTexture;
  113299. /**
  113300. * Stores the clear tint values in a texture.
  113301. * rgb is tint
  113302. * a is a thickness factor
  113303. */
  113304. tintTexture: Nullable<BaseTexture>;
  113305. /** @hidden */
  113306. private _internalMarkAllSubMeshesAsTexturesDirty;
  113307. /** @hidden */
  113308. _markAllSubMeshesAsTexturesDirty(): void;
  113309. /**
  113310. * Instantiate a new istance of clear coat configuration.
  113311. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113312. */
  113313. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113314. /**
  113315. * Gets wehter the submesh is ready to be used or not.
  113316. * @param defines the list of "defines" to update.
  113317. * @param scene defines the scene the material belongs to.
  113318. * @param engine defines the engine the material belongs to.
  113319. * @param disableBumpMap defines wether the material disables bump or not.
  113320. * @returns - boolean indicating that the submesh is ready or not.
  113321. */
  113322. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  113323. /**
  113324. * Checks to see if a texture is used in the material.
  113325. * @param defines the list of "defines" to update.
  113326. * @param scene defines the scene to the material belongs to.
  113327. */
  113328. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  113329. /**
  113330. * Binds the material data.
  113331. * @param uniformBuffer defines the Uniform buffer to fill in.
  113332. * @param scene defines the scene the material belongs to.
  113333. * @param engine defines the engine the material belongs to.
  113334. * @param disableBumpMap defines wether the material disables bump or not.
  113335. * @param isFrozen defines wether the material is frozen or not.
  113336. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  113337. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  113338. */
  113339. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  113340. /**
  113341. * Checks to see if a texture is used in the material.
  113342. * @param texture - Base texture to use.
  113343. * @returns - Boolean specifying if a texture is used in the material.
  113344. */
  113345. hasTexture(texture: BaseTexture): boolean;
  113346. /**
  113347. * Returns an array of the actively used textures.
  113348. * @param activeTextures Array of BaseTextures
  113349. */
  113350. getActiveTextures(activeTextures: BaseTexture[]): void;
  113351. /**
  113352. * Returns the animatable textures.
  113353. * @param animatables Array of animatable textures.
  113354. */
  113355. getAnimatables(animatables: IAnimatable[]): void;
  113356. /**
  113357. * Disposes the resources of the material.
  113358. * @param forceDisposeTextures - Forces the disposal of all textures.
  113359. */
  113360. dispose(forceDisposeTextures?: boolean): void;
  113361. /**
  113362. * Get the current class name of the texture useful for serialization or dynamic coding.
  113363. * @returns "PBRClearCoatConfiguration"
  113364. */
  113365. getClassName(): string;
  113366. /**
  113367. * Add fallbacks to the effect fallbacks list.
  113368. * @param defines defines the Base texture to use.
  113369. * @param fallbacks defines the current fallback list.
  113370. * @param currentRank defines the current fallback rank.
  113371. * @returns the new fallback rank.
  113372. */
  113373. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113374. /**
  113375. * Add the required uniforms to the current list.
  113376. * @param uniforms defines the current uniform list.
  113377. */
  113378. static AddUniforms(uniforms: string[]): void;
  113379. /**
  113380. * Add the required samplers to the current list.
  113381. * @param samplers defines the current sampler list.
  113382. */
  113383. static AddSamplers(samplers: string[]): void;
  113384. /**
  113385. * Add the required uniforms to the current buffer.
  113386. * @param uniformBuffer defines the current uniform buffer.
  113387. */
  113388. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113389. /**
  113390. * Makes a duplicate of the current configuration into another one.
  113391. * @param clearCoatConfiguration define the config where to copy the info
  113392. */
  113393. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  113394. /**
  113395. * Serializes this clear coat configuration.
  113396. * @returns - An object with the serialized config.
  113397. */
  113398. serialize(): any;
  113399. /**
  113400. * Parses a anisotropy Configuration from a serialized object.
  113401. * @param source - Serialized object.
  113402. * @param scene Defines the scene we are parsing for
  113403. * @param rootUrl Defines the rootUrl to load from
  113404. */
  113405. parse(source: any, scene: Scene, rootUrl: string): void;
  113406. }
  113407. }
  113408. declare module BABYLON {
  113409. /**
  113410. * @hidden
  113411. */
  113412. export interface IMaterialAnisotropicDefines {
  113413. ANISOTROPIC: boolean;
  113414. ANISOTROPIC_TEXTURE: boolean;
  113415. ANISOTROPIC_TEXTUREDIRECTUV: number;
  113416. MAINUV1: boolean;
  113417. _areTexturesDirty: boolean;
  113418. _needUVs: boolean;
  113419. }
  113420. /**
  113421. * Define the code related to the anisotropic parameters of the pbr material.
  113422. */
  113423. export class PBRAnisotropicConfiguration {
  113424. private _isEnabled;
  113425. /**
  113426. * Defines if the anisotropy is enabled in the material.
  113427. */
  113428. isEnabled: boolean;
  113429. /**
  113430. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  113431. */
  113432. intensity: number;
  113433. /**
  113434. * Defines if the effect is along the tangents, bitangents or in between.
  113435. * By default, the effect is "strectching" the highlights along the tangents.
  113436. */
  113437. direction: Vector2;
  113438. private _texture;
  113439. /**
  113440. * Stores the anisotropy values in a texture.
  113441. * rg is direction (like normal from -1 to 1)
  113442. * b is a intensity
  113443. */
  113444. texture: Nullable<BaseTexture>;
  113445. /** @hidden */
  113446. private _internalMarkAllSubMeshesAsTexturesDirty;
  113447. /** @hidden */
  113448. _markAllSubMeshesAsTexturesDirty(): void;
  113449. /**
  113450. * Instantiate a new istance of anisotropy configuration.
  113451. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113452. */
  113453. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113454. /**
  113455. * Specifies that the submesh is ready to be used.
  113456. * @param defines the list of "defines" to update.
  113457. * @param scene defines the scene the material belongs to.
  113458. * @returns - boolean indicating that the submesh is ready or not.
  113459. */
  113460. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  113461. /**
  113462. * Checks to see if a texture is used in the material.
  113463. * @param defines the list of "defines" to update.
  113464. * @param mesh the mesh we are preparing the defines for.
  113465. * @param scene defines the scene the material belongs to.
  113466. */
  113467. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  113468. /**
  113469. * Binds the material data.
  113470. * @param uniformBuffer defines the Uniform buffer to fill in.
  113471. * @param scene defines the scene the material belongs to.
  113472. * @param isFrozen defines wether the material is frozen or not.
  113473. */
  113474. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113475. /**
  113476. * Checks to see if a texture is used in the material.
  113477. * @param texture - Base texture to use.
  113478. * @returns - Boolean specifying if a texture is used in the material.
  113479. */
  113480. hasTexture(texture: BaseTexture): boolean;
  113481. /**
  113482. * Returns an array of the actively used textures.
  113483. * @param activeTextures Array of BaseTextures
  113484. */
  113485. getActiveTextures(activeTextures: BaseTexture[]): void;
  113486. /**
  113487. * Returns the animatable textures.
  113488. * @param animatables Array of animatable textures.
  113489. */
  113490. getAnimatables(animatables: IAnimatable[]): void;
  113491. /**
  113492. * Disposes the resources of the material.
  113493. * @param forceDisposeTextures - Forces the disposal of all textures.
  113494. */
  113495. dispose(forceDisposeTextures?: boolean): void;
  113496. /**
  113497. * Get the current class name of the texture useful for serialization or dynamic coding.
  113498. * @returns "PBRAnisotropicConfiguration"
  113499. */
  113500. getClassName(): string;
  113501. /**
  113502. * Add fallbacks to the effect fallbacks list.
  113503. * @param defines defines the Base texture to use.
  113504. * @param fallbacks defines the current fallback list.
  113505. * @param currentRank defines the current fallback rank.
  113506. * @returns the new fallback rank.
  113507. */
  113508. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113509. /**
  113510. * Add the required uniforms to the current list.
  113511. * @param uniforms defines the current uniform list.
  113512. */
  113513. static AddUniforms(uniforms: string[]): void;
  113514. /**
  113515. * Add the required uniforms to the current buffer.
  113516. * @param uniformBuffer defines the current uniform buffer.
  113517. */
  113518. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113519. /**
  113520. * Add the required samplers to the current list.
  113521. * @param samplers defines the current sampler list.
  113522. */
  113523. static AddSamplers(samplers: string[]): void;
  113524. /**
  113525. * Makes a duplicate of the current configuration into another one.
  113526. * @param anisotropicConfiguration define the config where to copy the info
  113527. */
  113528. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  113529. /**
  113530. * Serializes this anisotropy configuration.
  113531. * @returns - An object with the serialized config.
  113532. */
  113533. serialize(): any;
  113534. /**
  113535. * Parses a anisotropy Configuration from a serialized object.
  113536. * @param source - Serialized object.
  113537. * @param scene Defines the scene we are parsing for
  113538. * @param rootUrl Defines the rootUrl to load from
  113539. */
  113540. parse(source: any, scene: Scene, rootUrl: string): void;
  113541. }
  113542. }
  113543. declare module BABYLON {
  113544. /**
  113545. * @hidden
  113546. */
  113547. export interface IMaterialBRDFDefines {
  113548. BRDF_V_HEIGHT_CORRELATED: boolean;
  113549. MS_BRDF_ENERGY_CONSERVATION: boolean;
  113550. SPHERICAL_HARMONICS: boolean;
  113551. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  113552. /** @hidden */
  113553. _areMiscDirty: boolean;
  113554. }
  113555. /**
  113556. * Define the code related to the BRDF parameters of the pbr material.
  113557. */
  113558. export class PBRBRDFConfiguration {
  113559. /**
  113560. * Default value used for the energy conservation.
  113561. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113562. */
  113563. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  113564. /**
  113565. * Default value used for the Smith Visibility Height Correlated mode.
  113566. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  113567. */
  113568. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  113569. /**
  113570. * Default value used for the IBL diffuse part.
  113571. * This can help switching back to the polynomials mode globally which is a tiny bit
  113572. * less GPU intensive at the drawback of a lower quality.
  113573. */
  113574. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  113575. /**
  113576. * Default value used for activating energy conservation for the specular workflow.
  113577. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113578. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113579. */
  113580. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  113581. private _useEnergyConservation;
  113582. /**
  113583. * Defines if the material uses energy conservation.
  113584. */
  113585. useEnergyConservation: boolean;
  113586. private _useSmithVisibilityHeightCorrelated;
  113587. /**
  113588. * LEGACY Mode set to false
  113589. * Defines if the material uses height smith correlated visibility term.
  113590. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  113591. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  113592. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  113593. * Not relying on height correlated will also disable energy conservation.
  113594. */
  113595. useSmithVisibilityHeightCorrelated: boolean;
  113596. private _useSphericalHarmonics;
  113597. /**
  113598. * LEGACY Mode set to false
  113599. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  113600. * diffuse part of the IBL.
  113601. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  113602. * to the ground truth.
  113603. */
  113604. useSphericalHarmonics: boolean;
  113605. private _useSpecularGlossinessInputEnergyConservation;
  113606. /**
  113607. * Defines if the material uses energy conservation, when the specular workflow is active.
  113608. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  113609. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  113610. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  113611. */
  113612. useSpecularGlossinessInputEnergyConservation: boolean;
  113613. /** @hidden */
  113614. private _internalMarkAllSubMeshesAsMiscDirty;
  113615. /** @hidden */
  113616. _markAllSubMeshesAsMiscDirty(): void;
  113617. /**
  113618. * Instantiate a new istance of clear coat configuration.
  113619. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  113620. */
  113621. constructor(markAllSubMeshesAsMiscDirty: () => void);
  113622. /**
  113623. * Checks to see if a texture is used in the material.
  113624. * @param defines the list of "defines" to update.
  113625. */
  113626. prepareDefines(defines: IMaterialBRDFDefines): void;
  113627. /**
  113628. * Get the current class name of the texture useful for serialization or dynamic coding.
  113629. * @returns "PBRClearCoatConfiguration"
  113630. */
  113631. getClassName(): string;
  113632. /**
  113633. * Makes a duplicate of the current configuration into another one.
  113634. * @param brdfConfiguration define the config where to copy the info
  113635. */
  113636. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  113637. /**
  113638. * Serializes this BRDF configuration.
  113639. * @returns - An object with the serialized config.
  113640. */
  113641. serialize(): any;
  113642. /**
  113643. * Parses a anisotropy Configuration from a serialized object.
  113644. * @param source - Serialized object.
  113645. * @param scene Defines the scene we are parsing for
  113646. * @param rootUrl Defines the rootUrl to load from
  113647. */
  113648. parse(source: any, scene: Scene, rootUrl: string): void;
  113649. }
  113650. }
  113651. declare module BABYLON {
  113652. /**
  113653. * @hidden
  113654. */
  113655. export interface IMaterialSheenDefines {
  113656. SHEEN: boolean;
  113657. SHEEN_TEXTURE: boolean;
  113658. SHEEN_TEXTUREDIRECTUV: number;
  113659. SHEEN_LINKWITHALBEDO: boolean;
  113660. /** @hidden */
  113661. _areTexturesDirty: boolean;
  113662. }
  113663. /**
  113664. * Define the code related to the Sheen parameters of the pbr material.
  113665. */
  113666. export class PBRSheenConfiguration {
  113667. private _isEnabled;
  113668. /**
  113669. * Defines if the material uses sheen.
  113670. */
  113671. isEnabled: boolean;
  113672. private _linkSheenWithAlbedo;
  113673. /**
  113674. * Defines if the sheen is linked to the sheen color.
  113675. */
  113676. linkSheenWithAlbedo: boolean;
  113677. /**
  113678. * Defines the sheen intensity.
  113679. */
  113680. intensity: number;
  113681. /**
  113682. * Defines the sheen color.
  113683. */
  113684. color: Color3;
  113685. private _texture;
  113686. /**
  113687. * Stores the sheen tint values in a texture.
  113688. * rgb is tint
  113689. * a is a intensity
  113690. */
  113691. texture: Nullable<BaseTexture>;
  113692. /** @hidden */
  113693. private _internalMarkAllSubMeshesAsTexturesDirty;
  113694. /** @hidden */
  113695. _markAllSubMeshesAsTexturesDirty(): void;
  113696. /**
  113697. * Instantiate a new istance of clear coat configuration.
  113698. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113699. */
  113700. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113701. /**
  113702. * Specifies that the submesh is ready to be used.
  113703. * @param defines the list of "defines" to update.
  113704. * @param scene defines the scene the material belongs to.
  113705. * @returns - boolean indicating that the submesh is ready or not.
  113706. */
  113707. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  113708. /**
  113709. * Checks to see if a texture is used in the material.
  113710. * @param defines the list of "defines" to update.
  113711. * @param scene defines the scene the material belongs to.
  113712. */
  113713. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  113714. /**
  113715. * Binds the material data.
  113716. * @param uniformBuffer defines the Uniform buffer to fill in.
  113717. * @param scene defines the scene the material belongs to.
  113718. * @param isFrozen defines wether the material is frozen or not.
  113719. */
  113720. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  113721. /**
  113722. * Checks to see if a texture is used in the material.
  113723. * @param texture - Base texture to use.
  113724. * @returns - Boolean specifying if a texture is used in the material.
  113725. */
  113726. hasTexture(texture: BaseTexture): boolean;
  113727. /**
  113728. * Returns an array of the actively used textures.
  113729. * @param activeTextures Array of BaseTextures
  113730. */
  113731. getActiveTextures(activeTextures: BaseTexture[]): void;
  113732. /**
  113733. * Returns the animatable textures.
  113734. * @param animatables Array of animatable textures.
  113735. */
  113736. getAnimatables(animatables: IAnimatable[]): void;
  113737. /**
  113738. * Disposes the resources of the material.
  113739. * @param forceDisposeTextures - Forces the disposal of all textures.
  113740. */
  113741. dispose(forceDisposeTextures?: boolean): void;
  113742. /**
  113743. * Get the current class name of the texture useful for serialization or dynamic coding.
  113744. * @returns "PBRSheenConfiguration"
  113745. */
  113746. getClassName(): string;
  113747. /**
  113748. * Add fallbacks to the effect fallbacks list.
  113749. * @param defines defines the Base texture to use.
  113750. * @param fallbacks defines the current fallback list.
  113751. * @param currentRank defines the current fallback rank.
  113752. * @returns the new fallback rank.
  113753. */
  113754. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113755. /**
  113756. * Add the required uniforms to the current list.
  113757. * @param uniforms defines the current uniform list.
  113758. */
  113759. static AddUniforms(uniforms: string[]): void;
  113760. /**
  113761. * Add the required uniforms to the current buffer.
  113762. * @param uniformBuffer defines the current uniform buffer.
  113763. */
  113764. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  113765. /**
  113766. * Add the required samplers to the current list.
  113767. * @param samplers defines the current sampler list.
  113768. */
  113769. static AddSamplers(samplers: string[]): void;
  113770. /**
  113771. * Makes a duplicate of the current configuration into another one.
  113772. * @param sheenConfiguration define the config where to copy the info
  113773. */
  113774. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  113775. /**
  113776. * Serializes this BRDF configuration.
  113777. * @returns - An object with the serialized config.
  113778. */
  113779. serialize(): any;
  113780. /**
  113781. * Parses a anisotropy Configuration from a serialized object.
  113782. * @param source - Serialized object.
  113783. * @param scene Defines the scene we are parsing for
  113784. * @param rootUrl Defines the rootUrl to load from
  113785. */
  113786. parse(source: any, scene: Scene, rootUrl: string): void;
  113787. }
  113788. }
  113789. declare module BABYLON {
  113790. /**
  113791. * @hidden
  113792. */
  113793. export interface IMaterialSubSurfaceDefines {
  113794. SUBSURFACE: boolean;
  113795. SS_REFRACTION: boolean;
  113796. SS_TRANSLUCENCY: boolean;
  113797. SS_SCATERRING: boolean;
  113798. SS_THICKNESSANDMASK_TEXTURE: boolean;
  113799. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  113800. SS_REFRACTIONMAP_3D: boolean;
  113801. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  113802. SS_LODINREFRACTIONALPHA: boolean;
  113803. SS_GAMMAREFRACTION: boolean;
  113804. SS_RGBDREFRACTION: boolean;
  113805. SS_LINEARSPECULARREFRACTION: boolean;
  113806. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  113807. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  113808. /** @hidden */
  113809. _areTexturesDirty: boolean;
  113810. }
  113811. /**
  113812. * Define the code related to the sub surface parameters of the pbr material.
  113813. */
  113814. export class PBRSubSurfaceConfiguration {
  113815. private _isRefractionEnabled;
  113816. /**
  113817. * Defines if the refraction is enabled in the material.
  113818. */
  113819. isRefractionEnabled: boolean;
  113820. private _isTranslucencyEnabled;
  113821. /**
  113822. * Defines if the translucency is enabled in the material.
  113823. */
  113824. isTranslucencyEnabled: boolean;
  113825. private _isScatteringEnabled;
  113826. /**
  113827. * Defines the refraction intensity of the material.
  113828. * The refraction when enabled replaces the Diffuse part of the material.
  113829. * The intensity helps transitionning between diffuse and refraction.
  113830. */
  113831. refractionIntensity: number;
  113832. /**
  113833. * Defines the translucency intensity of the material.
  113834. * When translucency has been enabled, this defines how much of the "translucency"
  113835. * is addded to the diffuse part of the material.
  113836. */
  113837. translucencyIntensity: number;
  113838. /**
  113839. * Defines the scattering intensity of the material.
  113840. * When scattering has been enabled, this defines how much of the "scattered light"
  113841. * is addded to the diffuse part of the material.
  113842. */
  113843. scatteringIntensity: number;
  113844. private _thicknessTexture;
  113845. /**
  113846. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  113847. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  113848. * 0 would mean minimumThickness
  113849. * 1 would mean maximumThickness
  113850. * The other channels might be use as a mask to vary the different effects intensity.
  113851. */
  113852. thicknessTexture: Nullable<BaseTexture>;
  113853. private _refractionTexture;
  113854. /**
  113855. * Defines the texture to use for refraction.
  113856. */
  113857. refractionTexture: Nullable<BaseTexture>;
  113858. private _indexOfRefraction;
  113859. /**
  113860. * Defines the index of refraction used in the material.
  113861. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  113862. */
  113863. indexOfRefraction: number;
  113864. private _invertRefractionY;
  113865. /**
  113866. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  113867. */
  113868. invertRefractionY: boolean;
  113869. private _linkRefractionWithTransparency;
  113870. /**
  113871. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  113872. * Materials half opaque for instance using refraction could benefit from this control.
  113873. */
  113874. linkRefractionWithTransparency: boolean;
  113875. /**
  113876. * Defines the minimum thickness stored in the thickness map.
  113877. * If no thickness map is defined, this value will be used to simulate thickness.
  113878. */
  113879. minimumThickness: number;
  113880. /**
  113881. * Defines the maximum thickness stored in the thickness map.
  113882. */
  113883. maximumThickness: number;
  113884. /**
  113885. * Defines the volume tint of the material.
  113886. * This is used for both translucency and scattering.
  113887. */
  113888. tintColor: Color3;
  113889. /**
  113890. * Defines the distance at which the tint color should be found in the media.
  113891. * This is used for refraction only.
  113892. */
  113893. tintColorAtDistance: number;
  113894. /**
  113895. * Defines how far each channel transmit through the media.
  113896. * It is defined as a color to simplify it selection.
  113897. */
  113898. diffusionDistance: Color3;
  113899. private _useMaskFromThicknessTexture;
  113900. /**
  113901. * Stores the intensity of the different subsurface effects in the thickness texture.
  113902. * * the green channel is the translucency intensity.
  113903. * * the blue channel is the scattering intensity.
  113904. * * the alpha channel is the refraction intensity.
  113905. */
  113906. useMaskFromThicknessTexture: boolean;
  113907. /** @hidden */
  113908. private _internalMarkAllSubMeshesAsTexturesDirty;
  113909. /** @hidden */
  113910. _markAllSubMeshesAsTexturesDirty(): void;
  113911. /**
  113912. * Instantiate a new istance of sub surface configuration.
  113913. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  113914. */
  113915. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  113916. /**
  113917. * Gets wehter the submesh is ready to be used or not.
  113918. * @param defines the list of "defines" to update.
  113919. * @param scene defines the scene the material belongs to.
  113920. * @returns - boolean indicating that the submesh is ready or not.
  113921. */
  113922. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  113923. /**
  113924. * Checks to see if a texture is used in the material.
  113925. * @param defines the list of "defines" to update.
  113926. * @param scene defines the scene to the material belongs to.
  113927. */
  113928. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  113929. /**
  113930. * Binds the material data.
  113931. * @param uniformBuffer defines the Uniform buffer to fill in.
  113932. * @param scene defines the scene the material belongs to.
  113933. * @param engine defines the engine the material belongs to.
  113934. * @param isFrozen defines wether the material is frozen or not.
  113935. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  113936. */
  113937. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  113938. /**
  113939. * Unbinds the material from the mesh.
  113940. * @param activeEffect defines the effect that should be unbound from.
  113941. * @returns true if unbound, otherwise false
  113942. */
  113943. unbind(activeEffect: Effect): boolean;
  113944. /**
  113945. * Returns the texture used for refraction or null if none is used.
  113946. * @param scene defines the scene the material belongs to.
  113947. * @returns - Refraction texture if present. If no refraction texture and refraction
  113948. * is linked with transparency, returns environment texture. Otherwise, returns null.
  113949. */
  113950. private _getRefractionTexture;
  113951. /**
  113952. * Returns true if alpha blending should be disabled.
  113953. */
  113954. readonly disableAlphaBlending: boolean;
  113955. /**
  113956. * Fills the list of render target textures.
  113957. * @param renderTargets the list of render targets to update
  113958. */
  113959. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  113960. /**
  113961. * Checks to see if a texture is used in the material.
  113962. * @param texture - Base texture to use.
  113963. * @returns - Boolean specifying if a texture is used in the material.
  113964. */
  113965. hasTexture(texture: BaseTexture): boolean;
  113966. /**
  113967. * Gets a boolean indicating that current material needs to register RTT
  113968. * @returns true if this uses a render target otherwise false.
  113969. */
  113970. hasRenderTargetTextures(): boolean;
  113971. /**
  113972. * Returns an array of the actively used textures.
  113973. * @param activeTextures Array of BaseTextures
  113974. */
  113975. getActiveTextures(activeTextures: BaseTexture[]): void;
  113976. /**
  113977. * Returns the animatable textures.
  113978. * @param animatables Array of animatable textures.
  113979. */
  113980. getAnimatables(animatables: IAnimatable[]): void;
  113981. /**
  113982. * Disposes the resources of the material.
  113983. * @param forceDisposeTextures - Forces the disposal of all textures.
  113984. */
  113985. dispose(forceDisposeTextures?: boolean): void;
  113986. /**
  113987. * Get the current class name of the texture useful for serialization or dynamic coding.
  113988. * @returns "PBRSubSurfaceConfiguration"
  113989. */
  113990. getClassName(): string;
  113991. /**
  113992. * Add fallbacks to the effect fallbacks list.
  113993. * @param defines defines the Base texture to use.
  113994. * @param fallbacks defines the current fallback list.
  113995. * @param currentRank defines the current fallback rank.
  113996. * @returns the new fallback rank.
  113997. */
  113998. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  113999. /**
  114000. * Add the required uniforms to the current list.
  114001. * @param uniforms defines the current uniform list.
  114002. */
  114003. static AddUniforms(uniforms: string[]): void;
  114004. /**
  114005. * Add the required samplers to the current list.
  114006. * @param samplers defines the current sampler list.
  114007. */
  114008. static AddSamplers(samplers: string[]): void;
  114009. /**
  114010. * Add the required uniforms to the current buffer.
  114011. * @param uniformBuffer defines the current uniform buffer.
  114012. */
  114013. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  114014. /**
  114015. * Makes a duplicate of the current configuration into another one.
  114016. * @param configuration define the config where to copy the info
  114017. */
  114018. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  114019. /**
  114020. * Serializes this Sub Surface configuration.
  114021. * @returns - An object with the serialized config.
  114022. */
  114023. serialize(): any;
  114024. /**
  114025. * Parses a anisotropy Configuration from a serialized object.
  114026. * @param source - Serialized object.
  114027. * @param scene Defines the scene we are parsing for
  114028. * @param rootUrl Defines the rootUrl to load from
  114029. */
  114030. parse(source: any, scene: Scene, rootUrl: string): void;
  114031. }
  114032. }
  114033. declare module BABYLON {
  114034. /** @hidden */
  114035. export var pbrFragmentDeclaration: {
  114036. name: string;
  114037. shader: string;
  114038. };
  114039. }
  114040. declare module BABYLON {
  114041. /** @hidden */
  114042. export var pbrUboDeclaration: {
  114043. name: string;
  114044. shader: string;
  114045. };
  114046. }
  114047. declare module BABYLON {
  114048. /** @hidden */
  114049. export var pbrFragmentExtraDeclaration: {
  114050. name: string;
  114051. shader: string;
  114052. };
  114053. }
  114054. declare module BABYLON {
  114055. /** @hidden */
  114056. export var pbrFragmentSamplersDeclaration: {
  114057. name: string;
  114058. shader: string;
  114059. };
  114060. }
  114061. declare module BABYLON {
  114062. /** @hidden */
  114063. export var pbrHelperFunctions: {
  114064. name: string;
  114065. shader: string;
  114066. };
  114067. }
  114068. declare module BABYLON {
  114069. /** @hidden */
  114070. export var harmonicsFunctions: {
  114071. name: string;
  114072. shader: string;
  114073. };
  114074. }
  114075. declare module BABYLON {
  114076. /** @hidden */
  114077. export var pbrDirectLightingSetupFunctions: {
  114078. name: string;
  114079. shader: string;
  114080. };
  114081. }
  114082. declare module BABYLON {
  114083. /** @hidden */
  114084. export var pbrDirectLightingFalloffFunctions: {
  114085. name: string;
  114086. shader: string;
  114087. };
  114088. }
  114089. declare module BABYLON {
  114090. /** @hidden */
  114091. export var pbrBRDFFunctions: {
  114092. name: string;
  114093. shader: string;
  114094. };
  114095. }
  114096. declare module BABYLON {
  114097. /** @hidden */
  114098. export var pbrDirectLightingFunctions: {
  114099. name: string;
  114100. shader: string;
  114101. };
  114102. }
  114103. declare module BABYLON {
  114104. /** @hidden */
  114105. export var pbrIBLFunctions: {
  114106. name: string;
  114107. shader: string;
  114108. };
  114109. }
  114110. declare module BABYLON {
  114111. /** @hidden */
  114112. export var pbrDebug: {
  114113. name: string;
  114114. shader: string;
  114115. };
  114116. }
  114117. declare module BABYLON {
  114118. /** @hidden */
  114119. export var pbrPixelShader: {
  114120. name: string;
  114121. shader: string;
  114122. };
  114123. }
  114124. declare module BABYLON {
  114125. /** @hidden */
  114126. export var pbrVertexDeclaration: {
  114127. name: string;
  114128. shader: string;
  114129. };
  114130. }
  114131. declare module BABYLON {
  114132. /** @hidden */
  114133. export var pbrVertexShader: {
  114134. name: string;
  114135. shader: string;
  114136. };
  114137. }
  114138. declare module BABYLON {
  114139. /**
  114140. * Manages the defines for the PBR Material.
  114141. * @hidden
  114142. */
  114143. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  114144. PBR: boolean;
  114145. MAINUV1: boolean;
  114146. MAINUV2: boolean;
  114147. UV1: boolean;
  114148. UV2: boolean;
  114149. ALBEDO: boolean;
  114150. ALBEDODIRECTUV: number;
  114151. VERTEXCOLOR: boolean;
  114152. AMBIENT: boolean;
  114153. AMBIENTDIRECTUV: number;
  114154. AMBIENTINGRAYSCALE: boolean;
  114155. OPACITY: boolean;
  114156. VERTEXALPHA: boolean;
  114157. OPACITYDIRECTUV: number;
  114158. OPACITYRGB: boolean;
  114159. ALPHATEST: boolean;
  114160. DEPTHPREPASS: boolean;
  114161. ALPHABLEND: boolean;
  114162. ALPHAFROMALBEDO: boolean;
  114163. ALPHATESTVALUE: string;
  114164. SPECULAROVERALPHA: boolean;
  114165. RADIANCEOVERALPHA: boolean;
  114166. ALPHAFRESNEL: boolean;
  114167. LINEARALPHAFRESNEL: boolean;
  114168. PREMULTIPLYALPHA: boolean;
  114169. EMISSIVE: boolean;
  114170. EMISSIVEDIRECTUV: number;
  114171. REFLECTIVITY: boolean;
  114172. REFLECTIVITYDIRECTUV: number;
  114173. SPECULARTERM: boolean;
  114174. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  114175. MICROSURFACEAUTOMATIC: boolean;
  114176. LODBASEDMICROSFURACE: boolean;
  114177. MICROSURFACEMAP: boolean;
  114178. MICROSURFACEMAPDIRECTUV: number;
  114179. METALLICWORKFLOW: boolean;
  114180. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  114181. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  114182. METALLNESSSTOREINMETALMAPBLUE: boolean;
  114183. AOSTOREINMETALMAPRED: boolean;
  114184. ENVIRONMENTBRDF: boolean;
  114185. ENVIRONMENTBRDF_RGBD: boolean;
  114186. NORMAL: boolean;
  114187. TANGENT: boolean;
  114188. BUMP: boolean;
  114189. BUMPDIRECTUV: number;
  114190. OBJECTSPACE_NORMALMAP: boolean;
  114191. PARALLAX: boolean;
  114192. PARALLAXOCCLUSION: boolean;
  114193. NORMALXYSCALE: boolean;
  114194. LIGHTMAP: boolean;
  114195. LIGHTMAPDIRECTUV: number;
  114196. USELIGHTMAPASSHADOWMAP: boolean;
  114197. GAMMALIGHTMAP: boolean;
  114198. RGBDLIGHTMAP: boolean;
  114199. REFLECTION: boolean;
  114200. REFLECTIONMAP_3D: boolean;
  114201. REFLECTIONMAP_SPHERICAL: boolean;
  114202. REFLECTIONMAP_PLANAR: boolean;
  114203. REFLECTIONMAP_CUBIC: boolean;
  114204. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  114205. REFLECTIONMAP_PROJECTION: boolean;
  114206. REFLECTIONMAP_SKYBOX: boolean;
  114207. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  114208. REFLECTIONMAP_EXPLICIT: boolean;
  114209. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  114210. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  114211. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  114212. INVERTCUBICMAP: boolean;
  114213. USESPHERICALFROMREFLECTIONMAP: boolean;
  114214. USEIRRADIANCEMAP: boolean;
  114215. SPHERICAL_HARMONICS: boolean;
  114216. USESPHERICALINVERTEX: boolean;
  114217. REFLECTIONMAP_OPPOSITEZ: boolean;
  114218. LODINREFLECTIONALPHA: boolean;
  114219. GAMMAREFLECTION: boolean;
  114220. RGBDREFLECTION: boolean;
  114221. LINEARSPECULARREFLECTION: boolean;
  114222. RADIANCEOCCLUSION: boolean;
  114223. HORIZONOCCLUSION: boolean;
  114224. INSTANCES: boolean;
  114225. NUM_BONE_INFLUENCERS: number;
  114226. BonesPerMesh: number;
  114227. BONETEXTURE: boolean;
  114228. NONUNIFORMSCALING: boolean;
  114229. MORPHTARGETS: boolean;
  114230. MORPHTARGETS_NORMAL: boolean;
  114231. MORPHTARGETS_TANGENT: boolean;
  114232. MORPHTARGETS_UV: boolean;
  114233. NUM_MORPH_INFLUENCERS: number;
  114234. IMAGEPROCESSING: boolean;
  114235. VIGNETTE: boolean;
  114236. VIGNETTEBLENDMODEMULTIPLY: boolean;
  114237. VIGNETTEBLENDMODEOPAQUE: boolean;
  114238. TONEMAPPING: boolean;
  114239. TONEMAPPING_ACES: boolean;
  114240. CONTRAST: boolean;
  114241. COLORCURVES: boolean;
  114242. COLORGRADING: boolean;
  114243. COLORGRADING3D: boolean;
  114244. SAMPLER3DGREENDEPTH: boolean;
  114245. SAMPLER3DBGRMAP: boolean;
  114246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  114247. EXPOSURE: boolean;
  114248. MULTIVIEW: boolean;
  114249. USEPHYSICALLIGHTFALLOFF: boolean;
  114250. USEGLTFLIGHTFALLOFF: boolean;
  114251. TWOSIDEDLIGHTING: boolean;
  114252. SHADOWFLOAT: boolean;
  114253. CLIPPLANE: boolean;
  114254. CLIPPLANE2: boolean;
  114255. CLIPPLANE3: boolean;
  114256. CLIPPLANE4: boolean;
  114257. POINTSIZE: boolean;
  114258. FOG: boolean;
  114259. LOGARITHMICDEPTH: boolean;
  114260. FORCENORMALFORWARD: boolean;
  114261. SPECULARAA: boolean;
  114262. CLEARCOAT: boolean;
  114263. CLEARCOAT_DEFAULTIOR: boolean;
  114264. CLEARCOAT_TEXTURE: boolean;
  114265. CLEARCOAT_TEXTUREDIRECTUV: number;
  114266. CLEARCOAT_BUMP: boolean;
  114267. CLEARCOAT_BUMPDIRECTUV: number;
  114268. CLEARCOAT_TINT: boolean;
  114269. CLEARCOAT_TINT_TEXTURE: boolean;
  114270. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  114271. ANISOTROPIC: boolean;
  114272. ANISOTROPIC_TEXTURE: boolean;
  114273. ANISOTROPIC_TEXTUREDIRECTUV: number;
  114274. BRDF_V_HEIGHT_CORRELATED: boolean;
  114275. MS_BRDF_ENERGY_CONSERVATION: boolean;
  114276. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  114277. SHEEN: boolean;
  114278. SHEEN_TEXTURE: boolean;
  114279. SHEEN_TEXTUREDIRECTUV: number;
  114280. SHEEN_LINKWITHALBEDO: boolean;
  114281. SUBSURFACE: boolean;
  114282. SS_REFRACTION: boolean;
  114283. SS_TRANSLUCENCY: boolean;
  114284. SS_SCATERRING: boolean;
  114285. SS_THICKNESSANDMASK_TEXTURE: boolean;
  114286. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  114287. SS_REFRACTIONMAP_3D: boolean;
  114288. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  114289. SS_LODINREFRACTIONALPHA: boolean;
  114290. SS_GAMMAREFRACTION: boolean;
  114291. SS_RGBDREFRACTION: boolean;
  114292. SS_LINEARSPECULARREFRACTION: boolean;
  114293. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  114294. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  114295. UNLIT: boolean;
  114296. DEBUGMODE: number;
  114297. /**
  114298. * Initializes the PBR Material defines.
  114299. */
  114300. constructor();
  114301. /**
  114302. * Resets the PBR Material defines.
  114303. */
  114304. reset(): void;
  114305. }
  114306. /**
  114307. * The Physically based material base class of BJS.
  114308. *
  114309. * This offers the main features of a standard PBR material.
  114310. * For more information, please refer to the documentation :
  114311. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114312. */
  114313. export abstract class PBRBaseMaterial extends PushMaterial {
  114314. /**
  114315. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114316. */
  114317. static readonly PBRMATERIAL_OPAQUE: number;
  114318. /**
  114319. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114320. */
  114321. static readonly PBRMATERIAL_ALPHATEST: number;
  114322. /**
  114323. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114324. */
  114325. static readonly PBRMATERIAL_ALPHABLEND: number;
  114326. /**
  114327. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114328. * They are also discarded below the alpha cutoff threshold to improve performances.
  114329. */
  114330. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114331. /**
  114332. * Defines the default value of how much AO map is occluding the analytical lights
  114333. * (point spot...).
  114334. */
  114335. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114336. /**
  114337. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  114338. */
  114339. static readonly LIGHTFALLOFF_PHYSICAL: number;
  114340. /**
  114341. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  114342. * to enhance interoperability with other engines.
  114343. */
  114344. static readonly LIGHTFALLOFF_GLTF: number;
  114345. /**
  114346. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  114347. * to enhance interoperability with other materials.
  114348. */
  114349. static readonly LIGHTFALLOFF_STANDARD: number;
  114350. /**
  114351. * Intensity of the direct lights e.g. the four lights available in your scene.
  114352. * This impacts both the direct diffuse and specular highlights.
  114353. */
  114354. protected _directIntensity: number;
  114355. /**
  114356. * Intensity of the emissive part of the material.
  114357. * This helps controlling the emissive effect without modifying the emissive color.
  114358. */
  114359. protected _emissiveIntensity: number;
  114360. /**
  114361. * Intensity of the environment e.g. how much the environment will light the object
  114362. * either through harmonics for rough material or through the refelction for shiny ones.
  114363. */
  114364. protected _environmentIntensity: number;
  114365. /**
  114366. * This is a special control allowing the reduction of the specular highlights coming from the
  114367. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114368. */
  114369. protected _specularIntensity: number;
  114370. /**
  114371. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  114372. */
  114373. private _lightingInfos;
  114374. /**
  114375. * Debug Control allowing disabling the bump map on this material.
  114376. */
  114377. protected _disableBumpMap: boolean;
  114378. /**
  114379. * AKA Diffuse Texture in standard nomenclature.
  114380. */
  114381. protected _albedoTexture: Nullable<BaseTexture>;
  114382. /**
  114383. * AKA Occlusion Texture in other nomenclature.
  114384. */
  114385. protected _ambientTexture: Nullable<BaseTexture>;
  114386. /**
  114387. * AKA Occlusion Texture Intensity in other nomenclature.
  114388. */
  114389. protected _ambientTextureStrength: number;
  114390. /**
  114391. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114392. * 1 means it completely occludes it
  114393. * 0 mean it has no impact
  114394. */
  114395. protected _ambientTextureImpactOnAnalyticalLights: number;
  114396. /**
  114397. * Stores the alpha values in a texture.
  114398. */
  114399. protected _opacityTexture: Nullable<BaseTexture>;
  114400. /**
  114401. * Stores the reflection values in a texture.
  114402. */
  114403. protected _reflectionTexture: Nullable<BaseTexture>;
  114404. /**
  114405. * Stores the emissive values in a texture.
  114406. */
  114407. protected _emissiveTexture: Nullable<BaseTexture>;
  114408. /**
  114409. * AKA Specular texture in other nomenclature.
  114410. */
  114411. protected _reflectivityTexture: Nullable<BaseTexture>;
  114412. /**
  114413. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114414. */
  114415. protected _metallicTexture: Nullable<BaseTexture>;
  114416. /**
  114417. * Specifies the metallic scalar of the metallic/roughness workflow.
  114418. * Can also be used to scale the metalness values of the metallic texture.
  114419. */
  114420. protected _metallic: Nullable<number>;
  114421. /**
  114422. * Specifies the roughness scalar of the metallic/roughness workflow.
  114423. * Can also be used to scale the roughness values of the metallic texture.
  114424. */
  114425. protected _roughness: Nullable<number>;
  114426. /**
  114427. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114428. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114429. */
  114430. protected _microSurfaceTexture: Nullable<BaseTexture>;
  114431. /**
  114432. * Stores surface normal data used to displace a mesh in a texture.
  114433. */
  114434. protected _bumpTexture: Nullable<BaseTexture>;
  114435. /**
  114436. * Stores the pre-calculated light information of a mesh in a texture.
  114437. */
  114438. protected _lightmapTexture: Nullable<BaseTexture>;
  114439. /**
  114440. * The color of a material in ambient lighting.
  114441. */
  114442. protected _ambientColor: Color3;
  114443. /**
  114444. * AKA Diffuse Color in other nomenclature.
  114445. */
  114446. protected _albedoColor: Color3;
  114447. /**
  114448. * AKA Specular Color in other nomenclature.
  114449. */
  114450. protected _reflectivityColor: Color3;
  114451. /**
  114452. * The color applied when light is reflected from a material.
  114453. */
  114454. protected _reflectionColor: Color3;
  114455. /**
  114456. * The color applied when light is emitted from a material.
  114457. */
  114458. protected _emissiveColor: Color3;
  114459. /**
  114460. * AKA Glossiness in other nomenclature.
  114461. */
  114462. protected _microSurface: number;
  114463. /**
  114464. * Specifies that the material will use the light map as a show map.
  114465. */
  114466. protected _useLightmapAsShadowmap: boolean;
  114467. /**
  114468. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  114469. * makes the reflect vector face the model (under horizon).
  114470. */
  114471. protected _useHorizonOcclusion: boolean;
  114472. /**
  114473. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  114474. * too much the area relying on ambient texture to define their ambient occlusion.
  114475. */
  114476. protected _useRadianceOcclusion: boolean;
  114477. /**
  114478. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114479. */
  114480. protected _useAlphaFromAlbedoTexture: boolean;
  114481. /**
  114482. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  114483. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114484. */
  114485. protected _useSpecularOverAlpha: boolean;
  114486. /**
  114487. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114488. */
  114489. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114490. /**
  114491. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114492. */
  114493. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  114494. /**
  114495. * Specifies if the metallic texture contains the roughness information in its green channel.
  114496. */
  114497. protected _useRoughnessFromMetallicTextureGreen: boolean;
  114498. /**
  114499. * Specifies if the metallic texture contains the metallness information in its blue channel.
  114500. */
  114501. protected _useMetallnessFromMetallicTextureBlue: boolean;
  114502. /**
  114503. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  114504. */
  114505. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  114506. /**
  114507. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  114508. */
  114509. protected _useAmbientInGrayScale: boolean;
  114510. /**
  114511. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  114512. * The material will try to infer what glossiness each pixel should be.
  114513. */
  114514. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  114515. /**
  114516. * Defines the falloff type used in this material.
  114517. * It by default is Physical.
  114518. */
  114519. protected _lightFalloff: number;
  114520. /**
  114521. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  114522. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  114523. */
  114524. protected _useRadianceOverAlpha: boolean;
  114525. /**
  114526. * Allows using an object space normal map (instead of tangent space).
  114527. */
  114528. protected _useObjectSpaceNormalMap: boolean;
  114529. /**
  114530. * Allows using the bump map in parallax mode.
  114531. */
  114532. protected _useParallax: boolean;
  114533. /**
  114534. * Allows using the bump map in parallax occlusion mode.
  114535. */
  114536. protected _useParallaxOcclusion: boolean;
  114537. /**
  114538. * Controls the scale bias of the parallax mode.
  114539. */
  114540. protected _parallaxScaleBias: number;
  114541. /**
  114542. * If sets to true, disables all the lights affecting the material.
  114543. */
  114544. protected _disableLighting: boolean;
  114545. /**
  114546. * Number of Simultaneous lights allowed on the material.
  114547. */
  114548. protected _maxSimultaneousLights: number;
  114549. /**
  114550. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  114551. */
  114552. protected _invertNormalMapX: boolean;
  114553. /**
  114554. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  114555. */
  114556. protected _invertNormalMapY: boolean;
  114557. /**
  114558. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  114559. */
  114560. protected _twoSidedLighting: boolean;
  114561. /**
  114562. * Defines the alpha limits in alpha test mode.
  114563. */
  114564. protected _alphaCutOff: number;
  114565. /**
  114566. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114567. */
  114568. protected _forceAlphaTest: boolean;
  114569. /**
  114570. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114571. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  114572. */
  114573. protected _useAlphaFresnel: boolean;
  114574. /**
  114575. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  114576. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  114577. */
  114578. protected _useLinearAlphaFresnel: boolean;
  114579. /**
  114580. * The transparency mode of the material.
  114581. */
  114582. protected _transparencyMode: Nullable<number>;
  114583. /**
  114584. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  114585. * from cos thetav and roughness:
  114586. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  114587. */
  114588. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  114589. /**
  114590. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  114591. */
  114592. protected _forceIrradianceInFragment: boolean;
  114593. /**
  114594. * Force normal to face away from face.
  114595. */
  114596. protected _forceNormalForward: boolean;
  114597. /**
  114598. * Enables specular anti aliasing in the PBR shader.
  114599. * It will both interacts on the Geometry for analytical and IBL lighting.
  114600. * It also prefilter the roughness map based on the bump values.
  114601. */
  114602. protected _enableSpecularAntiAliasing: boolean;
  114603. /**
  114604. * Default configuration related to image processing available in the PBR Material.
  114605. */
  114606. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  114607. /**
  114608. * Keep track of the image processing observer to allow dispose and replace.
  114609. */
  114610. private _imageProcessingObserver;
  114611. /**
  114612. * Attaches a new image processing configuration to the PBR Material.
  114613. * @param configuration
  114614. */
  114615. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  114616. /**
  114617. * Stores the available render targets.
  114618. */
  114619. private _renderTargets;
  114620. /**
  114621. * Sets the global ambient color for the material used in lighting calculations.
  114622. */
  114623. private _globalAmbientColor;
  114624. /**
  114625. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  114626. */
  114627. private _useLogarithmicDepth;
  114628. /**
  114629. * If set to true, no lighting calculations will be applied.
  114630. */
  114631. private _unlit;
  114632. private _debugMode;
  114633. /**
  114634. * @hidden
  114635. * This is reserved for the inspector.
  114636. * Defines the material debug mode.
  114637. * It helps seeing only some components of the material while troubleshooting.
  114638. */
  114639. debugMode: number;
  114640. /**
  114641. * @hidden
  114642. * This is reserved for the inspector.
  114643. * Specify from where on screen the debug mode should start.
  114644. * The value goes from -1 (full screen) to 1 (not visible)
  114645. * It helps with side by side comparison against the final render
  114646. * This defaults to -1
  114647. */
  114648. private debugLimit;
  114649. /**
  114650. * @hidden
  114651. * This is reserved for the inspector.
  114652. * As the default viewing range might not be enough (if the ambient is really small for instance)
  114653. * You can use the factor to better multiply the final value.
  114654. */
  114655. private debugFactor;
  114656. /**
  114657. * Defines the clear coat layer parameters for the material.
  114658. */
  114659. readonly clearCoat: PBRClearCoatConfiguration;
  114660. /**
  114661. * Defines the anisotropic parameters for the material.
  114662. */
  114663. readonly anisotropy: PBRAnisotropicConfiguration;
  114664. /**
  114665. * Defines the BRDF parameters for the material.
  114666. */
  114667. readonly brdf: PBRBRDFConfiguration;
  114668. /**
  114669. * Defines the Sheen parameters for the material.
  114670. */
  114671. readonly sheen: PBRSheenConfiguration;
  114672. /**
  114673. * Defines the SubSurface parameters for the material.
  114674. */
  114675. readonly subSurface: PBRSubSurfaceConfiguration;
  114676. /**
  114677. * Custom callback helping to override the default shader used in the material.
  114678. */
  114679. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  114680. protected _rebuildInParallel: boolean;
  114681. /**
  114682. * Instantiates a new PBRMaterial instance.
  114683. *
  114684. * @param name The material name
  114685. * @param scene The scene the material will be use in.
  114686. */
  114687. constructor(name: string, scene: Scene);
  114688. /**
  114689. * Gets a boolean indicating that current material needs to register RTT
  114690. */
  114691. readonly hasRenderTargetTextures: boolean;
  114692. /**
  114693. * Gets the name of the material class.
  114694. */
  114695. getClassName(): string;
  114696. /**
  114697. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114698. */
  114699. /**
  114700. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  114701. */
  114702. useLogarithmicDepth: boolean;
  114703. /**
  114704. * Gets the current transparency mode.
  114705. */
  114706. /**
  114707. * Sets the transparency mode of the material.
  114708. *
  114709. * | Value | Type | Description |
  114710. * | ----- | ----------------------------------- | ----------- |
  114711. * | 0 | OPAQUE | |
  114712. * | 1 | ALPHATEST | |
  114713. * | 2 | ALPHABLEND | |
  114714. * | 3 | ALPHATESTANDBLEND | |
  114715. *
  114716. */
  114717. transparencyMode: Nullable<number>;
  114718. /**
  114719. * Returns true if alpha blending should be disabled.
  114720. */
  114721. private readonly _disableAlphaBlending;
  114722. /**
  114723. * Specifies whether or not this material should be rendered in alpha blend mode.
  114724. */
  114725. needAlphaBlending(): boolean;
  114726. /**
  114727. * Specifies if the mesh will require alpha blending.
  114728. * @param mesh - BJS mesh.
  114729. */
  114730. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  114731. /**
  114732. * Specifies whether or not this material should be rendered in alpha test mode.
  114733. */
  114734. needAlphaTesting(): boolean;
  114735. /**
  114736. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  114737. */
  114738. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  114739. /**
  114740. * Gets the texture used for the alpha test.
  114741. */
  114742. getAlphaTestTexture(): Nullable<BaseTexture>;
  114743. /**
  114744. * Specifies that the submesh is ready to be used.
  114745. * @param mesh - BJS mesh.
  114746. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  114747. * @param useInstances - Specifies that instances should be used.
  114748. * @returns - boolean indicating that the submesh is ready or not.
  114749. */
  114750. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  114751. /**
  114752. * Specifies if the material uses metallic roughness workflow.
  114753. * @returns boolean specifiying if the material uses metallic roughness workflow.
  114754. */
  114755. isMetallicWorkflow(): boolean;
  114756. private _prepareEffect;
  114757. private _prepareDefines;
  114758. /**
  114759. * Force shader compilation
  114760. */
  114761. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  114762. clipPlane: boolean;
  114763. }>): void;
  114764. /**
  114765. * Initializes the uniform buffer layout for the shader.
  114766. */
  114767. buildUniformLayout(): void;
  114768. /**
  114769. * Unbinds the material from the mesh
  114770. */
  114771. unbind(): void;
  114772. /**
  114773. * Binds the submesh data.
  114774. * @param world - The world matrix.
  114775. * @param mesh - The BJS mesh.
  114776. * @param subMesh - A submesh of the BJS mesh.
  114777. */
  114778. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  114779. /**
  114780. * Returns the animatable textures.
  114781. * @returns - Array of animatable textures.
  114782. */
  114783. getAnimatables(): IAnimatable[];
  114784. /**
  114785. * Returns the texture used for reflections.
  114786. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  114787. */
  114788. private _getReflectionTexture;
  114789. /**
  114790. * Returns an array of the actively used textures.
  114791. * @returns - Array of BaseTextures
  114792. */
  114793. getActiveTextures(): BaseTexture[];
  114794. /**
  114795. * Checks to see if a texture is used in the material.
  114796. * @param texture - Base texture to use.
  114797. * @returns - Boolean specifying if a texture is used in the material.
  114798. */
  114799. hasTexture(texture: BaseTexture): boolean;
  114800. /**
  114801. * Disposes the resources of the material.
  114802. * @param forceDisposeEffect - Forces the disposal of effects.
  114803. * @param forceDisposeTextures - Forces the disposal of all textures.
  114804. */
  114805. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  114806. }
  114807. }
  114808. declare module BABYLON {
  114809. /**
  114810. * The Physically based material of BJS.
  114811. *
  114812. * This offers the main features of a standard PBR material.
  114813. * For more information, please refer to the documentation :
  114814. * https://doc.babylonjs.com/how_to/physically_based_rendering
  114815. */
  114816. export class PBRMaterial extends PBRBaseMaterial {
  114817. /**
  114818. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  114819. */
  114820. static readonly PBRMATERIAL_OPAQUE: number;
  114821. /**
  114822. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  114823. */
  114824. static readonly PBRMATERIAL_ALPHATEST: number;
  114825. /**
  114826. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114827. */
  114828. static readonly PBRMATERIAL_ALPHABLEND: number;
  114829. /**
  114830. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  114831. * They are also discarded below the alpha cutoff threshold to improve performances.
  114832. */
  114833. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  114834. /**
  114835. * Defines the default value of how much AO map is occluding the analytical lights
  114836. * (point spot...).
  114837. */
  114838. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  114839. /**
  114840. * Intensity of the direct lights e.g. the four lights available in your scene.
  114841. * This impacts both the direct diffuse and specular highlights.
  114842. */
  114843. directIntensity: number;
  114844. /**
  114845. * Intensity of the emissive part of the material.
  114846. * This helps controlling the emissive effect without modifying the emissive color.
  114847. */
  114848. emissiveIntensity: number;
  114849. /**
  114850. * Intensity of the environment e.g. how much the environment will light the object
  114851. * either through harmonics for rough material or through the refelction for shiny ones.
  114852. */
  114853. environmentIntensity: number;
  114854. /**
  114855. * This is a special control allowing the reduction of the specular highlights coming from the
  114856. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  114857. */
  114858. specularIntensity: number;
  114859. /**
  114860. * Debug Control allowing disabling the bump map on this material.
  114861. */
  114862. disableBumpMap: boolean;
  114863. /**
  114864. * AKA Diffuse Texture in standard nomenclature.
  114865. */
  114866. albedoTexture: BaseTexture;
  114867. /**
  114868. * AKA Occlusion Texture in other nomenclature.
  114869. */
  114870. ambientTexture: BaseTexture;
  114871. /**
  114872. * AKA Occlusion Texture Intensity in other nomenclature.
  114873. */
  114874. ambientTextureStrength: number;
  114875. /**
  114876. * Defines how much the AO map is occluding the analytical lights (point spot...).
  114877. * 1 means it completely occludes it
  114878. * 0 mean it has no impact
  114879. */
  114880. ambientTextureImpactOnAnalyticalLights: number;
  114881. /**
  114882. * Stores the alpha values in a texture.
  114883. */
  114884. opacityTexture: BaseTexture;
  114885. /**
  114886. * Stores the reflection values in a texture.
  114887. */
  114888. reflectionTexture: Nullable<BaseTexture>;
  114889. /**
  114890. * Stores the emissive values in a texture.
  114891. */
  114892. emissiveTexture: BaseTexture;
  114893. /**
  114894. * AKA Specular texture in other nomenclature.
  114895. */
  114896. reflectivityTexture: BaseTexture;
  114897. /**
  114898. * Used to switch from specular/glossiness to metallic/roughness workflow.
  114899. */
  114900. metallicTexture: BaseTexture;
  114901. /**
  114902. * Specifies the metallic scalar of the metallic/roughness workflow.
  114903. * Can also be used to scale the metalness values of the metallic texture.
  114904. */
  114905. metallic: Nullable<number>;
  114906. /**
  114907. * Specifies the roughness scalar of the metallic/roughness workflow.
  114908. * Can also be used to scale the roughness values of the metallic texture.
  114909. */
  114910. roughness: Nullable<number>;
  114911. /**
  114912. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  114913. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  114914. */
  114915. microSurfaceTexture: BaseTexture;
  114916. /**
  114917. * Stores surface normal data used to displace a mesh in a texture.
  114918. */
  114919. bumpTexture: BaseTexture;
  114920. /**
  114921. * Stores the pre-calculated light information of a mesh in a texture.
  114922. */
  114923. lightmapTexture: BaseTexture;
  114924. /**
  114925. * Stores the refracted light information in a texture.
  114926. */
  114927. refractionTexture: Nullable<BaseTexture>;
  114928. /**
  114929. * The color of a material in ambient lighting.
  114930. */
  114931. ambientColor: Color3;
  114932. /**
  114933. * AKA Diffuse Color in other nomenclature.
  114934. */
  114935. albedoColor: Color3;
  114936. /**
  114937. * AKA Specular Color in other nomenclature.
  114938. */
  114939. reflectivityColor: Color3;
  114940. /**
  114941. * The color reflected from the material.
  114942. */
  114943. reflectionColor: Color3;
  114944. /**
  114945. * The color emitted from the material.
  114946. */
  114947. emissiveColor: Color3;
  114948. /**
  114949. * AKA Glossiness in other nomenclature.
  114950. */
  114951. microSurface: number;
  114952. /**
  114953. * source material index of refraction (IOR)' / 'destination material IOR.
  114954. */
  114955. indexOfRefraction: number;
  114956. /**
  114957. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  114958. */
  114959. invertRefractionY: boolean;
  114960. /**
  114961. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  114962. * Materials half opaque for instance using refraction could benefit from this control.
  114963. */
  114964. linkRefractionWithTransparency: boolean;
  114965. /**
  114966. * If true, the light map contains occlusion information instead of lighting info.
  114967. */
  114968. useLightmapAsShadowmap: boolean;
  114969. /**
  114970. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  114971. */
  114972. useAlphaFromAlbedoTexture: boolean;
  114973. /**
  114974. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  114975. */
  114976. forceAlphaTest: boolean;
  114977. /**
  114978. * Defines the alpha limits in alpha test mode.
  114979. */
  114980. alphaCutOff: number;
  114981. /**
  114982. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  114983. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  114984. */
  114985. useSpecularOverAlpha: boolean;
  114986. /**
  114987. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  114988. */
  114989. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  114990. /**
  114991. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  114992. */
  114993. useRoughnessFromMetallicTextureAlpha: boolean;
  114994. /**
  114995. * Specifies if the metallic texture contains the roughness information in its green channel.
  114996. */
  114997. useRoughnessFromMetallicTextureGreen: boolean;
  114998. /**
  114999. * Specifies if the metallic texture contains the metallness information in its blue channel.
  115000. */
  115001. useMetallnessFromMetallicTextureBlue: boolean;
  115002. /**
  115003. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  115004. */
  115005. useAmbientOcclusionFromMetallicTextureRed: boolean;
  115006. /**
  115007. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  115008. */
  115009. useAmbientInGrayScale: boolean;
  115010. /**
  115011. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  115012. * The material will try to infer what glossiness each pixel should be.
  115013. */
  115014. useAutoMicroSurfaceFromReflectivityMap: boolean;
  115015. /**
  115016. * BJS is using an harcoded light falloff based on a manually sets up range.
  115017. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115018. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115019. */
  115020. /**
  115021. * BJS is using an harcoded light falloff based on a manually sets up range.
  115022. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  115023. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  115024. */
  115025. usePhysicalLightFalloff: boolean;
  115026. /**
  115027. * In order to support the falloff compatibility with gltf, a special mode has been added
  115028. * to reproduce the gltf light falloff.
  115029. */
  115030. /**
  115031. * In order to support the falloff compatibility with gltf, a special mode has been added
  115032. * to reproduce the gltf light falloff.
  115033. */
  115034. useGLTFLightFalloff: boolean;
  115035. /**
  115036. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  115037. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  115038. */
  115039. useRadianceOverAlpha: boolean;
  115040. /**
  115041. * Allows using an object space normal map (instead of tangent space).
  115042. */
  115043. useObjectSpaceNormalMap: boolean;
  115044. /**
  115045. * Allows using the bump map in parallax mode.
  115046. */
  115047. useParallax: boolean;
  115048. /**
  115049. * Allows using the bump map in parallax occlusion mode.
  115050. */
  115051. useParallaxOcclusion: boolean;
  115052. /**
  115053. * Controls the scale bias of the parallax mode.
  115054. */
  115055. parallaxScaleBias: number;
  115056. /**
  115057. * If sets to true, disables all the lights affecting the material.
  115058. */
  115059. disableLighting: boolean;
  115060. /**
  115061. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  115062. */
  115063. forceIrradianceInFragment: boolean;
  115064. /**
  115065. * Number of Simultaneous lights allowed on the material.
  115066. */
  115067. maxSimultaneousLights: number;
  115068. /**
  115069. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  115070. */
  115071. invertNormalMapX: boolean;
  115072. /**
  115073. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  115074. */
  115075. invertNormalMapY: boolean;
  115076. /**
  115077. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  115078. */
  115079. twoSidedLighting: boolean;
  115080. /**
  115081. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115082. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  115083. */
  115084. useAlphaFresnel: boolean;
  115085. /**
  115086. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  115087. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  115088. */
  115089. useLinearAlphaFresnel: boolean;
  115090. /**
  115091. * Let user defines the brdf lookup texture used for IBL.
  115092. * A default 8bit version is embedded but you could point at :
  115093. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  115094. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  115095. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  115096. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  115097. */
  115098. environmentBRDFTexture: Nullable<BaseTexture>;
  115099. /**
  115100. * Force normal to face away from face.
  115101. */
  115102. forceNormalForward: boolean;
  115103. /**
  115104. * Enables specular anti aliasing in the PBR shader.
  115105. * It will both interacts on the Geometry for analytical and IBL lighting.
  115106. * It also prefilter the roughness map based on the bump values.
  115107. */
  115108. enableSpecularAntiAliasing: boolean;
  115109. /**
  115110. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  115111. * makes the reflect vector face the model (under horizon).
  115112. */
  115113. useHorizonOcclusion: boolean;
  115114. /**
  115115. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  115116. * too much the area relying on ambient texture to define their ambient occlusion.
  115117. */
  115118. useRadianceOcclusion: boolean;
  115119. /**
  115120. * If set to true, no lighting calculations will be applied.
  115121. */
  115122. unlit: boolean;
  115123. /**
  115124. * Gets the image processing configuration used either in this material.
  115125. */
  115126. /**
  115127. * Sets the Default image processing configuration used either in the this material.
  115128. *
  115129. * If sets to null, the scene one is in use.
  115130. */
  115131. imageProcessingConfiguration: ImageProcessingConfiguration;
  115132. /**
  115133. * Gets wether the color curves effect is enabled.
  115134. */
  115135. /**
  115136. * Sets wether the color curves effect is enabled.
  115137. */
  115138. cameraColorCurvesEnabled: boolean;
  115139. /**
  115140. * Gets wether the color grading effect is enabled.
  115141. */
  115142. /**
  115143. * Gets wether the color grading effect is enabled.
  115144. */
  115145. cameraColorGradingEnabled: boolean;
  115146. /**
  115147. * Gets wether tonemapping is enabled or not.
  115148. */
  115149. /**
  115150. * Sets wether tonemapping is enabled or not
  115151. */
  115152. cameraToneMappingEnabled: boolean;
  115153. /**
  115154. * The camera exposure used on this material.
  115155. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115156. * This corresponds to a photographic exposure.
  115157. */
  115158. /**
  115159. * The camera exposure used on this material.
  115160. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  115161. * This corresponds to a photographic exposure.
  115162. */
  115163. cameraExposure: number;
  115164. /**
  115165. * Gets The camera contrast used on this material.
  115166. */
  115167. /**
  115168. * Sets The camera contrast used on this material.
  115169. */
  115170. cameraContrast: number;
  115171. /**
  115172. * Gets the Color Grading 2D Lookup Texture.
  115173. */
  115174. /**
  115175. * Sets the Color Grading 2D Lookup Texture.
  115176. */
  115177. cameraColorGradingTexture: Nullable<BaseTexture>;
  115178. /**
  115179. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115180. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115181. * 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;
  115182. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115183. */
  115184. /**
  115185. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  115186. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  115187. * 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;
  115188. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  115189. */
  115190. cameraColorCurves: Nullable<ColorCurves>;
  115191. /**
  115192. * Instantiates a new PBRMaterial instance.
  115193. *
  115194. * @param name The material name
  115195. * @param scene The scene the material will be use in.
  115196. */
  115197. constructor(name: string, scene: Scene);
  115198. /**
  115199. * Returns the name of this material class.
  115200. */
  115201. getClassName(): string;
  115202. /**
  115203. * Makes a duplicate of the current material.
  115204. * @param name - name to use for the new material.
  115205. */
  115206. clone(name: string): PBRMaterial;
  115207. /**
  115208. * Serializes this PBR Material.
  115209. * @returns - An object with the serialized material.
  115210. */
  115211. serialize(): any;
  115212. /**
  115213. * Parses a PBR Material from a serialized object.
  115214. * @param source - Serialized object.
  115215. * @param scene - BJS scene instance.
  115216. * @param rootUrl - url for the scene object
  115217. * @returns - PBRMaterial
  115218. */
  115219. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  115220. }
  115221. }
  115222. declare module BABYLON {
  115223. /**
  115224. * Direct draw surface info
  115225. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  115226. */
  115227. export interface DDSInfo {
  115228. /**
  115229. * Width of the texture
  115230. */
  115231. width: number;
  115232. /**
  115233. * Width of the texture
  115234. */
  115235. height: number;
  115236. /**
  115237. * Number of Mipmaps for the texture
  115238. * @see https://en.wikipedia.org/wiki/Mipmap
  115239. */
  115240. mipmapCount: number;
  115241. /**
  115242. * If the textures format is a known fourCC format
  115243. * @see https://www.fourcc.org/
  115244. */
  115245. isFourCC: boolean;
  115246. /**
  115247. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  115248. */
  115249. isRGB: boolean;
  115250. /**
  115251. * If the texture is a lumincance format
  115252. */
  115253. isLuminance: boolean;
  115254. /**
  115255. * If this is a cube texture
  115256. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  115257. */
  115258. isCube: boolean;
  115259. /**
  115260. * If the texture is a compressed format eg. FOURCC_DXT1
  115261. */
  115262. isCompressed: boolean;
  115263. /**
  115264. * The dxgiFormat of the texture
  115265. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  115266. */
  115267. dxgiFormat: number;
  115268. /**
  115269. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  115270. */
  115271. textureType: number;
  115272. /**
  115273. * Sphericle polynomial created for the dds texture
  115274. */
  115275. sphericalPolynomial?: SphericalPolynomial;
  115276. }
  115277. /**
  115278. * Class used to provide DDS decompression tools
  115279. */
  115280. export class DDSTools {
  115281. /**
  115282. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  115283. */
  115284. static StoreLODInAlphaChannel: boolean;
  115285. /**
  115286. * Gets DDS information from an array buffer
  115287. * @param arrayBuffer defines the array buffer to read data from
  115288. * @returns the DDS information
  115289. */
  115290. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  115291. private static _FloatView;
  115292. private static _Int32View;
  115293. private static _ToHalfFloat;
  115294. private static _FromHalfFloat;
  115295. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  115296. private static _GetHalfFloatRGBAArrayBuffer;
  115297. private static _GetFloatRGBAArrayBuffer;
  115298. private static _GetFloatAsUIntRGBAArrayBuffer;
  115299. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  115300. private static _GetRGBAArrayBuffer;
  115301. private static _ExtractLongWordOrder;
  115302. private static _GetRGBArrayBuffer;
  115303. private static _GetLuminanceArrayBuffer;
  115304. /**
  115305. * Uploads DDS Levels to a Babylon Texture
  115306. * @hidden
  115307. */
  115308. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  115309. }
  115310. interface ThinEngine {
  115311. /**
  115312. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  115313. * @param rootUrl defines the url where the file to load is located
  115314. * @param scene defines the current scene
  115315. * @param lodScale defines scale to apply to the mip map selection
  115316. * @param lodOffset defines offset to apply to the mip map selection
  115317. * @param onLoad defines an optional callback raised when the texture is loaded
  115318. * @param onError defines an optional callback raised if there is an issue to load the texture
  115319. * @param format defines the format of the data
  115320. * @param forcedExtension defines the extension to use to pick the right loader
  115321. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  115322. * @returns the cube texture as an InternalTexture
  115323. */
  115324. 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;
  115325. }
  115326. }
  115327. declare module BABYLON {
  115328. /**
  115329. * Implementation of the DDS Texture Loader.
  115330. * @hidden
  115331. */
  115332. export class _DDSTextureLoader implements IInternalTextureLoader {
  115333. /**
  115334. * Defines wether the loader supports cascade loading the different faces.
  115335. */
  115336. readonly supportCascades: boolean;
  115337. /**
  115338. * This returns if the loader support the current file information.
  115339. * @param extension defines the file extension of the file being loaded
  115340. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115341. * @param fallback defines the fallback internal texture if any
  115342. * @param isBase64 defines whether the texture is encoded as a base64
  115343. * @param isBuffer defines whether the texture data are stored as a buffer
  115344. * @returns true if the loader can load the specified file
  115345. */
  115346. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115347. /**
  115348. * Transform the url before loading if required.
  115349. * @param rootUrl the url of the texture
  115350. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115351. * @returns the transformed texture
  115352. */
  115353. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115354. /**
  115355. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115356. * @param rootUrl the url of the texture
  115357. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115358. * @returns the fallback texture
  115359. */
  115360. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115361. /**
  115362. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115363. * @param data contains the texture data
  115364. * @param texture defines the BabylonJS internal texture
  115365. * @param createPolynomials will be true if polynomials have been requested
  115366. * @param onLoad defines the callback to trigger once the texture is ready
  115367. * @param onError defines the callback to trigger in case of error
  115368. */
  115369. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115370. /**
  115371. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115372. * @param data contains the texture data
  115373. * @param texture defines the BabylonJS internal texture
  115374. * @param callback defines the method to call once ready to upload
  115375. */
  115376. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115377. }
  115378. }
  115379. declare module BABYLON {
  115380. /**
  115381. * Implementation of the ENV Texture Loader.
  115382. * @hidden
  115383. */
  115384. export class _ENVTextureLoader implements IInternalTextureLoader {
  115385. /**
  115386. * Defines wether the loader supports cascade loading the different faces.
  115387. */
  115388. readonly supportCascades: boolean;
  115389. /**
  115390. * This returns if the loader support the current file information.
  115391. * @param extension defines the file extension of the file being loaded
  115392. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115393. * @param fallback defines the fallback internal texture if any
  115394. * @param isBase64 defines whether the texture is encoded as a base64
  115395. * @param isBuffer defines whether the texture data are stored as a buffer
  115396. * @returns true if the loader can load the specified file
  115397. */
  115398. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115399. /**
  115400. * Transform the url before loading if required.
  115401. * @param rootUrl the url of the texture
  115402. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115403. * @returns the transformed texture
  115404. */
  115405. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115406. /**
  115407. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115408. * @param rootUrl the url of the texture
  115409. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115410. * @returns the fallback texture
  115411. */
  115412. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115413. /**
  115414. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115415. * @param data contains the texture data
  115416. * @param texture defines the BabylonJS internal texture
  115417. * @param createPolynomials will be true if polynomials have been requested
  115418. * @param onLoad defines the callback to trigger once the texture is ready
  115419. * @param onError defines the callback to trigger in case of error
  115420. */
  115421. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115422. /**
  115423. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115424. * @param data contains the texture data
  115425. * @param texture defines the BabylonJS internal texture
  115426. * @param callback defines the method to call once ready to upload
  115427. */
  115428. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  115429. }
  115430. }
  115431. declare module BABYLON {
  115432. /**
  115433. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  115434. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  115435. */
  115436. export class KhronosTextureContainer {
  115437. /** contents of the KTX container file */
  115438. arrayBuffer: any;
  115439. private static HEADER_LEN;
  115440. private static COMPRESSED_2D;
  115441. private static COMPRESSED_3D;
  115442. private static TEX_2D;
  115443. private static TEX_3D;
  115444. /**
  115445. * Gets the openGL type
  115446. */
  115447. glType: number;
  115448. /**
  115449. * Gets the openGL type size
  115450. */
  115451. glTypeSize: number;
  115452. /**
  115453. * Gets the openGL format
  115454. */
  115455. glFormat: number;
  115456. /**
  115457. * Gets the openGL internal format
  115458. */
  115459. glInternalFormat: number;
  115460. /**
  115461. * Gets the base internal format
  115462. */
  115463. glBaseInternalFormat: number;
  115464. /**
  115465. * Gets image width in pixel
  115466. */
  115467. pixelWidth: number;
  115468. /**
  115469. * Gets image height in pixel
  115470. */
  115471. pixelHeight: number;
  115472. /**
  115473. * Gets image depth in pixels
  115474. */
  115475. pixelDepth: number;
  115476. /**
  115477. * Gets the number of array elements
  115478. */
  115479. numberOfArrayElements: number;
  115480. /**
  115481. * Gets the number of faces
  115482. */
  115483. numberOfFaces: number;
  115484. /**
  115485. * Gets the number of mipmap levels
  115486. */
  115487. numberOfMipmapLevels: number;
  115488. /**
  115489. * Gets the bytes of key value data
  115490. */
  115491. bytesOfKeyValueData: number;
  115492. /**
  115493. * Gets the load type
  115494. */
  115495. loadType: number;
  115496. /**
  115497. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  115498. */
  115499. isInvalid: boolean;
  115500. /**
  115501. * Creates a new KhronosTextureContainer
  115502. * @param arrayBuffer contents of the KTX container file
  115503. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  115504. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  115505. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  115506. */
  115507. constructor(
  115508. /** contents of the KTX container file */
  115509. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  115510. /**
  115511. * Uploads KTX content to a Babylon Texture.
  115512. * It is assumed that the texture has already been created & is currently bound
  115513. * @hidden
  115514. */
  115515. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  115516. private _upload2DCompressedLevels;
  115517. }
  115518. }
  115519. declare module BABYLON {
  115520. /**
  115521. * Implementation of the KTX Texture Loader.
  115522. * @hidden
  115523. */
  115524. export class _KTXTextureLoader implements IInternalTextureLoader {
  115525. /**
  115526. * Defines wether the loader supports cascade loading the different faces.
  115527. */
  115528. readonly supportCascades: boolean;
  115529. /**
  115530. * This returns if the loader support the current file information.
  115531. * @param extension defines the file extension of the file being loaded
  115532. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115533. * @param fallback defines the fallback internal texture if any
  115534. * @param isBase64 defines whether the texture is encoded as a base64
  115535. * @param isBuffer defines whether the texture data are stored as a buffer
  115536. * @returns true if the loader can load the specified file
  115537. */
  115538. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  115539. /**
  115540. * Transform the url before loading if required.
  115541. * @param rootUrl the url of the texture
  115542. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115543. * @returns the transformed texture
  115544. */
  115545. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  115546. /**
  115547. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  115548. * @param rootUrl the url of the texture
  115549. * @param textureFormatInUse defines the current compressed format in use iun the engine
  115550. * @returns the fallback texture
  115551. */
  115552. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  115553. /**
  115554. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  115555. * @param data contains the texture data
  115556. * @param texture defines the BabylonJS internal texture
  115557. * @param createPolynomials will be true if polynomials have been requested
  115558. * @param onLoad defines the callback to trigger once the texture is ready
  115559. * @param onError defines the callback to trigger in case of error
  115560. */
  115561. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  115562. /**
  115563. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  115564. * @param data contains the texture data
  115565. * @param texture defines the BabylonJS internal texture
  115566. * @param callback defines the method to call once ready to upload
  115567. */
  115568. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  115569. }
  115570. }
  115571. declare module BABYLON {
  115572. /**
  115573. * Options for the default xr helper
  115574. */
  115575. export class WebXRDefaultExperienceOptions {
  115576. /**
  115577. * Floor meshes that should be used for teleporting
  115578. */
  115579. floorMeshes: Array<AbstractMesh>;
  115580. }
  115581. /**
  115582. * Default experience which provides a similar setup to the previous webVRExperience
  115583. */
  115584. export class WebXRDefaultExperience {
  115585. /**
  115586. * Base experience
  115587. */
  115588. baseExperience: WebXRExperienceHelper;
  115589. /**
  115590. * Input experience extension
  115591. */
  115592. input: WebXRInput;
  115593. /**
  115594. * Loads the controller models
  115595. */
  115596. controllerModelLoader: WebXRControllerModelLoader;
  115597. /**
  115598. * Enables laser pointer and selection
  115599. */
  115600. pointerSelection: WebXRControllerPointerSelection;
  115601. /**
  115602. * Enables teleportation
  115603. */
  115604. teleportation: WebXRControllerTeleportation;
  115605. /**
  115606. * Enables ui for enetering/exiting xr
  115607. */
  115608. enterExitUI: WebXREnterExitUI;
  115609. /**
  115610. * Default output canvas xr should render to
  115611. */
  115612. outputCanvas: WebXRManagedOutputCanvas;
  115613. /**
  115614. * Creates the default xr experience
  115615. * @param scene scene
  115616. * @param options options for basic configuration
  115617. * @returns resulting WebXRDefaultExperience
  115618. */
  115619. static CreateAsync(scene: Scene, options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115620. private constructor();
  115621. /**
  115622. * DIsposes of the experience helper
  115623. */
  115624. dispose(): void;
  115625. }
  115626. }
  115627. declare module BABYLON {
  115628. /** @hidden */
  115629. export var _forceSceneHelpersToBundle: boolean;
  115630. interface Scene {
  115631. /**
  115632. * Creates a default light for the scene.
  115633. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  115634. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  115635. */
  115636. createDefaultLight(replace?: boolean): void;
  115637. /**
  115638. * Creates a default camera for the scene.
  115639. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  115640. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115641. * @param replace has default false, when true replaces the active camera in the scene
  115642. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  115643. */
  115644. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115645. /**
  115646. * Creates a default camera and a default light.
  115647. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  115648. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  115649. * @param replace has the default false, when true replaces the active camera/light in the scene
  115650. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  115651. */
  115652. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  115653. /**
  115654. * Creates a new sky box
  115655. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  115656. * @param environmentTexture defines the texture to use as environment texture
  115657. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  115658. * @param scale defines the overall scale of the skybox
  115659. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  115660. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  115661. * @returns a new mesh holding the sky box
  115662. */
  115663. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  115664. /**
  115665. * Creates a new environment
  115666. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  115667. * @param options defines the options you can use to configure the environment
  115668. * @returns the new EnvironmentHelper
  115669. */
  115670. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  115671. /**
  115672. * Creates a new VREXperienceHelper
  115673. * @see http://doc.babylonjs.com/how_to/webvr_helper
  115674. * @param webVROptions defines the options used to create the new VREXperienceHelper
  115675. * @returns a new VREXperienceHelper
  115676. */
  115677. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  115678. /**
  115679. * Creates a new WebXRDefaultExperience
  115680. * @see http://doc.babylonjs.com/how_to/webxr
  115681. * @param options experience options
  115682. * @returns a promise for a new WebXRDefaultExperience
  115683. */
  115684. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  115685. }
  115686. }
  115687. declare module BABYLON {
  115688. /**
  115689. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  115690. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  115691. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  115692. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  115693. */
  115694. export class VideoDome extends TransformNode {
  115695. /**
  115696. * Define the video source as a Monoscopic panoramic 360 video.
  115697. */
  115698. static readonly MODE_MONOSCOPIC: number;
  115699. /**
  115700. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115701. */
  115702. static readonly MODE_TOPBOTTOM: number;
  115703. /**
  115704. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115705. */
  115706. static readonly MODE_SIDEBYSIDE: number;
  115707. private _halfDome;
  115708. private _useDirectMapping;
  115709. /**
  115710. * The video texture being displayed on the sphere
  115711. */
  115712. protected _videoTexture: VideoTexture;
  115713. /**
  115714. * Gets the video texture being displayed on the sphere
  115715. */
  115716. readonly videoTexture: VideoTexture;
  115717. /**
  115718. * The skybox material
  115719. */
  115720. protected _material: BackgroundMaterial;
  115721. /**
  115722. * The surface used for the skybox
  115723. */
  115724. protected _mesh: Mesh;
  115725. /**
  115726. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  115727. */
  115728. private _halfDomeMask;
  115729. /**
  115730. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  115731. * Also see the options.resolution property.
  115732. */
  115733. fovMultiplier: number;
  115734. private _videoMode;
  115735. /**
  115736. * Gets or set the current video mode for the video. It can be:
  115737. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  115738. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  115739. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  115740. */
  115741. videoMode: number;
  115742. /**
  115743. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  115744. *
  115745. */
  115746. /**
  115747. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  115748. */
  115749. halfDome: boolean;
  115750. /**
  115751. * Oberserver used in Stereoscopic VR Mode.
  115752. */
  115753. private _onBeforeCameraRenderObserver;
  115754. /**
  115755. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  115756. * @param name Element's name, child elements will append suffixes for their own names.
  115757. * @param urlsOrVideo defines the url(s) or the video element to use
  115758. * @param options An object containing optional or exposed sub element properties
  115759. */
  115760. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  115761. resolution?: number;
  115762. clickToPlay?: boolean;
  115763. autoPlay?: boolean;
  115764. loop?: boolean;
  115765. size?: number;
  115766. poster?: string;
  115767. faceForward?: boolean;
  115768. useDirectMapping?: boolean;
  115769. halfDomeMode?: boolean;
  115770. }, scene: Scene);
  115771. private _changeVideoMode;
  115772. /**
  115773. * Releases resources associated with this node.
  115774. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  115775. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  115776. */
  115777. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  115778. }
  115779. }
  115780. declare module BABYLON {
  115781. /**
  115782. * This class can be used to get instrumentation data from a Babylon engine
  115783. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115784. */
  115785. export class EngineInstrumentation implements IDisposable {
  115786. /**
  115787. * Define the instrumented engine.
  115788. */
  115789. engine: Engine;
  115790. private _captureGPUFrameTime;
  115791. private _gpuFrameTimeToken;
  115792. private _gpuFrameTime;
  115793. private _captureShaderCompilationTime;
  115794. private _shaderCompilationTime;
  115795. private _onBeginFrameObserver;
  115796. private _onEndFrameObserver;
  115797. private _onBeforeShaderCompilationObserver;
  115798. private _onAfterShaderCompilationObserver;
  115799. /**
  115800. * Gets the perf counter used for GPU frame time
  115801. */
  115802. readonly gpuFrameTimeCounter: PerfCounter;
  115803. /**
  115804. * Gets the GPU frame time capture status
  115805. */
  115806. /**
  115807. * Enable or disable the GPU frame time capture
  115808. */
  115809. captureGPUFrameTime: boolean;
  115810. /**
  115811. * Gets the perf counter used for shader compilation time
  115812. */
  115813. readonly shaderCompilationTimeCounter: PerfCounter;
  115814. /**
  115815. * Gets the shader compilation time capture status
  115816. */
  115817. /**
  115818. * Enable or disable the shader compilation time capture
  115819. */
  115820. captureShaderCompilationTime: boolean;
  115821. /**
  115822. * Instantiates a new engine instrumentation.
  115823. * This class can be used to get instrumentation data from a Babylon engine
  115824. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  115825. * @param engine Defines the engine to instrument
  115826. */
  115827. constructor(
  115828. /**
  115829. * Define the instrumented engine.
  115830. */
  115831. engine: Engine);
  115832. /**
  115833. * Dispose and release associated resources.
  115834. */
  115835. dispose(): void;
  115836. }
  115837. }
  115838. declare module BABYLON {
  115839. /**
  115840. * This class can be used to get instrumentation data from a Babylon engine
  115841. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  115842. */
  115843. export class SceneInstrumentation implements IDisposable {
  115844. /**
  115845. * Defines the scene to instrument
  115846. */
  115847. scene: Scene;
  115848. private _captureActiveMeshesEvaluationTime;
  115849. private _activeMeshesEvaluationTime;
  115850. private _captureRenderTargetsRenderTime;
  115851. private _renderTargetsRenderTime;
  115852. private _captureFrameTime;
  115853. private _frameTime;
  115854. private _captureRenderTime;
  115855. private _renderTime;
  115856. private _captureInterFrameTime;
  115857. private _interFrameTime;
  115858. private _captureParticlesRenderTime;
  115859. private _particlesRenderTime;
  115860. private _captureSpritesRenderTime;
  115861. private _spritesRenderTime;
  115862. private _capturePhysicsTime;
  115863. private _physicsTime;
  115864. private _captureAnimationsTime;
  115865. private _animationsTime;
  115866. private _captureCameraRenderTime;
  115867. private _cameraRenderTime;
  115868. private _onBeforeActiveMeshesEvaluationObserver;
  115869. private _onAfterActiveMeshesEvaluationObserver;
  115870. private _onBeforeRenderTargetsRenderObserver;
  115871. private _onAfterRenderTargetsRenderObserver;
  115872. private _onAfterRenderObserver;
  115873. private _onBeforeDrawPhaseObserver;
  115874. private _onAfterDrawPhaseObserver;
  115875. private _onBeforeAnimationsObserver;
  115876. private _onBeforeParticlesRenderingObserver;
  115877. private _onAfterParticlesRenderingObserver;
  115878. private _onBeforeSpritesRenderingObserver;
  115879. private _onAfterSpritesRenderingObserver;
  115880. private _onBeforePhysicsObserver;
  115881. private _onAfterPhysicsObserver;
  115882. private _onAfterAnimationsObserver;
  115883. private _onBeforeCameraRenderObserver;
  115884. private _onAfterCameraRenderObserver;
  115885. /**
  115886. * Gets the perf counter used for active meshes evaluation time
  115887. */
  115888. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  115889. /**
  115890. * Gets the active meshes evaluation time capture status
  115891. */
  115892. /**
  115893. * Enable or disable the active meshes evaluation time capture
  115894. */
  115895. captureActiveMeshesEvaluationTime: boolean;
  115896. /**
  115897. * Gets the perf counter used for render targets render time
  115898. */
  115899. readonly renderTargetsRenderTimeCounter: PerfCounter;
  115900. /**
  115901. * Gets the render targets render time capture status
  115902. */
  115903. /**
  115904. * Enable or disable the render targets render time capture
  115905. */
  115906. captureRenderTargetsRenderTime: boolean;
  115907. /**
  115908. * Gets the perf counter used for particles render time
  115909. */
  115910. readonly particlesRenderTimeCounter: PerfCounter;
  115911. /**
  115912. * Gets the particles render time capture status
  115913. */
  115914. /**
  115915. * Enable or disable the particles render time capture
  115916. */
  115917. captureParticlesRenderTime: boolean;
  115918. /**
  115919. * Gets the perf counter used for sprites render time
  115920. */
  115921. readonly spritesRenderTimeCounter: PerfCounter;
  115922. /**
  115923. * Gets the sprites render time capture status
  115924. */
  115925. /**
  115926. * Enable or disable the sprites render time capture
  115927. */
  115928. captureSpritesRenderTime: boolean;
  115929. /**
  115930. * Gets the perf counter used for physics time
  115931. */
  115932. readonly physicsTimeCounter: PerfCounter;
  115933. /**
  115934. * Gets the physics time capture status
  115935. */
  115936. /**
  115937. * Enable or disable the physics time capture
  115938. */
  115939. capturePhysicsTime: boolean;
  115940. /**
  115941. * Gets the perf counter used for animations time
  115942. */
  115943. readonly animationsTimeCounter: PerfCounter;
  115944. /**
  115945. * Gets the animations time capture status
  115946. */
  115947. /**
  115948. * Enable or disable the animations time capture
  115949. */
  115950. captureAnimationsTime: boolean;
  115951. /**
  115952. * Gets the perf counter used for frame time capture
  115953. */
  115954. readonly frameTimeCounter: PerfCounter;
  115955. /**
  115956. * Gets the frame time capture status
  115957. */
  115958. /**
  115959. * Enable or disable the frame time capture
  115960. */
  115961. captureFrameTime: boolean;
  115962. /**
  115963. * Gets the perf counter used for inter-frames time capture
  115964. */
  115965. readonly interFrameTimeCounter: PerfCounter;
  115966. /**
  115967. * Gets the inter-frames time capture status
  115968. */
  115969. /**
  115970. * Enable or disable the inter-frames time capture
  115971. */
  115972. captureInterFrameTime: boolean;
  115973. /**
  115974. * Gets the perf counter used for render time capture
  115975. */
  115976. readonly renderTimeCounter: PerfCounter;
  115977. /**
  115978. * Gets the render time capture status
  115979. */
  115980. /**
  115981. * Enable or disable the render time capture
  115982. */
  115983. captureRenderTime: boolean;
  115984. /**
  115985. * Gets the perf counter used for camera render time capture
  115986. */
  115987. readonly cameraRenderTimeCounter: PerfCounter;
  115988. /**
  115989. * Gets the camera render time capture status
  115990. */
  115991. /**
  115992. * Enable or disable the camera render time capture
  115993. */
  115994. captureCameraRenderTime: boolean;
  115995. /**
  115996. * Gets the perf counter used for draw calls
  115997. */
  115998. readonly drawCallsCounter: PerfCounter;
  115999. /**
  116000. * Instantiates a new scene instrumentation.
  116001. * This class can be used to get instrumentation data from a Babylon engine
  116002. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  116003. * @param scene Defines the scene to instrument
  116004. */
  116005. constructor(
  116006. /**
  116007. * Defines the scene to instrument
  116008. */
  116009. scene: Scene);
  116010. /**
  116011. * Dispose and release associated resources.
  116012. */
  116013. dispose(): void;
  116014. }
  116015. }
  116016. declare module BABYLON {
  116017. /** @hidden */
  116018. export var glowMapGenerationPixelShader: {
  116019. name: string;
  116020. shader: string;
  116021. };
  116022. }
  116023. declare module BABYLON {
  116024. /** @hidden */
  116025. export var glowMapGenerationVertexShader: {
  116026. name: string;
  116027. shader: string;
  116028. };
  116029. }
  116030. declare module BABYLON {
  116031. /**
  116032. * Effect layer options. This helps customizing the behaviour
  116033. * of the effect layer.
  116034. */
  116035. export interface IEffectLayerOptions {
  116036. /**
  116037. * Multiplication factor apply to the canvas size to compute the render target size
  116038. * used to generated the objects (the smaller the faster).
  116039. */
  116040. mainTextureRatio: number;
  116041. /**
  116042. * Enforces a fixed size texture to ensure effect stability across devices.
  116043. */
  116044. mainTextureFixedSize?: number;
  116045. /**
  116046. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  116047. */
  116048. alphaBlendingMode: number;
  116049. /**
  116050. * The camera attached to the layer.
  116051. */
  116052. camera: Nullable<Camera>;
  116053. /**
  116054. * The rendering group to draw the layer in.
  116055. */
  116056. renderingGroupId: number;
  116057. }
  116058. /**
  116059. * The effect layer Helps adding post process effect blended with the main pass.
  116060. *
  116061. * This can be for instance use to generate glow or higlight effects on the scene.
  116062. *
  116063. * The effect layer class can not be used directly and is intented to inherited from to be
  116064. * customized per effects.
  116065. */
  116066. export abstract class EffectLayer {
  116067. private _vertexBuffers;
  116068. private _indexBuffer;
  116069. private _cachedDefines;
  116070. private _effectLayerMapGenerationEffect;
  116071. private _effectLayerOptions;
  116072. private _mergeEffect;
  116073. protected _scene: Scene;
  116074. protected _engine: Engine;
  116075. protected _maxSize: number;
  116076. protected _mainTextureDesiredSize: ISize;
  116077. protected _mainTexture: RenderTargetTexture;
  116078. protected _shouldRender: boolean;
  116079. protected _postProcesses: PostProcess[];
  116080. protected _textures: BaseTexture[];
  116081. protected _emissiveTextureAndColor: {
  116082. texture: Nullable<BaseTexture>;
  116083. color: Color4;
  116084. };
  116085. /**
  116086. * The name of the layer
  116087. */
  116088. name: string;
  116089. /**
  116090. * The clear color of the texture used to generate the glow map.
  116091. */
  116092. neutralColor: Color4;
  116093. /**
  116094. * Specifies wether the highlight layer is enabled or not.
  116095. */
  116096. isEnabled: boolean;
  116097. /**
  116098. * Gets the camera attached to the layer.
  116099. */
  116100. readonly camera: Nullable<Camera>;
  116101. /**
  116102. * Gets the rendering group id the layer should render in.
  116103. */
  116104. renderingGroupId: number;
  116105. /**
  116106. * An event triggered when the effect layer has been disposed.
  116107. */
  116108. onDisposeObservable: Observable<EffectLayer>;
  116109. /**
  116110. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  116111. */
  116112. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  116113. /**
  116114. * An event triggered when the generated texture is being merged in the scene.
  116115. */
  116116. onBeforeComposeObservable: Observable<EffectLayer>;
  116117. /**
  116118. * An event triggered when the generated texture has been merged in the scene.
  116119. */
  116120. onAfterComposeObservable: Observable<EffectLayer>;
  116121. /**
  116122. * An event triggered when the efffect layer changes its size.
  116123. */
  116124. onSizeChangedObservable: Observable<EffectLayer>;
  116125. /** @hidden */
  116126. static _SceneComponentInitialization: (scene: Scene) => void;
  116127. /**
  116128. * Instantiates a new effect Layer and references it in the scene.
  116129. * @param name The name of the layer
  116130. * @param scene The scene to use the layer in
  116131. */
  116132. constructor(
  116133. /** The Friendly of the effect in the scene */
  116134. name: string, scene: Scene);
  116135. /**
  116136. * Get the effect name of the layer.
  116137. * @return The effect name
  116138. */
  116139. abstract getEffectName(): string;
  116140. /**
  116141. * Checks for the readiness of the element composing the layer.
  116142. * @param subMesh the mesh to check for
  116143. * @param useInstances specify wether or not to use instances to render the mesh
  116144. * @return true if ready otherwise, false
  116145. */
  116146. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116147. /**
  116148. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116149. * @returns true if the effect requires stencil during the main canvas render pass.
  116150. */
  116151. abstract needStencil(): boolean;
  116152. /**
  116153. * Create the merge effect. This is the shader use to blit the information back
  116154. * to the main canvas at the end of the scene rendering.
  116155. * @returns The effect containing the shader used to merge the effect on the main canvas
  116156. */
  116157. protected abstract _createMergeEffect(): Effect;
  116158. /**
  116159. * Creates the render target textures and post processes used in the effect layer.
  116160. */
  116161. protected abstract _createTextureAndPostProcesses(): void;
  116162. /**
  116163. * Implementation specific of rendering the generating effect on the main canvas.
  116164. * @param effect The effect used to render through
  116165. */
  116166. protected abstract _internalRender(effect: Effect): void;
  116167. /**
  116168. * Sets the required values for both the emissive texture and and the main color.
  116169. */
  116170. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116171. /**
  116172. * Free any resources and references associated to a mesh.
  116173. * Internal use
  116174. * @param mesh The mesh to free.
  116175. */
  116176. abstract _disposeMesh(mesh: Mesh): void;
  116177. /**
  116178. * Serializes this layer (Glow or Highlight for example)
  116179. * @returns a serialized layer object
  116180. */
  116181. abstract serialize?(): any;
  116182. /**
  116183. * Initializes the effect layer with the required options.
  116184. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  116185. */
  116186. protected _init(options: Partial<IEffectLayerOptions>): void;
  116187. /**
  116188. * Generates the index buffer of the full screen quad blending to the main canvas.
  116189. */
  116190. private _generateIndexBuffer;
  116191. /**
  116192. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  116193. */
  116194. private _generateVertexBuffer;
  116195. /**
  116196. * Sets the main texture desired size which is the closest power of two
  116197. * of the engine canvas size.
  116198. */
  116199. private _setMainTextureSize;
  116200. /**
  116201. * Creates the main texture for the effect layer.
  116202. */
  116203. protected _createMainTexture(): void;
  116204. /**
  116205. * Adds specific effects defines.
  116206. * @param defines The defines to add specifics to.
  116207. */
  116208. protected _addCustomEffectDefines(defines: string[]): void;
  116209. /**
  116210. * Checks for the readiness of the element composing the layer.
  116211. * @param subMesh the mesh to check for
  116212. * @param useInstances specify wether or not to use instances to render the mesh
  116213. * @param emissiveTexture the associated emissive texture used to generate the glow
  116214. * @return true if ready otherwise, false
  116215. */
  116216. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  116217. /**
  116218. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  116219. */
  116220. render(): void;
  116221. /**
  116222. * Determine if a given mesh will be used in the current effect.
  116223. * @param mesh mesh to test
  116224. * @returns true if the mesh will be used
  116225. */
  116226. hasMesh(mesh: AbstractMesh): boolean;
  116227. /**
  116228. * Returns true if the layer contains information to display, otherwise false.
  116229. * @returns true if the glow layer should be rendered
  116230. */
  116231. shouldRender(): boolean;
  116232. /**
  116233. * Returns true if the mesh should render, otherwise false.
  116234. * @param mesh The mesh to render
  116235. * @returns true if it should render otherwise false
  116236. */
  116237. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  116238. /**
  116239. * Returns true if the mesh can be rendered, otherwise false.
  116240. * @param mesh The mesh to render
  116241. * @param material The material used on the mesh
  116242. * @returns true if it can be rendered otherwise false
  116243. */
  116244. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116245. /**
  116246. * Returns true if the mesh should render, otherwise false.
  116247. * @param mesh The mesh to render
  116248. * @returns true if it should render otherwise false
  116249. */
  116250. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  116251. /**
  116252. * Renders the submesh passed in parameter to the generation map.
  116253. */
  116254. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  116255. /**
  116256. * Rebuild the required buffers.
  116257. * @hidden Internal use only.
  116258. */
  116259. _rebuild(): void;
  116260. /**
  116261. * Dispose only the render target textures and post process.
  116262. */
  116263. private _disposeTextureAndPostProcesses;
  116264. /**
  116265. * Dispose the highlight layer and free resources.
  116266. */
  116267. dispose(): void;
  116268. /**
  116269. * Gets the class name of the effect layer
  116270. * @returns the string with the class name of the effect layer
  116271. */
  116272. getClassName(): string;
  116273. /**
  116274. * Creates an effect layer from parsed effect layer data
  116275. * @param parsedEffectLayer defines effect layer data
  116276. * @param scene defines the current scene
  116277. * @param rootUrl defines the root URL containing the effect layer information
  116278. * @returns a parsed effect Layer
  116279. */
  116280. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  116281. }
  116282. }
  116283. declare module BABYLON {
  116284. interface AbstractScene {
  116285. /**
  116286. * The list of effect layers (highlights/glow) added to the scene
  116287. * @see http://doc.babylonjs.com/how_to/highlight_layer
  116288. * @see http://doc.babylonjs.com/how_to/glow_layer
  116289. */
  116290. effectLayers: Array<EffectLayer>;
  116291. /**
  116292. * Removes the given effect layer from this scene.
  116293. * @param toRemove defines the effect layer to remove
  116294. * @returns the index of the removed effect layer
  116295. */
  116296. removeEffectLayer(toRemove: EffectLayer): number;
  116297. /**
  116298. * Adds the given effect layer to this scene
  116299. * @param newEffectLayer defines the effect layer to add
  116300. */
  116301. addEffectLayer(newEffectLayer: EffectLayer): void;
  116302. }
  116303. /**
  116304. * Defines the layer scene component responsible to manage any effect layers
  116305. * in a given scene.
  116306. */
  116307. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  116308. /**
  116309. * The component name helpfull to identify the component in the list of scene components.
  116310. */
  116311. readonly name: string;
  116312. /**
  116313. * The scene the component belongs to.
  116314. */
  116315. scene: Scene;
  116316. private _engine;
  116317. private _renderEffects;
  116318. private _needStencil;
  116319. private _previousStencilState;
  116320. /**
  116321. * Creates a new instance of the component for the given scene
  116322. * @param scene Defines the scene to register the component in
  116323. */
  116324. constructor(scene: Scene);
  116325. /**
  116326. * Registers the component in a given scene
  116327. */
  116328. register(): void;
  116329. /**
  116330. * Rebuilds the elements related to this component in case of
  116331. * context lost for instance.
  116332. */
  116333. rebuild(): void;
  116334. /**
  116335. * Serializes the component data to the specified json object
  116336. * @param serializationObject The object to serialize to
  116337. */
  116338. serialize(serializationObject: any): void;
  116339. /**
  116340. * Adds all the elements from the container to the scene
  116341. * @param container the container holding the elements
  116342. */
  116343. addFromContainer(container: AbstractScene): void;
  116344. /**
  116345. * Removes all the elements in the container from the scene
  116346. * @param container contains the elements to remove
  116347. * @param dispose if the removed element should be disposed (default: false)
  116348. */
  116349. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116350. /**
  116351. * Disposes the component and the associated ressources.
  116352. */
  116353. dispose(): void;
  116354. private _isReadyForMesh;
  116355. private _renderMainTexture;
  116356. private _setStencil;
  116357. private _setStencilBack;
  116358. private _draw;
  116359. private _drawCamera;
  116360. private _drawRenderingGroup;
  116361. }
  116362. }
  116363. declare module BABYLON {
  116364. /** @hidden */
  116365. export var glowMapMergePixelShader: {
  116366. name: string;
  116367. shader: string;
  116368. };
  116369. }
  116370. declare module BABYLON {
  116371. /** @hidden */
  116372. export var glowMapMergeVertexShader: {
  116373. name: string;
  116374. shader: string;
  116375. };
  116376. }
  116377. declare module BABYLON {
  116378. interface AbstractScene {
  116379. /**
  116380. * Return a the first highlight layer of the scene with a given name.
  116381. * @param name The name of the highlight layer to look for.
  116382. * @return The highlight layer if found otherwise null.
  116383. */
  116384. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  116385. }
  116386. /**
  116387. * Glow layer options. This helps customizing the behaviour
  116388. * of the glow layer.
  116389. */
  116390. export interface IGlowLayerOptions {
  116391. /**
  116392. * Multiplication factor apply to the canvas size to compute the render target size
  116393. * used to generated the glowing objects (the smaller the faster).
  116394. */
  116395. mainTextureRatio: number;
  116396. /**
  116397. * Enforces a fixed size texture to ensure resize independant blur.
  116398. */
  116399. mainTextureFixedSize?: number;
  116400. /**
  116401. * How big is the kernel of the blur texture.
  116402. */
  116403. blurKernelSize: number;
  116404. /**
  116405. * The camera attached to the layer.
  116406. */
  116407. camera: Nullable<Camera>;
  116408. /**
  116409. * Enable MSAA by chosing the number of samples.
  116410. */
  116411. mainTextureSamples?: number;
  116412. /**
  116413. * The rendering group to draw the layer in.
  116414. */
  116415. renderingGroupId: number;
  116416. }
  116417. /**
  116418. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  116419. *
  116420. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116421. * glowy meshes to your scene.
  116422. *
  116423. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  116424. */
  116425. export class GlowLayer extends EffectLayer {
  116426. /**
  116427. * Effect Name of the layer.
  116428. */
  116429. static readonly EffectName: string;
  116430. /**
  116431. * The default blur kernel size used for the glow.
  116432. */
  116433. static DefaultBlurKernelSize: number;
  116434. /**
  116435. * The default texture size ratio used for the glow.
  116436. */
  116437. static DefaultTextureRatio: number;
  116438. /**
  116439. * Sets the kernel size of the blur.
  116440. */
  116441. /**
  116442. * Gets the kernel size of the blur.
  116443. */
  116444. blurKernelSize: number;
  116445. /**
  116446. * Sets the glow intensity.
  116447. */
  116448. /**
  116449. * Gets the glow intensity.
  116450. */
  116451. intensity: number;
  116452. private _options;
  116453. private _intensity;
  116454. private _horizontalBlurPostprocess1;
  116455. private _verticalBlurPostprocess1;
  116456. private _horizontalBlurPostprocess2;
  116457. private _verticalBlurPostprocess2;
  116458. private _blurTexture1;
  116459. private _blurTexture2;
  116460. private _postProcesses1;
  116461. private _postProcesses2;
  116462. private _includedOnlyMeshes;
  116463. private _excludedMeshes;
  116464. /**
  116465. * Callback used to let the user override the color selection on a per mesh basis
  116466. */
  116467. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  116468. /**
  116469. * Callback used to let the user override the texture selection on a per mesh basis
  116470. */
  116471. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  116472. /**
  116473. * Instantiates a new glow Layer and references it to the scene.
  116474. * @param name The name of the layer
  116475. * @param scene The scene to use the layer in
  116476. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  116477. */
  116478. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  116479. /**
  116480. * Get the effect name of the layer.
  116481. * @return The effect name
  116482. */
  116483. getEffectName(): string;
  116484. /**
  116485. * Create the merge effect. This is the shader use to blit the information back
  116486. * to the main canvas at the end of the scene rendering.
  116487. */
  116488. protected _createMergeEffect(): Effect;
  116489. /**
  116490. * Creates the render target textures and post processes used in the glow layer.
  116491. */
  116492. protected _createTextureAndPostProcesses(): void;
  116493. /**
  116494. * Checks for the readiness of the element composing the layer.
  116495. * @param subMesh the mesh to check for
  116496. * @param useInstances specify wether or not to use instances to render the mesh
  116497. * @param emissiveTexture the associated emissive texture used to generate the glow
  116498. * @return true if ready otherwise, false
  116499. */
  116500. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116501. /**
  116502. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116503. */
  116504. needStencil(): boolean;
  116505. /**
  116506. * Returns true if the mesh can be rendered, otherwise false.
  116507. * @param mesh The mesh to render
  116508. * @param material The material used on the mesh
  116509. * @returns true if it can be rendered otherwise false
  116510. */
  116511. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  116512. /**
  116513. * Implementation specific of rendering the generating effect on the main canvas.
  116514. * @param effect The effect used to render through
  116515. */
  116516. protected _internalRender(effect: Effect): void;
  116517. /**
  116518. * Sets the required values for both the emissive texture and and the main color.
  116519. */
  116520. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116521. /**
  116522. * Returns true if the mesh should render, otherwise false.
  116523. * @param mesh The mesh to render
  116524. * @returns true if it should render otherwise false
  116525. */
  116526. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116527. /**
  116528. * Adds specific effects defines.
  116529. * @param defines The defines to add specifics to.
  116530. */
  116531. protected _addCustomEffectDefines(defines: string[]): void;
  116532. /**
  116533. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  116534. * @param mesh The mesh to exclude from the glow layer
  116535. */
  116536. addExcludedMesh(mesh: Mesh): void;
  116537. /**
  116538. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  116539. * @param mesh The mesh to remove
  116540. */
  116541. removeExcludedMesh(mesh: Mesh): void;
  116542. /**
  116543. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  116544. * @param mesh The mesh to include in the glow layer
  116545. */
  116546. addIncludedOnlyMesh(mesh: Mesh): void;
  116547. /**
  116548. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  116549. * @param mesh The mesh to remove
  116550. */
  116551. removeIncludedOnlyMesh(mesh: Mesh): void;
  116552. /**
  116553. * Determine if a given mesh will be used in the glow layer
  116554. * @param mesh The mesh to test
  116555. * @returns true if the mesh will be highlighted by the current glow layer
  116556. */
  116557. hasMesh(mesh: AbstractMesh): boolean;
  116558. /**
  116559. * Free any resources and references associated to a mesh.
  116560. * Internal use
  116561. * @param mesh The mesh to free.
  116562. * @hidden
  116563. */
  116564. _disposeMesh(mesh: Mesh): void;
  116565. /**
  116566. * Gets the class name of the effect layer
  116567. * @returns the string with the class name of the effect layer
  116568. */
  116569. getClassName(): string;
  116570. /**
  116571. * Serializes this glow layer
  116572. * @returns a serialized glow layer object
  116573. */
  116574. serialize(): any;
  116575. /**
  116576. * Creates a Glow Layer from parsed glow layer data
  116577. * @param parsedGlowLayer defines glow layer data
  116578. * @param scene defines the current scene
  116579. * @param rootUrl defines the root URL containing the glow layer information
  116580. * @returns a parsed Glow Layer
  116581. */
  116582. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  116583. }
  116584. }
  116585. declare module BABYLON {
  116586. /** @hidden */
  116587. export var glowBlurPostProcessPixelShader: {
  116588. name: string;
  116589. shader: string;
  116590. };
  116591. }
  116592. declare module BABYLON {
  116593. interface AbstractScene {
  116594. /**
  116595. * Return a the first highlight layer of the scene with a given name.
  116596. * @param name The name of the highlight layer to look for.
  116597. * @return The highlight layer if found otherwise null.
  116598. */
  116599. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  116600. }
  116601. /**
  116602. * Highlight layer options. This helps customizing the behaviour
  116603. * of the highlight layer.
  116604. */
  116605. export interface IHighlightLayerOptions {
  116606. /**
  116607. * Multiplication factor apply to the canvas size to compute the render target size
  116608. * used to generated the glowing objects (the smaller the faster).
  116609. */
  116610. mainTextureRatio: number;
  116611. /**
  116612. * Enforces a fixed size texture to ensure resize independant blur.
  116613. */
  116614. mainTextureFixedSize?: number;
  116615. /**
  116616. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  116617. * of the picture to blur (the smaller the faster).
  116618. */
  116619. blurTextureSizeRatio: number;
  116620. /**
  116621. * How big in texel of the blur texture is the vertical blur.
  116622. */
  116623. blurVerticalSize: number;
  116624. /**
  116625. * How big in texel of the blur texture is the horizontal blur.
  116626. */
  116627. blurHorizontalSize: number;
  116628. /**
  116629. * Alpha blending mode used to apply the blur. Default is combine.
  116630. */
  116631. alphaBlendingMode: number;
  116632. /**
  116633. * The camera attached to the layer.
  116634. */
  116635. camera: Nullable<Camera>;
  116636. /**
  116637. * Should we display highlight as a solid stroke?
  116638. */
  116639. isStroke?: boolean;
  116640. /**
  116641. * The rendering group to draw the layer in.
  116642. */
  116643. renderingGroupId: number;
  116644. }
  116645. /**
  116646. * The highlight layer Helps adding a glow effect around a mesh.
  116647. *
  116648. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  116649. * glowy meshes to your scene.
  116650. *
  116651. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  116652. */
  116653. export class HighlightLayer extends EffectLayer {
  116654. name: string;
  116655. /**
  116656. * Effect Name of the highlight layer.
  116657. */
  116658. static readonly EffectName: string;
  116659. /**
  116660. * The neutral color used during the preparation of the glow effect.
  116661. * This is black by default as the blend operation is a blend operation.
  116662. */
  116663. static NeutralColor: Color4;
  116664. /**
  116665. * Stencil value used for glowing meshes.
  116666. */
  116667. static GlowingMeshStencilReference: number;
  116668. /**
  116669. * Stencil value used for the other meshes in the scene.
  116670. */
  116671. static NormalMeshStencilReference: number;
  116672. /**
  116673. * Specifies whether or not the inner glow is ACTIVE in the layer.
  116674. */
  116675. innerGlow: boolean;
  116676. /**
  116677. * Specifies whether or not the outer glow is ACTIVE in the layer.
  116678. */
  116679. outerGlow: boolean;
  116680. /**
  116681. * Specifies the horizontal size of the blur.
  116682. */
  116683. /**
  116684. * Gets the horizontal size of the blur.
  116685. */
  116686. blurHorizontalSize: number;
  116687. /**
  116688. * Specifies the vertical size of the blur.
  116689. */
  116690. /**
  116691. * Gets the vertical size of the blur.
  116692. */
  116693. blurVerticalSize: number;
  116694. /**
  116695. * An event triggered when the highlight layer is being blurred.
  116696. */
  116697. onBeforeBlurObservable: Observable<HighlightLayer>;
  116698. /**
  116699. * An event triggered when the highlight layer has been blurred.
  116700. */
  116701. onAfterBlurObservable: Observable<HighlightLayer>;
  116702. private _instanceGlowingMeshStencilReference;
  116703. private _options;
  116704. private _downSamplePostprocess;
  116705. private _horizontalBlurPostprocess;
  116706. private _verticalBlurPostprocess;
  116707. private _blurTexture;
  116708. private _meshes;
  116709. private _excludedMeshes;
  116710. /**
  116711. * Instantiates a new highlight Layer and references it to the scene..
  116712. * @param name The name of the layer
  116713. * @param scene The scene to use the layer in
  116714. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  116715. */
  116716. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  116717. /**
  116718. * Get the effect name of the layer.
  116719. * @return The effect name
  116720. */
  116721. getEffectName(): string;
  116722. /**
  116723. * Create the merge effect. This is the shader use to blit the information back
  116724. * to the main canvas at the end of the scene rendering.
  116725. */
  116726. protected _createMergeEffect(): Effect;
  116727. /**
  116728. * Creates the render target textures and post processes used in the highlight layer.
  116729. */
  116730. protected _createTextureAndPostProcesses(): void;
  116731. /**
  116732. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  116733. */
  116734. needStencil(): boolean;
  116735. /**
  116736. * Checks for the readiness of the element composing the layer.
  116737. * @param subMesh the mesh to check for
  116738. * @param useInstances specify wether or not to use instances to render the mesh
  116739. * @param emissiveTexture the associated emissive texture used to generate the glow
  116740. * @return true if ready otherwise, false
  116741. */
  116742. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  116743. /**
  116744. * Implementation specific of rendering the generating effect on the main canvas.
  116745. * @param effect The effect used to render through
  116746. */
  116747. protected _internalRender(effect: Effect): void;
  116748. /**
  116749. * Returns true if the layer contains information to display, otherwise false.
  116750. */
  116751. shouldRender(): boolean;
  116752. /**
  116753. * Returns true if the mesh should render, otherwise false.
  116754. * @param mesh The mesh to render
  116755. * @returns true if it should render otherwise false
  116756. */
  116757. protected _shouldRenderMesh(mesh: Mesh): boolean;
  116758. /**
  116759. * Sets the required values for both the emissive texture and and the main color.
  116760. */
  116761. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  116762. /**
  116763. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  116764. * @param mesh The mesh to exclude from the highlight layer
  116765. */
  116766. addExcludedMesh(mesh: Mesh): void;
  116767. /**
  116768. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  116769. * @param mesh The mesh to highlight
  116770. */
  116771. removeExcludedMesh(mesh: Mesh): void;
  116772. /**
  116773. * Determine if a given mesh will be highlighted by the current HighlightLayer
  116774. * @param mesh mesh to test
  116775. * @returns true if the mesh will be highlighted by the current HighlightLayer
  116776. */
  116777. hasMesh(mesh: AbstractMesh): boolean;
  116778. /**
  116779. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  116780. * @param mesh The mesh to highlight
  116781. * @param color The color of the highlight
  116782. * @param glowEmissiveOnly Extract the glow from the emissive texture
  116783. */
  116784. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  116785. /**
  116786. * Remove a mesh from the highlight layer in order to make it stop glowing.
  116787. * @param mesh The mesh to highlight
  116788. */
  116789. removeMesh(mesh: Mesh): void;
  116790. /**
  116791. * Force the stencil to the normal expected value for none glowing parts
  116792. */
  116793. private _defaultStencilReference;
  116794. /**
  116795. * Free any resources and references associated to a mesh.
  116796. * Internal use
  116797. * @param mesh The mesh to free.
  116798. * @hidden
  116799. */
  116800. _disposeMesh(mesh: Mesh): void;
  116801. /**
  116802. * Dispose the highlight layer and free resources.
  116803. */
  116804. dispose(): void;
  116805. /**
  116806. * Gets the class name of the effect layer
  116807. * @returns the string with the class name of the effect layer
  116808. */
  116809. getClassName(): string;
  116810. /**
  116811. * Serializes this Highlight layer
  116812. * @returns a serialized Highlight layer object
  116813. */
  116814. serialize(): any;
  116815. /**
  116816. * Creates a Highlight layer from parsed Highlight layer data
  116817. * @param parsedHightlightLayer defines the Highlight layer data
  116818. * @param scene defines the current scene
  116819. * @param rootUrl defines the root URL containing the Highlight layer information
  116820. * @returns a parsed Highlight layer
  116821. */
  116822. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  116823. }
  116824. }
  116825. declare module BABYLON {
  116826. interface AbstractScene {
  116827. /**
  116828. * The list of layers (background and foreground) of the scene
  116829. */
  116830. layers: Array<Layer>;
  116831. }
  116832. /**
  116833. * Defines the layer scene component responsible to manage any layers
  116834. * in a given scene.
  116835. */
  116836. export class LayerSceneComponent implements ISceneComponent {
  116837. /**
  116838. * The component name helpfull to identify the component in the list of scene components.
  116839. */
  116840. readonly name: string;
  116841. /**
  116842. * The scene the component belongs to.
  116843. */
  116844. scene: Scene;
  116845. private _engine;
  116846. /**
  116847. * Creates a new instance of the component for the given scene
  116848. * @param scene Defines the scene to register the component in
  116849. */
  116850. constructor(scene: Scene);
  116851. /**
  116852. * Registers the component in a given scene
  116853. */
  116854. register(): void;
  116855. /**
  116856. * Rebuilds the elements related to this component in case of
  116857. * context lost for instance.
  116858. */
  116859. rebuild(): void;
  116860. /**
  116861. * Disposes the component and the associated ressources.
  116862. */
  116863. dispose(): void;
  116864. private _draw;
  116865. private _drawCameraPredicate;
  116866. private _drawCameraBackground;
  116867. private _drawCameraForeground;
  116868. private _drawRenderTargetPredicate;
  116869. private _drawRenderTargetBackground;
  116870. private _drawRenderTargetForeground;
  116871. /**
  116872. * Adds all the elements from the container to the scene
  116873. * @param container the container holding the elements
  116874. */
  116875. addFromContainer(container: AbstractScene): void;
  116876. /**
  116877. * Removes all the elements in the container from the scene
  116878. * @param container contains the elements to remove
  116879. * @param dispose if the removed element should be disposed (default: false)
  116880. */
  116881. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  116882. }
  116883. }
  116884. declare module BABYLON {
  116885. /** @hidden */
  116886. export var layerPixelShader: {
  116887. name: string;
  116888. shader: string;
  116889. };
  116890. }
  116891. declare module BABYLON {
  116892. /** @hidden */
  116893. export var layerVertexShader: {
  116894. name: string;
  116895. shader: string;
  116896. };
  116897. }
  116898. declare module BABYLON {
  116899. /**
  116900. * This represents a full screen 2d layer.
  116901. * This can be useful to display a picture in the background of your scene for instance.
  116902. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116903. */
  116904. export class Layer {
  116905. /**
  116906. * Define the name of the layer.
  116907. */
  116908. name: string;
  116909. /**
  116910. * Define the texture the layer should display.
  116911. */
  116912. texture: Nullable<Texture>;
  116913. /**
  116914. * Is the layer in background or foreground.
  116915. */
  116916. isBackground: boolean;
  116917. /**
  116918. * Define the color of the layer (instead of texture).
  116919. */
  116920. color: Color4;
  116921. /**
  116922. * Define the scale of the layer in order to zoom in out of the texture.
  116923. */
  116924. scale: Vector2;
  116925. /**
  116926. * Define an offset for the layer in order to shift the texture.
  116927. */
  116928. offset: Vector2;
  116929. /**
  116930. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  116931. */
  116932. alphaBlendingMode: number;
  116933. /**
  116934. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  116935. * Alpha test will not mix with the background color in case of transparency.
  116936. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  116937. */
  116938. alphaTest: boolean;
  116939. /**
  116940. * Define a mask to restrict the layer to only some of the scene cameras.
  116941. */
  116942. layerMask: number;
  116943. /**
  116944. * Define the list of render target the layer is visible into.
  116945. */
  116946. renderTargetTextures: RenderTargetTexture[];
  116947. /**
  116948. * Define if the layer is only used in renderTarget or if it also
  116949. * renders in the main frame buffer of the canvas.
  116950. */
  116951. renderOnlyInRenderTargetTextures: boolean;
  116952. private _scene;
  116953. private _vertexBuffers;
  116954. private _indexBuffer;
  116955. private _effect;
  116956. private _alphaTestEffect;
  116957. /**
  116958. * An event triggered when the layer is disposed.
  116959. */
  116960. onDisposeObservable: Observable<Layer>;
  116961. private _onDisposeObserver;
  116962. /**
  116963. * Back compatibility with callback before the onDisposeObservable existed.
  116964. * The set callback will be triggered when the layer has been disposed.
  116965. */
  116966. onDispose: () => void;
  116967. /**
  116968. * An event triggered before rendering the scene
  116969. */
  116970. onBeforeRenderObservable: Observable<Layer>;
  116971. private _onBeforeRenderObserver;
  116972. /**
  116973. * Back compatibility with callback before the onBeforeRenderObservable existed.
  116974. * The set callback will be triggered just before rendering the layer.
  116975. */
  116976. onBeforeRender: () => void;
  116977. /**
  116978. * An event triggered after rendering the scene
  116979. */
  116980. onAfterRenderObservable: Observable<Layer>;
  116981. private _onAfterRenderObserver;
  116982. /**
  116983. * Back compatibility with callback before the onAfterRenderObservable existed.
  116984. * The set callback will be triggered just after rendering the layer.
  116985. */
  116986. onAfterRender: () => void;
  116987. /**
  116988. * Instantiates a new layer.
  116989. * This represents a full screen 2d layer.
  116990. * This can be useful to display a picture in the background of your scene for instance.
  116991. * @see https://www.babylonjs-playground.com/#08A2BS#1
  116992. * @param name Define the name of the layer in the scene
  116993. * @param imgUrl Define the url of the texture to display in the layer
  116994. * @param scene Define the scene the layer belongs to
  116995. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  116996. * @param color Defines a color for the layer
  116997. */
  116998. constructor(
  116999. /**
  117000. * Define the name of the layer.
  117001. */
  117002. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  117003. private _createIndexBuffer;
  117004. /** @hidden */
  117005. _rebuild(): void;
  117006. /**
  117007. * Renders the layer in the scene.
  117008. */
  117009. render(): void;
  117010. /**
  117011. * Disposes and releases the associated ressources.
  117012. */
  117013. dispose(): void;
  117014. }
  117015. }
  117016. declare module BABYLON {
  117017. /** @hidden */
  117018. export var lensFlarePixelShader: {
  117019. name: string;
  117020. shader: string;
  117021. };
  117022. }
  117023. declare module BABYLON {
  117024. /** @hidden */
  117025. export var lensFlareVertexShader: {
  117026. name: string;
  117027. shader: string;
  117028. };
  117029. }
  117030. declare module BABYLON {
  117031. /**
  117032. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117033. * It is usually composed of several `lensFlare`.
  117034. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117035. */
  117036. export class LensFlareSystem {
  117037. /**
  117038. * Define the name of the lens flare system
  117039. */
  117040. name: string;
  117041. /**
  117042. * List of lens flares used in this system.
  117043. */
  117044. lensFlares: LensFlare[];
  117045. /**
  117046. * Define a limit from the border the lens flare can be visible.
  117047. */
  117048. borderLimit: number;
  117049. /**
  117050. * Define a viewport border we do not want to see the lens flare in.
  117051. */
  117052. viewportBorder: number;
  117053. /**
  117054. * Define a predicate which could limit the list of meshes able to occlude the effect.
  117055. */
  117056. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  117057. /**
  117058. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  117059. */
  117060. layerMask: number;
  117061. /**
  117062. * Define the id of the lens flare system in the scene.
  117063. * (equal to name by default)
  117064. */
  117065. id: string;
  117066. private _scene;
  117067. private _emitter;
  117068. private _vertexBuffers;
  117069. private _indexBuffer;
  117070. private _effect;
  117071. private _positionX;
  117072. private _positionY;
  117073. private _isEnabled;
  117074. /** @hidden */
  117075. static _SceneComponentInitialization: (scene: Scene) => void;
  117076. /**
  117077. * Instantiates a lens flare system.
  117078. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  117079. * It is usually composed of several `lensFlare`.
  117080. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117081. * @param name Define the name of the lens flare system in the scene
  117082. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  117083. * @param scene Define the scene the lens flare system belongs to
  117084. */
  117085. constructor(
  117086. /**
  117087. * Define the name of the lens flare system
  117088. */
  117089. name: string, emitter: any, scene: Scene);
  117090. /**
  117091. * Define if the lens flare system is enabled.
  117092. */
  117093. isEnabled: boolean;
  117094. /**
  117095. * Get the scene the effects belongs to.
  117096. * @returns the scene holding the lens flare system
  117097. */
  117098. getScene(): Scene;
  117099. /**
  117100. * Get the emitter of the lens flare system.
  117101. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117102. * @returns the emitter of the lens flare system
  117103. */
  117104. getEmitter(): any;
  117105. /**
  117106. * Set the emitter of the lens flare system.
  117107. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  117108. * @param newEmitter Define the new emitter of the system
  117109. */
  117110. setEmitter(newEmitter: any): void;
  117111. /**
  117112. * Get the lens flare system emitter position.
  117113. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  117114. * @returns the position
  117115. */
  117116. getEmitterPosition(): Vector3;
  117117. /**
  117118. * @hidden
  117119. */
  117120. computeEffectivePosition(globalViewport: Viewport): boolean;
  117121. /** @hidden */
  117122. _isVisible(): boolean;
  117123. /**
  117124. * @hidden
  117125. */
  117126. render(): boolean;
  117127. /**
  117128. * Dispose and release the lens flare with its associated resources.
  117129. */
  117130. dispose(): void;
  117131. /**
  117132. * Parse a lens flare system from a JSON repressentation
  117133. * @param parsedLensFlareSystem Define the JSON to parse
  117134. * @param scene Define the scene the parsed system should be instantiated in
  117135. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  117136. * @returns the parsed system
  117137. */
  117138. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  117139. /**
  117140. * Serialize the current Lens Flare System into a JSON representation.
  117141. * @returns the serialized JSON
  117142. */
  117143. serialize(): any;
  117144. }
  117145. }
  117146. declare module BABYLON {
  117147. /**
  117148. * This represents one of the lens effect in a `lensFlareSystem`.
  117149. * It controls one of the indiviual texture used in the effect.
  117150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117151. */
  117152. export class LensFlare {
  117153. /**
  117154. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117155. */
  117156. size: number;
  117157. /**
  117158. * 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.
  117159. */
  117160. position: number;
  117161. /**
  117162. * Define the lens color.
  117163. */
  117164. color: Color3;
  117165. /**
  117166. * Define the lens texture.
  117167. */
  117168. texture: Nullable<Texture>;
  117169. /**
  117170. * Define the alpha mode to render this particular lens.
  117171. */
  117172. alphaMode: number;
  117173. private _system;
  117174. /**
  117175. * Creates a new Lens Flare.
  117176. * This represents one of the lens effect in a `lensFlareSystem`.
  117177. * It controls one of the indiviual texture used in the effect.
  117178. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117179. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  117180. * @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.
  117181. * @param color Define the lens color
  117182. * @param imgUrl Define the lens texture url
  117183. * @param system Define the `lensFlareSystem` this flare is part of
  117184. * @returns The newly created Lens Flare
  117185. */
  117186. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  117187. /**
  117188. * Instantiates a new Lens Flare.
  117189. * This represents one of the lens effect in a `lensFlareSystem`.
  117190. * It controls one of the indiviual texture used in the effect.
  117191. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117192. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  117193. * @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.
  117194. * @param color Define the lens color
  117195. * @param imgUrl Define the lens texture url
  117196. * @param system Define the `lensFlareSystem` this flare is part of
  117197. */
  117198. constructor(
  117199. /**
  117200. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  117201. */
  117202. size: number,
  117203. /**
  117204. * 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.
  117205. */
  117206. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  117207. /**
  117208. * Dispose and release the lens flare with its associated resources.
  117209. */
  117210. dispose(): void;
  117211. }
  117212. }
  117213. declare module BABYLON {
  117214. interface AbstractScene {
  117215. /**
  117216. * The list of lens flare system added to the scene
  117217. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  117218. */
  117219. lensFlareSystems: Array<LensFlareSystem>;
  117220. /**
  117221. * Removes the given lens flare system from this scene.
  117222. * @param toRemove The lens flare system to remove
  117223. * @returns The index of the removed lens flare system
  117224. */
  117225. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  117226. /**
  117227. * Adds the given lens flare system to this scene
  117228. * @param newLensFlareSystem The lens flare system to add
  117229. */
  117230. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  117231. /**
  117232. * Gets a lens flare system using its name
  117233. * @param name defines the name to look for
  117234. * @returns the lens flare system or null if not found
  117235. */
  117236. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  117237. /**
  117238. * Gets a lens flare system using its id
  117239. * @param id defines the id to look for
  117240. * @returns the lens flare system or null if not found
  117241. */
  117242. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  117243. }
  117244. /**
  117245. * Defines the lens flare scene component responsible to manage any lens flares
  117246. * in a given scene.
  117247. */
  117248. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  117249. /**
  117250. * The component name helpfull to identify the component in the list of scene components.
  117251. */
  117252. readonly name: string;
  117253. /**
  117254. * The scene the component belongs to.
  117255. */
  117256. scene: Scene;
  117257. /**
  117258. * Creates a new instance of the component for the given scene
  117259. * @param scene Defines the scene to register the component in
  117260. */
  117261. constructor(scene: Scene);
  117262. /**
  117263. * Registers the component in a given scene
  117264. */
  117265. register(): void;
  117266. /**
  117267. * Rebuilds the elements related to this component in case of
  117268. * context lost for instance.
  117269. */
  117270. rebuild(): void;
  117271. /**
  117272. * Adds all the elements from the container to the scene
  117273. * @param container the container holding the elements
  117274. */
  117275. addFromContainer(container: AbstractScene): void;
  117276. /**
  117277. * Removes all the elements in the container from the scene
  117278. * @param container contains the elements to remove
  117279. * @param dispose if the removed element should be disposed (default: false)
  117280. */
  117281. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117282. /**
  117283. * Serializes the component data to the specified json object
  117284. * @param serializationObject The object to serialize to
  117285. */
  117286. serialize(serializationObject: any): void;
  117287. /**
  117288. * Disposes the component and the associated ressources.
  117289. */
  117290. dispose(): void;
  117291. private _draw;
  117292. }
  117293. }
  117294. declare module BABYLON {
  117295. /**
  117296. * Defines the shadow generator component responsible to manage any shadow generators
  117297. * in a given scene.
  117298. */
  117299. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  117300. /**
  117301. * The component name helpfull to identify the component in the list of scene components.
  117302. */
  117303. readonly name: string;
  117304. /**
  117305. * The scene the component belongs to.
  117306. */
  117307. scene: Scene;
  117308. /**
  117309. * Creates a new instance of the component for the given scene
  117310. * @param scene Defines the scene to register the component in
  117311. */
  117312. constructor(scene: Scene);
  117313. /**
  117314. * Registers the component in a given scene
  117315. */
  117316. register(): void;
  117317. /**
  117318. * Rebuilds the elements related to this component in case of
  117319. * context lost for instance.
  117320. */
  117321. rebuild(): void;
  117322. /**
  117323. * Serializes the component data to the specified json object
  117324. * @param serializationObject The object to serialize to
  117325. */
  117326. serialize(serializationObject: any): void;
  117327. /**
  117328. * Adds all the elements from the container to the scene
  117329. * @param container the container holding the elements
  117330. */
  117331. addFromContainer(container: AbstractScene): void;
  117332. /**
  117333. * Removes all the elements in the container from the scene
  117334. * @param container contains the elements to remove
  117335. * @param dispose if the removed element should be disposed (default: false)
  117336. */
  117337. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  117338. /**
  117339. * Rebuilds the elements related to this component in case of
  117340. * context lost for instance.
  117341. */
  117342. dispose(): void;
  117343. private _gatherRenderTargets;
  117344. }
  117345. }
  117346. declare module BABYLON {
  117347. /**
  117348. * A point light is a light defined by an unique point in world space.
  117349. * The light is emitted in every direction from this point.
  117350. * A good example of a point light is a standard light bulb.
  117351. * Documentation: https://doc.babylonjs.com/babylon101/lights
  117352. */
  117353. export class PointLight extends ShadowLight {
  117354. private _shadowAngle;
  117355. /**
  117356. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117357. * This specifies what angle the shadow will use to be created.
  117358. *
  117359. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117360. */
  117361. /**
  117362. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117363. * This specifies what angle the shadow will use to be created.
  117364. *
  117365. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  117366. */
  117367. shadowAngle: number;
  117368. /**
  117369. * Gets the direction if it has been set.
  117370. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117371. */
  117372. /**
  117373. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  117374. */
  117375. direction: Vector3;
  117376. /**
  117377. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  117378. * A PointLight emits the light in every direction.
  117379. * It can cast shadows.
  117380. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  117381. * ```javascript
  117382. * var pointLight = new PointLight("pl", camera.position, scene);
  117383. * ```
  117384. * Documentation : https://doc.babylonjs.com/babylon101/lights
  117385. * @param name The light friendly name
  117386. * @param position The position of the point light in the scene
  117387. * @param scene The scene the lights belongs to
  117388. */
  117389. constructor(name: string, position: Vector3, scene: Scene);
  117390. /**
  117391. * Returns the string "PointLight"
  117392. * @returns the class name
  117393. */
  117394. getClassName(): string;
  117395. /**
  117396. * Returns the integer 0.
  117397. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  117398. */
  117399. getTypeID(): number;
  117400. /**
  117401. * Specifies wether or not the shadowmap should be a cube texture.
  117402. * @returns true if the shadowmap needs to be a cube texture.
  117403. */
  117404. needCube(): boolean;
  117405. /**
  117406. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  117407. * @param faceIndex The index of the face we are computed the direction to generate shadow
  117408. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  117409. */
  117410. getShadowDirection(faceIndex?: number): Vector3;
  117411. /**
  117412. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  117413. * - fov = PI / 2
  117414. * - aspect ratio : 1.0
  117415. * - z-near and far equal to the active camera minZ and maxZ.
  117416. * Returns the PointLight.
  117417. */
  117418. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  117419. protected _buildUniformLayout(): void;
  117420. /**
  117421. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  117422. * @param effect The effect to update
  117423. * @param lightIndex The index of the light in the effect to update
  117424. * @returns The point light
  117425. */
  117426. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  117427. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  117428. /**
  117429. * Prepares the list of defines specific to the light type.
  117430. * @param defines the list of defines
  117431. * @param lightIndex defines the index of the light for the effect
  117432. */
  117433. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  117434. }
  117435. }
  117436. declare module BABYLON {
  117437. /**
  117438. * Header information of HDR texture files.
  117439. */
  117440. export interface HDRInfo {
  117441. /**
  117442. * The height of the texture in pixels.
  117443. */
  117444. height: number;
  117445. /**
  117446. * The width of the texture in pixels.
  117447. */
  117448. width: number;
  117449. /**
  117450. * The index of the beginning of the data in the binary file.
  117451. */
  117452. dataPosition: number;
  117453. }
  117454. /**
  117455. * This groups tools to convert HDR texture to native colors array.
  117456. */
  117457. export class HDRTools {
  117458. private static Ldexp;
  117459. private static Rgbe2float;
  117460. private static readStringLine;
  117461. /**
  117462. * Reads header information from an RGBE texture stored in a native array.
  117463. * More information on this format are available here:
  117464. * https://en.wikipedia.org/wiki/RGBE_image_format
  117465. *
  117466. * @param uint8array The binary file stored in native array.
  117467. * @return The header information.
  117468. */
  117469. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  117470. /**
  117471. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  117472. * This RGBE texture needs to store the information as a panorama.
  117473. *
  117474. * More information on this format are available here:
  117475. * https://en.wikipedia.org/wiki/RGBE_image_format
  117476. *
  117477. * @param buffer The binary file stored in an array buffer.
  117478. * @param size The expected size of the extracted cubemap.
  117479. * @return The Cube Map information.
  117480. */
  117481. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  117482. /**
  117483. * Returns the pixels data extracted from an RGBE texture.
  117484. * This pixels will be stored left to right up to down in the R G B order in one array.
  117485. *
  117486. * More information on this format are available here:
  117487. * https://en.wikipedia.org/wiki/RGBE_image_format
  117488. *
  117489. * @param uint8array The binary file stored in an array buffer.
  117490. * @param hdrInfo The header information of the file.
  117491. * @return The pixels data in RGB right to left up to down order.
  117492. */
  117493. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  117494. private static RGBE_ReadPixels_RLE;
  117495. }
  117496. }
  117497. declare module BABYLON {
  117498. /**
  117499. * This represents a texture coming from an HDR input.
  117500. *
  117501. * The only supported format is currently panorama picture stored in RGBE format.
  117502. * Example of such files can be found on HDRLib: http://hdrlib.com/
  117503. */
  117504. export class HDRCubeTexture extends BaseTexture {
  117505. private static _facesMapping;
  117506. private _generateHarmonics;
  117507. private _noMipmap;
  117508. private _textureMatrix;
  117509. private _size;
  117510. private _onLoad;
  117511. private _onError;
  117512. /**
  117513. * The texture URL.
  117514. */
  117515. url: string;
  117516. /**
  117517. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  117518. */
  117519. coordinatesMode: number;
  117520. protected _isBlocking: boolean;
  117521. /**
  117522. * Sets wether or not the texture is blocking during loading.
  117523. */
  117524. /**
  117525. * Gets wether or not the texture is blocking during loading.
  117526. */
  117527. isBlocking: boolean;
  117528. protected _rotationY: number;
  117529. /**
  117530. * Sets texture matrix rotation angle around Y axis in radians.
  117531. */
  117532. /**
  117533. * Gets texture matrix rotation angle around Y axis radians.
  117534. */
  117535. rotationY: number;
  117536. /**
  117537. * Gets or sets the center of the bounding box associated with the cube texture
  117538. * It must define where the camera used to render the texture was set
  117539. */
  117540. boundingBoxPosition: Vector3;
  117541. private _boundingBoxSize;
  117542. /**
  117543. * Gets or sets the size of the bounding box associated with the cube texture
  117544. * When defined, the cubemap will switch to local mode
  117545. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  117546. * @example https://www.babylonjs-playground.com/#RNASML
  117547. */
  117548. boundingBoxSize: Vector3;
  117549. /**
  117550. * Instantiates an HDRTexture from the following parameters.
  117551. *
  117552. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  117553. * @param scene The scene the texture will be used in
  117554. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  117555. * @param noMipmap Forces to not generate the mipmap if true
  117556. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  117557. * @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)
  117558. * @param reserved Reserved flag for internal use.
  117559. */
  117560. 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>);
  117561. /**
  117562. * Get the current class name of the texture useful for serialization or dynamic coding.
  117563. * @returns "HDRCubeTexture"
  117564. */
  117565. getClassName(): string;
  117566. /**
  117567. * Occurs when the file is raw .hdr file.
  117568. */
  117569. private loadTexture;
  117570. clone(): HDRCubeTexture;
  117571. delayLoad(): void;
  117572. /**
  117573. * Get the texture reflection matrix used to rotate/transform the reflection.
  117574. * @returns the reflection matrix
  117575. */
  117576. getReflectionTextureMatrix(): Matrix;
  117577. /**
  117578. * Set the texture reflection matrix used to rotate/transform the reflection.
  117579. * @param value Define the reflection matrix to set
  117580. */
  117581. setReflectionTextureMatrix(value: Matrix): void;
  117582. /**
  117583. * Parses a JSON representation of an HDR Texture in order to create the texture
  117584. * @param parsedTexture Define the JSON representation
  117585. * @param scene Define the scene the texture should be created in
  117586. * @param rootUrl Define the root url in case we need to load relative dependencies
  117587. * @returns the newly created texture after parsing
  117588. */
  117589. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  117590. serialize(): any;
  117591. }
  117592. }
  117593. declare module BABYLON {
  117594. /**
  117595. * Class used to control physics engine
  117596. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  117597. */
  117598. export class PhysicsEngine implements IPhysicsEngine {
  117599. private _physicsPlugin;
  117600. /**
  117601. * Global value used to control the smallest number supported by the simulation
  117602. */
  117603. static Epsilon: number;
  117604. private _impostors;
  117605. private _joints;
  117606. /**
  117607. * Gets the gravity vector used by the simulation
  117608. */
  117609. gravity: Vector3;
  117610. /**
  117611. * Factory used to create the default physics plugin.
  117612. * @returns The default physics plugin
  117613. */
  117614. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  117615. /**
  117616. * Creates a new Physics Engine
  117617. * @param gravity defines the gravity vector used by the simulation
  117618. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  117619. */
  117620. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  117621. /**
  117622. * Sets the gravity vector used by the simulation
  117623. * @param gravity defines the gravity vector to use
  117624. */
  117625. setGravity(gravity: Vector3): void;
  117626. /**
  117627. * Set the time step of the physics engine.
  117628. * Default is 1/60.
  117629. * To slow it down, enter 1/600 for example.
  117630. * To speed it up, 1/30
  117631. * @param newTimeStep defines the new timestep to apply to this world.
  117632. */
  117633. setTimeStep(newTimeStep?: number): void;
  117634. /**
  117635. * Get the time step of the physics engine.
  117636. * @returns the current time step
  117637. */
  117638. getTimeStep(): number;
  117639. /**
  117640. * Release all resources
  117641. */
  117642. dispose(): void;
  117643. /**
  117644. * Gets the name of the current physics plugin
  117645. * @returns the name of the plugin
  117646. */
  117647. getPhysicsPluginName(): string;
  117648. /**
  117649. * Adding a new impostor for the impostor tracking.
  117650. * This will be done by the impostor itself.
  117651. * @param impostor the impostor to add
  117652. */
  117653. addImpostor(impostor: PhysicsImpostor): void;
  117654. /**
  117655. * Remove an impostor from the engine.
  117656. * This impostor and its mesh will not longer be updated by the physics engine.
  117657. * @param impostor the impostor to remove
  117658. */
  117659. removeImpostor(impostor: PhysicsImpostor): void;
  117660. /**
  117661. * Add a joint to the physics engine
  117662. * @param mainImpostor defines the main impostor to which the joint is added.
  117663. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  117664. * @param joint defines the joint that will connect both impostors.
  117665. */
  117666. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117667. /**
  117668. * Removes a joint from the simulation
  117669. * @param mainImpostor defines the impostor used with the joint
  117670. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  117671. * @param joint defines the joint to remove
  117672. */
  117673. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  117674. /**
  117675. * Called by the scene. No need to call it.
  117676. * @param delta defines the timespam between frames
  117677. */
  117678. _step(delta: number): void;
  117679. /**
  117680. * Gets the current plugin used to run the simulation
  117681. * @returns current plugin
  117682. */
  117683. getPhysicsPlugin(): IPhysicsEnginePlugin;
  117684. /**
  117685. * Gets the list of physic impostors
  117686. * @returns an array of PhysicsImpostor
  117687. */
  117688. getImpostors(): Array<PhysicsImpostor>;
  117689. /**
  117690. * Gets the impostor for a physics enabled object
  117691. * @param object defines the object impersonated by the impostor
  117692. * @returns the PhysicsImpostor or null if not found
  117693. */
  117694. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  117695. /**
  117696. * Gets the impostor for a physics body object
  117697. * @param body defines physics body used by the impostor
  117698. * @returns the PhysicsImpostor or null if not found
  117699. */
  117700. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  117701. /**
  117702. * Does a raycast in the physics world
  117703. * @param from when should the ray start?
  117704. * @param to when should the ray end?
  117705. * @returns PhysicsRaycastResult
  117706. */
  117707. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117708. }
  117709. }
  117710. declare module BABYLON {
  117711. /** @hidden */
  117712. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  117713. private _useDeltaForWorldStep;
  117714. world: any;
  117715. name: string;
  117716. private _physicsMaterials;
  117717. private _fixedTimeStep;
  117718. private _cannonRaycastResult;
  117719. private _raycastResult;
  117720. private _physicsBodysToRemoveAfterStep;
  117721. BJSCANNON: any;
  117722. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  117723. setGravity(gravity: Vector3): void;
  117724. setTimeStep(timeStep: number): void;
  117725. getTimeStep(): number;
  117726. executeStep(delta: number): void;
  117727. private _removeMarkedPhysicsBodiesFromWorld;
  117728. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117729. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117730. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117731. private _processChildMeshes;
  117732. removePhysicsBody(impostor: PhysicsImpostor): void;
  117733. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117734. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117735. private _addMaterial;
  117736. private _checkWithEpsilon;
  117737. private _createShape;
  117738. private _createHeightmap;
  117739. private _minus90X;
  117740. private _plus90X;
  117741. private _tmpPosition;
  117742. private _tmpDeltaPosition;
  117743. private _tmpUnityRotation;
  117744. private _updatePhysicsBodyTransformation;
  117745. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117746. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117747. isSupported(): boolean;
  117748. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117749. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117750. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117751. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117752. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117753. getBodyMass(impostor: PhysicsImpostor): number;
  117754. getBodyFriction(impostor: PhysicsImpostor): number;
  117755. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117756. getBodyRestitution(impostor: PhysicsImpostor): number;
  117757. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117758. sleepBody(impostor: PhysicsImpostor): void;
  117759. wakeUpBody(impostor: PhysicsImpostor): void;
  117760. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  117761. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  117762. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  117763. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117764. getRadius(impostor: PhysicsImpostor): number;
  117765. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117766. dispose(): void;
  117767. private _extendNamespace;
  117768. /**
  117769. * Does a raycast in the physics world
  117770. * @param from when should the ray start?
  117771. * @param to when should the ray end?
  117772. * @returns PhysicsRaycastResult
  117773. */
  117774. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117775. }
  117776. }
  117777. declare module BABYLON {
  117778. /** @hidden */
  117779. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  117780. world: any;
  117781. name: string;
  117782. BJSOIMO: any;
  117783. private _raycastResult;
  117784. constructor(iterations?: number, oimoInjection?: any);
  117785. setGravity(gravity: Vector3): void;
  117786. setTimeStep(timeStep: number): void;
  117787. getTimeStep(): number;
  117788. private _tmpImpostorsArray;
  117789. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  117790. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117791. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  117792. generatePhysicsBody(impostor: PhysicsImpostor): void;
  117793. private _tmpPositionVector;
  117794. removePhysicsBody(impostor: PhysicsImpostor): void;
  117795. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  117796. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  117797. isSupported(): boolean;
  117798. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  117799. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  117800. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117801. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  117802. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117803. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  117804. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  117805. getBodyMass(impostor: PhysicsImpostor): number;
  117806. getBodyFriction(impostor: PhysicsImpostor): number;
  117807. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  117808. getBodyRestitution(impostor: PhysicsImpostor): number;
  117809. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  117810. sleepBody(impostor: PhysicsImpostor): void;
  117811. wakeUpBody(impostor: PhysicsImpostor): void;
  117812. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  117813. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  117814. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  117815. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  117816. getRadius(impostor: PhysicsImpostor): number;
  117817. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  117818. dispose(): void;
  117819. /**
  117820. * Does a raycast in the physics world
  117821. * @param from when should the ray start?
  117822. * @param to when should the ray end?
  117823. * @returns PhysicsRaycastResult
  117824. */
  117825. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  117826. }
  117827. }
  117828. declare module BABYLON {
  117829. /**
  117830. * Class containing static functions to help procedurally build meshes
  117831. */
  117832. export class RibbonBuilder {
  117833. /**
  117834. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  117835. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  117836. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  117837. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  117838. * * 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
  117839. * * 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
  117840. * * 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
  117841. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117842. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117843. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117844. * * 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
  117845. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  117846. * * 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
  117847. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  117848. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117849. * @param name defines the name of the mesh
  117850. * @param options defines the options used to create the mesh
  117851. * @param scene defines the hosting scene
  117852. * @returns the ribbon mesh
  117853. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  117854. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117855. */
  117856. static CreateRibbon(name: string, options: {
  117857. pathArray: Vector3[][];
  117858. closeArray?: boolean;
  117859. closePath?: boolean;
  117860. offset?: number;
  117861. updatable?: boolean;
  117862. sideOrientation?: number;
  117863. frontUVs?: Vector4;
  117864. backUVs?: Vector4;
  117865. instance?: Mesh;
  117866. invertUV?: boolean;
  117867. uvs?: Vector2[];
  117868. colors?: Color4[];
  117869. }, scene?: Nullable<Scene>): Mesh;
  117870. }
  117871. }
  117872. declare module BABYLON {
  117873. /**
  117874. * Class containing static functions to help procedurally build meshes
  117875. */
  117876. export class ShapeBuilder {
  117877. /**
  117878. * 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.
  117879. * * 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.
  117880. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117881. * * 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.
  117882. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  117883. * * 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
  117884. * * 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
  117885. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  117886. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117887. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117888. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  117889. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117890. * @param name defines the name of the mesh
  117891. * @param options defines the options used to create the mesh
  117892. * @param scene defines the hosting scene
  117893. * @returns the extruded shape mesh
  117894. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117895. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117896. */
  117897. static ExtrudeShape(name: string, options: {
  117898. shape: Vector3[];
  117899. path: Vector3[];
  117900. scale?: number;
  117901. rotation?: number;
  117902. cap?: number;
  117903. updatable?: boolean;
  117904. sideOrientation?: number;
  117905. frontUVs?: Vector4;
  117906. backUVs?: Vector4;
  117907. instance?: Mesh;
  117908. invertUV?: boolean;
  117909. }, scene?: Nullable<Scene>): Mesh;
  117910. /**
  117911. * Creates an custom extruded shape mesh.
  117912. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  117913. * * 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.
  117914. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  117915. * * 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
  117916. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  117917. * * 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
  117918. * * It must returns a float value that will be the scale value applied to the shape on each path point
  117919. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  117920. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  117921. * * 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
  117922. * * 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
  117923. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  117924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117926. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  117927. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117928. * @param name defines the name of the mesh
  117929. * @param options defines the options used to create the mesh
  117930. * @param scene defines the hosting scene
  117931. * @returns the custom extruded shape mesh
  117932. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  117933. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  117934. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  117935. */
  117936. static ExtrudeShapeCustom(name: string, options: {
  117937. shape: Vector3[];
  117938. path: Vector3[];
  117939. scaleFunction?: any;
  117940. rotationFunction?: any;
  117941. ribbonCloseArray?: boolean;
  117942. ribbonClosePath?: boolean;
  117943. cap?: number;
  117944. updatable?: boolean;
  117945. sideOrientation?: number;
  117946. frontUVs?: Vector4;
  117947. backUVs?: Vector4;
  117948. instance?: Mesh;
  117949. invertUV?: boolean;
  117950. }, scene?: Nullable<Scene>): Mesh;
  117951. private static _ExtrudeShapeGeneric;
  117952. }
  117953. }
  117954. declare module BABYLON {
  117955. /**
  117956. * AmmoJS Physics plugin
  117957. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  117958. * @see https://github.com/kripken/ammo.js/
  117959. */
  117960. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  117961. private _useDeltaForWorldStep;
  117962. /**
  117963. * Reference to the Ammo library
  117964. */
  117965. bjsAMMO: any;
  117966. /**
  117967. * Created ammoJS world which physics bodies are added to
  117968. */
  117969. world: any;
  117970. /**
  117971. * Name of the plugin
  117972. */
  117973. name: string;
  117974. private _timeStep;
  117975. private _fixedTimeStep;
  117976. private _maxSteps;
  117977. private _tmpQuaternion;
  117978. private _tmpAmmoTransform;
  117979. private _tmpAmmoQuaternion;
  117980. private _tmpAmmoConcreteContactResultCallback;
  117981. private _collisionConfiguration;
  117982. private _dispatcher;
  117983. private _overlappingPairCache;
  117984. private _solver;
  117985. private _softBodySolver;
  117986. private _tmpAmmoVectorA;
  117987. private _tmpAmmoVectorB;
  117988. private _tmpAmmoVectorC;
  117989. private _tmpAmmoVectorD;
  117990. private _tmpContactCallbackResult;
  117991. private _tmpAmmoVectorRCA;
  117992. private _tmpAmmoVectorRCB;
  117993. private _raycastResult;
  117994. private static readonly DISABLE_COLLISION_FLAG;
  117995. private static readonly KINEMATIC_FLAG;
  117996. private static readonly DISABLE_DEACTIVATION_FLAG;
  117997. /**
  117998. * Initializes the ammoJS plugin
  117999. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  118000. * @param ammoInjection can be used to inject your own ammo reference
  118001. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  118002. */
  118003. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  118004. /**
  118005. * Sets the gravity of the physics world (m/(s^2))
  118006. * @param gravity Gravity to set
  118007. */
  118008. setGravity(gravity: Vector3): void;
  118009. /**
  118010. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  118011. * @param timeStep timestep to use in seconds
  118012. */
  118013. setTimeStep(timeStep: number): void;
  118014. /**
  118015. * 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)
  118016. * @param fixedTimeStep fixedTimeStep to use in seconds
  118017. */
  118018. setFixedTimeStep(fixedTimeStep: number): void;
  118019. /**
  118020. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  118021. * @param maxSteps the maximum number of steps by the physics engine per frame
  118022. */
  118023. setMaxSteps(maxSteps: number): void;
  118024. /**
  118025. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  118026. * @returns the current timestep in seconds
  118027. */
  118028. getTimeStep(): number;
  118029. private _isImpostorInContact;
  118030. private _isImpostorPairInContact;
  118031. private _stepSimulation;
  118032. /**
  118033. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  118034. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  118035. * After the step the babylon meshes are set to the position of the physics imposters
  118036. * @param delta amount of time to step forward
  118037. * @param impostors array of imposters to update before/after the step
  118038. */
  118039. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  118040. /**
  118041. * Update babylon mesh to match physics world object
  118042. * @param impostor imposter to match
  118043. */
  118044. private _afterSoftStep;
  118045. /**
  118046. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118047. * @param impostor imposter to match
  118048. */
  118049. private _ropeStep;
  118050. /**
  118051. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  118052. * @param impostor imposter to match
  118053. */
  118054. private _softbodyOrClothStep;
  118055. private _tmpVector;
  118056. private _tmpMatrix;
  118057. /**
  118058. * Applies an impulse on the imposter
  118059. * @param impostor imposter to apply impulse to
  118060. * @param force amount of force to be applied to the imposter
  118061. * @param contactPoint the location to apply the impulse on the imposter
  118062. */
  118063. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118064. /**
  118065. * Applies a force on the imposter
  118066. * @param impostor imposter to apply force
  118067. * @param force amount of force to be applied to the imposter
  118068. * @param contactPoint the location to apply the force on the imposter
  118069. */
  118070. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  118071. /**
  118072. * Creates a physics body using the plugin
  118073. * @param impostor the imposter to create the physics body on
  118074. */
  118075. generatePhysicsBody(impostor: PhysicsImpostor): void;
  118076. /**
  118077. * Removes the physics body from the imposter and disposes of the body's memory
  118078. * @param impostor imposter to remove the physics body from
  118079. */
  118080. removePhysicsBody(impostor: PhysicsImpostor): void;
  118081. /**
  118082. * Generates a joint
  118083. * @param impostorJoint the imposter joint to create the joint with
  118084. */
  118085. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  118086. /**
  118087. * Removes a joint
  118088. * @param impostorJoint the imposter joint to remove the joint from
  118089. */
  118090. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  118091. private _addMeshVerts;
  118092. /**
  118093. * Initialise the soft body vertices to match its object's (mesh) vertices
  118094. * Softbody vertices (nodes) are in world space and to match this
  118095. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  118096. * @param impostor to create the softbody for
  118097. */
  118098. private _softVertexData;
  118099. /**
  118100. * Create an impostor's soft body
  118101. * @param impostor to create the softbody for
  118102. */
  118103. private _createSoftbody;
  118104. /**
  118105. * Create cloth for an impostor
  118106. * @param impostor to create the softbody for
  118107. */
  118108. private _createCloth;
  118109. /**
  118110. * Create rope for an impostor
  118111. * @param impostor to create the softbody for
  118112. */
  118113. private _createRope;
  118114. private _addHullVerts;
  118115. private _createShape;
  118116. /**
  118117. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  118118. * @param impostor imposter containing the physics body and babylon object
  118119. */
  118120. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  118121. /**
  118122. * Sets the babylon object's position/rotation from the physics body's position/rotation
  118123. * @param impostor imposter containing the physics body and babylon object
  118124. * @param newPosition new position
  118125. * @param newRotation new rotation
  118126. */
  118127. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  118128. /**
  118129. * If this plugin is supported
  118130. * @returns true if its supported
  118131. */
  118132. isSupported(): boolean;
  118133. /**
  118134. * Sets the linear velocity of the physics body
  118135. * @param impostor imposter to set the velocity on
  118136. * @param velocity velocity to set
  118137. */
  118138. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118139. /**
  118140. * Sets the angular velocity of the physics body
  118141. * @param impostor imposter to set the velocity on
  118142. * @param velocity velocity to set
  118143. */
  118144. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  118145. /**
  118146. * gets the linear velocity
  118147. * @param impostor imposter to get linear velocity from
  118148. * @returns linear velocity
  118149. */
  118150. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118151. /**
  118152. * gets the angular velocity
  118153. * @param impostor imposter to get angular velocity from
  118154. * @returns angular velocity
  118155. */
  118156. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  118157. /**
  118158. * Sets the mass of physics body
  118159. * @param impostor imposter to set the mass on
  118160. * @param mass mass to set
  118161. */
  118162. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  118163. /**
  118164. * Gets the mass of the physics body
  118165. * @param impostor imposter to get the mass from
  118166. * @returns mass
  118167. */
  118168. getBodyMass(impostor: PhysicsImpostor): number;
  118169. /**
  118170. * Gets friction of the impostor
  118171. * @param impostor impostor to get friction from
  118172. * @returns friction value
  118173. */
  118174. getBodyFriction(impostor: PhysicsImpostor): number;
  118175. /**
  118176. * Sets friction of the impostor
  118177. * @param impostor impostor to set friction on
  118178. * @param friction friction value
  118179. */
  118180. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  118181. /**
  118182. * Gets restitution of the impostor
  118183. * @param impostor impostor to get restitution from
  118184. * @returns restitution value
  118185. */
  118186. getBodyRestitution(impostor: PhysicsImpostor): number;
  118187. /**
  118188. * Sets resitution of the impostor
  118189. * @param impostor impostor to set resitution on
  118190. * @param restitution resitution value
  118191. */
  118192. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  118193. /**
  118194. * Gets pressure inside the impostor
  118195. * @param impostor impostor to get pressure from
  118196. * @returns pressure value
  118197. */
  118198. getBodyPressure(impostor: PhysicsImpostor): number;
  118199. /**
  118200. * Sets pressure inside a soft body impostor
  118201. * Cloth and rope must remain 0 pressure
  118202. * @param impostor impostor to set pressure on
  118203. * @param pressure pressure value
  118204. */
  118205. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  118206. /**
  118207. * Gets stiffness of the impostor
  118208. * @param impostor impostor to get stiffness from
  118209. * @returns pressure value
  118210. */
  118211. getBodyStiffness(impostor: PhysicsImpostor): number;
  118212. /**
  118213. * Sets stiffness of the impostor
  118214. * @param impostor impostor to set stiffness on
  118215. * @param stiffness stiffness value from 0 to 1
  118216. */
  118217. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  118218. /**
  118219. * Gets velocityIterations of the impostor
  118220. * @param impostor impostor to get velocity iterations from
  118221. * @returns velocityIterations value
  118222. */
  118223. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  118224. /**
  118225. * Sets velocityIterations of the impostor
  118226. * @param impostor impostor to set velocity iterations on
  118227. * @param velocityIterations velocityIterations value
  118228. */
  118229. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  118230. /**
  118231. * Gets positionIterations of the impostor
  118232. * @param impostor impostor to get position iterations from
  118233. * @returns positionIterations value
  118234. */
  118235. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  118236. /**
  118237. * Sets positionIterations of the impostor
  118238. * @param impostor impostor to set position on
  118239. * @param positionIterations positionIterations value
  118240. */
  118241. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  118242. /**
  118243. * Append an anchor to a cloth object
  118244. * @param impostor is the cloth impostor to add anchor to
  118245. * @param otherImpostor is the rigid impostor to anchor to
  118246. * @param width ratio across width from 0 to 1
  118247. * @param height ratio up height from 0 to 1
  118248. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  118249. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118250. */
  118251. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118252. /**
  118253. * Append an hook to a rope object
  118254. * @param impostor is the rope impostor to add hook to
  118255. * @param otherImpostor is the rigid impostor to hook to
  118256. * @param length ratio along the rope from 0 to 1
  118257. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  118258. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  118259. */
  118260. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  118261. /**
  118262. * Sleeps the physics body and stops it from being active
  118263. * @param impostor impostor to sleep
  118264. */
  118265. sleepBody(impostor: PhysicsImpostor): void;
  118266. /**
  118267. * Activates the physics body
  118268. * @param impostor impostor to activate
  118269. */
  118270. wakeUpBody(impostor: PhysicsImpostor): void;
  118271. /**
  118272. * Updates the distance parameters of the joint
  118273. * @param joint joint to update
  118274. * @param maxDistance maximum distance of the joint
  118275. * @param minDistance minimum distance of the joint
  118276. */
  118277. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  118278. /**
  118279. * Sets a motor on the joint
  118280. * @param joint joint to set motor on
  118281. * @param speed speed of the motor
  118282. * @param maxForce maximum force of the motor
  118283. * @param motorIndex index of the motor
  118284. */
  118285. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  118286. /**
  118287. * Sets the motors limit
  118288. * @param joint joint to set limit on
  118289. * @param upperLimit upper limit
  118290. * @param lowerLimit lower limit
  118291. */
  118292. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  118293. /**
  118294. * Syncs the position and rotation of a mesh with the impostor
  118295. * @param mesh mesh to sync
  118296. * @param impostor impostor to update the mesh with
  118297. */
  118298. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  118299. /**
  118300. * Gets the radius of the impostor
  118301. * @param impostor impostor to get radius from
  118302. * @returns the radius
  118303. */
  118304. getRadius(impostor: PhysicsImpostor): number;
  118305. /**
  118306. * Gets the box size of the impostor
  118307. * @param impostor impostor to get box size from
  118308. * @param result the resulting box size
  118309. */
  118310. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  118311. /**
  118312. * Disposes of the impostor
  118313. */
  118314. dispose(): void;
  118315. /**
  118316. * Does a raycast in the physics world
  118317. * @param from when should the ray start?
  118318. * @param to when should the ray end?
  118319. * @returns PhysicsRaycastResult
  118320. */
  118321. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  118322. }
  118323. }
  118324. declare module BABYLON {
  118325. interface AbstractScene {
  118326. /**
  118327. * The list of reflection probes added to the scene
  118328. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118329. */
  118330. reflectionProbes: Array<ReflectionProbe>;
  118331. /**
  118332. * Removes the given reflection probe from this scene.
  118333. * @param toRemove The reflection probe to remove
  118334. * @returns The index of the removed reflection probe
  118335. */
  118336. removeReflectionProbe(toRemove: ReflectionProbe): number;
  118337. /**
  118338. * Adds the given reflection probe to this scene.
  118339. * @param newReflectionProbe The reflection probe to add
  118340. */
  118341. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  118342. }
  118343. /**
  118344. * Class used to generate realtime reflection / refraction cube textures
  118345. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  118346. */
  118347. export class ReflectionProbe {
  118348. /** defines the name of the probe */
  118349. name: string;
  118350. private _scene;
  118351. private _renderTargetTexture;
  118352. private _projectionMatrix;
  118353. private _viewMatrix;
  118354. private _target;
  118355. private _add;
  118356. private _attachedMesh;
  118357. private _invertYAxis;
  118358. /** Gets or sets probe position (center of the cube map) */
  118359. position: Vector3;
  118360. /**
  118361. * Creates a new reflection probe
  118362. * @param name defines the name of the probe
  118363. * @param size defines the texture resolution (for each face)
  118364. * @param scene defines the hosting scene
  118365. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  118366. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  118367. */
  118368. constructor(
  118369. /** defines the name of the probe */
  118370. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  118371. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  118372. samples: number;
  118373. /** Gets or sets the refresh rate to use (on every frame by default) */
  118374. refreshRate: number;
  118375. /**
  118376. * Gets the hosting scene
  118377. * @returns a Scene
  118378. */
  118379. getScene(): Scene;
  118380. /** Gets the internal CubeTexture used to render to */
  118381. readonly cubeTexture: RenderTargetTexture;
  118382. /** Gets the list of meshes to render */
  118383. readonly renderList: Nullable<AbstractMesh[]>;
  118384. /**
  118385. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  118386. * @param mesh defines the mesh to attach to
  118387. */
  118388. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  118389. /**
  118390. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  118391. * @param renderingGroupId The rendering group id corresponding to its index
  118392. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  118393. */
  118394. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  118395. /**
  118396. * Clean all associated resources
  118397. */
  118398. dispose(): void;
  118399. /**
  118400. * Converts the reflection probe information to a readable string for debug purpose.
  118401. * @param fullDetails Supports for multiple levels of logging within scene loading
  118402. * @returns the human readable reflection probe info
  118403. */
  118404. toString(fullDetails?: boolean): string;
  118405. /**
  118406. * Get the class name of the relfection probe.
  118407. * @returns "ReflectionProbe"
  118408. */
  118409. getClassName(): string;
  118410. /**
  118411. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  118412. * @returns The JSON representation of the texture
  118413. */
  118414. serialize(): any;
  118415. /**
  118416. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  118417. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  118418. * @param scene Define the scene the parsed reflection probe should be instantiated in
  118419. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  118420. * @returns The parsed reflection probe if successful
  118421. */
  118422. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  118423. }
  118424. }
  118425. declare module BABYLON {
  118426. /** @hidden */
  118427. export var _BabylonLoaderRegistered: boolean;
  118428. }
  118429. declare module BABYLON {
  118430. /**
  118431. * The Physically based simple base material of BJS.
  118432. *
  118433. * This enables better naming and convention enforcements on top of the pbrMaterial.
  118434. * It is used as the base class for both the specGloss and metalRough conventions.
  118435. */
  118436. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  118437. /**
  118438. * Number of Simultaneous lights allowed on the material.
  118439. */
  118440. maxSimultaneousLights: number;
  118441. /**
  118442. * If sets to true, disables all the lights affecting the material.
  118443. */
  118444. disableLighting: boolean;
  118445. /**
  118446. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  118447. */
  118448. environmentTexture: BaseTexture;
  118449. /**
  118450. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  118451. */
  118452. invertNormalMapX: boolean;
  118453. /**
  118454. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  118455. */
  118456. invertNormalMapY: boolean;
  118457. /**
  118458. * Normal map used in the model.
  118459. */
  118460. normalTexture: BaseTexture;
  118461. /**
  118462. * Emissivie color used to self-illuminate the model.
  118463. */
  118464. emissiveColor: Color3;
  118465. /**
  118466. * Emissivie texture used to self-illuminate the model.
  118467. */
  118468. emissiveTexture: BaseTexture;
  118469. /**
  118470. * Occlusion Channel Strenght.
  118471. */
  118472. occlusionStrength: number;
  118473. /**
  118474. * Occlusion Texture of the material (adding extra occlusion effects).
  118475. */
  118476. occlusionTexture: BaseTexture;
  118477. /**
  118478. * Defines the alpha limits in alpha test mode.
  118479. */
  118480. alphaCutOff: number;
  118481. /**
  118482. * Gets the current double sided mode.
  118483. */
  118484. /**
  118485. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  118486. */
  118487. doubleSided: boolean;
  118488. /**
  118489. * Stores the pre-calculated light information of a mesh in a texture.
  118490. */
  118491. lightmapTexture: BaseTexture;
  118492. /**
  118493. * If true, the light map contains occlusion information instead of lighting info.
  118494. */
  118495. useLightmapAsShadowmap: boolean;
  118496. /**
  118497. * Instantiates a new PBRMaterial instance.
  118498. *
  118499. * @param name The material name
  118500. * @param scene The scene the material will be use in.
  118501. */
  118502. constructor(name: string, scene: Scene);
  118503. getClassName(): string;
  118504. }
  118505. }
  118506. declare module BABYLON {
  118507. /**
  118508. * The PBR material of BJS following the metal roughness convention.
  118509. *
  118510. * This fits to the PBR convention in the GLTF definition:
  118511. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  118512. */
  118513. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  118514. /**
  118515. * The base color has two different interpretations depending on the value of metalness.
  118516. * When the material is a metal, the base color is the specific measured reflectance value
  118517. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  118518. * of the material.
  118519. */
  118520. baseColor: Color3;
  118521. /**
  118522. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  118523. * well as opacity information in the alpha channel.
  118524. */
  118525. baseTexture: BaseTexture;
  118526. /**
  118527. * Specifies the metallic scalar value of the material.
  118528. * Can also be used to scale the metalness values of the metallic texture.
  118529. */
  118530. metallic: number;
  118531. /**
  118532. * Specifies the roughness scalar value of the material.
  118533. * Can also be used to scale the roughness values of the metallic texture.
  118534. */
  118535. roughness: number;
  118536. /**
  118537. * Texture containing both the metallic value in the B channel and the
  118538. * roughness value in the G channel to keep better precision.
  118539. */
  118540. metallicRoughnessTexture: BaseTexture;
  118541. /**
  118542. * Instantiates a new PBRMetalRoughnessMaterial instance.
  118543. *
  118544. * @param name The material name
  118545. * @param scene The scene the material will be use in.
  118546. */
  118547. constructor(name: string, scene: Scene);
  118548. /**
  118549. * Return the currrent class name of the material.
  118550. */
  118551. getClassName(): string;
  118552. /**
  118553. * Makes a duplicate of the current material.
  118554. * @param name - name to use for the new material.
  118555. */
  118556. clone(name: string): PBRMetallicRoughnessMaterial;
  118557. /**
  118558. * Serialize the material to a parsable JSON object.
  118559. */
  118560. serialize(): any;
  118561. /**
  118562. * Parses a JSON object correponding to the serialize function.
  118563. */
  118564. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  118565. }
  118566. }
  118567. declare module BABYLON {
  118568. /**
  118569. * The PBR material of BJS following the specular glossiness convention.
  118570. *
  118571. * This fits to the PBR convention in the GLTF definition:
  118572. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  118573. */
  118574. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  118575. /**
  118576. * Specifies the diffuse color of the material.
  118577. */
  118578. diffuseColor: Color3;
  118579. /**
  118580. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  118581. * channel.
  118582. */
  118583. diffuseTexture: BaseTexture;
  118584. /**
  118585. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  118586. */
  118587. specularColor: Color3;
  118588. /**
  118589. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  118590. */
  118591. glossiness: number;
  118592. /**
  118593. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  118594. */
  118595. specularGlossinessTexture: BaseTexture;
  118596. /**
  118597. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  118598. *
  118599. * @param name The material name
  118600. * @param scene The scene the material will be use in.
  118601. */
  118602. constructor(name: string, scene: Scene);
  118603. /**
  118604. * Return the currrent class name of the material.
  118605. */
  118606. getClassName(): string;
  118607. /**
  118608. * Makes a duplicate of the current material.
  118609. * @param name - name to use for the new material.
  118610. */
  118611. clone(name: string): PBRSpecularGlossinessMaterial;
  118612. /**
  118613. * Serialize the material to a parsable JSON object.
  118614. */
  118615. serialize(): any;
  118616. /**
  118617. * Parses a JSON object correponding to the serialize function.
  118618. */
  118619. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  118620. }
  118621. }
  118622. declare module BABYLON {
  118623. /**
  118624. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  118625. * It can help converting any input color in a desired output one. This can then be used to create effects
  118626. * from sepia, black and white to sixties or futuristic rendering...
  118627. *
  118628. * The only supported format is currently 3dl.
  118629. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  118630. */
  118631. export class ColorGradingTexture extends BaseTexture {
  118632. /**
  118633. * The current texture matrix. (will always be identity in color grading texture)
  118634. */
  118635. private _textureMatrix;
  118636. /**
  118637. * The texture URL.
  118638. */
  118639. url: string;
  118640. /**
  118641. * Empty line regex stored for GC.
  118642. */
  118643. private static _noneEmptyLineRegex;
  118644. private _engine;
  118645. /**
  118646. * Instantiates a ColorGradingTexture from the following parameters.
  118647. *
  118648. * @param url The location of the color gradind data (currently only supporting 3dl)
  118649. * @param scene The scene the texture will be used in
  118650. */
  118651. constructor(url: string, scene: Scene);
  118652. /**
  118653. * Returns the texture matrix used in most of the material.
  118654. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  118655. */
  118656. getTextureMatrix(): Matrix;
  118657. /**
  118658. * Occurs when the file being loaded is a .3dl LUT file.
  118659. */
  118660. private load3dlTexture;
  118661. /**
  118662. * Starts the loading process of the texture.
  118663. */
  118664. private loadTexture;
  118665. /**
  118666. * Clones the color gradind texture.
  118667. */
  118668. clone(): ColorGradingTexture;
  118669. /**
  118670. * Called during delayed load for textures.
  118671. */
  118672. delayLoad(): void;
  118673. /**
  118674. * Parses a color grading texture serialized by Babylon.
  118675. * @param parsedTexture The texture information being parsedTexture
  118676. * @param scene The scene to load the texture in
  118677. * @param rootUrl The root url of the data assets to load
  118678. * @return A color gradind texture
  118679. */
  118680. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  118681. /**
  118682. * Serializes the LUT texture to json format.
  118683. */
  118684. serialize(): any;
  118685. }
  118686. }
  118687. declare module BABYLON {
  118688. /**
  118689. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  118690. */
  118691. export class EquiRectangularCubeTexture extends BaseTexture {
  118692. /** The six faces of the cube. */
  118693. private static _FacesMapping;
  118694. private _noMipmap;
  118695. private _onLoad;
  118696. private _onError;
  118697. /** The size of the cubemap. */
  118698. private _size;
  118699. /** The buffer of the image. */
  118700. private _buffer;
  118701. /** The width of the input image. */
  118702. private _width;
  118703. /** The height of the input image. */
  118704. private _height;
  118705. /** The URL to the image. */
  118706. url: string;
  118707. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  118708. coordinatesMode: number;
  118709. /**
  118710. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  118711. * @param url The location of the image
  118712. * @param scene The scene the texture will be used in
  118713. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  118714. * @param noMipmap Forces to not generate the mipmap if true
  118715. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  118716. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  118717. * @param onLoad — defines a callback called when texture is loaded
  118718. * @param onError — defines a callback called if there is an error
  118719. */
  118720. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  118721. /**
  118722. * Load the image data, by putting the image on a canvas and extracting its buffer.
  118723. */
  118724. private loadImage;
  118725. /**
  118726. * Convert the image buffer into a cubemap and create a CubeTexture.
  118727. */
  118728. private loadTexture;
  118729. /**
  118730. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  118731. * @param buffer The ArrayBuffer that should be converted.
  118732. * @returns The buffer as Float32Array.
  118733. */
  118734. private getFloat32ArrayFromArrayBuffer;
  118735. /**
  118736. * Get the current class name of the texture useful for serialization or dynamic coding.
  118737. * @returns "EquiRectangularCubeTexture"
  118738. */
  118739. getClassName(): string;
  118740. /**
  118741. * Create a clone of the current EquiRectangularCubeTexture and return it.
  118742. * @returns A clone of the current EquiRectangularCubeTexture.
  118743. */
  118744. clone(): EquiRectangularCubeTexture;
  118745. }
  118746. }
  118747. declare module BABYLON {
  118748. /**
  118749. * Based on jsTGALoader - Javascript loader for TGA file
  118750. * By Vincent Thibault
  118751. * @see http://blog.robrowser.com/javascript-tga-loader.html
  118752. */
  118753. export class TGATools {
  118754. private static _TYPE_INDEXED;
  118755. private static _TYPE_RGB;
  118756. private static _TYPE_GREY;
  118757. private static _TYPE_RLE_INDEXED;
  118758. private static _TYPE_RLE_RGB;
  118759. private static _TYPE_RLE_GREY;
  118760. private static _ORIGIN_MASK;
  118761. private static _ORIGIN_SHIFT;
  118762. private static _ORIGIN_BL;
  118763. private static _ORIGIN_BR;
  118764. private static _ORIGIN_UL;
  118765. private static _ORIGIN_UR;
  118766. /**
  118767. * Gets the header of a TGA file
  118768. * @param data defines the TGA data
  118769. * @returns the header
  118770. */
  118771. static GetTGAHeader(data: Uint8Array): any;
  118772. /**
  118773. * Uploads TGA content to a Babylon Texture
  118774. * @hidden
  118775. */
  118776. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  118777. /** @hidden */
  118778. 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;
  118779. /** @hidden */
  118780. 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;
  118781. /** @hidden */
  118782. 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;
  118783. /** @hidden */
  118784. 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;
  118785. /** @hidden */
  118786. 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;
  118787. /** @hidden */
  118788. 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;
  118789. }
  118790. }
  118791. declare module BABYLON {
  118792. /**
  118793. * Implementation of the TGA Texture Loader.
  118794. * @hidden
  118795. */
  118796. export class _TGATextureLoader implements IInternalTextureLoader {
  118797. /**
  118798. * Defines wether the loader supports cascade loading the different faces.
  118799. */
  118800. readonly supportCascades: boolean;
  118801. /**
  118802. * This returns if the loader support the current file information.
  118803. * @param extension defines the file extension of the file being loaded
  118804. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118805. * @param fallback defines the fallback internal texture if any
  118806. * @param isBase64 defines whether the texture is encoded as a base64
  118807. * @param isBuffer defines whether the texture data are stored as a buffer
  118808. * @returns true if the loader can load the specified file
  118809. */
  118810. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118811. /**
  118812. * Transform the url before loading if required.
  118813. * @param rootUrl the url of the texture
  118814. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118815. * @returns the transformed texture
  118816. */
  118817. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118818. /**
  118819. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118820. * @param rootUrl the url of the texture
  118821. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118822. * @returns the fallback texture
  118823. */
  118824. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118825. /**
  118826. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  118827. * @param data contains the texture data
  118828. * @param texture defines the BabylonJS internal texture
  118829. * @param createPolynomials will be true if polynomials have been requested
  118830. * @param onLoad defines the callback to trigger once the texture is ready
  118831. * @param onError defines the callback to trigger in case of error
  118832. */
  118833. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118834. /**
  118835. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118836. * @param data contains the texture data
  118837. * @param texture defines the BabylonJS internal texture
  118838. * @param callback defines the method to call once ready to upload
  118839. */
  118840. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118841. }
  118842. }
  118843. declare module BABYLON {
  118844. /**
  118845. * Info about the .basis files
  118846. */
  118847. class BasisFileInfo {
  118848. /**
  118849. * If the file has alpha
  118850. */
  118851. hasAlpha: boolean;
  118852. /**
  118853. * Info about each image of the basis file
  118854. */
  118855. images: Array<{
  118856. levels: Array<{
  118857. width: number;
  118858. height: number;
  118859. transcodedPixels: ArrayBufferView;
  118860. }>;
  118861. }>;
  118862. }
  118863. /**
  118864. * Result of transcoding a basis file
  118865. */
  118866. class TranscodeResult {
  118867. /**
  118868. * Info about the .basis file
  118869. */
  118870. fileInfo: BasisFileInfo;
  118871. /**
  118872. * Format to use when loading the file
  118873. */
  118874. format: number;
  118875. }
  118876. /**
  118877. * Configuration options for the Basis transcoder
  118878. */
  118879. export class BasisTranscodeConfiguration {
  118880. /**
  118881. * Supported compression formats used to determine the supported output format of the transcoder
  118882. */
  118883. supportedCompressionFormats?: {
  118884. /**
  118885. * etc1 compression format
  118886. */
  118887. etc1?: boolean;
  118888. /**
  118889. * s3tc compression format
  118890. */
  118891. s3tc?: boolean;
  118892. /**
  118893. * pvrtc compression format
  118894. */
  118895. pvrtc?: boolean;
  118896. /**
  118897. * etc2 compression format
  118898. */
  118899. etc2?: boolean;
  118900. };
  118901. /**
  118902. * If mipmap levels should be loaded for transcoded images (Default: true)
  118903. */
  118904. loadMipmapLevels?: boolean;
  118905. /**
  118906. * Index of a single image to load (Default: all images)
  118907. */
  118908. loadSingleImage?: number;
  118909. }
  118910. /**
  118911. * Used to load .Basis files
  118912. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  118913. */
  118914. export class BasisTools {
  118915. private static _IgnoreSupportedFormats;
  118916. /**
  118917. * URL to use when loading the basis transcoder
  118918. */
  118919. static JSModuleURL: string;
  118920. /**
  118921. * URL to use when loading the wasm module for the transcoder
  118922. */
  118923. static WasmModuleURL: string;
  118924. /**
  118925. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  118926. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  118927. * @returns internal format corresponding to the Basis format
  118928. */
  118929. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  118930. private static _WorkerPromise;
  118931. private static _Worker;
  118932. private static _actionId;
  118933. private static _CreateWorkerAsync;
  118934. /**
  118935. * Transcodes a loaded image file to compressed pixel data
  118936. * @param imageData image data to transcode
  118937. * @param config configuration options for the transcoding
  118938. * @returns a promise resulting in the transcoded image
  118939. */
  118940. static TranscodeAsync(imageData: ArrayBuffer, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  118941. /**
  118942. * Loads a texture from the transcode result
  118943. * @param texture texture load to
  118944. * @param transcodeResult the result of transcoding the basis file to load from
  118945. */
  118946. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  118947. }
  118948. }
  118949. declare module BABYLON {
  118950. /**
  118951. * Loader for .basis file format
  118952. */
  118953. export class _BasisTextureLoader implements IInternalTextureLoader {
  118954. /**
  118955. * Defines whether the loader supports cascade loading the different faces.
  118956. */
  118957. readonly supportCascades: boolean;
  118958. /**
  118959. * This returns if the loader support the current file information.
  118960. * @param extension defines the file extension of the file being loaded
  118961. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118962. * @param fallback defines the fallback internal texture if any
  118963. * @param isBase64 defines whether the texture is encoded as a base64
  118964. * @param isBuffer defines whether the texture data are stored as a buffer
  118965. * @returns true if the loader can load the specified file
  118966. */
  118967. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  118968. /**
  118969. * Transform the url before loading if required.
  118970. * @param rootUrl the url of the texture
  118971. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118972. * @returns the transformed texture
  118973. */
  118974. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  118975. /**
  118976. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  118977. * @param rootUrl the url of the texture
  118978. * @param textureFormatInUse defines the current compressed format in use iun the engine
  118979. * @returns the fallback texture
  118980. */
  118981. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  118982. /**
  118983. * Uploads the cube texture data to the WebGl Texture. It has already been bound.
  118984. * @param data contains the texture data
  118985. * @param texture defines the BabylonJS internal texture
  118986. * @param createPolynomials will be true if polynomials have been requested
  118987. * @param onLoad defines the callback to trigger once the texture is ready
  118988. * @param onError defines the callback to trigger in case of error
  118989. */
  118990. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  118991. /**
  118992. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  118993. * @param data contains the texture data
  118994. * @param texture defines the BabylonJS internal texture
  118995. * @param callback defines the method to call once ready to upload
  118996. */
  118997. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  118998. }
  118999. }
  119000. declare module BABYLON {
  119001. /**
  119002. * 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.
  119003. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119004. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119005. */
  119006. export class CustomProceduralTexture extends ProceduralTexture {
  119007. private _animate;
  119008. private _time;
  119009. private _config;
  119010. private _texturePath;
  119011. /**
  119012. * Instantiates a new Custom Procedural Texture.
  119013. * 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.
  119014. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  119015. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  119016. * @param name Define the name of the texture
  119017. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  119018. * @param size Define the size of the texture to create
  119019. * @param scene Define the scene the texture belongs to
  119020. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  119021. * @param generateMipMaps Define if the texture should creates mip maps or not
  119022. */
  119023. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119024. private _loadJson;
  119025. /**
  119026. * Is the texture ready to be used ? (rendered at least once)
  119027. * @returns true if ready, otherwise, false.
  119028. */
  119029. isReady(): boolean;
  119030. /**
  119031. * Render the texture to its associated render target.
  119032. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  119033. */
  119034. render(useCameraPostProcess?: boolean): void;
  119035. /**
  119036. * Update the list of dependant textures samplers in the shader.
  119037. */
  119038. updateTextures(): void;
  119039. /**
  119040. * Update the uniform values of the procedural texture in the shader.
  119041. */
  119042. updateShaderUniforms(): void;
  119043. /**
  119044. * Define if the texture animates or not.
  119045. */
  119046. animate: boolean;
  119047. }
  119048. }
  119049. declare module BABYLON {
  119050. /** @hidden */
  119051. export var noisePixelShader: {
  119052. name: string;
  119053. shader: string;
  119054. };
  119055. }
  119056. declare module BABYLON {
  119057. /**
  119058. * Class used to generate noise procedural textures
  119059. */
  119060. export class NoiseProceduralTexture extends ProceduralTexture {
  119061. private _time;
  119062. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  119063. brightness: number;
  119064. /** Defines the number of octaves to process */
  119065. octaves: number;
  119066. /** Defines the level of persistence (0.8 by default) */
  119067. persistence: number;
  119068. /** Gets or sets animation speed factor (default is 1) */
  119069. animationSpeedFactor: number;
  119070. /**
  119071. * Creates a new NoiseProceduralTexture
  119072. * @param name defines the name fo the texture
  119073. * @param size defines the size of the texture (default is 256)
  119074. * @param scene defines the hosting scene
  119075. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  119076. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  119077. */
  119078. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  119079. private _updateShaderUniforms;
  119080. protected _getDefines(): string;
  119081. /** Generate the current state of the procedural texture */
  119082. render(useCameraPostProcess?: boolean): void;
  119083. /**
  119084. * Serializes this noise procedural texture
  119085. * @returns a serialized noise procedural texture object
  119086. */
  119087. serialize(): any;
  119088. /**
  119089. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  119090. * @param parsedTexture defines parsed texture data
  119091. * @param scene defines the current scene
  119092. * @param rootUrl defines the root URL containing noise procedural texture information
  119093. * @returns a parsed NoiseProceduralTexture
  119094. */
  119095. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  119096. }
  119097. }
  119098. declare module BABYLON {
  119099. /**
  119100. * Raw cube texture where the raw buffers are passed in
  119101. */
  119102. export class RawCubeTexture extends CubeTexture {
  119103. /**
  119104. * Creates a cube texture where the raw buffers are passed in.
  119105. * @param scene defines the scene the texture is attached to
  119106. * @param data defines the array of data to use to create each face
  119107. * @param size defines the size of the textures
  119108. * @param format defines the format of the data
  119109. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  119110. * @param generateMipMaps defines if the engine should generate the mip levels
  119111. * @param invertY defines if data must be stored with Y axis inverted
  119112. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  119113. * @param compression defines the compression used (null by default)
  119114. */
  119115. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  119116. /**
  119117. * Updates the raw cube texture.
  119118. * @param data defines the data to store
  119119. * @param format defines the data format
  119120. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  119121. * @param invertY defines if data must be stored with Y axis inverted
  119122. * @param compression defines the compression used (null by default)
  119123. * @param level defines which level of the texture to update
  119124. */
  119125. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  119126. /**
  119127. * Updates a raw cube texture with RGBD encoded data.
  119128. * @param data defines the array of data [mipmap][face] to use to create each face
  119129. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  119130. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  119131. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  119132. * @returns a promsie that resolves when the operation is complete
  119133. */
  119134. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  119135. /**
  119136. * Clones the raw cube texture.
  119137. * @return a new cube texture
  119138. */
  119139. clone(): CubeTexture;
  119140. /** @hidden */
  119141. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  119142. }
  119143. }
  119144. declare module BABYLON {
  119145. /**
  119146. * Class used to store 3D textures containing user data
  119147. */
  119148. export class RawTexture3D extends Texture {
  119149. /** Gets or sets the texture format to use */
  119150. format: number;
  119151. private _engine;
  119152. /**
  119153. * Create a new RawTexture3D
  119154. * @param data defines the data of the texture
  119155. * @param width defines the width of the texture
  119156. * @param height defines the height of the texture
  119157. * @param depth defines the depth of the texture
  119158. * @param format defines the texture format to use
  119159. * @param scene defines the hosting scene
  119160. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  119161. * @param invertY defines if texture must be stored with Y axis inverted
  119162. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  119163. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  119164. */
  119165. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  119166. /** Gets or sets the texture format to use */
  119167. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  119168. /**
  119169. * Update the texture with new data
  119170. * @param data defines the data to store in the texture
  119171. */
  119172. update(data: ArrayBufferView): void;
  119173. }
  119174. }
  119175. declare module BABYLON {
  119176. /**
  119177. * Creates a refraction texture used by refraction channel of the standard material.
  119178. * It is like a mirror but to see through a material.
  119179. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119180. */
  119181. export class RefractionTexture extends RenderTargetTexture {
  119182. /**
  119183. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  119184. * 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.
  119185. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119186. */
  119187. refractionPlane: Plane;
  119188. /**
  119189. * Define how deep under the surface we should see.
  119190. */
  119191. depth: number;
  119192. /**
  119193. * Creates a refraction texture used by refraction channel of the standard material.
  119194. * It is like a mirror but to see through a material.
  119195. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  119196. * @param name Define the texture name
  119197. * @param size Define the size of the underlying texture
  119198. * @param scene Define the scene the refraction belongs to
  119199. * @param generateMipMaps Define if we need to generate mips level for the refraction
  119200. */
  119201. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  119202. /**
  119203. * Clone the refraction texture.
  119204. * @returns the cloned texture
  119205. */
  119206. clone(): RefractionTexture;
  119207. /**
  119208. * Serialize the texture to a JSON representation you could use in Parse later on
  119209. * @returns the serialized JSON representation
  119210. */
  119211. serialize(): any;
  119212. }
  119213. }
  119214. declare module BABYLON {
  119215. /**
  119216. * Defines the options related to the creation of an HtmlElementTexture
  119217. */
  119218. export interface IHtmlElementTextureOptions {
  119219. /**
  119220. * Defines wether mip maps should be created or not.
  119221. */
  119222. generateMipMaps?: boolean;
  119223. /**
  119224. * Defines the sampling mode of the texture.
  119225. */
  119226. samplingMode?: number;
  119227. /**
  119228. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  119229. */
  119230. engine: Nullable<Engine>;
  119231. /**
  119232. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  119233. */
  119234. scene: Nullable<Scene>;
  119235. }
  119236. /**
  119237. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  119238. * To be as efficient as possible depending on your constraints nothing aside the first upload
  119239. * is automatically managed.
  119240. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  119241. * in your application.
  119242. *
  119243. * As the update is not automatic, you need to call them manually.
  119244. */
  119245. export class HtmlElementTexture extends BaseTexture {
  119246. /**
  119247. * The texture URL.
  119248. */
  119249. element: HTMLVideoElement | HTMLCanvasElement;
  119250. private static readonly DefaultOptions;
  119251. private _textureMatrix;
  119252. private _engine;
  119253. private _isVideo;
  119254. private _generateMipMaps;
  119255. private _samplingMode;
  119256. /**
  119257. * Instantiates a HtmlElementTexture from the following parameters.
  119258. *
  119259. * @param name Defines the name of the texture
  119260. * @param element Defines the video or canvas the texture is filled with
  119261. * @param options Defines the other none mandatory texture creation options
  119262. */
  119263. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  119264. private _createInternalTexture;
  119265. /**
  119266. * Returns the texture matrix used in most of the material.
  119267. */
  119268. getTextureMatrix(): Matrix;
  119269. /**
  119270. * Updates the content of the texture.
  119271. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  119272. */
  119273. update(invertY?: Nullable<boolean>): void;
  119274. }
  119275. }
  119276. declare module BABYLON {
  119277. /**
  119278. * Enum used to define the target of a block
  119279. */
  119280. export enum NodeMaterialBlockTargets {
  119281. /** Vertex shader */
  119282. Vertex = 1,
  119283. /** Fragment shader */
  119284. Fragment = 2,
  119285. /** Neutral */
  119286. Neutral = 4,
  119287. /** Vertex and Fragment */
  119288. VertexAndFragment = 3
  119289. }
  119290. }
  119291. declare module BABYLON {
  119292. /**
  119293. * Defines the kind of connection point for node based material
  119294. */
  119295. export enum NodeMaterialBlockConnectionPointTypes {
  119296. /** Float */
  119297. Float = 1,
  119298. /** Int */
  119299. Int = 2,
  119300. /** Vector2 */
  119301. Vector2 = 4,
  119302. /** Vector3 */
  119303. Vector3 = 8,
  119304. /** Vector4 */
  119305. Vector4 = 16,
  119306. /** Color3 */
  119307. Color3 = 32,
  119308. /** Color4 */
  119309. Color4 = 64,
  119310. /** Matrix */
  119311. Matrix = 128,
  119312. /** Detect type based on connection */
  119313. AutoDetect = 1024,
  119314. /** Output type that will be defined by input type */
  119315. BasedOnInput = 2048
  119316. }
  119317. }
  119318. declare module BABYLON {
  119319. /**
  119320. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  119321. */
  119322. export enum NodeMaterialBlockConnectionPointMode {
  119323. /** Value is an uniform */
  119324. Uniform = 0,
  119325. /** Value is a mesh attribute */
  119326. Attribute = 1,
  119327. /** Value is a varying between vertex and fragment shaders */
  119328. Varying = 2,
  119329. /** Mode is undefined */
  119330. Undefined = 3
  119331. }
  119332. }
  119333. declare module BABYLON {
  119334. /**
  119335. * Enum used to define system values e.g. values automatically provided by the system
  119336. */
  119337. export enum NodeMaterialSystemValues {
  119338. /** World */
  119339. World = 1,
  119340. /** View */
  119341. View = 2,
  119342. /** Projection */
  119343. Projection = 3,
  119344. /** ViewProjection */
  119345. ViewProjection = 4,
  119346. /** WorldView */
  119347. WorldView = 5,
  119348. /** WorldViewProjection */
  119349. WorldViewProjection = 6,
  119350. /** CameraPosition */
  119351. CameraPosition = 7,
  119352. /** Fog Color */
  119353. FogColor = 8,
  119354. /** Delta time */
  119355. DeltaTime = 9
  119356. }
  119357. }
  119358. declare module BABYLON {
  119359. /**
  119360. * Root class for all node material optimizers
  119361. */
  119362. export class NodeMaterialOptimizer {
  119363. /**
  119364. * Function used to optimize a NodeMaterial graph
  119365. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  119366. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  119367. */
  119368. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  119369. }
  119370. }
  119371. declare module BABYLON {
  119372. /**
  119373. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  119374. */
  119375. export class TransformBlock extends NodeMaterialBlock {
  119376. /**
  119377. * Defines the value to use to complement W value to transform it to a Vector4
  119378. */
  119379. complementW: number;
  119380. /**
  119381. * Defines the value to use to complement z value to transform it to a Vector4
  119382. */
  119383. complementZ: number;
  119384. /**
  119385. * Creates a new TransformBlock
  119386. * @param name defines the block name
  119387. */
  119388. constructor(name: string);
  119389. /**
  119390. * Gets the current class name
  119391. * @returns the class name
  119392. */
  119393. getClassName(): string;
  119394. /**
  119395. * Gets the vector input
  119396. */
  119397. readonly vector: NodeMaterialConnectionPoint;
  119398. /**
  119399. * Gets the output component
  119400. */
  119401. readonly output: NodeMaterialConnectionPoint;
  119402. /**
  119403. * Gets the matrix transform input
  119404. */
  119405. readonly transform: NodeMaterialConnectionPoint;
  119406. protected _buildBlock(state: NodeMaterialBuildState): this;
  119407. serialize(): any;
  119408. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119409. protected _dumpPropertiesCode(): string;
  119410. }
  119411. }
  119412. declare module BABYLON {
  119413. /**
  119414. * Block used to output the vertex position
  119415. */
  119416. export class VertexOutputBlock extends NodeMaterialBlock {
  119417. /**
  119418. * Creates a new VertexOutputBlock
  119419. * @param name defines the block name
  119420. */
  119421. constructor(name: string);
  119422. /**
  119423. * Gets the current class name
  119424. * @returns the class name
  119425. */
  119426. getClassName(): string;
  119427. /**
  119428. * Gets the vector input component
  119429. */
  119430. readonly vector: NodeMaterialConnectionPoint;
  119431. protected _buildBlock(state: NodeMaterialBuildState): this;
  119432. }
  119433. }
  119434. declare module BABYLON {
  119435. /**
  119436. * Block used to output the final color
  119437. */
  119438. export class FragmentOutputBlock extends NodeMaterialBlock {
  119439. /**
  119440. * Create a new FragmentOutputBlock
  119441. * @param name defines the block name
  119442. */
  119443. constructor(name: string);
  119444. /**
  119445. * Gets the current class name
  119446. * @returns the class name
  119447. */
  119448. getClassName(): string;
  119449. /**
  119450. * Gets the rgba input component
  119451. */
  119452. readonly rgba: NodeMaterialConnectionPoint;
  119453. /**
  119454. * Gets the rgb input component
  119455. */
  119456. readonly rgb: NodeMaterialConnectionPoint;
  119457. /**
  119458. * Gets the a input component
  119459. */
  119460. readonly a: NodeMaterialConnectionPoint;
  119461. protected _buildBlock(state: NodeMaterialBuildState): this;
  119462. }
  119463. }
  119464. declare module BABYLON {
  119465. /**
  119466. * Block used to read a reflection texture from a sampler
  119467. */
  119468. export class ReflectionTextureBlock extends NodeMaterialBlock {
  119469. private _define3DName;
  119470. private _defineCubicName;
  119471. private _defineExplicitName;
  119472. private _defineProjectionName;
  119473. private _defineLocalCubicName;
  119474. private _defineSphericalName;
  119475. private _definePlanarName;
  119476. private _defineEquirectangularName;
  119477. private _defineMirroredEquirectangularFixedName;
  119478. private _defineEquirectangularFixedName;
  119479. private _defineSkyboxName;
  119480. private _cubeSamplerName;
  119481. private _2DSamplerName;
  119482. private _positionUVWName;
  119483. private _directionWName;
  119484. private _reflectionCoordsName;
  119485. private _reflection2DCoordsName;
  119486. private _reflectionColorName;
  119487. private _reflectionMatrixName;
  119488. /**
  119489. * Gets or sets the texture associated with the node
  119490. */
  119491. texture: Nullable<BaseTexture>;
  119492. /**
  119493. * Create a new TextureBlock
  119494. * @param name defines the block name
  119495. */
  119496. constructor(name: string);
  119497. /**
  119498. * Gets the current class name
  119499. * @returns the class name
  119500. */
  119501. getClassName(): string;
  119502. /**
  119503. * Gets the world position input component
  119504. */
  119505. readonly position: NodeMaterialConnectionPoint;
  119506. /**
  119507. * Gets the world position input component
  119508. */
  119509. readonly worldPosition: NodeMaterialConnectionPoint;
  119510. /**
  119511. * Gets the world normal input component
  119512. */
  119513. readonly worldNormal: NodeMaterialConnectionPoint;
  119514. /**
  119515. * Gets the world input component
  119516. */
  119517. readonly world: NodeMaterialConnectionPoint;
  119518. /**
  119519. * Gets the camera (or eye) position component
  119520. */
  119521. readonly cameraPosition: NodeMaterialConnectionPoint;
  119522. /**
  119523. * Gets the view input component
  119524. */
  119525. readonly view: NodeMaterialConnectionPoint;
  119526. /**
  119527. * Gets the rgb output component
  119528. */
  119529. readonly rgb: NodeMaterialConnectionPoint;
  119530. /**
  119531. * Gets the r output component
  119532. */
  119533. readonly r: NodeMaterialConnectionPoint;
  119534. /**
  119535. * Gets the g output component
  119536. */
  119537. readonly g: NodeMaterialConnectionPoint;
  119538. /**
  119539. * Gets the b output component
  119540. */
  119541. readonly b: NodeMaterialConnectionPoint;
  119542. autoConfigure(material: NodeMaterial): void;
  119543. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119544. isReady(): boolean;
  119545. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119546. private _injectVertexCode;
  119547. private _writeOutput;
  119548. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119549. serialize(): any;
  119550. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119551. }
  119552. }
  119553. declare module BABYLON {
  119554. /**
  119555. * Interface used to configure the node material editor
  119556. */
  119557. export interface INodeMaterialEditorOptions {
  119558. /** Define the URl to load node editor script */
  119559. editorURL?: string;
  119560. }
  119561. /** @hidden */
  119562. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  119563. /** BONES */
  119564. NUM_BONE_INFLUENCERS: number;
  119565. BonesPerMesh: number;
  119566. BONETEXTURE: boolean;
  119567. /** MORPH TARGETS */
  119568. MORPHTARGETS: boolean;
  119569. MORPHTARGETS_NORMAL: boolean;
  119570. MORPHTARGETS_TANGENT: boolean;
  119571. MORPHTARGETS_UV: boolean;
  119572. NUM_MORPH_INFLUENCERS: number;
  119573. /** IMAGE PROCESSING */
  119574. IMAGEPROCESSING: boolean;
  119575. VIGNETTE: boolean;
  119576. VIGNETTEBLENDMODEMULTIPLY: boolean;
  119577. VIGNETTEBLENDMODEOPAQUE: boolean;
  119578. TONEMAPPING: boolean;
  119579. TONEMAPPING_ACES: boolean;
  119580. CONTRAST: boolean;
  119581. EXPOSURE: boolean;
  119582. COLORCURVES: boolean;
  119583. COLORGRADING: boolean;
  119584. COLORGRADING3D: boolean;
  119585. SAMPLER3DGREENDEPTH: boolean;
  119586. SAMPLER3DBGRMAP: boolean;
  119587. IMAGEPROCESSINGPOSTPROCESS: boolean;
  119588. /** MISC. */
  119589. BUMPDIRECTUV: number;
  119590. constructor();
  119591. setValue(name: string, value: boolean): void;
  119592. }
  119593. /**
  119594. * Class used to configure NodeMaterial
  119595. */
  119596. export interface INodeMaterialOptions {
  119597. /**
  119598. * Defines if blocks should emit comments
  119599. */
  119600. emitComments: boolean;
  119601. }
  119602. /**
  119603. * Class used to create a node based material built by assembling shader blocks
  119604. */
  119605. export class NodeMaterial extends PushMaterial {
  119606. private static _BuildIdGenerator;
  119607. private _options;
  119608. private _vertexCompilationState;
  119609. private _fragmentCompilationState;
  119610. private _sharedData;
  119611. private _buildId;
  119612. private _buildWasSuccessful;
  119613. private _cachedWorldViewMatrix;
  119614. private _cachedWorldViewProjectionMatrix;
  119615. private _optimizers;
  119616. private _animationFrame;
  119617. /** Define the URl to load node editor script */
  119618. static EditorURL: string;
  119619. private BJSNODEMATERIALEDITOR;
  119620. /** Get the inspector from bundle or global */
  119621. private _getGlobalNodeMaterialEditor;
  119622. /**
  119623. * 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)
  119624. */
  119625. ignoreAlpha: boolean;
  119626. /**
  119627. * Defines the maximum number of lights that can be used in the material
  119628. */
  119629. maxSimultaneousLights: number;
  119630. /**
  119631. * Observable raised when the material is built
  119632. */
  119633. onBuildObservable: Observable<NodeMaterial>;
  119634. /**
  119635. * Gets or sets the root nodes of the material vertex shader
  119636. */
  119637. _vertexOutputNodes: NodeMaterialBlock[];
  119638. /**
  119639. * Gets or sets the root nodes of the material fragment (pixel) shader
  119640. */
  119641. _fragmentOutputNodes: NodeMaterialBlock[];
  119642. /** Gets or sets options to control the node material overall behavior */
  119643. options: INodeMaterialOptions;
  119644. /**
  119645. * Default configuration related to image processing available in the standard Material.
  119646. */
  119647. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  119648. /**
  119649. * Gets the image processing configuration used either in this material.
  119650. */
  119651. /**
  119652. * Sets the Default image processing configuration used either in the this material.
  119653. *
  119654. * If sets to null, the scene one is in use.
  119655. */
  119656. imageProcessingConfiguration: ImageProcessingConfiguration;
  119657. /**
  119658. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  119659. */
  119660. attachedBlocks: NodeMaterialBlock[];
  119661. /**
  119662. * Create a new node based material
  119663. * @param name defines the material name
  119664. * @param scene defines the hosting scene
  119665. * @param options defines creation option
  119666. */
  119667. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  119668. /**
  119669. * Gets the current class name of the material e.g. "NodeMaterial"
  119670. * @returns the class name
  119671. */
  119672. getClassName(): string;
  119673. /**
  119674. * Keep track of the image processing observer to allow dispose and replace.
  119675. */
  119676. private _imageProcessingObserver;
  119677. /**
  119678. * Attaches a new image processing configuration to the Standard Material.
  119679. * @param configuration
  119680. */
  119681. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  119682. /**
  119683. * Get a block by its name
  119684. * @param name defines the name of the block to retrieve
  119685. * @returns the required block or null if not found
  119686. */
  119687. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  119688. /**
  119689. * Get a block by its name
  119690. * @param predicate defines the predicate used to find the good candidate
  119691. * @returns the required block or null if not found
  119692. */
  119693. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  119694. /**
  119695. * Get an input block by its name
  119696. * @param predicate defines the predicate used to find the good candidate
  119697. * @returns the required input block or null if not found
  119698. */
  119699. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  119700. /**
  119701. * Gets the list of input blocks attached to this material
  119702. * @returns an array of InputBlocks
  119703. */
  119704. getInputBlocks(): InputBlock[];
  119705. /**
  119706. * Adds a new optimizer to the list of optimizers
  119707. * @param optimizer defines the optimizers to add
  119708. * @returns the current material
  119709. */
  119710. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119711. /**
  119712. * Remove an optimizer from the list of optimizers
  119713. * @param optimizer defines the optimizers to remove
  119714. * @returns the current material
  119715. */
  119716. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  119717. /**
  119718. * Add a new block to the list of output nodes
  119719. * @param node defines the node to add
  119720. * @returns the current material
  119721. */
  119722. addOutputNode(node: NodeMaterialBlock): this;
  119723. /**
  119724. * Remove a block from the list of root nodes
  119725. * @param node defines the node to remove
  119726. * @returns the current material
  119727. */
  119728. removeOutputNode(node: NodeMaterialBlock): this;
  119729. private _addVertexOutputNode;
  119730. private _removeVertexOutputNode;
  119731. private _addFragmentOutputNode;
  119732. private _removeFragmentOutputNode;
  119733. /**
  119734. * Specifies if the material will require alpha blending
  119735. * @returns a boolean specifying if alpha blending is needed
  119736. */
  119737. needAlphaBlending(): boolean;
  119738. /**
  119739. * Specifies if this material should be rendered in alpha test mode
  119740. * @returns a boolean specifying if an alpha test is needed.
  119741. */
  119742. needAlphaTesting(): boolean;
  119743. private _initializeBlock;
  119744. private _resetDualBlocks;
  119745. /**
  119746. * Build the material and generates the inner effect
  119747. * @param verbose defines if the build should log activity
  119748. */
  119749. build(verbose?: boolean): void;
  119750. /**
  119751. * Runs an otpimization phase to try to improve the shader code
  119752. */
  119753. optimize(): void;
  119754. private _prepareDefinesForAttributes;
  119755. /**
  119756. * Get if the submesh is ready to be used and all its information available.
  119757. * Child classes can use it to update shaders
  119758. * @param mesh defines the mesh to check
  119759. * @param subMesh defines which submesh to check
  119760. * @param useInstances specifies that instances should be used
  119761. * @returns a boolean indicating that the submesh is ready or not
  119762. */
  119763. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  119764. /**
  119765. * Get a string representing the shaders built by the current node graph
  119766. */
  119767. readonly compiledShaders: string;
  119768. /**
  119769. * Binds the world matrix to the material
  119770. * @param world defines the world transformation matrix
  119771. */
  119772. bindOnlyWorldMatrix(world: Matrix): void;
  119773. /**
  119774. * Binds the submesh to this material by preparing the effect and shader to draw
  119775. * @param world defines the world transformation matrix
  119776. * @param mesh defines the mesh containing the submesh
  119777. * @param subMesh defines the submesh to bind the material to
  119778. */
  119779. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  119780. /**
  119781. * Gets the active textures from the material
  119782. * @returns an array of textures
  119783. */
  119784. getActiveTextures(): BaseTexture[];
  119785. /**
  119786. * Gets the list of texture blocks
  119787. * @returns an array of texture blocks
  119788. */
  119789. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  119790. /**
  119791. * Specifies if the material uses a texture
  119792. * @param texture defines the texture to check against the material
  119793. * @returns a boolean specifying if the material uses the texture
  119794. */
  119795. hasTexture(texture: BaseTexture): boolean;
  119796. /**
  119797. * Disposes the material
  119798. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  119799. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  119800. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  119801. */
  119802. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  119803. /** Creates the node editor window. */
  119804. private _createNodeEditor;
  119805. /**
  119806. * Launch the node material editor
  119807. * @param config Define the configuration of the editor
  119808. * @return a promise fulfilled when the node editor is visible
  119809. */
  119810. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  119811. /**
  119812. * Clear the current material
  119813. */
  119814. clear(): void;
  119815. /**
  119816. * Clear the current material and set it to a default state
  119817. */
  119818. setToDefault(): void;
  119819. /**
  119820. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  119821. * @param url defines the url to load from
  119822. * @returns a promise that will fullfil when the material is fully loaded
  119823. */
  119824. loadAsync(url: string): Promise<unknown>;
  119825. private _gatherBlocks;
  119826. /**
  119827. * Generate a string containing the code declaration required to create an equivalent of this material
  119828. * @returns a string
  119829. */
  119830. generateCode(): string;
  119831. /**
  119832. * Serializes this material in a JSON representation
  119833. * @returns the serialized material object
  119834. */
  119835. serialize(): any;
  119836. private _restoreConnections;
  119837. /**
  119838. * Clear the current graph and load a new one from a serialization object
  119839. * @param source defines the JSON representation of the material
  119840. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119841. */
  119842. loadFromSerialization(source: any, rootUrl?: string): void;
  119843. /**
  119844. * Creates a node material from parsed material data
  119845. * @param source defines the JSON representation of the material
  119846. * @param scene defines the hosting scene
  119847. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  119848. * @returns a new node material
  119849. */
  119850. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  119851. /**
  119852. * Creates a new node material set to default basic configuration
  119853. * @param name defines the name of the material
  119854. * @param scene defines the hosting scene
  119855. * @returns a new NodeMaterial
  119856. */
  119857. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  119858. }
  119859. }
  119860. declare module BABYLON {
  119861. /**
  119862. * Block used to read a texture from a sampler
  119863. */
  119864. export class TextureBlock extends NodeMaterialBlock {
  119865. private _defineName;
  119866. private _linearDefineName;
  119867. private _samplerName;
  119868. private _transformedUVName;
  119869. private _textureTransformName;
  119870. private _textureInfoName;
  119871. private _mainUVName;
  119872. private _mainUVDefineName;
  119873. /**
  119874. * Gets or sets the texture associated with the node
  119875. */
  119876. texture: Nullable<Texture>;
  119877. /**
  119878. * Create a new TextureBlock
  119879. * @param name defines the block name
  119880. */
  119881. constructor(name: string);
  119882. /**
  119883. * Gets the current class name
  119884. * @returns the class name
  119885. */
  119886. getClassName(): string;
  119887. /**
  119888. * Gets the uv input component
  119889. */
  119890. readonly uv: NodeMaterialConnectionPoint;
  119891. /**
  119892. * Gets the rgba output component
  119893. */
  119894. readonly rgba: NodeMaterialConnectionPoint;
  119895. /**
  119896. * Gets the rgb output component
  119897. */
  119898. readonly rgb: NodeMaterialConnectionPoint;
  119899. /**
  119900. * Gets the r output component
  119901. */
  119902. readonly r: NodeMaterialConnectionPoint;
  119903. /**
  119904. * Gets the g output component
  119905. */
  119906. readonly g: NodeMaterialConnectionPoint;
  119907. /**
  119908. * Gets the b output component
  119909. */
  119910. readonly b: NodeMaterialConnectionPoint;
  119911. /**
  119912. * Gets the a output component
  119913. */
  119914. readonly a: NodeMaterialConnectionPoint;
  119915. readonly target: NodeMaterialBlockTargets;
  119916. autoConfigure(material: NodeMaterial): void;
  119917. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  119918. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  119919. isReady(): boolean;
  119920. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  119921. private readonly _isMixed;
  119922. private _injectVertexCode;
  119923. private _writeOutput;
  119924. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  119925. protected _dumpPropertiesCode(): string;
  119926. serialize(): any;
  119927. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  119928. }
  119929. }
  119930. declare module BABYLON {
  119931. /**
  119932. * Class used to store shared data between 2 NodeMaterialBuildState
  119933. */
  119934. export class NodeMaterialBuildStateSharedData {
  119935. /**
  119936. * Gets the list of emitted varyings
  119937. */
  119938. temps: string[];
  119939. /**
  119940. * Gets the list of emitted varyings
  119941. */
  119942. varyings: string[];
  119943. /**
  119944. * Gets the varying declaration string
  119945. */
  119946. varyingDeclaration: string;
  119947. /**
  119948. * Input blocks
  119949. */
  119950. inputBlocks: InputBlock[];
  119951. /**
  119952. * Input blocks
  119953. */
  119954. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  119955. /**
  119956. * Bindable blocks (Blocks that need to set data to the effect)
  119957. */
  119958. bindableBlocks: NodeMaterialBlock[];
  119959. /**
  119960. * List of blocks that can provide a compilation fallback
  119961. */
  119962. blocksWithFallbacks: NodeMaterialBlock[];
  119963. /**
  119964. * List of blocks that can provide a define update
  119965. */
  119966. blocksWithDefines: NodeMaterialBlock[];
  119967. /**
  119968. * List of blocks that can provide a repeatable content
  119969. */
  119970. repeatableContentBlocks: NodeMaterialBlock[];
  119971. /**
  119972. * List of blocks that can provide a dynamic list of uniforms
  119973. */
  119974. dynamicUniformBlocks: NodeMaterialBlock[];
  119975. /**
  119976. * List of blocks that can block the isReady function for the material
  119977. */
  119978. blockingBlocks: NodeMaterialBlock[];
  119979. /**
  119980. * Gets the list of animated inputs
  119981. */
  119982. animatedInputs: InputBlock[];
  119983. /**
  119984. * Build Id used to avoid multiple recompilations
  119985. */
  119986. buildId: number;
  119987. /** List of emitted variables */
  119988. variableNames: {
  119989. [key: string]: number;
  119990. };
  119991. /** List of emitted defines */
  119992. defineNames: {
  119993. [key: string]: number;
  119994. };
  119995. /** Should emit comments? */
  119996. emitComments: boolean;
  119997. /** Emit build activity */
  119998. verbose: boolean;
  119999. /** Gets or sets the hosting scene */
  120000. scene: Scene;
  120001. /**
  120002. * Gets the compilation hints emitted at compilation time
  120003. */
  120004. hints: {
  120005. needWorldViewMatrix: boolean;
  120006. needWorldViewProjectionMatrix: boolean;
  120007. needAlphaBlending: boolean;
  120008. needAlphaTesting: boolean;
  120009. };
  120010. /**
  120011. * List of compilation checks
  120012. */
  120013. checks: {
  120014. emitVertex: boolean;
  120015. emitFragment: boolean;
  120016. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  120017. };
  120018. /** Creates a new shared data */
  120019. constructor();
  120020. /**
  120021. * Emits console errors and exceptions if there is a failing check
  120022. */
  120023. emitErrors(): void;
  120024. }
  120025. }
  120026. declare module BABYLON {
  120027. /**
  120028. * Class used to store node based material build state
  120029. */
  120030. export class NodeMaterialBuildState {
  120031. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  120032. supportUniformBuffers: boolean;
  120033. /**
  120034. * Gets the list of emitted attributes
  120035. */
  120036. attributes: string[];
  120037. /**
  120038. * Gets the list of emitted uniforms
  120039. */
  120040. uniforms: string[];
  120041. /**
  120042. * Gets the list of emitted constants
  120043. */
  120044. constants: string[];
  120045. /**
  120046. * Gets the list of emitted uniform buffers
  120047. */
  120048. uniformBuffers: string[];
  120049. /**
  120050. * Gets the list of emitted samplers
  120051. */
  120052. samplers: string[];
  120053. /**
  120054. * Gets the list of emitted functions
  120055. */
  120056. functions: {
  120057. [key: string]: string;
  120058. };
  120059. /**
  120060. * Gets the list of emitted extensions
  120061. */
  120062. extensions: {
  120063. [key: string]: string;
  120064. };
  120065. /**
  120066. * Gets the target of the compilation state
  120067. */
  120068. target: NodeMaterialBlockTargets;
  120069. /**
  120070. * Gets the list of emitted counters
  120071. */
  120072. counters: {
  120073. [key: string]: number;
  120074. };
  120075. /**
  120076. * Shared data between multiple NodeMaterialBuildState instances
  120077. */
  120078. sharedData: NodeMaterialBuildStateSharedData;
  120079. /** @hidden */
  120080. _vertexState: NodeMaterialBuildState;
  120081. /** @hidden */
  120082. _attributeDeclaration: string;
  120083. /** @hidden */
  120084. _uniformDeclaration: string;
  120085. /** @hidden */
  120086. _constantDeclaration: string;
  120087. /** @hidden */
  120088. _samplerDeclaration: string;
  120089. /** @hidden */
  120090. _varyingTransfer: string;
  120091. private _repeatableContentAnchorIndex;
  120092. /** @hidden */
  120093. _builtCompilationString: string;
  120094. /**
  120095. * Gets the emitted compilation strings
  120096. */
  120097. compilationString: string;
  120098. /**
  120099. * Finalize the compilation strings
  120100. * @param state defines the current compilation state
  120101. */
  120102. finalize(state: NodeMaterialBuildState): void;
  120103. /** @hidden */
  120104. readonly _repeatableContentAnchor: string;
  120105. /** @hidden */
  120106. _getFreeVariableName(prefix: string): string;
  120107. /** @hidden */
  120108. _getFreeDefineName(prefix: string): string;
  120109. /** @hidden */
  120110. _excludeVariableName(name: string): void;
  120111. /** @hidden */
  120112. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  120113. /** @hidden */
  120114. _emitExtension(name: string, extension: string): void;
  120115. /** @hidden */
  120116. _emitFunction(name: string, code: string, comments: string): void;
  120117. /** @hidden */
  120118. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  120119. replaceStrings?: {
  120120. search: RegExp;
  120121. replace: string;
  120122. }[];
  120123. repeatKey?: string;
  120124. }): string;
  120125. /** @hidden */
  120126. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  120127. repeatKey?: string;
  120128. removeAttributes?: boolean;
  120129. removeUniforms?: boolean;
  120130. removeVaryings?: boolean;
  120131. removeIfDef?: boolean;
  120132. replaceStrings?: {
  120133. search: RegExp;
  120134. replace: string;
  120135. }[];
  120136. }, storeKey?: string): void;
  120137. /** @hidden */
  120138. _registerTempVariable(name: string): boolean;
  120139. /** @hidden */
  120140. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  120141. /** @hidden */
  120142. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  120143. /** @hidden */
  120144. _emitFloat(value: number): string;
  120145. }
  120146. }
  120147. declare module BABYLON {
  120148. /**
  120149. * Defines a block that can be used inside a node based material
  120150. */
  120151. export class NodeMaterialBlock {
  120152. private _buildId;
  120153. private _buildTarget;
  120154. private _target;
  120155. private _isFinalMerger;
  120156. private _isInput;
  120157. /** @hidden */
  120158. _codeVariableName: string;
  120159. /** @hidden */
  120160. _inputs: NodeMaterialConnectionPoint[];
  120161. /** @hidden */
  120162. _outputs: NodeMaterialConnectionPoint[];
  120163. /** @hidden */
  120164. _preparationId: number;
  120165. /**
  120166. * Gets or sets the name of the block
  120167. */
  120168. name: string;
  120169. /**
  120170. * Gets or sets the unique id of the node
  120171. */
  120172. uniqueId: number;
  120173. /**
  120174. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  120175. */
  120176. readonly isFinalMerger: boolean;
  120177. /**
  120178. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  120179. */
  120180. readonly isInput: boolean;
  120181. /**
  120182. * Gets or sets the build Id
  120183. */
  120184. buildId: number;
  120185. /**
  120186. * Gets or sets the target of the block
  120187. */
  120188. target: NodeMaterialBlockTargets;
  120189. /**
  120190. * Gets the list of input points
  120191. */
  120192. readonly inputs: NodeMaterialConnectionPoint[];
  120193. /** Gets the list of output points */
  120194. readonly outputs: NodeMaterialConnectionPoint[];
  120195. /**
  120196. * Find an input by its name
  120197. * @param name defines the name of the input to look for
  120198. * @returns the input or null if not found
  120199. */
  120200. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120201. /**
  120202. * Find an output by its name
  120203. * @param name defines the name of the outputto look for
  120204. * @returns the output or null if not found
  120205. */
  120206. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  120207. /**
  120208. * Creates a new NodeMaterialBlock
  120209. * @param name defines the block name
  120210. * @param target defines the target of that block (Vertex by default)
  120211. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  120212. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  120213. */
  120214. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  120215. /**
  120216. * Initialize the block and prepare the context for build
  120217. * @param state defines the state that will be used for the build
  120218. */
  120219. initialize(state: NodeMaterialBuildState): void;
  120220. /**
  120221. * Bind data to effect. Will only be called for blocks with isBindable === true
  120222. * @param effect defines the effect to bind data to
  120223. * @param nodeMaterial defines the hosting NodeMaterial
  120224. * @param mesh defines the mesh that will be rendered
  120225. */
  120226. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120227. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  120228. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  120229. protected _writeFloat(value: number): string;
  120230. /**
  120231. * Gets the current class name e.g. "NodeMaterialBlock"
  120232. * @returns the class name
  120233. */
  120234. getClassName(): string;
  120235. /**
  120236. * Register a new input. Must be called inside a block constructor
  120237. * @param name defines the connection point name
  120238. * @param type defines the connection point type
  120239. * @param isOptional defines a boolean indicating that this input can be omitted
  120240. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120241. * @returns the current block
  120242. */
  120243. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  120244. /**
  120245. * Register a new output. Must be called inside a block constructor
  120246. * @param name defines the connection point name
  120247. * @param type defines the connection point type
  120248. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  120249. * @returns the current block
  120250. */
  120251. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  120252. /**
  120253. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  120254. * @param forOutput defines an optional connection point to check compatibility with
  120255. * @returns the first available input or null
  120256. */
  120257. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  120258. /**
  120259. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  120260. * @param forBlock defines an optional block to check compatibility with
  120261. * @returns the first available input or null
  120262. */
  120263. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  120264. /**
  120265. * Gets the sibling of the given output
  120266. * @param current defines the current output
  120267. * @returns the next output in the list or null
  120268. */
  120269. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  120270. /**
  120271. * Connect current block with another block
  120272. * @param other defines the block to connect with
  120273. * @param options define the various options to help pick the right connections
  120274. * @returns the current block
  120275. */
  120276. connectTo(other: NodeMaterialBlock, options?: {
  120277. input?: string;
  120278. output?: string;
  120279. outputSwizzle?: string;
  120280. }): this | undefined;
  120281. protected _buildBlock(state: NodeMaterialBuildState): void;
  120282. /**
  120283. * Add uniforms, samplers and uniform buffers at compilation time
  120284. * @param state defines the state to update
  120285. * @param nodeMaterial defines the node material requesting the update
  120286. * @param defines defines the material defines to update
  120287. */
  120288. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120289. /**
  120290. * Add potential fallbacks if shader compilation fails
  120291. * @param mesh defines the mesh to be rendered
  120292. * @param fallbacks defines the current prioritized list of fallbacks
  120293. */
  120294. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120295. /**
  120296. * Initialize defines for shader compilation
  120297. * @param mesh defines the mesh to be rendered
  120298. * @param nodeMaterial defines the node material requesting the update
  120299. * @param defines defines the material defines to update
  120300. * @param useInstances specifies that instances should be used
  120301. */
  120302. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120303. /**
  120304. * Update defines for shader compilation
  120305. * @param mesh defines the mesh to be rendered
  120306. * @param nodeMaterial defines the node material requesting the update
  120307. * @param defines defines the material defines to update
  120308. * @param useInstances specifies that instances should be used
  120309. */
  120310. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120311. /**
  120312. * Lets the block try to connect some inputs automatically
  120313. * @param material defines the hosting NodeMaterial
  120314. */
  120315. autoConfigure(material: NodeMaterial): void;
  120316. /**
  120317. * Function called when a block is declared as repeatable content generator
  120318. * @param vertexShaderState defines the current compilation state for the vertex shader
  120319. * @param fragmentShaderState defines the current compilation state for the fragment shader
  120320. * @param mesh defines the mesh to be rendered
  120321. * @param defines defines the material defines to update
  120322. */
  120323. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120324. /**
  120325. * Checks if the block is ready
  120326. * @param mesh defines the mesh to be rendered
  120327. * @param nodeMaterial defines the node material requesting the update
  120328. * @param defines defines the material defines to update
  120329. * @param useInstances specifies that instances should be used
  120330. * @returns true if the block is ready
  120331. */
  120332. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  120333. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  120334. private _processBuild;
  120335. /**
  120336. * Compile the current node and generate the shader code
  120337. * @param state defines the current compilation state (uniforms, samplers, current string)
  120338. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  120339. * @returns true if already built
  120340. */
  120341. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  120342. protected _inputRename(name: string): string;
  120343. protected _outputRename(name: string): string;
  120344. protected _dumpPropertiesCode(): string;
  120345. /** @hidden */
  120346. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  120347. /**
  120348. * Clone the current block to a new identical block
  120349. * @param scene defines the hosting scene
  120350. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  120351. * @returns a copy of the current block
  120352. */
  120353. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  120354. /**
  120355. * Serializes this block in a JSON representation
  120356. * @returns the serialized block object
  120357. */
  120358. serialize(): any;
  120359. /** @hidden */
  120360. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120361. }
  120362. }
  120363. declare module BABYLON {
  120364. /**
  120365. * Enum defining the type of animations supported by InputBlock
  120366. */
  120367. export enum AnimatedInputBlockTypes {
  120368. /** No animation */
  120369. None = 0,
  120370. /** Time based animation. Will only work for floats */
  120371. Time = 1
  120372. }
  120373. }
  120374. declare module BABYLON {
  120375. /**
  120376. * Block used to expose an input value
  120377. */
  120378. export class InputBlock extends NodeMaterialBlock {
  120379. private _mode;
  120380. private _associatedVariableName;
  120381. private _storedValue;
  120382. private _valueCallback;
  120383. private _type;
  120384. private _animationType;
  120385. /** Gets or set a value used to limit the range of float values */
  120386. min: number;
  120387. /** Gets or set a value used to limit the range of float values */
  120388. max: number;
  120389. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  120390. matrixMode: number;
  120391. /** @hidden */
  120392. _systemValue: Nullable<NodeMaterialSystemValues>;
  120393. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  120394. visibleInInspector: boolean;
  120395. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  120396. isConstant: boolean;
  120397. /**
  120398. * Gets or sets the connection point type (default is float)
  120399. */
  120400. readonly type: NodeMaterialBlockConnectionPointTypes;
  120401. /**
  120402. * Creates a new InputBlock
  120403. * @param name defines the block name
  120404. * @param target defines the target of that block (Vertex by default)
  120405. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  120406. */
  120407. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  120408. /**
  120409. * Gets the output component
  120410. */
  120411. readonly output: NodeMaterialConnectionPoint;
  120412. /**
  120413. * Set the source of this connection point to a vertex attribute
  120414. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  120415. * @returns the current connection point
  120416. */
  120417. setAsAttribute(attributeName?: string): InputBlock;
  120418. /**
  120419. * Set the source of this connection point to a system value
  120420. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  120421. * @returns the current connection point
  120422. */
  120423. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  120424. /**
  120425. * Gets or sets the value of that point.
  120426. * Please note that this value will be ignored if valueCallback is defined
  120427. */
  120428. value: any;
  120429. /**
  120430. * Gets or sets a callback used to get the value of that point.
  120431. * Please note that setting this value will force the connection point to ignore the value property
  120432. */
  120433. valueCallback: () => any;
  120434. /**
  120435. * Gets or sets the associated variable name in the shader
  120436. */
  120437. associatedVariableName: string;
  120438. /** Gets or sets the type of animation applied to the input */
  120439. animationType: AnimatedInputBlockTypes;
  120440. /**
  120441. * Gets a boolean indicating that this connection point not defined yet
  120442. */
  120443. readonly isUndefined: boolean;
  120444. /**
  120445. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  120446. * In this case the connection point name must be the name of the uniform to use.
  120447. * Can only be set on inputs
  120448. */
  120449. isUniform: boolean;
  120450. /**
  120451. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  120452. * In this case the connection point name must be the name of the attribute to use
  120453. * Can only be set on inputs
  120454. */
  120455. isAttribute: boolean;
  120456. /**
  120457. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  120458. * Can only be set on exit points
  120459. */
  120460. isVarying: boolean;
  120461. /**
  120462. * Gets a boolean indicating that the current connection point is a system value
  120463. */
  120464. readonly isSystemValue: boolean;
  120465. /**
  120466. * Gets or sets the current well known value or null if not defined as a system value
  120467. */
  120468. systemValue: Nullable<NodeMaterialSystemValues>;
  120469. /**
  120470. * Gets the current class name
  120471. * @returns the class name
  120472. */
  120473. getClassName(): string;
  120474. /**
  120475. * Animate the input if animationType !== None
  120476. * @param scene defines the rendering scene
  120477. */
  120478. animate(scene: Scene): void;
  120479. private _emitDefine;
  120480. initialize(state: NodeMaterialBuildState): void;
  120481. /**
  120482. * Set the input block to its default value (based on its type)
  120483. */
  120484. setDefaultValue(): void;
  120485. private _emitConstant;
  120486. private _emit;
  120487. /** @hidden */
  120488. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  120489. /** @hidden */
  120490. _transmit(effect: Effect, scene: Scene): void;
  120491. protected _buildBlock(state: NodeMaterialBuildState): void;
  120492. protected _dumpPropertiesCode(): string;
  120493. serialize(): any;
  120494. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120495. }
  120496. }
  120497. declare module BABYLON {
  120498. /**
  120499. * Defines a connection point for a block
  120500. */
  120501. export class NodeMaterialConnectionPoint {
  120502. /** @hidden */
  120503. _ownerBlock: NodeMaterialBlock;
  120504. /** @hidden */
  120505. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120506. private _endpoints;
  120507. private _associatedVariableName;
  120508. /** @hidden */
  120509. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120510. /** @hidden */
  120511. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  120512. private _type;
  120513. /** @hidden */
  120514. _enforceAssociatedVariableName: boolean;
  120515. /**
  120516. * Gets or sets the additional types supported by this connection point
  120517. */
  120518. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120519. /**
  120520. * Gets or sets the additional types excluded by this connection point
  120521. */
  120522. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  120523. /**
  120524. * Gets or sets the associated variable name in the shader
  120525. */
  120526. associatedVariableName: string;
  120527. /**
  120528. * Gets or sets the connection point type (default is float)
  120529. */
  120530. type: NodeMaterialBlockConnectionPointTypes;
  120531. /**
  120532. * Gets or sets the connection point name
  120533. */
  120534. name: string;
  120535. /**
  120536. * Gets or sets a boolean indicating that this connection point can be omitted
  120537. */
  120538. isOptional: boolean;
  120539. /**
  120540. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  120541. */
  120542. define: string;
  120543. /** Gets or sets the target of that connection point */
  120544. target: NodeMaterialBlockTargets;
  120545. /**
  120546. * Gets a boolean indicating that the current point is connected
  120547. */
  120548. readonly isConnected: boolean;
  120549. /**
  120550. * Gets a boolean indicating that the current point is connected to an input block
  120551. */
  120552. readonly isConnectedToInputBlock: boolean;
  120553. /**
  120554. * Gets a the connected input block (if any)
  120555. */
  120556. readonly connectInputBlock: Nullable<InputBlock>;
  120557. /** Get the other side of the connection (if any) */
  120558. readonly connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  120559. /** Get the block that owns this connection point */
  120560. readonly ownerBlock: NodeMaterialBlock;
  120561. /** Get the block connected on the other side of this connection (if any) */
  120562. readonly sourceBlock: Nullable<NodeMaterialBlock>;
  120563. /** Get the block connected on the endpoints of this connection (if any) */
  120564. readonly connectedBlocks: Array<NodeMaterialBlock>;
  120565. /** Gets the list of connected endpoints */
  120566. readonly endpoints: NodeMaterialConnectionPoint[];
  120567. /** Gets a boolean indicating if that output point is connected to at least one input */
  120568. readonly hasEndpoints: boolean;
  120569. /**
  120570. * Creates a new connection point
  120571. * @param name defines the connection point name
  120572. * @param ownerBlock defines the block hosting this connection point
  120573. */
  120574. constructor(name: string, ownerBlock: NodeMaterialBlock);
  120575. /**
  120576. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  120577. * @returns the class name
  120578. */
  120579. getClassName(): string;
  120580. /**
  120581. * Gets an boolean indicating if the current point can be connected to another point
  120582. * @param connectionPoint defines the other connection point
  120583. * @returns true if the connection is possible
  120584. */
  120585. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  120586. /**
  120587. * Connect this point to another connection point
  120588. * @param connectionPoint defines the other connection point
  120589. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  120590. * @returns the current connection point
  120591. */
  120592. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  120593. /**
  120594. * Disconnect this point from one of his endpoint
  120595. * @param endpoint defines the other connection point
  120596. * @returns the current connection point
  120597. */
  120598. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  120599. /**
  120600. * Serializes this point in a JSON representation
  120601. * @returns the serialized point object
  120602. */
  120603. serialize(): any;
  120604. }
  120605. }
  120606. declare module BABYLON {
  120607. /**
  120608. * Block used to add support for vertex skinning (bones)
  120609. */
  120610. export class BonesBlock extends NodeMaterialBlock {
  120611. /**
  120612. * Creates a new BonesBlock
  120613. * @param name defines the block name
  120614. */
  120615. constructor(name: string);
  120616. /**
  120617. * Initialize the block and prepare the context for build
  120618. * @param state defines the state that will be used for the build
  120619. */
  120620. initialize(state: NodeMaterialBuildState): void;
  120621. /**
  120622. * Gets the current class name
  120623. * @returns the class name
  120624. */
  120625. getClassName(): string;
  120626. /**
  120627. * Gets the matrix indices input component
  120628. */
  120629. readonly matricesIndices: NodeMaterialConnectionPoint;
  120630. /**
  120631. * Gets the matrix weights input component
  120632. */
  120633. readonly matricesWeights: NodeMaterialConnectionPoint;
  120634. /**
  120635. * Gets the extra matrix indices input component
  120636. */
  120637. readonly matricesIndicesExtra: NodeMaterialConnectionPoint;
  120638. /**
  120639. * Gets the extra matrix weights input component
  120640. */
  120641. readonly matricesWeightsExtra: NodeMaterialConnectionPoint;
  120642. /**
  120643. * Gets the world input component
  120644. */
  120645. readonly world: NodeMaterialConnectionPoint;
  120646. /**
  120647. * Gets the output component
  120648. */
  120649. readonly output: NodeMaterialConnectionPoint;
  120650. autoConfigure(material: NodeMaterial): void;
  120651. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  120652. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120653. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120654. protected _buildBlock(state: NodeMaterialBuildState): this;
  120655. }
  120656. }
  120657. declare module BABYLON {
  120658. /**
  120659. * Block used to add support for instances
  120660. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  120661. */
  120662. export class InstancesBlock extends NodeMaterialBlock {
  120663. /**
  120664. * Creates a new InstancesBlock
  120665. * @param name defines the block name
  120666. */
  120667. constructor(name: string);
  120668. /**
  120669. * Gets the current class name
  120670. * @returns the class name
  120671. */
  120672. getClassName(): string;
  120673. /**
  120674. * Gets the first world row input component
  120675. */
  120676. readonly world0: NodeMaterialConnectionPoint;
  120677. /**
  120678. * Gets the second world row input component
  120679. */
  120680. readonly world1: NodeMaterialConnectionPoint;
  120681. /**
  120682. * Gets the third world row input component
  120683. */
  120684. readonly world2: NodeMaterialConnectionPoint;
  120685. /**
  120686. * Gets the forth world row input component
  120687. */
  120688. readonly world3: NodeMaterialConnectionPoint;
  120689. /**
  120690. * Gets the world input component
  120691. */
  120692. readonly world: NodeMaterialConnectionPoint;
  120693. /**
  120694. * Gets the output component
  120695. */
  120696. readonly output: NodeMaterialConnectionPoint;
  120697. autoConfigure(material: NodeMaterial): void;
  120698. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  120699. protected _buildBlock(state: NodeMaterialBuildState): this;
  120700. }
  120701. }
  120702. declare module BABYLON {
  120703. /**
  120704. * Block used to add morph targets support to vertex shader
  120705. */
  120706. export class MorphTargetsBlock extends NodeMaterialBlock {
  120707. private _repeatableContentAnchor;
  120708. private _repeatebleContentGenerated;
  120709. /**
  120710. * Create a new MorphTargetsBlock
  120711. * @param name defines the block name
  120712. */
  120713. constructor(name: string);
  120714. /**
  120715. * Gets the current class name
  120716. * @returns the class name
  120717. */
  120718. getClassName(): string;
  120719. /**
  120720. * Gets the position input component
  120721. */
  120722. readonly position: NodeMaterialConnectionPoint;
  120723. /**
  120724. * Gets the normal input component
  120725. */
  120726. readonly normal: NodeMaterialConnectionPoint;
  120727. /**
  120728. * Gets the tangent input component
  120729. */
  120730. readonly tangent: NodeMaterialConnectionPoint;
  120731. /**
  120732. * Gets the tangent input component
  120733. */
  120734. readonly uv: NodeMaterialConnectionPoint;
  120735. /**
  120736. * Gets the position output component
  120737. */
  120738. readonly positionOutput: NodeMaterialConnectionPoint;
  120739. /**
  120740. * Gets the normal output component
  120741. */
  120742. readonly normalOutput: NodeMaterialConnectionPoint;
  120743. /**
  120744. * Gets the tangent output component
  120745. */
  120746. readonly tangentOutput: NodeMaterialConnectionPoint;
  120747. /**
  120748. * Gets the tangent output component
  120749. */
  120750. readonly uvOutput: NodeMaterialConnectionPoint;
  120751. initialize(state: NodeMaterialBuildState): void;
  120752. autoConfigure(material: NodeMaterial): void;
  120753. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120755. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  120756. protected _buildBlock(state: NodeMaterialBuildState): this;
  120757. }
  120758. }
  120759. declare module BABYLON {
  120760. /**
  120761. * Block used to get data information from a light
  120762. */
  120763. export class LightInformationBlock extends NodeMaterialBlock {
  120764. private _lightDataUniformName;
  120765. private _lightColorUniformName;
  120766. private _lightTypeDefineName;
  120767. /**
  120768. * Gets or sets the light associated with this block
  120769. */
  120770. light: Nullable<Light>;
  120771. /**
  120772. * Creates a new LightInformationBlock
  120773. * @param name defines the block name
  120774. */
  120775. constructor(name: string);
  120776. /**
  120777. * Gets the current class name
  120778. * @returns the class name
  120779. */
  120780. getClassName(): string;
  120781. /**
  120782. * Gets the world position input component
  120783. */
  120784. readonly worldPosition: NodeMaterialConnectionPoint;
  120785. /**
  120786. * Gets the direction output component
  120787. */
  120788. readonly direction: NodeMaterialConnectionPoint;
  120789. /**
  120790. * Gets the direction output component
  120791. */
  120792. readonly color: NodeMaterialConnectionPoint;
  120793. /**
  120794. * Gets the direction output component
  120795. */
  120796. readonly intensity: NodeMaterialConnectionPoint;
  120797. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120798. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120799. protected _buildBlock(state: NodeMaterialBuildState): this;
  120800. serialize(): any;
  120801. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120802. }
  120803. }
  120804. declare module BABYLON {
  120805. /**
  120806. * Block used to add image processing support to fragment shader
  120807. */
  120808. export class ImageProcessingBlock extends NodeMaterialBlock {
  120809. /**
  120810. * Create a new ImageProcessingBlock
  120811. * @param name defines the block name
  120812. */
  120813. constructor(name: string);
  120814. /**
  120815. * Gets the current class name
  120816. * @returns the class name
  120817. */
  120818. getClassName(): string;
  120819. /**
  120820. * Gets the color input component
  120821. */
  120822. readonly color: NodeMaterialConnectionPoint;
  120823. /**
  120824. * Gets the output component
  120825. */
  120826. readonly output: NodeMaterialConnectionPoint;
  120827. /**
  120828. * Initialize the block and prepare the context for build
  120829. * @param state defines the state that will be used for the build
  120830. */
  120831. initialize(state: NodeMaterialBuildState): void;
  120832. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  120833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120834. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120835. protected _buildBlock(state: NodeMaterialBuildState): this;
  120836. }
  120837. }
  120838. declare module BABYLON {
  120839. /**
  120840. * Block used to pertub normals based on a normal map
  120841. */
  120842. export class PerturbNormalBlock extends NodeMaterialBlock {
  120843. private _tangentSpaceParameterName;
  120844. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  120845. invertX: boolean;
  120846. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  120847. invertY: boolean;
  120848. /**
  120849. * Create a new PerturbNormalBlock
  120850. * @param name defines the block name
  120851. */
  120852. constructor(name: string);
  120853. /**
  120854. * Gets the current class name
  120855. * @returns the class name
  120856. */
  120857. getClassName(): string;
  120858. /**
  120859. * Gets the world position input component
  120860. */
  120861. readonly worldPosition: NodeMaterialConnectionPoint;
  120862. /**
  120863. * Gets the world normal input component
  120864. */
  120865. readonly worldNormal: NodeMaterialConnectionPoint;
  120866. /**
  120867. * Gets the uv input component
  120868. */
  120869. readonly uv: NodeMaterialConnectionPoint;
  120870. /**
  120871. * Gets the normal map color input component
  120872. */
  120873. readonly normalMapColor: NodeMaterialConnectionPoint;
  120874. /**
  120875. * Gets the strength input component
  120876. */
  120877. readonly strength: NodeMaterialConnectionPoint;
  120878. /**
  120879. * Gets the output component
  120880. */
  120881. readonly output: NodeMaterialConnectionPoint;
  120882. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120883. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120884. autoConfigure(material: NodeMaterial): void;
  120885. protected _buildBlock(state: NodeMaterialBuildState): this;
  120886. protected _dumpPropertiesCode(): string;
  120887. serialize(): any;
  120888. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  120889. }
  120890. }
  120891. declare module BABYLON {
  120892. /**
  120893. * Block used to discard a pixel if a value is smaller than a cutoff
  120894. */
  120895. export class DiscardBlock extends NodeMaterialBlock {
  120896. /**
  120897. * Create a new DiscardBlock
  120898. * @param name defines the block name
  120899. */
  120900. constructor(name: string);
  120901. /**
  120902. * Gets the current class name
  120903. * @returns the class name
  120904. */
  120905. getClassName(): string;
  120906. /**
  120907. * Gets the color input component
  120908. */
  120909. readonly value: NodeMaterialConnectionPoint;
  120910. /**
  120911. * Gets the cutoff input component
  120912. */
  120913. readonly cutoff: NodeMaterialConnectionPoint;
  120914. protected _buildBlock(state: NodeMaterialBuildState): this;
  120915. }
  120916. }
  120917. declare module BABYLON {
  120918. /**
  120919. * Block used to add support for scene fog
  120920. */
  120921. export class FogBlock extends NodeMaterialBlock {
  120922. private _fogDistanceName;
  120923. private _fogParameters;
  120924. /**
  120925. * Create a new FogBlock
  120926. * @param name defines the block name
  120927. */
  120928. constructor(name: string);
  120929. /**
  120930. * Gets the current class name
  120931. * @returns the class name
  120932. */
  120933. getClassName(): string;
  120934. /**
  120935. * Gets the world position input component
  120936. */
  120937. readonly worldPosition: NodeMaterialConnectionPoint;
  120938. /**
  120939. * Gets the view input component
  120940. */
  120941. readonly view: NodeMaterialConnectionPoint;
  120942. /**
  120943. * Gets the color input component
  120944. */
  120945. readonly input: NodeMaterialConnectionPoint;
  120946. /**
  120947. * Gets the fog color input component
  120948. */
  120949. readonly fogColor: NodeMaterialConnectionPoint;
  120950. /**
  120951. * Gets the output component
  120952. */
  120953. readonly output: NodeMaterialConnectionPoint;
  120954. autoConfigure(material: NodeMaterial): void;
  120955. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  120956. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  120957. protected _buildBlock(state: NodeMaterialBuildState): this;
  120958. }
  120959. }
  120960. declare module BABYLON {
  120961. /**
  120962. * Block used to add light in the fragment shader
  120963. */
  120964. export class LightBlock extends NodeMaterialBlock {
  120965. private _lightId;
  120966. /**
  120967. * Gets or sets the light associated with this block
  120968. */
  120969. light: Nullable<Light>;
  120970. /**
  120971. * Create a new LightBlock
  120972. * @param name defines the block name
  120973. */
  120974. constructor(name: string);
  120975. /**
  120976. * Gets the current class name
  120977. * @returns the class name
  120978. */
  120979. getClassName(): string;
  120980. /**
  120981. * Gets the world position input component
  120982. */
  120983. readonly worldPosition: NodeMaterialConnectionPoint;
  120984. /**
  120985. * Gets the world normal input component
  120986. */
  120987. readonly worldNormal: NodeMaterialConnectionPoint;
  120988. /**
  120989. * Gets the camera (or eye) position component
  120990. */
  120991. readonly cameraPosition: NodeMaterialConnectionPoint;
  120992. /**
  120993. * Gets the glossiness component
  120994. */
  120995. readonly glossiness: NodeMaterialConnectionPoint;
  120996. /**
  120997. * Gets the glossinness power component
  120998. */
  120999. readonly glossPower: NodeMaterialConnectionPoint;
  121000. /**
  121001. * Gets the diffuse color component
  121002. */
  121003. readonly diffuseColor: NodeMaterialConnectionPoint;
  121004. /**
  121005. * Gets the specular color component
  121006. */
  121007. readonly specularColor: NodeMaterialConnectionPoint;
  121008. /**
  121009. * Gets the diffuse output component
  121010. */
  121011. readonly diffuseOutput: NodeMaterialConnectionPoint;
  121012. /**
  121013. * Gets the specular output component
  121014. */
  121015. readonly specularOutput: NodeMaterialConnectionPoint;
  121016. autoConfigure(material: NodeMaterial): void;
  121017. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121018. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  121019. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  121020. private _injectVertexCode;
  121021. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121022. serialize(): any;
  121023. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121024. }
  121025. }
  121026. declare module BABYLON {
  121027. /**
  121028. * Block used to multiply 2 values
  121029. */
  121030. export class MultiplyBlock extends NodeMaterialBlock {
  121031. /**
  121032. * Creates a new MultiplyBlock
  121033. * @param name defines the block name
  121034. */
  121035. constructor(name: string);
  121036. /**
  121037. * Gets the current class name
  121038. * @returns the class name
  121039. */
  121040. getClassName(): string;
  121041. /**
  121042. * Gets the left operand input component
  121043. */
  121044. readonly left: NodeMaterialConnectionPoint;
  121045. /**
  121046. * Gets the right operand input component
  121047. */
  121048. readonly right: NodeMaterialConnectionPoint;
  121049. /**
  121050. * Gets the output component
  121051. */
  121052. readonly output: NodeMaterialConnectionPoint;
  121053. protected _buildBlock(state: NodeMaterialBuildState): this;
  121054. }
  121055. }
  121056. declare module BABYLON {
  121057. /**
  121058. * Block used to add 2 vectors
  121059. */
  121060. export class AddBlock extends NodeMaterialBlock {
  121061. /**
  121062. * Creates a new AddBlock
  121063. * @param name defines the block name
  121064. */
  121065. constructor(name: string);
  121066. /**
  121067. * Gets the current class name
  121068. * @returns the class name
  121069. */
  121070. getClassName(): string;
  121071. /**
  121072. * Gets the left operand input component
  121073. */
  121074. readonly left: NodeMaterialConnectionPoint;
  121075. /**
  121076. * Gets the right operand input component
  121077. */
  121078. readonly right: NodeMaterialConnectionPoint;
  121079. /**
  121080. * Gets the output component
  121081. */
  121082. readonly output: NodeMaterialConnectionPoint;
  121083. protected _buildBlock(state: NodeMaterialBuildState): this;
  121084. }
  121085. }
  121086. declare module BABYLON {
  121087. /**
  121088. * Block used to scale a vector by a float
  121089. */
  121090. export class ScaleBlock extends NodeMaterialBlock {
  121091. /**
  121092. * Creates a new ScaleBlock
  121093. * @param name defines the block name
  121094. */
  121095. constructor(name: string);
  121096. /**
  121097. * Gets the current class name
  121098. * @returns the class name
  121099. */
  121100. getClassName(): string;
  121101. /**
  121102. * Gets the input component
  121103. */
  121104. readonly input: NodeMaterialConnectionPoint;
  121105. /**
  121106. * Gets the factor input component
  121107. */
  121108. readonly factor: NodeMaterialConnectionPoint;
  121109. /**
  121110. * Gets the output component
  121111. */
  121112. readonly output: NodeMaterialConnectionPoint;
  121113. protected _buildBlock(state: NodeMaterialBuildState): this;
  121114. }
  121115. }
  121116. declare module BABYLON {
  121117. /**
  121118. * Block used to clamp a float
  121119. */
  121120. export class ClampBlock extends NodeMaterialBlock {
  121121. /** Gets or sets the minimum range */
  121122. minimum: number;
  121123. /** Gets or sets the maximum range */
  121124. maximum: number;
  121125. /**
  121126. * Creates a new ClampBlock
  121127. * @param name defines the block name
  121128. */
  121129. constructor(name: string);
  121130. /**
  121131. * Gets the current class name
  121132. * @returns the class name
  121133. */
  121134. getClassName(): string;
  121135. /**
  121136. * Gets the value input component
  121137. */
  121138. readonly value: NodeMaterialConnectionPoint;
  121139. /**
  121140. * Gets the output component
  121141. */
  121142. readonly output: NodeMaterialConnectionPoint;
  121143. protected _buildBlock(state: NodeMaterialBuildState): this;
  121144. protected _dumpPropertiesCode(): string;
  121145. serialize(): any;
  121146. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121147. }
  121148. }
  121149. declare module BABYLON {
  121150. /**
  121151. * Block used to apply a cross product between 2 vectors
  121152. */
  121153. export class CrossBlock extends NodeMaterialBlock {
  121154. /**
  121155. * Creates a new CrossBlock
  121156. * @param name defines the block name
  121157. */
  121158. constructor(name: string);
  121159. /**
  121160. * Gets the current class name
  121161. * @returns the class name
  121162. */
  121163. getClassName(): string;
  121164. /**
  121165. * Gets the left operand input component
  121166. */
  121167. readonly left: NodeMaterialConnectionPoint;
  121168. /**
  121169. * Gets the right operand input component
  121170. */
  121171. readonly right: NodeMaterialConnectionPoint;
  121172. /**
  121173. * Gets the output component
  121174. */
  121175. readonly output: NodeMaterialConnectionPoint;
  121176. protected _buildBlock(state: NodeMaterialBuildState): this;
  121177. }
  121178. }
  121179. declare module BABYLON {
  121180. /**
  121181. * Block used to apply a dot product between 2 vectors
  121182. */
  121183. export class DotBlock extends NodeMaterialBlock {
  121184. /**
  121185. * Creates a new DotBlock
  121186. * @param name defines the block name
  121187. */
  121188. constructor(name: string);
  121189. /**
  121190. * Gets the current class name
  121191. * @returns the class name
  121192. */
  121193. getClassName(): string;
  121194. /**
  121195. * Gets the left operand input component
  121196. */
  121197. readonly left: NodeMaterialConnectionPoint;
  121198. /**
  121199. * Gets the right operand input component
  121200. */
  121201. readonly right: NodeMaterialConnectionPoint;
  121202. /**
  121203. * Gets the output component
  121204. */
  121205. readonly output: NodeMaterialConnectionPoint;
  121206. protected _buildBlock(state: NodeMaterialBuildState): this;
  121207. }
  121208. }
  121209. declare module BABYLON {
  121210. /**
  121211. * Block used to remap a float from a range to a new one
  121212. */
  121213. export class RemapBlock extends NodeMaterialBlock {
  121214. /**
  121215. * Gets or sets the source range
  121216. */
  121217. sourceRange: Vector2;
  121218. /**
  121219. * Gets or sets the target range
  121220. */
  121221. targetRange: Vector2;
  121222. /**
  121223. * Creates a new RemapBlock
  121224. * @param name defines the block name
  121225. */
  121226. constructor(name: string);
  121227. /**
  121228. * Gets the current class name
  121229. * @returns the class name
  121230. */
  121231. getClassName(): string;
  121232. /**
  121233. * Gets the input component
  121234. */
  121235. readonly input: NodeMaterialConnectionPoint;
  121236. /**
  121237. * Gets the source min input component
  121238. */
  121239. readonly sourceMin: NodeMaterialConnectionPoint;
  121240. /**
  121241. * Gets the source max input component
  121242. */
  121243. readonly sourceMax: NodeMaterialConnectionPoint;
  121244. /**
  121245. * Gets the target min input component
  121246. */
  121247. readonly targetMin: NodeMaterialConnectionPoint;
  121248. /**
  121249. * Gets the target max input component
  121250. */
  121251. readonly targetMax: NodeMaterialConnectionPoint;
  121252. /**
  121253. * Gets the output component
  121254. */
  121255. readonly output: NodeMaterialConnectionPoint;
  121256. protected _buildBlock(state: NodeMaterialBuildState): this;
  121257. protected _dumpPropertiesCode(): string;
  121258. serialize(): any;
  121259. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121260. }
  121261. }
  121262. declare module BABYLON {
  121263. /**
  121264. * Block used to normalize a vector
  121265. */
  121266. export class NormalizeBlock extends NodeMaterialBlock {
  121267. /**
  121268. * Creates a new NormalizeBlock
  121269. * @param name defines the block name
  121270. */
  121271. constructor(name: string);
  121272. /**
  121273. * Gets the current class name
  121274. * @returns the class name
  121275. */
  121276. getClassName(): string;
  121277. /**
  121278. * Gets the input component
  121279. */
  121280. readonly input: NodeMaterialConnectionPoint;
  121281. /**
  121282. * Gets the output component
  121283. */
  121284. readonly output: NodeMaterialConnectionPoint;
  121285. protected _buildBlock(state: NodeMaterialBuildState): this;
  121286. }
  121287. }
  121288. declare module BABYLON {
  121289. /**
  121290. * Operations supported by the Trigonometry block
  121291. */
  121292. export enum TrigonometryBlockOperations {
  121293. /** Cos */
  121294. Cos = 0,
  121295. /** Sin */
  121296. Sin = 1,
  121297. /** Abs */
  121298. Abs = 2,
  121299. /** Exp */
  121300. Exp = 3,
  121301. /** Exp2 */
  121302. Exp2 = 4,
  121303. /** Round */
  121304. Round = 5,
  121305. /** Floor */
  121306. Floor = 6,
  121307. /** Ceiling */
  121308. Ceiling = 7,
  121309. /** Square root */
  121310. Sqrt = 8,
  121311. /** Log */
  121312. Log = 9,
  121313. /** Tangent */
  121314. Tan = 10,
  121315. /** Arc tangent */
  121316. ArcTan = 11,
  121317. /** Arc cosinus */
  121318. ArcCos = 12,
  121319. /** Arc sinus */
  121320. ArcSin = 13,
  121321. /** Fraction */
  121322. Fract = 14,
  121323. /** Sign */
  121324. Sign = 15,
  121325. /** To radians (from degrees) */
  121326. Radians = 16,
  121327. /** To degrees (from radians) */
  121328. Degrees = 17
  121329. }
  121330. /**
  121331. * Block used to apply trigonometry operation to floats
  121332. */
  121333. export class TrigonometryBlock extends NodeMaterialBlock {
  121334. /**
  121335. * Gets or sets the operation applied by the block
  121336. */
  121337. operation: TrigonometryBlockOperations;
  121338. /**
  121339. * Creates a new TrigonometryBlock
  121340. * @param name defines the block name
  121341. */
  121342. constructor(name: string);
  121343. /**
  121344. * Gets the current class name
  121345. * @returns the class name
  121346. */
  121347. getClassName(): string;
  121348. /**
  121349. * Gets the input component
  121350. */
  121351. readonly input: NodeMaterialConnectionPoint;
  121352. /**
  121353. * Gets the output component
  121354. */
  121355. readonly output: NodeMaterialConnectionPoint;
  121356. protected _buildBlock(state: NodeMaterialBuildState): this;
  121357. serialize(): any;
  121358. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  121359. }
  121360. }
  121361. declare module BABYLON {
  121362. /**
  121363. * Block used to create a Color3/4 out of individual inputs (one for each component)
  121364. */
  121365. export class ColorMergerBlock extends NodeMaterialBlock {
  121366. /**
  121367. * Create a new ColorMergerBlock
  121368. * @param name defines the block name
  121369. */
  121370. constructor(name: string);
  121371. /**
  121372. * Gets the current class name
  121373. * @returns the class name
  121374. */
  121375. getClassName(): string;
  121376. /**
  121377. * Gets the r component (input)
  121378. */
  121379. readonly r: NodeMaterialConnectionPoint;
  121380. /**
  121381. * Gets the g component (input)
  121382. */
  121383. readonly g: NodeMaterialConnectionPoint;
  121384. /**
  121385. * Gets the b component (input)
  121386. */
  121387. readonly b: NodeMaterialConnectionPoint;
  121388. /**
  121389. * Gets the a component (input)
  121390. */
  121391. readonly a: NodeMaterialConnectionPoint;
  121392. /**
  121393. * Gets the rgba component (output)
  121394. */
  121395. readonly rgba: NodeMaterialConnectionPoint;
  121396. /**
  121397. * Gets the rgb component (output)
  121398. */
  121399. readonly rgb: NodeMaterialConnectionPoint;
  121400. protected _buildBlock(state: NodeMaterialBuildState): this;
  121401. }
  121402. }
  121403. declare module BABYLON {
  121404. /**
  121405. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  121406. */
  121407. export class VectorMergerBlock extends NodeMaterialBlock {
  121408. /**
  121409. * Create a new VectorMergerBlock
  121410. * @param name defines the block name
  121411. */
  121412. constructor(name: string);
  121413. /**
  121414. * Gets the current class name
  121415. * @returns the class name
  121416. */
  121417. getClassName(): string;
  121418. /**
  121419. * Gets the x component (input)
  121420. */
  121421. readonly x: NodeMaterialConnectionPoint;
  121422. /**
  121423. * Gets the y component (input)
  121424. */
  121425. readonly y: NodeMaterialConnectionPoint;
  121426. /**
  121427. * Gets the z component (input)
  121428. */
  121429. readonly z: NodeMaterialConnectionPoint;
  121430. /**
  121431. * Gets the w component (input)
  121432. */
  121433. readonly w: NodeMaterialConnectionPoint;
  121434. /**
  121435. * Gets the xyzw component (output)
  121436. */
  121437. readonly xyzw: NodeMaterialConnectionPoint;
  121438. /**
  121439. * Gets the xyz component (output)
  121440. */
  121441. readonly xyz: NodeMaterialConnectionPoint;
  121442. /**
  121443. * Gets the xy component (output)
  121444. */
  121445. readonly xy: NodeMaterialConnectionPoint;
  121446. protected _buildBlock(state: NodeMaterialBuildState): this;
  121447. }
  121448. }
  121449. declare module BABYLON {
  121450. /**
  121451. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  121452. */
  121453. export class ColorSplitterBlock extends NodeMaterialBlock {
  121454. /**
  121455. * Create a new ColorSplitterBlock
  121456. * @param name defines the block name
  121457. */
  121458. constructor(name: string);
  121459. /**
  121460. * Gets the current class name
  121461. * @returns the class name
  121462. */
  121463. getClassName(): string;
  121464. /**
  121465. * Gets the rgba component (input)
  121466. */
  121467. readonly rgba: NodeMaterialConnectionPoint;
  121468. /**
  121469. * Gets the rgb component (input)
  121470. */
  121471. readonly rgbIn: NodeMaterialConnectionPoint;
  121472. /**
  121473. * Gets the rgb component (output)
  121474. */
  121475. readonly rgbOut: NodeMaterialConnectionPoint;
  121476. /**
  121477. * Gets the r component (output)
  121478. */
  121479. readonly r: NodeMaterialConnectionPoint;
  121480. /**
  121481. * Gets the g component (output)
  121482. */
  121483. readonly g: NodeMaterialConnectionPoint;
  121484. /**
  121485. * Gets the b component (output)
  121486. */
  121487. readonly b: NodeMaterialConnectionPoint;
  121488. /**
  121489. * Gets the a component (output)
  121490. */
  121491. readonly a: NodeMaterialConnectionPoint;
  121492. protected _inputRename(name: string): string;
  121493. protected _outputRename(name: string): string;
  121494. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  121495. }
  121496. }
  121497. declare module BABYLON {
  121498. /**
  121499. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  121500. */
  121501. export class VectorSplitterBlock extends NodeMaterialBlock {
  121502. /**
  121503. * Create a new VectorSplitterBlock
  121504. * @param name defines the block name
  121505. */
  121506. constructor(name: string);
  121507. /**
  121508. * Gets the current class name
  121509. * @returns the class name
  121510. */
  121511. getClassName(): string;
  121512. /**
  121513. * Gets the xyzw component (input)
  121514. */
  121515. readonly xyzw: NodeMaterialConnectionPoint;
  121516. /**
  121517. * Gets the xyz component (input)
  121518. */
  121519. readonly xyzIn: NodeMaterialConnectionPoint;
  121520. /**
  121521. * Gets the xy component (input)
  121522. */
  121523. readonly xyIn: NodeMaterialConnectionPoint;
  121524. /**
  121525. * Gets the xyz component (output)
  121526. */
  121527. readonly xyzOut: NodeMaterialConnectionPoint;
  121528. /**
  121529. * Gets the xy component (output)
  121530. */
  121531. readonly xyOut: NodeMaterialConnectionPoint;
  121532. /**
  121533. * Gets the x component (output)
  121534. */
  121535. readonly x: NodeMaterialConnectionPoint;
  121536. /**
  121537. * Gets the y component (output)
  121538. */
  121539. readonly y: NodeMaterialConnectionPoint;
  121540. /**
  121541. * Gets the z component (output)
  121542. */
  121543. readonly z: NodeMaterialConnectionPoint;
  121544. /**
  121545. * Gets the w component (output)
  121546. */
  121547. readonly w: NodeMaterialConnectionPoint;
  121548. protected _inputRename(name: string): string;
  121549. protected _outputRename(name: string): string;
  121550. protected _buildBlock(state: NodeMaterialBuildState): this;
  121551. }
  121552. }
  121553. declare module BABYLON {
  121554. /**
  121555. * Block used to lerp between 2 values
  121556. */
  121557. export class LerpBlock extends NodeMaterialBlock {
  121558. /**
  121559. * Creates a new LerpBlock
  121560. * @param name defines the block name
  121561. */
  121562. constructor(name: string);
  121563. /**
  121564. * Gets the current class name
  121565. * @returns the class name
  121566. */
  121567. getClassName(): string;
  121568. /**
  121569. * Gets the left operand input component
  121570. */
  121571. readonly left: NodeMaterialConnectionPoint;
  121572. /**
  121573. * Gets the right operand input component
  121574. */
  121575. readonly right: NodeMaterialConnectionPoint;
  121576. /**
  121577. * Gets the gradient operand input component
  121578. */
  121579. readonly gradient: NodeMaterialConnectionPoint;
  121580. /**
  121581. * Gets the output component
  121582. */
  121583. readonly output: NodeMaterialConnectionPoint;
  121584. protected _buildBlock(state: NodeMaterialBuildState): this;
  121585. }
  121586. }
  121587. declare module BABYLON {
  121588. /**
  121589. * Block used to divide 2 vectors
  121590. */
  121591. export class DivideBlock extends NodeMaterialBlock {
  121592. /**
  121593. * Creates a new DivideBlock
  121594. * @param name defines the block name
  121595. */
  121596. constructor(name: string);
  121597. /**
  121598. * Gets the current class name
  121599. * @returns the class name
  121600. */
  121601. getClassName(): string;
  121602. /**
  121603. * Gets the left operand input component
  121604. */
  121605. readonly left: NodeMaterialConnectionPoint;
  121606. /**
  121607. * Gets the right operand input component
  121608. */
  121609. readonly right: NodeMaterialConnectionPoint;
  121610. /**
  121611. * Gets the output component
  121612. */
  121613. readonly output: NodeMaterialConnectionPoint;
  121614. protected _buildBlock(state: NodeMaterialBuildState): this;
  121615. }
  121616. }
  121617. declare module BABYLON {
  121618. /**
  121619. * Block used to subtract 2 vectors
  121620. */
  121621. export class SubtractBlock extends NodeMaterialBlock {
  121622. /**
  121623. * Creates a new SubtractBlock
  121624. * @param name defines the block name
  121625. */
  121626. constructor(name: string);
  121627. /**
  121628. * Gets the current class name
  121629. * @returns the class name
  121630. */
  121631. getClassName(): string;
  121632. /**
  121633. * Gets the left operand input component
  121634. */
  121635. readonly left: NodeMaterialConnectionPoint;
  121636. /**
  121637. * Gets the right operand input component
  121638. */
  121639. readonly right: NodeMaterialConnectionPoint;
  121640. /**
  121641. * Gets the output component
  121642. */
  121643. readonly output: NodeMaterialConnectionPoint;
  121644. protected _buildBlock(state: NodeMaterialBuildState): this;
  121645. }
  121646. }
  121647. declare module BABYLON {
  121648. /**
  121649. * Block used to step a value
  121650. */
  121651. export class StepBlock extends NodeMaterialBlock {
  121652. /**
  121653. * Creates a new StepBlock
  121654. * @param name defines the block name
  121655. */
  121656. constructor(name: string);
  121657. /**
  121658. * Gets the current class name
  121659. * @returns the class name
  121660. */
  121661. getClassName(): string;
  121662. /**
  121663. * Gets the value operand input component
  121664. */
  121665. readonly value: NodeMaterialConnectionPoint;
  121666. /**
  121667. * Gets the edge operand input component
  121668. */
  121669. readonly edge: NodeMaterialConnectionPoint;
  121670. /**
  121671. * Gets the output component
  121672. */
  121673. readonly output: NodeMaterialConnectionPoint;
  121674. protected _buildBlock(state: NodeMaterialBuildState): this;
  121675. }
  121676. }
  121677. declare module BABYLON {
  121678. /**
  121679. * Block used to get the opposite (1 - x) of a value
  121680. */
  121681. export class OneMinusBlock extends NodeMaterialBlock {
  121682. /**
  121683. * Creates a new OneMinusBlock
  121684. * @param name defines the block name
  121685. */
  121686. constructor(name: string);
  121687. /**
  121688. * Gets the current class name
  121689. * @returns the class name
  121690. */
  121691. getClassName(): string;
  121692. /**
  121693. * Gets the input component
  121694. */
  121695. readonly input: NodeMaterialConnectionPoint;
  121696. /**
  121697. * Gets the output component
  121698. */
  121699. readonly output: NodeMaterialConnectionPoint;
  121700. protected _buildBlock(state: NodeMaterialBuildState): this;
  121701. }
  121702. }
  121703. declare module BABYLON {
  121704. /**
  121705. * Block used to get the view direction
  121706. */
  121707. export class ViewDirectionBlock extends NodeMaterialBlock {
  121708. /**
  121709. * Creates a new ViewDirectionBlock
  121710. * @param name defines the block name
  121711. */
  121712. constructor(name: string);
  121713. /**
  121714. * Gets the current class name
  121715. * @returns the class name
  121716. */
  121717. getClassName(): string;
  121718. /**
  121719. * Gets the world position component
  121720. */
  121721. readonly worldPosition: NodeMaterialConnectionPoint;
  121722. /**
  121723. * Gets the camera position component
  121724. */
  121725. readonly cameraPosition: NodeMaterialConnectionPoint;
  121726. /**
  121727. * Gets the output component
  121728. */
  121729. readonly output: NodeMaterialConnectionPoint;
  121730. autoConfigure(material: NodeMaterial): void;
  121731. protected _buildBlock(state: NodeMaterialBuildState): this;
  121732. }
  121733. }
  121734. declare module BABYLON {
  121735. /**
  121736. * Block used to compute fresnel value
  121737. */
  121738. export class FresnelBlock extends NodeMaterialBlock {
  121739. /**
  121740. * Create a new FresnelBlock
  121741. * @param name defines the block name
  121742. */
  121743. constructor(name: string);
  121744. /**
  121745. * Gets the current class name
  121746. * @returns the class name
  121747. */
  121748. getClassName(): string;
  121749. /**
  121750. * Gets the world normal input component
  121751. */
  121752. readonly worldNormal: NodeMaterialConnectionPoint;
  121753. /**
  121754. * Gets the view direction input component
  121755. */
  121756. readonly viewDirection: NodeMaterialConnectionPoint;
  121757. /**
  121758. * Gets the bias input component
  121759. */
  121760. readonly bias: NodeMaterialConnectionPoint;
  121761. /**
  121762. * Gets the camera (or eye) position component
  121763. */
  121764. readonly power: NodeMaterialConnectionPoint;
  121765. /**
  121766. * Gets the fresnel output component
  121767. */
  121768. readonly fresnel: NodeMaterialConnectionPoint;
  121769. autoConfigure(material: NodeMaterial): void;
  121770. protected _buildBlock(state: NodeMaterialBuildState): this;
  121771. }
  121772. }
  121773. declare module BABYLON {
  121774. /**
  121775. * Block used to get the max of 2 values
  121776. */
  121777. export class MaxBlock extends NodeMaterialBlock {
  121778. /**
  121779. * Creates a new MaxBlock
  121780. * @param name defines the block name
  121781. */
  121782. constructor(name: string);
  121783. /**
  121784. * Gets the current class name
  121785. * @returns the class name
  121786. */
  121787. getClassName(): string;
  121788. /**
  121789. * Gets the left operand input component
  121790. */
  121791. readonly left: NodeMaterialConnectionPoint;
  121792. /**
  121793. * Gets the right operand input component
  121794. */
  121795. readonly right: NodeMaterialConnectionPoint;
  121796. /**
  121797. * Gets the output component
  121798. */
  121799. readonly output: NodeMaterialConnectionPoint;
  121800. protected _buildBlock(state: NodeMaterialBuildState): this;
  121801. }
  121802. }
  121803. declare module BABYLON {
  121804. /**
  121805. * Block used to get the min of 2 values
  121806. */
  121807. export class MinBlock extends NodeMaterialBlock {
  121808. /**
  121809. * Creates a new MinBlock
  121810. * @param name defines the block name
  121811. */
  121812. constructor(name: string);
  121813. /**
  121814. * Gets the current class name
  121815. * @returns the class name
  121816. */
  121817. getClassName(): string;
  121818. /**
  121819. * Gets the left operand input component
  121820. */
  121821. readonly left: NodeMaterialConnectionPoint;
  121822. /**
  121823. * Gets the right operand input component
  121824. */
  121825. readonly right: NodeMaterialConnectionPoint;
  121826. /**
  121827. * Gets the output component
  121828. */
  121829. readonly output: NodeMaterialConnectionPoint;
  121830. protected _buildBlock(state: NodeMaterialBuildState): this;
  121831. }
  121832. }
  121833. declare module BABYLON {
  121834. /**
  121835. * Block used to get the distance between 2 values
  121836. */
  121837. export class DistanceBlock extends NodeMaterialBlock {
  121838. /**
  121839. * Creates a new DistanceBlock
  121840. * @param name defines the block name
  121841. */
  121842. constructor(name: string);
  121843. /**
  121844. * Gets the current class name
  121845. * @returns the class name
  121846. */
  121847. getClassName(): string;
  121848. /**
  121849. * Gets the left operand input component
  121850. */
  121851. readonly left: NodeMaterialConnectionPoint;
  121852. /**
  121853. * Gets the right operand input component
  121854. */
  121855. readonly right: NodeMaterialConnectionPoint;
  121856. /**
  121857. * Gets the output component
  121858. */
  121859. readonly output: NodeMaterialConnectionPoint;
  121860. protected _buildBlock(state: NodeMaterialBuildState): this;
  121861. }
  121862. }
  121863. declare module BABYLON {
  121864. /**
  121865. * Block used to get the length of a vector
  121866. */
  121867. export class LengthBlock extends NodeMaterialBlock {
  121868. /**
  121869. * Creates a new LengthBlock
  121870. * @param name defines the block name
  121871. */
  121872. constructor(name: string);
  121873. /**
  121874. * Gets the current class name
  121875. * @returns the class name
  121876. */
  121877. getClassName(): string;
  121878. /**
  121879. * Gets the value input component
  121880. */
  121881. readonly value: NodeMaterialConnectionPoint;
  121882. /**
  121883. * Gets the output component
  121884. */
  121885. readonly output: NodeMaterialConnectionPoint;
  121886. protected _buildBlock(state: NodeMaterialBuildState): this;
  121887. }
  121888. }
  121889. declare module BABYLON {
  121890. /**
  121891. * Block used to get negative version of a value (i.e. x * -1)
  121892. */
  121893. export class NegateBlock extends NodeMaterialBlock {
  121894. /**
  121895. * Creates a new NegateBlock
  121896. * @param name defines the block name
  121897. */
  121898. constructor(name: string);
  121899. /**
  121900. * Gets the current class name
  121901. * @returns the class name
  121902. */
  121903. getClassName(): string;
  121904. /**
  121905. * Gets the value input component
  121906. */
  121907. readonly value: NodeMaterialConnectionPoint;
  121908. /**
  121909. * Gets the output component
  121910. */
  121911. readonly output: NodeMaterialConnectionPoint;
  121912. protected _buildBlock(state: NodeMaterialBuildState): this;
  121913. }
  121914. }
  121915. declare module BABYLON {
  121916. /**
  121917. * Block used to get the value of the first parameter raised to the power of the second
  121918. */
  121919. export class PowBlock extends NodeMaterialBlock {
  121920. /**
  121921. * Creates a new PowBlock
  121922. * @param name defines the block name
  121923. */
  121924. constructor(name: string);
  121925. /**
  121926. * Gets the current class name
  121927. * @returns the class name
  121928. */
  121929. getClassName(): string;
  121930. /**
  121931. * Gets the value operand input component
  121932. */
  121933. readonly value: NodeMaterialConnectionPoint;
  121934. /**
  121935. * Gets the power operand input component
  121936. */
  121937. readonly power: NodeMaterialConnectionPoint;
  121938. /**
  121939. * Gets the output component
  121940. */
  121941. readonly output: NodeMaterialConnectionPoint;
  121942. protected _buildBlock(state: NodeMaterialBuildState): this;
  121943. }
  121944. }
  121945. declare module BABYLON {
  121946. /**
  121947. * Block used to get a random number
  121948. */
  121949. export class RandomNumberBlock extends NodeMaterialBlock {
  121950. /**
  121951. * Creates a new RandomNumberBlock
  121952. * @param name defines the block name
  121953. */
  121954. constructor(name: string);
  121955. /**
  121956. * Gets the current class name
  121957. * @returns the class name
  121958. */
  121959. getClassName(): string;
  121960. /**
  121961. * Gets the seed input component
  121962. */
  121963. readonly seed: NodeMaterialConnectionPoint;
  121964. /**
  121965. * Gets the output component
  121966. */
  121967. readonly output: NodeMaterialConnectionPoint;
  121968. protected _buildBlock(state: NodeMaterialBuildState): this;
  121969. }
  121970. }
  121971. declare module BABYLON {
  121972. /**
  121973. * Block used to compute arc tangent of 2 values
  121974. */
  121975. export class ArcTan2Block extends NodeMaterialBlock {
  121976. /**
  121977. * Creates a new ArcTan2Block
  121978. * @param name defines the block name
  121979. */
  121980. constructor(name: string);
  121981. /**
  121982. * Gets the current class name
  121983. * @returns the class name
  121984. */
  121985. getClassName(): string;
  121986. /**
  121987. * Gets the x operand input component
  121988. */
  121989. readonly x: NodeMaterialConnectionPoint;
  121990. /**
  121991. * Gets the y operand input component
  121992. */
  121993. readonly y: NodeMaterialConnectionPoint;
  121994. /**
  121995. * Gets the output component
  121996. */
  121997. readonly output: NodeMaterialConnectionPoint;
  121998. protected _buildBlock(state: NodeMaterialBuildState): this;
  121999. }
  122000. }
  122001. declare module BABYLON {
  122002. /**
  122003. * Block used to smooth step a value
  122004. */
  122005. export class SmoothStepBlock extends NodeMaterialBlock {
  122006. /**
  122007. * Creates a new SmoothStepBlock
  122008. * @param name defines the block name
  122009. */
  122010. constructor(name: string);
  122011. /**
  122012. * Gets the current class name
  122013. * @returns the class name
  122014. */
  122015. getClassName(): string;
  122016. /**
  122017. * Gets the value operand input component
  122018. */
  122019. readonly value: NodeMaterialConnectionPoint;
  122020. /**
  122021. * Gets the first edge operand input component
  122022. */
  122023. readonly edge0: NodeMaterialConnectionPoint;
  122024. /**
  122025. * Gets the second edge operand input component
  122026. */
  122027. readonly edge1: NodeMaterialConnectionPoint;
  122028. /**
  122029. * Gets the output component
  122030. */
  122031. readonly output: NodeMaterialConnectionPoint;
  122032. protected _buildBlock(state: NodeMaterialBuildState): this;
  122033. }
  122034. }
  122035. declare module BABYLON {
  122036. /**
  122037. * Block used to get the reciprocal (1 / x) of a value
  122038. */
  122039. export class ReciprocalBlock extends NodeMaterialBlock {
  122040. /**
  122041. * Creates a new ReciprocalBlock
  122042. * @param name defines the block name
  122043. */
  122044. constructor(name: string);
  122045. /**
  122046. * Gets the current class name
  122047. * @returns the class name
  122048. */
  122049. getClassName(): string;
  122050. /**
  122051. * Gets the input component
  122052. */
  122053. readonly input: NodeMaterialConnectionPoint;
  122054. /**
  122055. * Gets the output component
  122056. */
  122057. readonly output: NodeMaterialConnectionPoint;
  122058. protected _buildBlock(state: NodeMaterialBuildState): this;
  122059. }
  122060. }
  122061. declare module BABYLON {
  122062. /**
  122063. * Block used to replace a color by another one
  122064. */
  122065. export class ReplaceColorBlock extends NodeMaterialBlock {
  122066. /**
  122067. * Creates a new ReplaceColorBlock
  122068. * @param name defines the block name
  122069. */
  122070. constructor(name: string);
  122071. /**
  122072. * Gets the current class name
  122073. * @returns the class name
  122074. */
  122075. getClassName(): string;
  122076. /**
  122077. * Gets the value input component
  122078. */
  122079. readonly value: NodeMaterialConnectionPoint;
  122080. /**
  122081. * Gets the reference input component
  122082. */
  122083. readonly reference: NodeMaterialConnectionPoint;
  122084. /**
  122085. * Gets the distance input component
  122086. */
  122087. readonly distance: NodeMaterialConnectionPoint;
  122088. /**
  122089. * Gets the replacement input component
  122090. */
  122091. readonly replacement: NodeMaterialConnectionPoint;
  122092. /**
  122093. * Gets the output component
  122094. */
  122095. readonly output: NodeMaterialConnectionPoint;
  122096. protected _buildBlock(state: NodeMaterialBuildState): this;
  122097. }
  122098. }
  122099. declare module BABYLON {
  122100. /**
  122101. * Block used to posterize a value
  122102. * @see https://en.wikipedia.org/wiki/Posterization
  122103. */
  122104. export class PosterizeBlock extends NodeMaterialBlock {
  122105. /**
  122106. * Creates a new PosterizeBlock
  122107. * @param name defines the block name
  122108. */
  122109. constructor(name: string);
  122110. /**
  122111. * Gets the current class name
  122112. * @returns the class name
  122113. */
  122114. getClassName(): string;
  122115. /**
  122116. * Gets the value input component
  122117. */
  122118. readonly value: NodeMaterialConnectionPoint;
  122119. /**
  122120. * Gets the steps input component
  122121. */
  122122. readonly steps: NodeMaterialConnectionPoint;
  122123. /**
  122124. * Gets the output component
  122125. */
  122126. readonly output: NodeMaterialConnectionPoint;
  122127. protected _buildBlock(state: NodeMaterialBuildState): this;
  122128. }
  122129. }
  122130. declare module BABYLON {
  122131. /**
  122132. * Operations supported by the Wave block
  122133. */
  122134. export enum WaveBlockKind {
  122135. /** SawTooth */
  122136. SawTooth = 0,
  122137. /** Square */
  122138. Square = 1,
  122139. /** Triangle */
  122140. Triangle = 2
  122141. }
  122142. /**
  122143. * Block used to apply wave operation to floats
  122144. */
  122145. export class WaveBlock extends NodeMaterialBlock {
  122146. /**
  122147. * Gets or sets the kibnd of wave to be applied by the block
  122148. */
  122149. kind: WaveBlockKind;
  122150. /**
  122151. * Creates a new WaveBlock
  122152. * @param name defines the block name
  122153. */
  122154. constructor(name: string);
  122155. /**
  122156. * Gets the current class name
  122157. * @returns the class name
  122158. */
  122159. getClassName(): string;
  122160. /**
  122161. * Gets the input component
  122162. */
  122163. readonly input: NodeMaterialConnectionPoint;
  122164. /**
  122165. * Gets the output component
  122166. */
  122167. readonly output: NodeMaterialConnectionPoint;
  122168. protected _buildBlock(state: NodeMaterialBuildState): this;
  122169. serialize(): any;
  122170. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122171. }
  122172. }
  122173. declare module BABYLON {
  122174. /**
  122175. * Class used to store a color step for the GradientBlock
  122176. */
  122177. export class GradientBlockColorStep {
  122178. /**
  122179. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122180. */
  122181. step: number;
  122182. /**
  122183. * Gets or sets the color associated with this step
  122184. */
  122185. color: Color3;
  122186. /**
  122187. * Creates a new GradientBlockColorStep
  122188. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  122189. * @param color defines the color associated with this step
  122190. */
  122191. constructor(
  122192. /**
  122193. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  122194. */
  122195. step: number,
  122196. /**
  122197. * Gets or sets the color associated with this step
  122198. */
  122199. color: Color3);
  122200. }
  122201. /**
  122202. * Block used to return a color from a gradient based on an input value between 0 and 1
  122203. */
  122204. export class GradientBlock extends NodeMaterialBlock {
  122205. /**
  122206. * Gets or sets the list of color steps
  122207. */
  122208. colorSteps: GradientBlockColorStep[];
  122209. /**
  122210. * Creates a new GradientBlock
  122211. * @param name defines the block name
  122212. */
  122213. constructor(name: string);
  122214. /**
  122215. * Gets the current class name
  122216. * @returns the class name
  122217. */
  122218. getClassName(): string;
  122219. /**
  122220. * Gets the gradient input component
  122221. */
  122222. readonly gradient: NodeMaterialConnectionPoint;
  122223. /**
  122224. * Gets the output component
  122225. */
  122226. readonly output: NodeMaterialConnectionPoint;
  122227. private _writeColorConstant;
  122228. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  122229. serialize(): any;
  122230. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  122231. protected _dumpPropertiesCode(): string;
  122232. }
  122233. }
  122234. declare module BABYLON {
  122235. /**
  122236. * Block used to normalize lerp between 2 values
  122237. */
  122238. export class NLerpBlock extends NodeMaterialBlock {
  122239. /**
  122240. * Creates a new NLerpBlock
  122241. * @param name defines the block name
  122242. */
  122243. constructor(name: string);
  122244. /**
  122245. * Gets the current class name
  122246. * @returns the class name
  122247. */
  122248. getClassName(): string;
  122249. /**
  122250. * Gets the left operand input component
  122251. */
  122252. readonly left: NodeMaterialConnectionPoint;
  122253. /**
  122254. * Gets the right operand input component
  122255. */
  122256. readonly right: NodeMaterialConnectionPoint;
  122257. /**
  122258. * Gets the gradient operand input component
  122259. */
  122260. readonly gradient: NodeMaterialConnectionPoint;
  122261. /**
  122262. * Gets the output component
  122263. */
  122264. readonly output: NodeMaterialConnectionPoint;
  122265. protected _buildBlock(state: NodeMaterialBuildState): this;
  122266. }
  122267. }
  122268. declare module BABYLON {
  122269. /**
  122270. * Effect Render Options
  122271. */
  122272. export interface IEffectRendererOptions {
  122273. /**
  122274. * Defines the vertices positions.
  122275. */
  122276. positions?: number[];
  122277. /**
  122278. * Defines the indices.
  122279. */
  122280. indices?: number[];
  122281. }
  122282. /**
  122283. * Helper class to render one or more effects
  122284. */
  122285. export class EffectRenderer {
  122286. private engine;
  122287. private static _DefaultOptions;
  122288. private _vertexBuffers;
  122289. private _indexBuffer;
  122290. private _ringBufferIndex;
  122291. private _ringScreenBuffer;
  122292. private _fullscreenViewport;
  122293. private _getNextFrameBuffer;
  122294. /**
  122295. * Creates an effect renderer
  122296. * @param engine the engine to use for rendering
  122297. * @param options defines the options of the effect renderer
  122298. */
  122299. constructor(engine: Engine, options?: IEffectRendererOptions);
  122300. /**
  122301. * Sets the current viewport in normalized coordinates 0-1
  122302. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  122303. */
  122304. setViewport(viewport?: Viewport): void;
  122305. /**
  122306. * Binds the embedded attributes buffer to the effect.
  122307. * @param effect Defines the effect to bind the attributes for
  122308. */
  122309. bindBuffers(effect: Effect): void;
  122310. /**
  122311. * Sets the current effect wrapper to use during draw.
  122312. * The effect needs to be ready before calling this api.
  122313. * This also sets the default full screen position attribute.
  122314. * @param effectWrapper Defines the effect to draw with
  122315. */
  122316. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  122317. /**
  122318. * Draws a full screen quad.
  122319. */
  122320. draw(): void;
  122321. /**
  122322. * renders one or more effects to a specified texture
  122323. * @param effectWrappers list of effects to renderer
  122324. * @param outputTexture texture to draw to, if null it will render to the screen
  122325. */
  122326. render(effectWrappers: Array<EffectWrapper> | EffectWrapper, outputTexture?: Nullable<Texture>): void;
  122327. /**
  122328. * Disposes of the effect renderer
  122329. */
  122330. dispose(): void;
  122331. }
  122332. /**
  122333. * Options to create an EffectWrapper
  122334. */
  122335. interface EffectWrapperCreationOptions {
  122336. /**
  122337. * Engine to use to create the effect
  122338. */
  122339. engine: Engine;
  122340. /**
  122341. * Fragment shader for the effect
  122342. */
  122343. fragmentShader: string;
  122344. /**
  122345. * Vertex shader for the effect
  122346. */
  122347. vertexShader?: string;
  122348. /**
  122349. * Attributes to use in the shader
  122350. */
  122351. attributeNames?: Array<string>;
  122352. /**
  122353. * Uniforms to use in the shader
  122354. */
  122355. uniformNames?: Array<string>;
  122356. /**
  122357. * Texture sampler names to use in the shader
  122358. */
  122359. samplerNames?: Array<string>;
  122360. /**
  122361. * The friendly name of the effect displayed in Spector.
  122362. */
  122363. name?: string;
  122364. }
  122365. /**
  122366. * Wraps an effect to be used for rendering
  122367. */
  122368. export class EffectWrapper {
  122369. /**
  122370. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  122371. */
  122372. onApplyObservable: Observable<{}>;
  122373. /**
  122374. * The underlying effect
  122375. */
  122376. effect: Effect;
  122377. /**
  122378. * Creates an effect to be renderer
  122379. * @param creationOptions options to create the effect
  122380. */
  122381. constructor(creationOptions: EffectWrapperCreationOptions);
  122382. /**
  122383. * Disposes of the effect wrapper
  122384. */
  122385. dispose(): void;
  122386. }
  122387. }
  122388. declare module BABYLON {
  122389. /**
  122390. * Helper class to push actions to a pool of workers.
  122391. */
  122392. export class WorkerPool implements IDisposable {
  122393. private _workerInfos;
  122394. private _pendingActions;
  122395. /**
  122396. * Constructor
  122397. * @param workers Array of workers to use for actions
  122398. */
  122399. constructor(workers: Array<Worker>);
  122400. /**
  122401. * Terminates all workers and clears any pending actions.
  122402. */
  122403. dispose(): void;
  122404. /**
  122405. * Pushes an action to the worker pool. If all the workers are active, the action will be
  122406. * pended until a worker has completed its action.
  122407. * @param action The action to perform. Call onComplete when the action is complete.
  122408. */
  122409. push(action: (worker: Worker, onComplete: () => void) => void): void;
  122410. private _execute;
  122411. }
  122412. }
  122413. declare module BABYLON {
  122414. /**
  122415. * Configuration for Draco compression
  122416. */
  122417. export interface IDracoCompressionConfiguration {
  122418. /**
  122419. * Configuration for the decoder.
  122420. */
  122421. decoder: {
  122422. /**
  122423. * The url to the WebAssembly module.
  122424. */
  122425. wasmUrl?: string;
  122426. /**
  122427. * The url to the WebAssembly binary.
  122428. */
  122429. wasmBinaryUrl?: string;
  122430. /**
  122431. * The url to the fallback JavaScript module.
  122432. */
  122433. fallbackUrl?: string;
  122434. };
  122435. }
  122436. /**
  122437. * Draco compression (https://google.github.io/draco/)
  122438. *
  122439. * This class wraps the Draco module.
  122440. *
  122441. * **Encoder**
  122442. *
  122443. * The encoder is not currently implemented.
  122444. *
  122445. * **Decoder**
  122446. *
  122447. * 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.
  122448. *
  122449. * To update the configuration, use the following code:
  122450. * ```javascript
  122451. * DracoCompression.Configuration = {
  122452. * decoder: {
  122453. * wasmUrl: "<url to the WebAssembly library>",
  122454. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  122455. * fallbackUrl: "<url to the fallback JavaScript library>",
  122456. * }
  122457. * };
  122458. * ```
  122459. *
  122460. * 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.
  122461. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  122462. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  122463. *
  122464. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  122465. * ```javascript
  122466. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  122467. * ```
  122468. *
  122469. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  122470. */
  122471. export class DracoCompression implements IDisposable {
  122472. private _workerPoolPromise?;
  122473. private _decoderModulePromise?;
  122474. /**
  122475. * The configuration. Defaults to the following urls:
  122476. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  122477. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  122478. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  122479. */
  122480. static Configuration: IDracoCompressionConfiguration;
  122481. /**
  122482. * Returns true if the decoder configuration is available.
  122483. */
  122484. static readonly DecoderAvailable: boolean;
  122485. /**
  122486. * Default number of workers to create when creating the draco compression object.
  122487. */
  122488. static DefaultNumWorkers: number;
  122489. private static GetDefaultNumWorkers;
  122490. private static _Default;
  122491. /**
  122492. * Default instance for the draco compression object.
  122493. */
  122494. static readonly Default: DracoCompression;
  122495. /**
  122496. * Constructor
  122497. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  122498. */
  122499. constructor(numWorkers?: number);
  122500. /**
  122501. * Stop all async operations and release resources.
  122502. */
  122503. dispose(): void;
  122504. /**
  122505. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  122506. * @returns a promise that resolves when ready
  122507. */
  122508. whenReadyAsync(): Promise<void>;
  122509. /**
  122510. * Decode Draco compressed mesh data to vertex data.
  122511. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  122512. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  122513. * @returns A promise that resolves with the decoded vertex data
  122514. */
  122515. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  122516. [kind: string]: number;
  122517. }): Promise<VertexData>;
  122518. }
  122519. }
  122520. declare module BABYLON {
  122521. /**
  122522. * Class for building Constructive Solid Geometry
  122523. */
  122524. export class CSG {
  122525. private polygons;
  122526. /**
  122527. * The world matrix
  122528. */
  122529. matrix: Matrix;
  122530. /**
  122531. * Stores the position
  122532. */
  122533. position: Vector3;
  122534. /**
  122535. * Stores the rotation
  122536. */
  122537. rotation: Vector3;
  122538. /**
  122539. * Stores the rotation quaternion
  122540. */
  122541. rotationQuaternion: Nullable<Quaternion>;
  122542. /**
  122543. * Stores the scaling vector
  122544. */
  122545. scaling: Vector3;
  122546. /**
  122547. * Convert the Mesh to CSG
  122548. * @param mesh The Mesh to convert to CSG
  122549. * @returns A new CSG from the Mesh
  122550. */
  122551. static FromMesh(mesh: Mesh): CSG;
  122552. /**
  122553. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  122554. * @param polygons Polygons used to construct a CSG solid
  122555. */
  122556. private static FromPolygons;
  122557. /**
  122558. * Clones, or makes a deep copy, of the CSG
  122559. * @returns A new CSG
  122560. */
  122561. clone(): CSG;
  122562. /**
  122563. * Unions this CSG with another CSG
  122564. * @param csg The CSG to union against this CSG
  122565. * @returns The unioned CSG
  122566. */
  122567. union(csg: CSG): CSG;
  122568. /**
  122569. * Unions this CSG with another CSG in place
  122570. * @param csg The CSG to union against this CSG
  122571. */
  122572. unionInPlace(csg: CSG): void;
  122573. /**
  122574. * Subtracts this CSG with another CSG
  122575. * @param csg The CSG to subtract against this CSG
  122576. * @returns A new CSG
  122577. */
  122578. subtract(csg: CSG): CSG;
  122579. /**
  122580. * Subtracts this CSG with another CSG in place
  122581. * @param csg The CSG to subtact against this CSG
  122582. */
  122583. subtractInPlace(csg: CSG): void;
  122584. /**
  122585. * Intersect this CSG with another CSG
  122586. * @param csg The CSG to intersect against this CSG
  122587. * @returns A new CSG
  122588. */
  122589. intersect(csg: CSG): CSG;
  122590. /**
  122591. * Intersects this CSG with another CSG in place
  122592. * @param csg The CSG to intersect against this CSG
  122593. */
  122594. intersectInPlace(csg: CSG): void;
  122595. /**
  122596. * Return a new CSG solid with solid and empty space switched. This solid is
  122597. * not modified.
  122598. * @returns A new CSG solid with solid and empty space switched
  122599. */
  122600. inverse(): CSG;
  122601. /**
  122602. * Inverses the CSG in place
  122603. */
  122604. inverseInPlace(): void;
  122605. /**
  122606. * This is used to keep meshes transformations so they can be restored
  122607. * when we build back a Babylon Mesh
  122608. * NB : All CSG operations are performed in world coordinates
  122609. * @param csg The CSG to copy the transform attributes from
  122610. * @returns This CSG
  122611. */
  122612. copyTransformAttributes(csg: CSG): CSG;
  122613. /**
  122614. * Build Raw mesh from CSG
  122615. * Coordinates here are in world space
  122616. * @param name The name of the mesh geometry
  122617. * @param scene The Scene
  122618. * @param keepSubMeshes Specifies if the submeshes should be kept
  122619. * @returns A new Mesh
  122620. */
  122621. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122622. /**
  122623. * Build Mesh from CSG taking material and transforms into account
  122624. * @param name The name of the Mesh
  122625. * @param material The material of the Mesh
  122626. * @param scene The Scene
  122627. * @param keepSubMeshes Specifies if submeshes should be kept
  122628. * @returns The new Mesh
  122629. */
  122630. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  122631. }
  122632. }
  122633. declare module BABYLON {
  122634. /**
  122635. * Class used to create a trail following a mesh
  122636. */
  122637. export class TrailMesh extends Mesh {
  122638. private _generator;
  122639. private _autoStart;
  122640. private _running;
  122641. private _diameter;
  122642. private _length;
  122643. private _sectionPolygonPointsCount;
  122644. private _sectionVectors;
  122645. private _sectionNormalVectors;
  122646. private _beforeRenderObserver;
  122647. /**
  122648. * @constructor
  122649. * @param name The value used by scene.getMeshByName() to do a lookup.
  122650. * @param generator The mesh to generate a trail.
  122651. * @param scene The scene to add this mesh to.
  122652. * @param diameter Diameter of trailing mesh. Default is 1.
  122653. * @param length Length of trailing mesh. Default is 60.
  122654. * @param autoStart Automatically start trailing mesh. Default true.
  122655. */
  122656. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  122657. /**
  122658. * "TrailMesh"
  122659. * @returns "TrailMesh"
  122660. */
  122661. getClassName(): string;
  122662. private _createMesh;
  122663. /**
  122664. * Start trailing mesh.
  122665. */
  122666. start(): void;
  122667. /**
  122668. * Stop trailing mesh.
  122669. */
  122670. stop(): void;
  122671. /**
  122672. * Update trailing mesh geometry.
  122673. */
  122674. update(): void;
  122675. /**
  122676. * Returns a new TrailMesh object.
  122677. * @param name is a string, the name given to the new mesh
  122678. * @param newGenerator use new generator object for cloned trail mesh
  122679. * @returns a new mesh
  122680. */
  122681. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  122682. /**
  122683. * Serializes this trail mesh
  122684. * @param serializationObject object to write serialization to
  122685. */
  122686. serialize(serializationObject: any): void;
  122687. /**
  122688. * Parses a serialized trail mesh
  122689. * @param parsedMesh the serialized mesh
  122690. * @param scene the scene to create the trail mesh in
  122691. * @returns the created trail mesh
  122692. */
  122693. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  122694. }
  122695. }
  122696. declare module BABYLON {
  122697. /**
  122698. * Class containing static functions to help procedurally build meshes
  122699. */
  122700. export class TiledBoxBuilder {
  122701. /**
  122702. * Creates a box mesh
  122703. * 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)
  122704. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122705. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122706. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122707. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122708. * @param name defines the name of the mesh
  122709. * @param options defines the options used to create the mesh
  122710. * @param scene defines the hosting scene
  122711. * @returns the box mesh
  122712. */
  122713. static CreateTiledBox(name: string, options: {
  122714. pattern?: number;
  122715. width?: number;
  122716. height?: number;
  122717. depth?: number;
  122718. tileSize?: number;
  122719. tileWidth?: number;
  122720. tileHeight?: number;
  122721. alignHorizontal?: number;
  122722. alignVertical?: number;
  122723. faceUV?: Vector4[];
  122724. faceColors?: Color4[];
  122725. sideOrientation?: number;
  122726. updatable?: boolean;
  122727. }, scene?: Nullable<Scene>): Mesh;
  122728. }
  122729. }
  122730. declare module BABYLON {
  122731. /**
  122732. * Class containing static functions to help procedurally build meshes
  122733. */
  122734. export class TorusKnotBuilder {
  122735. /**
  122736. * Creates a torus knot mesh
  122737. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  122738. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  122739. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  122740. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  122741. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122742. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122743. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  122744. * @param name defines the name of the mesh
  122745. * @param options defines the options used to create the mesh
  122746. * @param scene defines the hosting scene
  122747. * @returns the torus knot mesh
  122748. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  122749. */
  122750. static CreateTorusKnot(name: string, options: {
  122751. radius?: number;
  122752. tube?: number;
  122753. radialSegments?: number;
  122754. tubularSegments?: number;
  122755. p?: number;
  122756. q?: number;
  122757. updatable?: boolean;
  122758. sideOrientation?: number;
  122759. frontUVs?: Vector4;
  122760. backUVs?: Vector4;
  122761. }, scene: any): Mesh;
  122762. }
  122763. }
  122764. declare module BABYLON {
  122765. /**
  122766. * Polygon
  122767. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  122768. */
  122769. export class Polygon {
  122770. /**
  122771. * Creates a rectangle
  122772. * @param xmin bottom X coord
  122773. * @param ymin bottom Y coord
  122774. * @param xmax top X coord
  122775. * @param ymax top Y coord
  122776. * @returns points that make the resulting rectation
  122777. */
  122778. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  122779. /**
  122780. * Creates a circle
  122781. * @param radius radius of circle
  122782. * @param cx scale in x
  122783. * @param cy scale in y
  122784. * @param numberOfSides number of sides that make up the circle
  122785. * @returns points that make the resulting circle
  122786. */
  122787. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  122788. /**
  122789. * Creates a polygon from input string
  122790. * @param input Input polygon data
  122791. * @returns the parsed points
  122792. */
  122793. static Parse(input: string): Vector2[];
  122794. /**
  122795. * Starts building a polygon from x and y coordinates
  122796. * @param x x coordinate
  122797. * @param y y coordinate
  122798. * @returns the started path2
  122799. */
  122800. static StartingAt(x: number, y: number): Path2;
  122801. }
  122802. /**
  122803. * Builds a polygon
  122804. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  122805. */
  122806. export class PolygonMeshBuilder {
  122807. private _points;
  122808. private _outlinepoints;
  122809. private _holes;
  122810. private _name;
  122811. private _scene;
  122812. private _epoints;
  122813. private _eholes;
  122814. private _addToepoint;
  122815. /**
  122816. * Babylon reference to the earcut plugin.
  122817. */
  122818. bjsEarcut: any;
  122819. /**
  122820. * Creates a PolygonMeshBuilder
  122821. * @param name name of the builder
  122822. * @param contours Path of the polygon
  122823. * @param scene scene to add to when creating the mesh
  122824. * @param earcutInjection can be used to inject your own earcut reference
  122825. */
  122826. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  122827. /**
  122828. * Adds a whole within the polygon
  122829. * @param hole Array of points defining the hole
  122830. * @returns this
  122831. */
  122832. addHole(hole: Vector2[]): PolygonMeshBuilder;
  122833. /**
  122834. * Creates the polygon
  122835. * @param updatable If the mesh should be updatable
  122836. * @param depth The depth of the mesh created
  122837. * @returns the created mesh
  122838. */
  122839. build(updatable?: boolean, depth?: number): Mesh;
  122840. /**
  122841. * Creates the polygon
  122842. * @param depth The depth of the mesh created
  122843. * @returns the created VertexData
  122844. */
  122845. buildVertexData(depth?: number): VertexData;
  122846. /**
  122847. * Adds a side to the polygon
  122848. * @param positions points that make the polygon
  122849. * @param normals normals of the polygon
  122850. * @param uvs uvs of the polygon
  122851. * @param indices indices of the polygon
  122852. * @param bounds bounds of the polygon
  122853. * @param points points of the polygon
  122854. * @param depth depth of the polygon
  122855. * @param flip flip of the polygon
  122856. */
  122857. private addSide;
  122858. }
  122859. }
  122860. declare module BABYLON {
  122861. /**
  122862. * Class containing static functions to help procedurally build meshes
  122863. */
  122864. export class PolygonBuilder {
  122865. /**
  122866. * Creates a polygon mesh
  122867. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  122868. * * 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
  122869. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122871. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  122872. * * Remember you can only change the shape positions, not their number when updating a polygon
  122873. * @param name defines the name of the mesh
  122874. * @param options defines the options used to create the mesh
  122875. * @param scene defines the hosting scene
  122876. * @param earcutInjection can be used to inject your own earcut reference
  122877. * @returns the polygon mesh
  122878. */
  122879. static CreatePolygon(name: string, options: {
  122880. shape: Vector3[];
  122881. holes?: Vector3[][];
  122882. depth?: number;
  122883. faceUV?: Vector4[];
  122884. faceColors?: Color4[];
  122885. updatable?: boolean;
  122886. sideOrientation?: number;
  122887. frontUVs?: Vector4;
  122888. backUVs?: Vector4;
  122889. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122890. /**
  122891. * Creates an extruded polygon mesh, with depth in the Y direction.
  122892. * * 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)
  122893. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  122894. * @param name defines the name of the mesh
  122895. * @param options defines the options used to create the mesh
  122896. * @param scene defines the hosting scene
  122897. * @param earcutInjection can be used to inject your own earcut reference
  122898. * @returns the polygon mesh
  122899. */
  122900. static ExtrudePolygon(name: string, options: {
  122901. shape: Vector3[];
  122902. holes?: Vector3[][];
  122903. depth?: number;
  122904. faceUV?: Vector4[];
  122905. faceColors?: Color4[];
  122906. updatable?: boolean;
  122907. sideOrientation?: number;
  122908. frontUVs?: Vector4;
  122909. backUVs?: Vector4;
  122910. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  122911. }
  122912. }
  122913. declare module BABYLON {
  122914. /**
  122915. * Class containing static functions to help procedurally build meshes
  122916. */
  122917. export class LatheBuilder {
  122918. /**
  122919. * Creates lathe mesh.
  122920. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  122921. * * 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
  122922. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  122923. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  122924. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  122925. * * 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
  122926. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  122927. * * 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
  122928. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  122929. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122930. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  122931. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  122932. * @param name defines the name of the mesh
  122933. * @param options defines the options used to create the mesh
  122934. * @param scene defines the hosting scene
  122935. * @returns the lathe mesh
  122936. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  122937. */
  122938. static CreateLathe(name: string, options: {
  122939. shape: Vector3[];
  122940. radius?: number;
  122941. tessellation?: number;
  122942. clip?: number;
  122943. arc?: number;
  122944. closed?: boolean;
  122945. updatable?: boolean;
  122946. sideOrientation?: number;
  122947. frontUVs?: Vector4;
  122948. backUVs?: Vector4;
  122949. cap?: number;
  122950. invertUV?: boolean;
  122951. }, scene?: Nullable<Scene>): Mesh;
  122952. }
  122953. }
  122954. declare module BABYLON {
  122955. /**
  122956. * Class containing static functions to help procedurally build meshes
  122957. */
  122958. export class TiledPlaneBuilder {
  122959. /**
  122960. * Creates a tiled plane mesh
  122961. * * The parameter `pattern` will, depending on value, do nothing or
  122962. * * * flip (reflect about central vertical) alternate tiles across and up
  122963. * * * flip every tile on alternate rows
  122964. * * * rotate (180 degs) alternate tiles across and up
  122965. * * * rotate every tile on alternate rows
  122966. * * * flip and rotate alternate tiles across and up
  122967. * * * flip and rotate every tile on alternate rows
  122968. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  122969. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  122970. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  122971. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  122972. * * 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)
  122973. * * 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)
  122974. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  122975. * @param name defines the name of the mesh
  122976. * @param options defines the options used to create the mesh
  122977. * @param scene defines the hosting scene
  122978. * @returns the box mesh
  122979. */
  122980. static CreateTiledPlane(name: string, options: {
  122981. pattern?: number;
  122982. tileSize?: number;
  122983. tileWidth?: number;
  122984. tileHeight?: number;
  122985. size?: number;
  122986. width?: number;
  122987. height?: number;
  122988. alignHorizontal?: number;
  122989. alignVertical?: number;
  122990. sideOrientation?: number;
  122991. frontUVs?: Vector4;
  122992. backUVs?: Vector4;
  122993. updatable?: boolean;
  122994. }, scene?: Nullable<Scene>): Mesh;
  122995. }
  122996. }
  122997. declare module BABYLON {
  122998. /**
  122999. * Class containing static functions to help procedurally build meshes
  123000. */
  123001. export class TubeBuilder {
  123002. /**
  123003. * Creates a tube mesh.
  123004. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123005. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123006. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123007. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123008. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123009. * * 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)
  123010. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123011. * * 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
  123012. * * 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
  123013. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123014. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123015. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123016. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123017. * @param name defines the name of the mesh
  123018. * @param options defines the options used to create the mesh
  123019. * @param scene defines the hosting scene
  123020. * @returns the tube mesh
  123021. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123022. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123023. */
  123024. static CreateTube(name: string, options: {
  123025. path: Vector3[];
  123026. radius?: number;
  123027. tessellation?: number;
  123028. radiusFunction?: {
  123029. (i: number, distance: number): number;
  123030. };
  123031. cap?: number;
  123032. arc?: number;
  123033. updatable?: boolean;
  123034. sideOrientation?: number;
  123035. frontUVs?: Vector4;
  123036. backUVs?: Vector4;
  123037. instance?: Mesh;
  123038. invertUV?: boolean;
  123039. }, scene?: Nullable<Scene>): Mesh;
  123040. }
  123041. }
  123042. declare module BABYLON {
  123043. /**
  123044. * Class containing static functions to help procedurally build meshes
  123045. */
  123046. export class IcoSphereBuilder {
  123047. /**
  123048. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123049. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123050. * * 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`)
  123051. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123052. * * 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
  123053. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123054. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123056. * @param name defines the name of the mesh
  123057. * @param options defines the options used to create the mesh
  123058. * @param scene defines the hosting scene
  123059. * @returns the icosahedron mesh
  123060. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123061. */
  123062. static CreateIcoSphere(name: string, options: {
  123063. radius?: number;
  123064. radiusX?: number;
  123065. radiusY?: number;
  123066. radiusZ?: number;
  123067. flat?: boolean;
  123068. subdivisions?: number;
  123069. sideOrientation?: number;
  123070. frontUVs?: Vector4;
  123071. backUVs?: Vector4;
  123072. updatable?: boolean;
  123073. }, scene?: Nullable<Scene>): Mesh;
  123074. }
  123075. }
  123076. declare module BABYLON {
  123077. /**
  123078. * Class containing static functions to help procedurally build meshes
  123079. */
  123080. export class DecalBuilder {
  123081. /**
  123082. * Creates a decal mesh.
  123083. * 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
  123084. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123085. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123086. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123087. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123088. * @param name defines the name of the mesh
  123089. * @param sourceMesh defines the mesh where the decal must be applied
  123090. * @param options defines the options used to create the mesh
  123091. * @param scene defines the hosting scene
  123092. * @returns the decal mesh
  123093. * @see https://doc.babylonjs.com/how_to/decals
  123094. */
  123095. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123096. position?: Vector3;
  123097. normal?: Vector3;
  123098. size?: Vector3;
  123099. angle?: number;
  123100. }): Mesh;
  123101. }
  123102. }
  123103. declare module BABYLON {
  123104. /**
  123105. * Class containing static functions to help procedurally build meshes
  123106. */
  123107. export class MeshBuilder {
  123108. /**
  123109. * Creates a box mesh
  123110. * * The parameter `size` sets the size (float) of each box side (default 1)
  123111. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  123112. * * 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)
  123113. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123114. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123115. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123116. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123117. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  123118. * @param name defines the name of the mesh
  123119. * @param options defines the options used to create the mesh
  123120. * @param scene defines the hosting scene
  123121. * @returns the box mesh
  123122. */
  123123. static CreateBox(name: string, options: {
  123124. size?: number;
  123125. width?: number;
  123126. height?: number;
  123127. depth?: number;
  123128. faceUV?: Vector4[];
  123129. faceColors?: Color4[];
  123130. sideOrientation?: number;
  123131. frontUVs?: Vector4;
  123132. backUVs?: Vector4;
  123133. updatable?: boolean;
  123134. }, scene?: Nullable<Scene>): Mesh;
  123135. /**
  123136. * Creates a tiled box mesh
  123137. * * faceTiles sets the pattern, tile size and number of tiles for a face
  123138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123139. * @param name defines the name of the mesh
  123140. * @param options defines the options used to create the mesh
  123141. * @param scene defines the hosting scene
  123142. * @returns the tiled box mesh
  123143. */
  123144. static CreateTiledBox(name: string, options: {
  123145. pattern?: number;
  123146. size?: number;
  123147. width?: number;
  123148. height?: number;
  123149. depth: number;
  123150. tileSize?: number;
  123151. tileWidth?: number;
  123152. tileHeight?: number;
  123153. faceUV?: Vector4[];
  123154. faceColors?: Color4[];
  123155. alignHorizontal?: number;
  123156. alignVertical?: number;
  123157. sideOrientation?: number;
  123158. updatable?: boolean;
  123159. }, scene?: Nullable<Scene>): Mesh;
  123160. /**
  123161. * Creates a sphere mesh
  123162. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  123163. * * 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`)
  123164. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  123165. * * 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
  123166. * * 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)
  123167. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123168. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123169. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123170. * @param name defines the name of the mesh
  123171. * @param options defines the options used to create the mesh
  123172. * @param scene defines the hosting scene
  123173. * @returns the sphere mesh
  123174. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  123175. */
  123176. static CreateSphere(name: string, options: {
  123177. segments?: number;
  123178. diameter?: number;
  123179. diameterX?: number;
  123180. diameterY?: number;
  123181. diameterZ?: number;
  123182. arc?: number;
  123183. slice?: number;
  123184. sideOrientation?: number;
  123185. frontUVs?: Vector4;
  123186. backUVs?: Vector4;
  123187. updatable?: boolean;
  123188. }, scene?: Nullable<Scene>): Mesh;
  123189. /**
  123190. * Creates a plane polygonal mesh. By default, this is a disc
  123191. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  123192. * * 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
  123193. * * 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
  123194. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123195. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123197. * @param name defines the name of the mesh
  123198. * @param options defines the options used to create the mesh
  123199. * @param scene defines the hosting scene
  123200. * @returns the plane polygonal mesh
  123201. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  123202. */
  123203. static CreateDisc(name: string, options: {
  123204. radius?: number;
  123205. tessellation?: number;
  123206. arc?: number;
  123207. updatable?: boolean;
  123208. sideOrientation?: number;
  123209. frontUVs?: Vector4;
  123210. backUVs?: Vector4;
  123211. }, scene?: Nullable<Scene>): Mesh;
  123212. /**
  123213. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  123214. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  123215. * * 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`)
  123216. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  123217. * * 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
  123218. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123219. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123220. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123221. * @param name defines the name of the mesh
  123222. * @param options defines the options used to create the mesh
  123223. * @param scene defines the hosting scene
  123224. * @returns the icosahedron mesh
  123225. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  123226. */
  123227. static CreateIcoSphere(name: string, options: {
  123228. radius?: number;
  123229. radiusX?: number;
  123230. radiusY?: number;
  123231. radiusZ?: number;
  123232. flat?: boolean;
  123233. subdivisions?: number;
  123234. sideOrientation?: number;
  123235. frontUVs?: Vector4;
  123236. backUVs?: Vector4;
  123237. updatable?: boolean;
  123238. }, scene?: Nullable<Scene>): Mesh;
  123239. /**
  123240. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123241. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  123242. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  123243. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  123244. * * 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
  123245. * * 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
  123246. * * 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
  123247. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123248. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123249. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123250. * * 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
  123251. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  123252. * * 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
  123253. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  123254. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123255. * @param name defines the name of the mesh
  123256. * @param options defines the options used to create the mesh
  123257. * @param scene defines the hosting scene
  123258. * @returns the ribbon mesh
  123259. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  123260. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123261. */
  123262. static CreateRibbon(name: string, options: {
  123263. pathArray: Vector3[][];
  123264. closeArray?: boolean;
  123265. closePath?: boolean;
  123266. offset?: number;
  123267. updatable?: boolean;
  123268. sideOrientation?: number;
  123269. frontUVs?: Vector4;
  123270. backUVs?: Vector4;
  123271. instance?: Mesh;
  123272. invertUV?: boolean;
  123273. uvs?: Vector2[];
  123274. colors?: Color4[];
  123275. }, scene?: Nullable<Scene>): Mesh;
  123276. /**
  123277. * Creates a cylinder or a cone mesh
  123278. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  123279. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  123280. * * 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.
  123281. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  123282. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  123283. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  123284. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  123285. * * 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).
  123286. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  123287. * * 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).
  123288. * * 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
  123289. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  123290. * * 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
  123291. * * 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.
  123292. * * If `enclose` is false, a ring surface is one element.
  123293. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  123294. * * 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
  123295. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123296. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123297. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123298. * @param name defines the name of the mesh
  123299. * @param options defines the options used to create the mesh
  123300. * @param scene defines the hosting scene
  123301. * @returns the cylinder mesh
  123302. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  123303. */
  123304. static CreateCylinder(name: string, options: {
  123305. height?: number;
  123306. diameterTop?: number;
  123307. diameterBottom?: number;
  123308. diameter?: number;
  123309. tessellation?: number;
  123310. subdivisions?: number;
  123311. arc?: number;
  123312. faceColors?: Color4[];
  123313. faceUV?: Vector4[];
  123314. updatable?: boolean;
  123315. hasRings?: boolean;
  123316. enclose?: boolean;
  123317. cap?: number;
  123318. sideOrientation?: number;
  123319. frontUVs?: Vector4;
  123320. backUVs?: Vector4;
  123321. }, scene?: Nullable<Scene>): Mesh;
  123322. /**
  123323. * Creates a torus mesh
  123324. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  123325. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  123326. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  123327. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123328. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123329. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123330. * @param name defines the name of the mesh
  123331. * @param options defines the options used to create the mesh
  123332. * @param scene defines the hosting scene
  123333. * @returns the torus mesh
  123334. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  123335. */
  123336. static CreateTorus(name: string, options: {
  123337. diameter?: number;
  123338. thickness?: number;
  123339. tessellation?: number;
  123340. updatable?: boolean;
  123341. sideOrientation?: number;
  123342. frontUVs?: Vector4;
  123343. backUVs?: Vector4;
  123344. }, scene?: Nullable<Scene>): Mesh;
  123345. /**
  123346. * Creates a torus knot mesh
  123347. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  123348. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  123349. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  123350. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  123351. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123352. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123354. * @param name defines the name of the mesh
  123355. * @param options defines the options used to create the mesh
  123356. * @param scene defines the hosting scene
  123357. * @returns the torus knot mesh
  123358. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  123359. */
  123360. static CreateTorusKnot(name: string, options: {
  123361. radius?: number;
  123362. tube?: number;
  123363. radialSegments?: number;
  123364. tubularSegments?: number;
  123365. p?: number;
  123366. q?: number;
  123367. updatable?: boolean;
  123368. sideOrientation?: number;
  123369. frontUVs?: Vector4;
  123370. backUVs?: Vector4;
  123371. }, scene?: Nullable<Scene>): Mesh;
  123372. /**
  123373. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  123374. * * 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
  123375. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  123376. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  123377. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  123378. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  123379. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  123380. * * 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
  123381. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  123382. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123383. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  123384. * @param name defines the name of the new line system
  123385. * @param options defines the options used to create the line system
  123386. * @param scene defines the hosting scene
  123387. * @returns a new line system mesh
  123388. */
  123389. static CreateLineSystem(name: string, options: {
  123390. lines: Vector3[][];
  123391. updatable?: boolean;
  123392. instance?: Nullable<LinesMesh>;
  123393. colors?: Nullable<Color4[][]>;
  123394. useVertexAlpha?: boolean;
  123395. }, scene: Nullable<Scene>): LinesMesh;
  123396. /**
  123397. * Creates a line mesh
  123398. * 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
  123399. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123400. * * The parameter `points` is an array successive Vector3
  123401. * * 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
  123402. * * The optional parameter `colors` is an array of successive Color4, one per line point
  123403. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  123404. * * When updating an instance, remember that only point positions can change, not the number of points
  123405. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123406. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  123407. * @param name defines the name of the new line system
  123408. * @param options defines the options used to create the line system
  123409. * @param scene defines the hosting scene
  123410. * @returns a new line mesh
  123411. */
  123412. static CreateLines(name: string, options: {
  123413. points: Vector3[];
  123414. updatable?: boolean;
  123415. instance?: Nullable<LinesMesh>;
  123416. colors?: Color4[];
  123417. useVertexAlpha?: boolean;
  123418. }, scene?: Nullable<Scene>): LinesMesh;
  123419. /**
  123420. * Creates a dashed line mesh
  123421. * * 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
  123422. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  123423. * * The parameter `points` is an array successive Vector3
  123424. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  123425. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  123426. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  123427. * * 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
  123428. * * When updating an instance, remember that only point positions can change, not the number of points
  123429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123430. * @param name defines the name of the mesh
  123431. * @param options defines the options used to create the mesh
  123432. * @param scene defines the hosting scene
  123433. * @returns the dashed line mesh
  123434. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  123435. */
  123436. static CreateDashedLines(name: string, options: {
  123437. points: Vector3[];
  123438. dashSize?: number;
  123439. gapSize?: number;
  123440. dashNb?: number;
  123441. updatable?: boolean;
  123442. instance?: LinesMesh;
  123443. }, scene?: Nullable<Scene>): LinesMesh;
  123444. /**
  123445. * 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.
  123446. * * 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.
  123447. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123448. * * 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.
  123449. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  123450. * * 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
  123451. * * 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
  123452. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  123453. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123454. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123455. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  123456. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123457. * @param name defines the name of the mesh
  123458. * @param options defines the options used to create the mesh
  123459. * @param scene defines the hosting scene
  123460. * @returns the extruded shape mesh
  123461. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123462. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123463. */
  123464. static ExtrudeShape(name: string, options: {
  123465. shape: Vector3[];
  123466. path: Vector3[];
  123467. scale?: number;
  123468. rotation?: number;
  123469. cap?: number;
  123470. updatable?: boolean;
  123471. sideOrientation?: number;
  123472. frontUVs?: Vector4;
  123473. backUVs?: Vector4;
  123474. instance?: Mesh;
  123475. invertUV?: boolean;
  123476. }, scene?: Nullable<Scene>): Mesh;
  123477. /**
  123478. * Creates an custom extruded shape mesh.
  123479. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  123480. * * 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.
  123481. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  123482. * * 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
  123483. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  123484. * * 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
  123485. * * It must returns a float value that will be the scale value applied to the shape on each path point
  123486. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  123487. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  123488. * * 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
  123489. * * 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
  123490. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  123491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123493. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123494. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123495. * @param name defines the name of the mesh
  123496. * @param options defines the options used to create the mesh
  123497. * @param scene defines the hosting scene
  123498. * @returns the custom extruded shape mesh
  123499. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  123500. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123501. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  123502. */
  123503. static ExtrudeShapeCustom(name: string, options: {
  123504. shape: Vector3[];
  123505. path: Vector3[];
  123506. scaleFunction?: any;
  123507. rotationFunction?: any;
  123508. ribbonCloseArray?: boolean;
  123509. ribbonClosePath?: boolean;
  123510. cap?: number;
  123511. updatable?: boolean;
  123512. sideOrientation?: number;
  123513. frontUVs?: Vector4;
  123514. backUVs?: Vector4;
  123515. instance?: Mesh;
  123516. invertUV?: boolean;
  123517. }, scene?: Nullable<Scene>): Mesh;
  123518. /**
  123519. * Creates lathe mesh.
  123520. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  123521. * * 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
  123522. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  123523. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  123524. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  123525. * * 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
  123526. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  123527. * * 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
  123528. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123529. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123530. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123531. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123532. * @param name defines the name of the mesh
  123533. * @param options defines the options used to create the mesh
  123534. * @param scene defines the hosting scene
  123535. * @returns the lathe mesh
  123536. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  123537. */
  123538. static CreateLathe(name: string, options: {
  123539. shape: Vector3[];
  123540. radius?: number;
  123541. tessellation?: number;
  123542. clip?: number;
  123543. arc?: number;
  123544. closed?: boolean;
  123545. updatable?: boolean;
  123546. sideOrientation?: number;
  123547. frontUVs?: Vector4;
  123548. backUVs?: Vector4;
  123549. cap?: number;
  123550. invertUV?: boolean;
  123551. }, scene?: Nullable<Scene>): Mesh;
  123552. /**
  123553. * Creates a tiled plane mesh
  123554. * * You can set a limited pattern arrangement with the tiles
  123555. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123556. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123557. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123558. * @param name defines the name of the mesh
  123559. * @param options defines the options used to create the mesh
  123560. * @param scene defines the hosting scene
  123561. * @returns the plane mesh
  123562. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123563. */
  123564. static CreateTiledPlane(name: string, options: {
  123565. pattern?: number;
  123566. tileSize?: number;
  123567. tileWidth?: number;
  123568. tileHeight?: number;
  123569. size?: number;
  123570. width?: number;
  123571. height?: number;
  123572. alignHorizontal?: number;
  123573. alignVertical?: number;
  123574. sideOrientation?: number;
  123575. frontUVs?: Vector4;
  123576. backUVs?: Vector4;
  123577. updatable?: boolean;
  123578. }, scene?: Nullable<Scene>): Mesh;
  123579. /**
  123580. * Creates a plane mesh
  123581. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  123582. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  123583. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  123584. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123585. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123586. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123587. * @param name defines the name of the mesh
  123588. * @param options defines the options used to create the mesh
  123589. * @param scene defines the hosting scene
  123590. * @returns the plane mesh
  123591. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  123592. */
  123593. static CreatePlane(name: string, options: {
  123594. size?: number;
  123595. width?: number;
  123596. height?: number;
  123597. sideOrientation?: number;
  123598. frontUVs?: Vector4;
  123599. backUVs?: Vector4;
  123600. updatable?: boolean;
  123601. sourcePlane?: Plane;
  123602. }, scene?: Nullable<Scene>): Mesh;
  123603. /**
  123604. * Creates a ground mesh
  123605. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  123606. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  123607. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123608. * @param name defines the name of the mesh
  123609. * @param options defines the options used to create the mesh
  123610. * @param scene defines the hosting scene
  123611. * @returns the ground mesh
  123612. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  123613. */
  123614. static CreateGround(name: string, options: {
  123615. width?: number;
  123616. height?: number;
  123617. subdivisions?: number;
  123618. subdivisionsX?: number;
  123619. subdivisionsY?: number;
  123620. updatable?: boolean;
  123621. }, scene?: Nullable<Scene>): Mesh;
  123622. /**
  123623. * Creates a tiled ground mesh
  123624. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  123625. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  123626. * * 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
  123627. * * 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
  123628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123629. * @param name defines the name of the mesh
  123630. * @param options defines the options used to create the mesh
  123631. * @param scene defines the hosting scene
  123632. * @returns the tiled ground mesh
  123633. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  123634. */
  123635. static CreateTiledGround(name: string, options: {
  123636. xmin: number;
  123637. zmin: number;
  123638. xmax: number;
  123639. zmax: number;
  123640. subdivisions?: {
  123641. w: number;
  123642. h: number;
  123643. };
  123644. precision?: {
  123645. w: number;
  123646. h: number;
  123647. };
  123648. updatable?: boolean;
  123649. }, scene?: Nullable<Scene>): Mesh;
  123650. /**
  123651. * Creates a ground mesh from a height map
  123652. * * The parameter `url` sets the URL of the height map image resource.
  123653. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  123654. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  123655. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  123656. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  123657. * * 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.
  123658. * * 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).
  123659. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  123660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  123661. * @param name defines the name of the mesh
  123662. * @param url defines the url to the height map
  123663. * @param options defines the options used to create the mesh
  123664. * @param scene defines the hosting scene
  123665. * @returns the ground mesh
  123666. * @see https://doc.babylonjs.com/babylon101/height_map
  123667. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  123668. */
  123669. static CreateGroundFromHeightMap(name: string, url: string, options: {
  123670. width?: number;
  123671. height?: number;
  123672. subdivisions?: number;
  123673. minHeight?: number;
  123674. maxHeight?: number;
  123675. colorFilter?: Color3;
  123676. alphaFilter?: number;
  123677. updatable?: boolean;
  123678. onReady?: (mesh: GroundMesh) => void;
  123679. }, scene?: Nullable<Scene>): GroundMesh;
  123680. /**
  123681. * Creates a polygon mesh
  123682. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  123683. * * 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
  123684. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  123685. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123686. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  123687. * * Remember you can only change the shape positions, not their number when updating a polygon
  123688. * @param name defines the name of the mesh
  123689. * @param options defines the options used to create the mesh
  123690. * @param scene defines the hosting scene
  123691. * @param earcutInjection can be used to inject your own earcut reference
  123692. * @returns the polygon mesh
  123693. */
  123694. static CreatePolygon(name: string, options: {
  123695. shape: Vector3[];
  123696. holes?: Vector3[][];
  123697. depth?: number;
  123698. faceUV?: Vector4[];
  123699. faceColors?: Color4[];
  123700. updatable?: boolean;
  123701. sideOrientation?: number;
  123702. frontUVs?: Vector4;
  123703. backUVs?: Vector4;
  123704. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123705. /**
  123706. * Creates an extruded polygon mesh, with depth in the Y direction.
  123707. * * 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)
  123708. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  123709. * @param name defines the name of the mesh
  123710. * @param options defines the options used to create the mesh
  123711. * @param scene defines the hosting scene
  123712. * @param earcutInjection can be used to inject your own earcut reference
  123713. * @returns the polygon mesh
  123714. */
  123715. static ExtrudePolygon(name: string, options: {
  123716. shape: Vector3[];
  123717. holes?: Vector3[][];
  123718. depth?: number;
  123719. faceUV?: Vector4[];
  123720. faceColors?: Color4[];
  123721. updatable?: boolean;
  123722. sideOrientation?: number;
  123723. frontUVs?: Vector4;
  123724. backUVs?: Vector4;
  123725. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  123726. /**
  123727. * Creates a tube mesh.
  123728. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  123729. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  123730. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  123731. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  123732. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  123733. * * 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)
  123734. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  123735. * * 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
  123736. * * 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
  123737. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123738. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123739. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  123740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123741. * @param name defines the name of the mesh
  123742. * @param options defines the options used to create the mesh
  123743. * @param scene defines the hosting scene
  123744. * @returns the tube mesh
  123745. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  123746. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  123747. */
  123748. static CreateTube(name: string, options: {
  123749. path: Vector3[];
  123750. radius?: number;
  123751. tessellation?: number;
  123752. radiusFunction?: {
  123753. (i: number, distance: number): number;
  123754. };
  123755. cap?: number;
  123756. arc?: number;
  123757. updatable?: boolean;
  123758. sideOrientation?: number;
  123759. frontUVs?: Vector4;
  123760. backUVs?: Vector4;
  123761. instance?: Mesh;
  123762. invertUV?: boolean;
  123763. }, scene?: Nullable<Scene>): Mesh;
  123764. /**
  123765. * Creates a polyhedron mesh
  123766. * * 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
  123767. * * The parameter `size` (positive float, default 1) sets the polygon size
  123768. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123769. * * 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`
  123770. * * 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
  123771. * * 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)`)
  123772. * * 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
  123773. * * 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
  123774. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123775. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123776. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123777. * @param name defines the name of the mesh
  123778. * @param options defines the options used to create the mesh
  123779. * @param scene defines the hosting scene
  123780. * @returns the polyhedron mesh
  123781. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123782. */
  123783. static CreatePolyhedron(name: string, options: {
  123784. type?: number;
  123785. size?: number;
  123786. sizeX?: number;
  123787. sizeY?: number;
  123788. sizeZ?: number;
  123789. custom?: any;
  123790. faceUV?: Vector4[];
  123791. faceColors?: Color4[];
  123792. flat?: boolean;
  123793. updatable?: boolean;
  123794. sideOrientation?: number;
  123795. frontUVs?: Vector4;
  123796. backUVs?: Vector4;
  123797. }, scene?: Nullable<Scene>): Mesh;
  123798. /**
  123799. * Creates a decal mesh.
  123800. * 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
  123801. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  123802. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  123803. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  123804. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  123805. * @param name defines the name of the mesh
  123806. * @param sourceMesh defines the mesh where the decal must be applied
  123807. * @param options defines the options used to create the mesh
  123808. * @param scene defines the hosting scene
  123809. * @returns the decal mesh
  123810. * @see https://doc.babylonjs.com/how_to/decals
  123811. */
  123812. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  123813. position?: Vector3;
  123814. normal?: Vector3;
  123815. size?: Vector3;
  123816. angle?: number;
  123817. }): Mesh;
  123818. }
  123819. }
  123820. declare module BABYLON {
  123821. /**
  123822. * A simplifier interface for future simplification implementations
  123823. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123824. */
  123825. export interface ISimplifier {
  123826. /**
  123827. * Simplification of a given mesh according to the given settings.
  123828. * Since this requires computation, it is assumed that the function runs async.
  123829. * @param settings The settings of the simplification, including quality and distance
  123830. * @param successCallback A callback that will be called after the mesh was simplified.
  123831. * @param errorCallback in case of an error, this callback will be called. optional.
  123832. */
  123833. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  123834. }
  123835. /**
  123836. * Expected simplification settings.
  123837. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  123838. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123839. */
  123840. export interface ISimplificationSettings {
  123841. /**
  123842. * Gets or sets the expected quality
  123843. */
  123844. quality: number;
  123845. /**
  123846. * Gets or sets the distance when this optimized version should be used
  123847. */
  123848. distance: number;
  123849. /**
  123850. * Gets an already optimized mesh
  123851. */
  123852. optimizeMesh?: boolean;
  123853. }
  123854. /**
  123855. * Class used to specify simplification options
  123856. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123857. */
  123858. export class SimplificationSettings implements ISimplificationSettings {
  123859. /** expected quality */
  123860. quality: number;
  123861. /** distance when this optimized version should be used */
  123862. distance: number;
  123863. /** already optimized mesh */
  123864. optimizeMesh?: boolean | undefined;
  123865. /**
  123866. * Creates a SimplificationSettings
  123867. * @param quality expected quality
  123868. * @param distance distance when this optimized version should be used
  123869. * @param optimizeMesh already optimized mesh
  123870. */
  123871. constructor(
  123872. /** expected quality */
  123873. quality: number,
  123874. /** distance when this optimized version should be used */
  123875. distance: number,
  123876. /** already optimized mesh */
  123877. optimizeMesh?: boolean | undefined);
  123878. }
  123879. /**
  123880. * Interface used to define a simplification task
  123881. */
  123882. export interface ISimplificationTask {
  123883. /**
  123884. * Array of settings
  123885. */
  123886. settings: Array<ISimplificationSettings>;
  123887. /**
  123888. * Simplification type
  123889. */
  123890. simplificationType: SimplificationType;
  123891. /**
  123892. * Mesh to simplify
  123893. */
  123894. mesh: Mesh;
  123895. /**
  123896. * Callback called on success
  123897. */
  123898. successCallback?: () => void;
  123899. /**
  123900. * Defines if parallel processing can be used
  123901. */
  123902. parallelProcessing: boolean;
  123903. }
  123904. /**
  123905. * Queue used to order the simplification tasks
  123906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123907. */
  123908. export class SimplificationQueue {
  123909. private _simplificationArray;
  123910. /**
  123911. * Gets a boolean indicating that the process is still running
  123912. */
  123913. running: boolean;
  123914. /**
  123915. * Creates a new queue
  123916. */
  123917. constructor();
  123918. /**
  123919. * Adds a new simplification task
  123920. * @param task defines a task to add
  123921. */
  123922. addTask(task: ISimplificationTask): void;
  123923. /**
  123924. * Execute next task
  123925. */
  123926. executeNext(): void;
  123927. /**
  123928. * Execute a simplification task
  123929. * @param task defines the task to run
  123930. */
  123931. runSimplification(task: ISimplificationTask): void;
  123932. private getSimplifier;
  123933. }
  123934. /**
  123935. * The implemented types of simplification
  123936. * At the moment only Quadratic Error Decimation is implemented
  123937. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123938. */
  123939. export enum SimplificationType {
  123940. /** Quadratic error decimation */
  123941. QUADRATIC = 0
  123942. }
  123943. }
  123944. declare module BABYLON {
  123945. interface Scene {
  123946. /** @hidden (Backing field) */
  123947. _simplificationQueue: SimplificationQueue;
  123948. /**
  123949. * Gets or sets the simplification queue attached to the scene
  123950. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  123951. */
  123952. simplificationQueue: SimplificationQueue;
  123953. }
  123954. interface Mesh {
  123955. /**
  123956. * Simplify the mesh according to the given array of settings.
  123957. * Function will return immediately and will simplify async
  123958. * @param settings a collection of simplification settings
  123959. * @param parallelProcessing should all levels calculate parallel or one after the other
  123960. * @param simplificationType the type of simplification to run
  123961. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  123962. * @returns the current mesh
  123963. */
  123964. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  123965. }
  123966. /**
  123967. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  123968. * created in a scene
  123969. */
  123970. export class SimplicationQueueSceneComponent implements ISceneComponent {
  123971. /**
  123972. * The component name helpfull 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 _beforeCameraUpdate;
  123998. }
  123999. }
  124000. declare module BABYLON {
  124001. /**
  124002. * Navigation plugin interface to add navigation constrained by a navigation mesh
  124003. */
  124004. export interface INavigationEnginePlugin {
  124005. /**
  124006. * plugin name
  124007. */
  124008. name: string;
  124009. /**
  124010. * Creates a navigation mesh
  124011. * @param meshes array of all the geometry used to compute the navigatio mesh
  124012. * @param parameters bunch of parameters used to filter geometry
  124013. */
  124014. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124015. /**
  124016. * Create a navigation mesh debug mesh
  124017. * @param scene is where the mesh will be added
  124018. * @returns debug display mesh
  124019. */
  124020. createDebugNavMesh(scene: Scene): Mesh;
  124021. /**
  124022. * Get a navigation mesh constrained position, closest to the parameter position
  124023. * @param position world position
  124024. * @returns the closest point to position constrained by the navigation mesh
  124025. */
  124026. getClosestPoint(position: Vector3): Vector3;
  124027. /**
  124028. * Get a navigation mesh constrained position, within a particular radius
  124029. * @param position world position
  124030. * @param maxRadius the maximum distance to the constrained world position
  124031. * @returns the closest point to position constrained by the navigation mesh
  124032. */
  124033. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124034. /**
  124035. * Compute the final position from a segment made of destination-position
  124036. * @param position world position
  124037. * @param destination world position
  124038. * @returns the resulting point along the navmesh
  124039. */
  124040. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124041. /**
  124042. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124043. * @param start world position
  124044. * @param end world position
  124045. * @returns array containing world position composing the path
  124046. */
  124047. computePath(start: Vector3, end: Vector3): Vector3[];
  124048. /**
  124049. * If this plugin is supported
  124050. * @returns true if plugin is supported
  124051. */
  124052. isSupported(): boolean;
  124053. /**
  124054. * Create a new Crowd so you can add agents
  124055. * @param maxAgents the maximum agent count in the crowd
  124056. * @param maxAgentRadius the maximum radius an agent can have
  124057. * @param scene to attach the crowd to
  124058. * @returns the crowd you can add agents to
  124059. */
  124060. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124061. /**
  124062. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124063. * The queries will try to find a solution within those bounds
  124064. * default is (1,1,1)
  124065. * @param extent x,y,z value that define the extent around the queries point of reference
  124066. */
  124067. setDefaultQueryExtent(extent: Vector3): void;
  124068. /**
  124069. * Get the Bounding box extent specified by setDefaultQueryExtent
  124070. * @returns the box extent values
  124071. */
  124072. getDefaultQueryExtent(): Vector3;
  124073. /**
  124074. * Release all resources
  124075. */
  124076. dispose(): void;
  124077. }
  124078. /**
  124079. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  124080. */
  124081. export interface ICrowd {
  124082. /**
  124083. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124084. * You can attach anything to that node. The node position is updated in the scene update tick.
  124085. * @param pos world position that will be constrained by the navigation mesh
  124086. * @param parameters agent parameters
  124087. * @param transform hooked to the agent that will be update by the scene
  124088. * @returns agent index
  124089. */
  124090. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124091. /**
  124092. * Returns the agent position in world space
  124093. * @param index agent index returned by addAgent
  124094. * @returns world space position
  124095. */
  124096. getAgentPosition(index: number): Vector3;
  124097. /**
  124098. * Gets the agent velocity in world space
  124099. * @param index agent index returned by addAgent
  124100. * @returns world space velocity
  124101. */
  124102. getAgentVelocity(index: number): Vector3;
  124103. /**
  124104. * remove a particular agent previously created
  124105. * @param index agent index returned by addAgent
  124106. */
  124107. removeAgent(index: number): void;
  124108. /**
  124109. * get the list of all agents attached to this crowd
  124110. * @returns list of agent indices
  124111. */
  124112. getAgents(): number[];
  124113. /**
  124114. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124115. * @param deltaTime in seconds
  124116. */
  124117. update(deltaTime: number): void;
  124118. /**
  124119. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124120. * @param index agent index returned by addAgent
  124121. * @param destination targeted world position
  124122. */
  124123. agentGoto(index: number, destination: Vector3): void;
  124124. /**
  124125. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124126. * The queries will try to find a solution within those bounds
  124127. * default is (1,1,1)
  124128. * @param extent x,y,z value that define the extent around the queries point of reference
  124129. */
  124130. setDefaultQueryExtent(extent: Vector3): void;
  124131. /**
  124132. * Get the Bounding box extent specified by setDefaultQueryExtent
  124133. * @returns the box extent values
  124134. */
  124135. getDefaultQueryExtent(): Vector3;
  124136. /**
  124137. * Release all resources
  124138. */
  124139. dispose(): void;
  124140. }
  124141. /**
  124142. * Configures an agent
  124143. */
  124144. export interface IAgentParameters {
  124145. /**
  124146. * Agent radius. [Limit: >= 0]
  124147. */
  124148. radius: number;
  124149. /**
  124150. * Agent height. [Limit: > 0]
  124151. */
  124152. height: number;
  124153. /**
  124154. * Maximum allowed acceleration. [Limit: >= 0]
  124155. */
  124156. maxAcceleration: number;
  124157. /**
  124158. * Maximum allowed speed. [Limit: >= 0]
  124159. */
  124160. maxSpeed: number;
  124161. /**
  124162. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  124163. */
  124164. collisionQueryRange: number;
  124165. /**
  124166. * The path visibility optimization range. [Limit: > 0]
  124167. */
  124168. pathOptimizationRange: number;
  124169. /**
  124170. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  124171. */
  124172. separationWeight: number;
  124173. }
  124174. /**
  124175. * Configures the navigation mesh creation
  124176. */
  124177. export interface INavMeshParameters {
  124178. /**
  124179. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  124180. */
  124181. cs: number;
  124182. /**
  124183. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  124184. */
  124185. ch: number;
  124186. /**
  124187. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  124188. */
  124189. walkableSlopeAngle: number;
  124190. /**
  124191. * Minimum floor to 'ceiling' height that will still allow the floor area to
  124192. * be considered walkable. [Limit: >= 3] [Units: vx]
  124193. */
  124194. walkableHeight: number;
  124195. /**
  124196. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  124197. */
  124198. walkableClimb: number;
  124199. /**
  124200. * The distance to erode/shrink the walkable area of the heightfield away from
  124201. * obstructions. [Limit: >=0] [Units: vx]
  124202. */
  124203. walkableRadius: number;
  124204. /**
  124205. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  124206. */
  124207. maxEdgeLen: number;
  124208. /**
  124209. * The maximum distance a simplfied contour's border edges should deviate
  124210. * the original raw contour. [Limit: >=0] [Units: vx]
  124211. */
  124212. maxSimplificationError: number;
  124213. /**
  124214. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  124215. */
  124216. minRegionArea: number;
  124217. /**
  124218. * Any regions with a span count smaller than this value will, if possible,
  124219. * be merged with larger regions. [Limit: >=0] [Units: vx]
  124220. */
  124221. mergeRegionArea: number;
  124222. /**
  124223. * The maximum number of vertices allowed for polygons generated during the
  124224. * contour to polygon conversion process. [Limit: >= 3]
  124225. */
  124226. maxVertsPerPoly: number;
  124227. /**
  124228. * Sets the sampling distance to use when generating the detail mesh.
  124229. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  124230. */
  124231. detailSampleDist: number;
  124232. /**
  124233. * The maximum distance the detail mesh surface should deviate from heightfield
  124234. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  124235. */
  124236. detailSampleMaxError: number;
  124237. }
  124238. }
  124239. declare module BABYLON {
  124240. /**
  124241. * RecastJS navigation plugin
  124242. */
  124243. export class RecastJSPlugin implements INavigationEnginePlugin {
  124244. /**
  124245. * Reference to the Recast library
  124246. */
  124247. bjsRECAST: any;
  124248. /**
  124249. * plugin name
  124250. */
  124251. name: string;
  124252. /**
  124253. * the first navmesh created. We might extend this to support multiple navmeshes
  124254. */
  124255. navMesh: any;
  124256. /**
  124257. * Initializes the recastJS plugin
  124258. * @param recastInjection can be used to inject your own recast reference
  124259. */
  124260. constructor(recastInjection?: any);
  124261. /**
  124262. * Creates a navigation mesh
  124263. * @param meshes array of all the geometry used to compute the navigatio mesh
  124264. * @param parameters bunch of parameters used to filter geometry
  124265. */
  124266. createMavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  124267. /**
  124268. * Create a navigation mesh debug mesh
  124269. * @param scene is where the mesh will be added
  124270. * @returns debug display mesh
  124271. */
  124272. createDebugNavMesh(scene: Scene): Mesh;
  124273. /**
  124274. * Get a navigation mesh constrained position, closest to the parameter position
  124275. * @param position world position
  124276. * @returns the closest point to position constrained by the navigation mesh
  124277. */
  124278. getClosestPoint(position: Vector3): Vector3;
  124279. /**
  124280. * Get a navigation mesh constrained position, within a particular radius
  124281. * @param position world position
  124282. * @param maxRadius the maximum distance to the constrained world position
  124283. * @returns the closest point to position constrained by the navigation mesh
  124284. */
  124285. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  124286. /**
  124287. * Compute the final position from a segment made of destination-position
  124288. * @param position world position
  124289. * @param destination world position
  124290. * @returns the resulting point along the navmesh
  124291. */
  124292. moveAlong(position: Vector3, destination: Vector3): Vector3;
  124293. /**
  124294. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  124295. * @param start world position
  124296. * @param end world position
  124297. * @returns array containing world position composing the path
  124298. */
  124299. computePath(start: Vector3, end: Vector3): Vector3[];
  124300. /**
  124301. * Create a new Crowd so you can add agents
  124302. * @param maxAgents the maximum agent count in the crowd
  124303. * @param maxAgentRadius the maximum radius an agent can have
  124304. * @param scene to attach the crowd to
  124305. * @returns the crowd you can add agents to
  124306. */
  124307. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  124308. /**
  124309. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124310. * The queries will try to find a solution within those bounds
  124311. * default is (1,1,1)
  124312. * @param extent x,y,z value that define the extent around the queries point of reference
  124313. */
  124314. setDefaultQueryExtent(extent: Vector3): void;
  124315. /**
  124316. * Get the Bounding box extent specified by setDefaultQueryExtent
  124317. * @returns the box extent values
  124318. */
  124319. getDefaultQueryExtent(): Vector3;
  124320. /**
  124321. * Disposes
  124322. */
  124323. dispose(): void;
  124324. /**
  124325. * If this plugin is supported
  124326. * @returns true if plugin is supported
  124327. */
  124328. isSupported(): boolean;
  124329. }
  124330. /**
  124331. * Recast detour crowd implementation
  124332. */
  124333. export class RecastJSCrowd implements ICrowd {
  124334. /**
  124335. * Recast/detour plugin
  124336. */
  124337. bjsRECASTPlugin: RecastJSPlugin;
  124338. /**
  124339. * Link to the detour crowd
  124340. */
  124341. recastCrowd: any;
  124342. /**
  124343. * One transform per agent
  124344. */
  124345. transforms: TransformNode[];
  124346. /**
  124347. * All agents created
  124348. */
  124349. agents: number[];
  124350. /**
  124351. * Link to the scene is kept to unregister the crowd from the scene
  124352. */
  124353. private _scene;
  124354. /**
  124355. * Observer for crowd updates
  124356. */
  124357. private _onBeforeAnimationsObserver;
  124358. /**
  124359. * Constructor
  124360. * @param plugin recastJS plugin
  124361. * @param maxAgents the maximum agent count in the crowd
  124362. * @param maxAgentRadius the maximum radius an agent can have
  124363. * @param scene to attach the crowd to
  124364. * @returns the crowd you can add agents to
  124365. */
  124366. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  124367. /**
  124368. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  124369. * You can attach anything to that node. The node position is updated in the scene update tick.
  124370. * @param pos world position that will be constrained by the navigation mesh
  124371. * @param parameters agent parameters
  124372. * @param transform hooked to the agent that will be update by the scene
  124373. * @returns agent index
  124374. */
  124375. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  124376. /**
  124377. * Returns the agent position in world space
  124378. * @param index agent index returned by addAgent
  124379. * @returns world space position
  124380. */
  124381. getAgentPosition(index: number): Vector3;
  124382. /**
  124383. * Returns the agent velocity in world space
  124384. * @param index agent index returned by addAgent
  124385. * @returns world space velocity
  124386. */
  124387. getAgentVelocity(index: number): Vector3;
  124388. /**
  124389. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  124390. * @param index agent index returned by addAgent
  124391. * @param destination targeted world position
  124392. */
  124393. agentGoto(index: number, destination: Vector3): void;
  124394. /**
  124395. * remove a particular agent previously created
  124396. * @param index agent index returned by addAgent
  124397. */
  124398. removeAgent(index: number): void;
  124399. /**
  124400. * get the list of all agents attached to this crowd
  124401. * @returns list of agent indices
  124402. */
  124403. getAgents(): number[];
  124404. /**
  124405. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  124406. * @param deltaTime in seconds
  124407. */
  124408. update(deltaTime: number): void;
  124409. /**
  124410. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  124411. * The queries will try to find a solution within those bounds
  124412. * default is (1,1,1)
  124413. * @param extent x,y,z value that define the extent around the queries point of reference
  124414. */
  124415. setDefaultQueryExtent(extent: Vector3): void;
  124416. /**
  124417. * Get the Bounding box extent specified by setDefaultQueryExtent
  124418. * @returns the box extent values
  124419. */
  124420. getDefaultQueryExtent(): Vector3;
  124421. /**
  124422. * Release all resources
  124423. */
  124424. dispose(): void;
  124425. }
  124426. }
  124427. declare module BABYLON {
  124428. /**
  124429. * Class used to enable access to IndexedDB
  124430. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  124431. */
  124432. export class Database implements IOfflineProvider {
  124433. private _callbackManifestChecked;
  124434. private _currentSceneUrl;
  124435. private _db;
  124436. private _enableSceneOffline;
  124437. private _enableTexturesOffline;
  124438. private _manifestVersionFound;
  124439. private _mustUpdateRessources;
  124440. private _hasReachedQuota;
  124441. private _isSupported;
  124442. private _idbFactory;
  124443. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  124444. private static IsUASupportingBlobStorage;
  124445. /**
  124446. * Gets a boolean indicating if Database storate is enabled (off by default)
  124447. */
  124448. static IDBStorageEnabled: boolean;
  124449. /**
  124450. * Gets a boolean indicating if scene must be saved in the database
  124451. */
  124452. readonly enableSceneOffline: boolean;
  124453. /**
  124454. * Gets a boolean indicating if textures must be saved in the database
  124455. */
  124456. readonly enableTexturesOffline: boolean;
  124457. /**
  124458. * Creates a new Database
  124459. * @param urlToScene defines the url to load the scene
  124460. * @param callbackManifestChecked defines the callback to use when manifest is checked
  124461. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  124462. */
  124463. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  124464. private static _ParseURL;
  124465. private static _ReturnFullUrlLocation;
  124466. private _checkManifestFile;
  124467. /**
  124468. * Open the database and make it available
  124469. * @param successCallback defines the callback to call on success
  124470. * @param errorCallback defines the callback to call on error
  124471. */
  124472. open(successCallback: () => void, errorCallback: () => void): void;
  124473. /**
  124474. * Loads an image from the database
  124475. * @param url defines the url to load from
  124476. * @param image defines the target DOM image
  124477. */
  124478. loadImage(url: string, image: HTMLImageElement): void;
  124479. private _loadImageFromDBAsync;
  124480. private _saveImageIntoDBAsync;
  124481. private _checkVersionFromDB;
  124482. private _loadVersionFromDBAsync;
  124483. private _saveVersionIntoDBAsync;
  124484. /**
  124485. * Loads a file from database
  124486. * @param url defines the URL to load from
  124487. * @param sceneLoaded defines a callback to call on success
  124488. * @param progressCallBack defines a callback to call when progress changed
  124489. * @param errorCallback defines a callback to call on error
  124490. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  124491. */
  124492. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  124493. private _loadFileAsync;
  124494. private _saveFileAsync;
  124495. /**
  124496. * Validates if xhr data is correct
  124497. * @param xhr defines the request to validate
  124498. * @param dataType defines the expected data type
  124499. * @returns true if data is correct
  124500. */
  124501. private static _ValidateXHRData;
  124502. }
  124503. }
  124504. declare module BABYLON {
  124505. /** @hidden */
  124506. export var gpuUpdateParticlesPixelShader: {
  124507. name: string;
  124508. shader: string;
  124509. };
  124510. }
  124511. declare module BABYLON {
  124512. /** @hidden */
  124513. export var gpuUpdateParticlesVertexShader: {
  124514. name: string;
  124515. shader: string;
  124516. };
  124517. }
  124518. declare module BABYLON {
  124519. /** @hidden */
  124520. export var clipPlaneFragmentDeclaration2: {
  124521. name: string;
  124522. shader: string;
  124523. };
  124524. }
  124525. declare module BABYLON {
  124526. /** @hidden */
  124527. export var gpuRenderParticlesPixelShader: {
  124528. name: string;
  124529. shader: string;
  124530. };
  124531. }
  124532. declare module BABYLON {
  124533. /** @hidden */
  124534. export var clipPlaneVertexDeclaration2: {
  124535. name: string;
  124536. shader: string;
  124537. };
  124538. }
  124539. declare module BABYLON {
  124540. /** @hidden */
  124541. export var gpuRenderParticlesVertexShader: {
  124542. name: string;
  124543. shader: string;
  124544. };
  124545. }
  124546. declare module BABYLON {
  124547. /**
  124548. * This represents a GPU particle system in Babylon
  124549. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  124550. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  124551. */
  124552. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  124553. /**
  124554. * The layer mask we are rendering the particles through.
  124555. */
  124556. layerMask: number;
  124557. private _capacity;
  124558. private _activeCount;
  124559. private _currentActiveCount;
  124560. private _accumulatedCount;
  124561. private _renderEffect;
  124562. private _updateEffect;
  124563. private _buffer0;
  124564. private _buffer1;
  124565. private _spriteBuffer;
  124566. private _updateVAO;
  124567. private _renderVAO;
  124568. private _targetIndex;
  124569. private _sourceBuffer;
  124570. private _targetBuffer;
  124571. private _engine;
  124572. private _currentRenderId;
  124573. private _started;
  124574. private _stopped;
  124575. private _timeDelta;
  124576. private _randomTexture;
  124577. private _randomTexture2;
  124578. private _attributesStrideSize;
  124579. private _updateEffectOptions;
  124580. private _randomTextureSize;
  124581. private _actualFrame;
  124582. private readonly _rawTextureWidth;
  124583. /**
  124584. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  124585. */
  124586. static readonly IsSupported: boolean;
  124587. /**
  124588. * An event triggered when the system is disposed.
  124589. */
  124590. onDisposeObservable: Observable<GPUParticleSystem>;
  124591. /**
  124592. * Gets the maximum number of particles active at the same time.
  124593. * @returns The max number of active particles.
  124594. */
  124595. getCapacity(): number;
  124596. /**
  124597. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  124598. * to override the particles.
  124599. */
  124600. forceDepthWrite: boolean;
  124601. /**
  124602. * Gets or set the number of active particles
  124603. */
  124604. activeParticleCount: number;
  124605. private _preWarmDone;
  124606. /**
  124607. * Is this system ready to be used/rendered
  124608. * @return true if the system is ready
  124609. */
  124610. isReady(): boolean;
  124611. /**
  124612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  124613. * @returns True if it has been started, otherwise false.
  124614. */
  124615. isStarted(): boolean;
  124616. /**
  124617. * Starts the particle system and begins to emit
  124618. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  124619. */
  124620. start(delay?: number): void;
  124621. /**
  124622. * Stops the particle system.
  124623. */
  124624. stop(): void;
  124625. /**
  124626. * Remove all active particles
  124627. */
  124628. reset(): void;
  124629. /**
  124630. * Returns the string "GPUParticleSystem"
  124631. * @returns a string containing the class name
  124632. */
  124633. getClassName(): string;
  124634. private _colorGradientsTexture;
  124635. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  124636. /**
  124637. * Adds a new color gradient
  124638. * @param gradient defines the gradient to use (between 0 and 1)
  124639. * @param color1 defines the color to affect to the specified gradient
  124640. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  124641. * @returns the current particle system
  124642. */
  124643. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  124644. /**
  124645. * Remove a specific color gradient
  124646. * @param gradient defines the gradient to remove
  124647. * @returns the current particle system
  124648. */
  124649. removeColorGradient(gradient: number): GPUParticleSystem;
  124650. private _angularSpeedGradientsTexture;
  124651. private _sizeGradientsTexture;
  124652. private _velocityGradientsTexture;
  124653. private _limitVelocityGradientsTexture;
  124654. private _dragGradientsTexture;
  124655. private _addFactorGradient;
  124656. /**
  124657. * Adds a new size gradient
  124658. * @param gradient defines the gradient to use (between 0 and 1)
  124659. * @param factor defines the size factor to affect to the specified gradient
  124660. * @returns the current particle system
  124661. */
  124662. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  124663. /**
  124664. * Remove a specific size gradient
  124665. * @param gradient defines the gradient to remove
  124666. * @returns the current particle system
  124667. */
  124668. removeSizeGradient(gradient: number): GPUParticleSystem;
  124669. /**
  124670. * Adds a new angular speed gradient
  124671. * @param gradient defines the gradient to use (between 0 and 1)
  124672. * @param factor defines the angular speed to affect to the specified gradient
  124673. * @returns the current particle system
  124674. */
  124675. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  124676. /**
  124677. * Remove a specific angular speed gradient
  124678. * @param gradient defines the gradient to remove
  124679. * @returns the current particle system
  124680. */
  124681. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  124682. /**
  124683. * Adds a new velocity gradient
  124684. * @param gradient defines the gradient to use (between 0 and 1)
  124685. * @param factor defines the velocity to affect to the specified gradient
  124686. * @returns the current particle system
  124687. */
  124688. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124689. /**
  124690. * Remove a specific velocity gradient
  124691. * @param gradient defines the gradient to remove
  124692. * @returns the current particle system
  124693. */
  124694. removeVelocityGradient(gradient: number): GPUParticleSystem;
  124695. /**
  124696. * Adds a new limit velocity gradient
  124697. * @param gradient defines the gradient to use (between 0 and 1)
  124698. * @param factor defines the limit velocity value to affect to the specified gradient
  124699. * @returns the current particle system
  124700. */
  124701. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  124702. /**
  124703. * Remove a specific limit velocity gradient
  124704. * @param gradient defines the gradient to remove
  124705. * @returns the current particle system
  124706. */
  124707. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  124708. /**
  124709. * Adds a new drag gradient
  124710. * @param gradient defines the gradient to use (between 0 and 1)
  124711. * @param factor defines the drag value to affect to the specified gradient
  124712. * @returns the current particle system
  124713. */
  124714. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  124715. /**
  124716. * Remove a specific drag gradient
  124717. * @param gradient defines the gradient to remove
  124718. * @returns the current particle system
  124719. */
  124720. removeDragGradient(gradient: number): GPUParticleSystem;
  124721. /**
  124722. * Not supported by GPUParticleSystem
  124723. * @param gradient defines the gradient to use (between 0 and 1)
  124724. * @param factor defines the emit rate value to affect to the specified gradient
  124725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124726. * @returns the current particle system
  124727. */
  124728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124729. /**
  124730. * Not supported by GPUParticleSystem
  124731. * @param gradient defines the gradient to remove
  124732. * @returns the current particle system
  124733. */
  124734. removeEmitRateGradient(gradient: number): IParticleSystem;
  124735. /**
  124736. * Not supported by GPUParticleSystem
  124737. * @param gradient defines the gradient to use (between 0 and 1)
  124738. * @param factor defines the start size value to affect to the specified gradient
  124739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124740. * @returns the current particle system
  124741. */
  124742. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124743. /**
  124744. * Not supported by GPUParticleSystem
  124745. * @param gradient defines the gradient to remove
  124746. * @returns the current particle system
  124747. */
  124748. removeStartSizeGradient(gradient: number): IParticleSystem;
  124749. /**
  124750. * Not supported by GPUParticleSystem
  124751. * @param gradient defines the gradient to use (between 0 and 1)
  124752. * @param min defines the color remap minimal range
  124753. * @param max defines the color remap maximal range
  124754. * @returns the current particle system
  124755. */
  124756. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124757. /**
  124758. * Not supported by GPUParticleSystem
  124759. * @param gradient defines the gradient to remove
  124760. * @returns the current particle system
  124761. */
  124762. removeColorRemapGradient(): IParticleSystem;
  124763. /**
  124764. * Not supported by GPUParticleSystem
  124765. * @param gradient defines the gradient to use (between 0 and 1)
  124766. * @param min defines the alpha remap minimal range
  124767. * @param max defines the alpha remap maximal range
  124768. * @returns the current particle system
  124769. */
  124770. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  124771. /**
  124772. * Not supported by GPUParticleSystem
  124773. * @param gradient defines the gradient to remove
  124774. * @returns the current particle system
  124775. */
  124776. removeAlphaRemapGradient(): IParticleSystem;
  124777. /**
  124778. * Not supported by GPUParticleSystem
  124779. * @param gradient defines the gradient to use (between 0 and 1)
  124780. * @param color defines the color to affect to the specified gradient
  124781. * @returns the current particle system
  124782. */
  124783. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  124784. /**
  124785. * Not supported by GPUParticleSystem
  124786. * @param gradient defines the gradient to remove
  124787. * @returns the current particle system
  124788. */
  124789. removeRampGradient(): IParticleSystem;
  124790. /**
  124791. * Not supported by GPUParticleSystem
  124792. * @returns the list of ramp gradients
  124793. */
  124794. getRampGradients(): Nullable<Array<Color3Gradient>>;
  124795. /**
  124796. * Not supported by GPUParticleSystem
  124797. * Gets or sets a boolean indicating that ramp gradients must be used
  124798. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  124799. */
  124800. useRampGradients: boolean;
  124801. /**
  124802. * Not supported by GPUParticleSystem
  124803. * @param gradient defines the gradient to use (between 0 and 1)
  124804. * @param factor defines the life time factor to affect to the specified gradient
  124805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  124806. * @returns the current particle system
  124807. */
  124808. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  124809. /**
  124810. * Not supported by GPUParticleSystem
  124811. * @param gradient defines the gradient to remove
  124812. * @returns the current particle system
  124813. */
  124814. removeLifeTimeGradient(gradient: number): IParticleSystem;
  124815. /**
  124816. * Instantiates a GPU particle system.
  124817. * 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.
  124818. * @param name The name of the particle system
  124819. * @param options The options used to create the system
  124820. * @param scene The scene the particle system belongs to
  124821. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  124822. */
  124823. constructor(name: string, options: Partial<{
  124824. capacity: number;
  124825. randomTextureSize: number;
  124826. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  124827. protected _reset(): void;
  124828. private _createUpdateVAO;
  124829. private _createRenderVAO;
  124830. private _initialize;
  124831. /** @hidden */
  124832. _recreateUpdateEffect(): void;
  124833. /** @hidden */
  124834. _recreateRenderEffect(): void;
  124835. /**
  124836. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  124837. * @param preWarm defines if we are in the pre-warmimg phase
  124838. */
  124839. animate(preWarm?: boolean): void;
  124840. private _createFactorGradientTexture;
  124841. private _createSizeGradientTexture;
  124842. private _createAngularSpeedGradientTexture;
  124843. private _createVelocityGradientTexture;
  124844. private _createLimitVelocityGradientTexture;
  124845. private _createDragGradientTexture;
  124846. private _createColorGradientTexture;
  124847. /**
  124848. * Renders the particle system in its current state
  124849. * @param preWarm defines if the system should only update the particles but not render them
  124850. * @returns the current number of particles
  124851. */
  124852. render(preWarm?: boolean): number;
  124853. /**
  124854. * Rebuilds the particle system
  124855. */
  124856. rebuild(): void;
  124857. private _releaseBuffers;
  124858. private _releaseVAOs;
  124859. /**
  124860. * Disposes the particle system and free the associated resources
  124861. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  124862. */
  124863. dispose(disposeTexture?: boolean): void;
  124864. /**
  124865. * Clones the particle system.
  124866. * @param name The name of the cloned object
  124867. * @param newEmitter The new emitter to use
  124868. * @returns the cloned particle system
  124869. */
  124870. clone(name: string, newEmitter: any): GPUParticleSystem;
  124871. /**
  124872. * Serializes the particle system to a JSON object.
  124873. * @returns the JSON object
  124874. */
  124875. serialize(): any;
  124876. /**
  124877. * Parses a JSON object to create a GPU particle system.
  124878. * @param parsedParticleSystem The JSON object to parse
  124879. * @param scene The scene to create the particle system in
  124880. * @param rootUrl The root url to use to load external dependencies like texture
  124881. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  124882. * @returns the parsed GPU particle system
  124883. */
  124884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  124885. }
  124886. }
  124887. declare module BABYLON {
  124888. /**
  124889. * Represents a set of particle systems working together to create a specific effect
  124890. */
  124891. export class ParticleSystemSet implements IDisposable {
  124892. private _emitterCreationOptions;
  124893. private _emitterNode;
  124894. /**
  124895. * Gets the particle system list
  124896. */
  124897. systems: IParticleSystem[];
  124898. /**
  124899. * Gets the emitter node used with this set
  124900. */
  124901. readonly emitterNode: Nullable<TransformNode>;
  124902. /**
  124903. * Creates a new emitter mesh as a sphere
  124904. * @param options defines the options used to create the sphere
  124905. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  124906. * @param scene defines the hosting scene
  124907. */
  124908. setEmitterAsSphere(options: {
  124909. diameter: number;
  124910. segments: number;
  124911. color: Color3;
  124912. }, renderingGroupId: number, scene: Scene): void;
  124913. /**
  124914. * Starts all particle systems of the set
  124915. * @param emitter defines an optional mesh to use as emitter for the particle systems
  124916. */
  124917. start(emitter?: AbstractMesh): void;
  124918. /**
  124919. * Release all associated resources
  124920. */
  124921. dispose(): void;
  124922. /**
  124923. * Serialize the set into a JSON compatible object
  124924. * @returns a JSON compatible representation of the set
  124925. */
  124926. serialize(): any;
  124927. /**
  124928. * Parse a new ParticleSystemSet from a serialized source
  124929. * @param data defines a JSON compatible representation of the set
  124930. * @param scene defines the hosting scene
  124931. * @param gpu defines if we want GPU particles or CPU particles
  124932. * @returns a new ParticleSystemSet
  124933. */
  124934. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  124935. }
  124936. }
  124937. declare module BABYLON {
  124938. /**
  124939. * This class is made for on one-liner static method to help creating particle system set.
  124940. */
  124941. export class ParticleHelper {
  124942. /**
  124943. * Gets or sets base Assets URL
  124944. */
  124945. static BaseAssetsUrl: string;
  124946. /**
  124947. * Create a default particle system that you can tweak
  124948. * @param emitter defines the emitter to use
  124949. * @param capacity defines the system capacity (default is 500 particles)
  124950. * @param scene defines the hosting scene
  124951. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  124952. * @returns the new Particle system
  124953. */
  124954. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  124955. /**
  124956. * This is the main static method (one-liner) of this helper to create different particle systems
  124957. * @param type This string represents the type to the particle system to create
  124958. * @param scene The scene where the particle system should live
  124959. * @param gpu If the system will use gpu
  124960. * @returns the ParticleSystemSet created
  124961. */
  124962. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  124963. /**
  124964. * Static function used to export a particle system to a ParticleSystemSet variable.
  124965. * Please note that the emitter shape is not exported
  124966. * @param systems defines the particle systems to export
  124967. * @returns the created particle system set
  124968. */
  124969. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  124970. }
  124971. }
  124972. declare module BABYLON {
  124973. interface Engine {
  124974. /**
  124975. * Create an effect to use with particle systems.
  124976. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  124977. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  124978. * @param uniformsNames defines a list of attribute names
  124979. * @param samplers defines an array of string used to represent textures
  124980. * @param defines defines the string containing the defines to use to compile the shaders
  124981. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  124982. * @param onCompiled defines a function to call when the effect creation is successful
  124983. * @param onError defines a function to call when the effect creation has failed
  124984. * @returns the new Effect
  124985. */
  124986. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  124987. }
  124988. interface Mesh {
  124989. /**
  124990. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  124991. * @returns an array of IParticleSystem
  124992. */
  124993. getEmittedParticleSystems(): IParticleSystem[];
  124994. /**
  124995. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  124996. * @returns an array of IParticleSystem
  124997. */
  124998. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  124999. }
  125000. /**
  125001. * @hidden
  125002. */
  125003. export var _IDoNeedToBeInTheBuild: number;
  125004. }
  125005. declare module BABYLON {
  125006. interface Scene {
  125007. /** @hidden (Backing field) */
  125008. _physicsEngine: Nullable<IPhysicsEngine>;
  125009. /**
  125010. * Gets the current physics engine
  125011. * @returns a IPhysicsEngine or null if none attached
  125012. */
  125013. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  125014. /**
  125015. * Enables physics to the current scene
  125016. * @param gravity defines the scene's gravity for the physics engine
  125017. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  125018. * @return a boolean indicating if the physics engine was initialized
  125019. */
  125020. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  125021. /**
  125022. * Disables and disposes the physics engine associated with the scene
  125023. */
  125024. disablePhysicsEngine(): void;
  125025. /**
  125026. * Gets a boolean indicating if there is an active physics engine
  125027. * @returns a boolean indicating if there is an active physics engine
  125028. */
  125029. isPhysicsEnabled(): boolean;
  125030. /**
  125031. * Deletes a physics compound impostor
  125032. * @param compound defines the compound to delete
  125033. */
  125034. deleteCompoundImpostor(compound: any): void;
  125035. /**
  125036. * An event triggered when physic simulation is about to be run
  125037. */
  125038. onBeforePhysicsObservable: Observable<Scene>;
  125039. /**
  125040. * An event triggered when physic simulation has been done
  125041. */
  125042. onAfterPhysicsObservable: Observable<Scene>;
  125043. }
  125044. interface AbstractMesh {
  125045. /** @hidden */
  125046. _physicsImpostor: Nullable<PhysicsImpostor>;
  125047. /**
  125048. * Gets or sets impostor used for physic simulation
  125049. * @see http://doc.babylonjs.com/features/physics_engine
  125050. */
  125051. physicsImpostor: Nullable<PhysicsImpostor>;
  125052. /**
  125053. * Gets the current physics impostor
  125054. * @see http://doc.babylonjs.com/features/physics_engine
  125055. * @returns a physics impostor or null
  125056. */
  125057. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  125058. /** Apply a physic impulse to the mesh
  125059. * @param force defines the force to apply
  125060. * @param contactPoint defines where to apply the force
  125061. * @returns the current mesh
  125062. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  125063. */
  125064. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  125065. /**
  125066. * Creates a physic joint between two meshes
  125067. * @param otherMesh defines the other mesh to use
  125068. * @param pivot1 defines the pivot to use on this mesh
  125069. * @param pivot2 defines the pivot to use on the other mesh
  125070. * @param options defines additional options (can be plugin dependent)
  125071. * @returns the current mesh
  125072. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  125073. */
  125074. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  125075. /** @hidden */
  125076. _disposePhysicsObserver: Nullable<Observer<Node>>;
  125077. }
  125078. /**
  125079. * Defines the physics engine scene component responsible to manage a physics engine
  125080. */
  125081. export class PhysicsEngineSceneComponent implements ISceneComponent {
  125082. /**
  125083. * The component name helpful to identify the component in the list of scene components.
  125084. */
  125085. readonly name: string;
  125086. /**
  125087. * The scene the component belongs to.
  125088. */
  125089. scene: Scene;
  125090. /**
  125091. * Creates a new instance of the component for the given scene
  125092. * @param scene Defines the scene to register the component in
  125093. */
  125094. constructor(scene: Scene);
  125095. /**
  125096. * Registers the component in a given scene
  125097. */
  125098. register(): void;
  125099. /**
  125100. * Rebuilds the elements related to this component in case of
  125101. * context lost for instance.
  125102. */
  125103. rebuild(): void;
  125104. /**
  125105. * Disposes the component and the associated ressources
  125106. */
  125107. dispose(): void;
  125108. }
  125109. }
  125110. declare module BABYLON {
  125111. /**
  125112. * A helper for physics simulations
  125113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125114. */
  125115. export class PhysicsHelper {
  125116. private _scene;
  125117. private _physicsEngine;
  125118. /**
  125119. * Initializes the Physics helper
  125120. * @param scene Babylon.js scene
  125121. */
  125122. constructor(scene: Scene);
  125123. /**
  125124. * Applies a radial explosion impulse
  125125. * @param origin the origin of the explosion
  125126. * @param radiusOrEventOptions the radius or the options of radial explosion
  125127. * @param strength the explosion strength
  125128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125129. * @returns A physics radial explosion event, or null
  125130. */
  125131. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125132. /**
  125133. * Applies a radial explosion force
  125134. * @param origin the origin of the explosion
  125135. * @param radiusOrEventOptions the radius or the options of radial explosion
  125136. * @param strength the explosion strength
  125137. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125138. * @returns A physics radial explosion event, or null
  125139. */
  125140. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  125141. /**
  125142. * Creates a gravitational field
  125143. * @param origin the origin of the explosion
  125144. * @param radiusOrEventOptions the radius or the options of radial explosion
  125145. * @param strength the explosion strength
  125146. * @param falloff possible options: Constant & Linear. Defaults to Constant
  125147. * @returns A physics gravitational field event, or null
  125148. */
  125149. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  125150. /**
  125151. * Creates a physics updraft event
  125152. * @param origin the origin of the updraft
  125153. * @param radiusOrEventOptions the radius or the options of the updraft
  125154. * @param strength the strength of the updraft
  125155. * @param height the height of the updraft
  125156. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  125157. * @returns A physics updraft event, or null
  125158. */
  125159. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  125160. /**
  125161. * Creates a physics vortex event
  125162. * @param origin the of the vortex
  125163. * @param radiusOrEventOptions the radius or the options of the vortex
  125164. * @param strength the strength of the vortex
  125165. * @param height the height of the vortex
  125166. * @returns a Physics vortex event, or null
  125167. * A physics vortex event or null
  125168. */
  125169. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  125170. }
  125171. /**
  125172. * Represents a physics radial explosion event
  125173. */
  125174. class PhysicsRadialExplosionEvent {
  125175. private _scene;
  125176. private _options;
  125177. private _sphere;
  125178. private _dataFetched;
  125179. /**
  125180. * Initializes a radial explosioin event
  125181. * @param _scene BabylonJS scene
  125182. * @param _options The options for the vortex event
  125183. */
  125184. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  125185. /**
  125186. * Returns the data related to the radial explosion event (sphere).
  125187. * @returns The radial explosion event data
  125188. */
  125189. getData(): PhysicsRadialExplosionEventData;
  125190. /**
  125191. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  125192. * @param impostor A physics imposter
  125193. * @param origin the origin of the explosion
  125194. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  125195. */
  125196. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  125197. /**
  125198. * Triggers affecterd impostors callbacks
  125199. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  125200. */
  125201. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  125202. /**
  125203. * Disposes the sphere.
  125204. * @param force Specifies if the sphere should be disposed by force
  125205. */
  125206. dispose(force?: boolean): void;
  125207. /*** Helpers ***/
  125208. private _prepareSphere;
  125209. private _intersectsWithSphere;
  125210. }
  125211. /**
  125212. * Represents a gravitational field event
  125213. */
  125214. class PhysicsGravitationalFieldEvent {
  125215. private _physicsHelper;
  125216. private _scene;
  125217. private _origin;
  125218. private _options;
  125219. private _tickCallback;
  125220. private _sphere;
  125221. private _dataFetched;
  125222. /**
  125223. * Initializes the physics gravitational field event
  125224. * @param _physicsHelper A physics helper
  125225. * @param _scene BabylonJS scene
  125226. * @param _origin The origin position of the gravitational field event
  125227. * @param _options The options for the vortex event
  125228. */
  125229. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  125230. /**
  125231. * Returns the data related to the gravitational field event (sphere).
  125232. * @returns A gravitational field event
  125233. */
  125234. getData(): PhysicsGravitationalFieldEventData;
  125235. /**
  125236. * Enables the gravitational field.
  125237. */
  125238. enable(): void;
  125239. /**
  125240. * Disables the gravitational field.
  125241. */
  125242. disable(): void;
  125243. /**
  125244. * Disposes the sphere.
  125245. * @param force The force to dispose from the gravitational field event
  125246. */
  125247. dispose(force?: boolean): void;
  125248. private _tick;
  125249. }
  125250. /**
  125251. * Represents a physics updraft event
  125252. */
  125253. class PhysicsUpdraftEvent {
  125254. private _scene;
  125255. private _origin;
  125256. private _options;
  125257. private _physicsEngine;
  125258. private _originTop;
  125259. private _originDirection;
  125260. private _tickCallback;
  125261. private _cylinder;
  125262. private _cylinderPosition;
  125263. private _dataFetched;
  125264. /**
  125265. * Initializes the physics updraft event
  125266. * @param _scene BabylonJS scene
  125267. * @param _origin The origin position of the updraft
  125268. * @param _options The options for the updraft event
  125269. */
  125270. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  125271. /**
  125272. * Returns the data related to the updraft event (cylinder).
  125273. * @returns A physics updraft event
  125274. */
  125275. getData(): PhysicsUpdraftEventData;
  125276. /**
  125277. * Enables the updraft.
  125278. */
  125279. enable(): void;
  125280. /**
  125281. * Disables the updraft.
  125282. */
  125283. disable(): void;
  125284. /**
  125285. * Disposes the cylinder.
  125286. * @param force Specifies if the updraft should be disposed by force
  125287. */
  125288. dispose(force?: boolean): void;
  125289. private getImpostorHitData;
  125290. private _tick;
  125291. /*** Helpers ***/
  125292. private _prepareCylinder;
  125293. private _intersectsWithCylinder;
  125294. }
  125295. /**
  125296. * Represents a physics vortex event
  125297. */
  125298. class PhysicsVortexEvent {
  125299. private _scene;
  125300. private _origin;
  125301. private _options;
  125302. private _physicsEngine;
  125303. private _originTop;
  125304. private _tickCallback;
  125305. private _cylinder;
  125306. private _cylinderPosition;
  125307. private _dataFetched;
  125308. /**
  125309. * Initializes the physics vortex event
  125310. * @param _scene The BabylonJS scene
  125311. * @param _origin The origin position of the vortex
  125312. * @param _options The options for the vortex event
  125313. */
  125314. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  125315. /**
  125316. * Returns the data related to the vortex event (cylinder).
  125317. * @returns The physics vortex event data
  125318. */
  125319. getData(): PhysicsVortexEventData;
  125320. /**
  125321. * Enables the vortex.
  125322. */
  125323. enable(): void;
  125324. /**
  125325. * Disables the cortex.
  125326. */
  125327. disable(): void;
  125328. /**
  125329. * Disposes the sphere.
  125330. * @param force
  125331. */
  125332. dispose(force?: boolean): void;
  125333. private getImpostorHitData;
  125334. private _tick;
  125335. /*** Helpers ***/
  125336. private _prepareCylinder;
  125337. private _intersectsWithCylinder;
  125338. }
  125339. /**
  125340. * Options fot the radial explosion event
  125341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125342. */
  125343. export class PhysicsRadialExplosionEventOptions {
  125344. /**
  125345. * The radius of the sphere for the radial explosion.
  125346. */
  125347. radius: number;
  125348. /**
  125349. * The strenth of the explosion.
  125350. */
  125351. strength: number;
  125352. /**
  125353. * The strenght of the force in correspondence to the distance of the affected object
  125354. */
  125355. falloff: PhysicsRadialImpulseFalloff;
  125356. /**
  125357. * Sphere options for the radial explosion.
  125358. */
  125359. sphere: {
  125360. segments: number;
  125361. diameter: number;
  125362. };
  125363. /**
  125364. * Sphere options for the radial explosion.
  125365. */
  125366. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  125367. }
  125368. /**
  125369. * Options fot the updraft event
  125370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125371. */
  125372. export class PhysicsUpdraftEventOptions {
  125373. /**
  125374. * The radius of the cylinder for the vortex
  125375. */
  125376. radius: number;
  125377. /**
  125378. * The strenth of the updraft.
  125379. */
  125380. strength: number;
  125381. /**
  125382. * The height of the cylinder for the updraft.
  125383. */
  125384. height: number;
  125385. /**
  125386. * The mode for the the updraft.
  125387. */
  125388. updraftMode: PhysicsUpdraftMode;
  125389. }
  125390. /**
  125391. * Options fot the vortex event
  125392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125393. */
  125394. export class PhysicsVortexEventOptions {
  125395. /**
  125396. * The radius of the cylinder for the vortex
  125397. */
  125398. radius: number;
  125399. /**
  125400. * The strenth of the vortex.
  125401. */
  125402. strength: number;
  125403. /**
  125404. * The height of the cylinder for the vortex.
  125405. */
  125406. height: number;
  125407. /**
  125408. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  125409. */
  125410. centripetalForceThreshold: number;
  125411. /**
  125412. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  125413. */
  125414. centripetalForceMultiplier: number;
  125415. /**
  125416. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  125417. */
  125418. centrifugalForceMultiplier: number;
  125419. /**
  125420. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  125421. */
  125422. updraftForceMultiplier: number;
  125423. }
  125424. /**
  125425. * The strenght of the force in correspondence to the distance of the affected object
  125426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125427. */
  125428. export enum PhysicsRadialImpulseFalloff {
  125429. /** Defines that impulse is constant in strength across it's whole radius */
  125430. Constant = 0,
  125431. /** Defines that impulse gets weaker if it's further from the origin */
  125432. Linear = 1
  125433. }
  125434. /**
  125435. * The strength of the force in correspondence to the distance of the affected object
  125436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125437. */
  125438. export enum PhysicsUpdraftMode {
  125439. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  125440. Center = 0,
  125441. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  125442. Perpendicular = 1
  125443. }
  125444. /**
  125445. * Interface for a physics hit data
  125446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125447. */
  125448. export interface PhysicsHitData {
  125449. /**
  125450. * The force applied at the contact point
  125451. */
  125452. force: Vector3;
  125453. /**
  125454. * The contact point
  125455. */
  125456. contactPoint: Vector3;
  125457. /**
  125458. * The distance from the origin to the contact point
  125459. */
  125460. distanceFromOrigin: number;
  125461. }
  125462. /**
  125463. * Interface for radial explosion event data
  125464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125465. */
  125466. export interface PhysicsRadialExplosionEventData {
  125467. /**
  125468. * A sphere used for the radial explosion event
  125469. */
  125470. sphere: Mesh;
  125471. }
  125472. /**
  125473. * Interface for gravitational field event data
  125474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125475. */
  125476. export interface PhysicsGravitationalFieldEventData {
  125477. /**
  125478. * A sphere mesh used for the gravitational field event
  125479. */
  125480. sphere: Mesh;
  125481. }
  125482. /**
  125483. * Interface for updraft event data
  125484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125485. */
  125486. export interface PhysicsUpdraftEventData {
  125487. /**
  125488. * A cylinder used for the updraft event
  125489. */
  125490. cylinder: Mesh;
  125491. }
  125492. /**
  125493. * Interface for vortex event data
  125494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125495. */
  125496. export interface PhysicsVortexEventData {
  125497. /**
  125498. * A cylinder used for the vortex event
  125499. */
  125500. cylinder: Mesh;
  125501. }
  125502. /**
  125503. * Interface for an affected physics impostor
  125504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  125505. */
  125506. export interface PhysicsAffectedImpostorWithData {
  125507. /**
  125508. * The impostor affected by the effect
  125509. */
  125510. impostor: PhysicsImpostor;
  125511. /**
  125512. * The data about the hit/horce from the explosion
  125513. */
  125514. hitData: PhysicsHitData;
  125515. }
  125516. }
  125517. declare module BABYLON {
  125518. /** @hidden */
  125519. export var blackAndWhitePixelShader: {
  125520. name: string;
  125521. shader: string;
  125522. };
  125523. }
  125524. declare module BABYLON {
  125525. /**
  125526. * Post process used to render in black and white
  125527. */
  125528. export class BlackAndWhitePostProcess extends PostProcess {
  125529. /**
  125530. * Linear about to convert he result to black and white (default: 1)
  125531. */
  125532. degree: number;
  125533. /**
  125534. * Creates a black and white post process
  125535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  125536. * @param name The name of the effect.
  125537. * @param options The required width/height ratio to downsize to before computing the render pass.
  125538. * @param camera The camera to apply the render pass to.
  125539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125540. * @param engine The engine which the post process will be applied. (default: current engine)
  125541. * @param reusable If the post process can be reused on the same frame. (default: false)
  125542. */
  125543. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125544. }
  125545. }
  125546. declare module BABYLON {
  125547. /**
  125548. * This represents a set of one or more post processes in Babylon.
  125549. * A post process can be used to apply a shader to a texture after it is rendered.
  125550. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  125551. */
  125552. export class PostProcessRenderEffect {
  125553. private _postProcesses;
  125554. private _getPostProcesses;
  125555. private _singleInstance;
  125556. private _cameras;
  125557. private _indicesForCamera;
  125558. /**
  125559. * Name of the effect
  125560. * @hidden
  125561. */
  125562. _name: string;
  125563. /**
  125564. * Instantiates a post process render effect.
  125565. * A post process can be used to apply a shader to a texture after it is rendered.
  125566. * @param engine The engine the effect is tied to
  125567. * @param name The name of the effect
  125568. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  125569. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  125570. */
  125571. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  125572. /**
  125573. * Checks if all the post processes in the effect are supported.
  125574. */
  125575. readonly isSupported: boolean;
  125576. /**
  125577. * Updates the current state of the effect
  125578. * @hidden
  125579. */
  125580. _update(): void;
  125581. /**
  125582. * Attaches the effect on cameras
  125583. * @param cameras The camera to attach to.
  125584. * @hidden
  125585. */
  125586. _attachCameras(cameras: Camera): void;
  125587. /**
  125588. * Attaches the effect on cameras
  125589. * @param cameras The camera to attach to.
  125590. * @hidden
  125591. */
  125592. _attachCameras(cameras: Camera[]): void;
  125593. /**
  125594. * Detaches the effect on cameras
  125595. * @param cameras The camera to detatch from.
  125596. * @hidden
  125597. */
  125598. _detachCameras(cameras: Camera): void;
  125599. /**
  125600. * Detatches the effect on cameras
  125601. * @param cameras The camera to detatch from.
  125602. * @hidden
  125603. */
  125604. _detachCameras(cameras: Camera[]): void;
  125605. /**
  125606. * Enables the effect on given cameras
  125607. * @param cameras The camera to enable.
  125608. * @hidden
  125609. */
  125610. _enable(cameras: Camera): void;
  125611. /**
  125612. * Enables the effect on given cameras
  125613. * @param cameras The camera to enable.
  125614. * @hidden
  125615. */
  125616. _enable(cameras: Nullable<Camera[]>): void;
  125617. /**
  125618. * Disables the effect on the given cameras
  125619. * @param cameras The camera to disable.
  125620. * @hidden
  125621. */
  125622. _disable(cameras: Camera): void;
  125623. /**
  125624. * Disables the effect on the given cameras
  125625. * @param cameras The camera to disable.
  125626. * @hidden
  125627. */
  125628. _disable(cameras: Nullable<Camera[]>): void;
  125629. /**
  125630. * Gets a list of the post processes contained in the effect.
  125631. * @param camera The camera to get the post processes on.
  125632. * @returns The list of the post processes in the effect.
  125633. */
  125634. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  125635. }
  125636. }
  125637. declare module BABYLON {
  125638. /** @hidden */
  125639. export var extractHighlightsPixelShader: {
  125640. name: string;
  125641. shader: string;
  125642. };
  125643. }
  125644. declare module BABYLON {
  125645. /**
  125646. * 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.
  125647. */
  125648. export class ExtractHighlightsPostProcess extends PostProcess {
  125649. /**
  125650. * The luminance threshold, pixels below this value will be set to black.
  125651. */
  125652. threshold: number;
  125653. /** @hidden */
  125654. _exposure: number;
  125655. /**
  125656. * Post process which has the input texture to be used when performing highlight extraction
  125657. * @hidden
  125658. */
  125659. _inputPostProcess: Nullable<PostProcess>;
  125660. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125661. }
  125662. }
  125663. declare module BABYLON {
  125664. /** @hidden */
  125665. export var bloomMergePixelShader: {
  125666. name: string;
  125667. shader: string;
  125668. };
  125669. }
  125670. declare module BABYLON {
  125671. /**
  125672. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125673. */
  125674. export class BloomMergePostProcess extends PostProcess {
  125675. /** Weight of the bloom to be added to the original input. */
  125676. weight: number;
  125677. /**
  125678. * Creates a new instance of @see BloomMergePostProcess
  125679. * @param name The name of the effect.
  125680. * @param originalFromInput Post process which's input will be used for the merge.
  125681. * @param blurred Blurred highlights post process which's output will be used.
  125682. * @param weight Weight of the bloom to be added to the original input.
  125683. * @param options The required width/height ratio to downsize to before computing the render pass.
  125684. * @param camera The camera to apply the render pass to.
  125685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125686. * @param engine The engine which the post process will be applied. (default: current engine)
  125687. * @param reusable If the post process can be reused on the same frame. (default: false)
  125688. * @param textureType Type of textures used when performing the post process. (default: 0)
  125689. * @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)
  125690. */
  125691. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  125692. /** Weight of the bloom to be added to the original input. */
  125693. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125694. }
  125695. }
  125696. declare module BABYLON {
  125697. /**
  125698. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  125699. */
  125700. export class BloomEffect extends PostProcessRenderEffect {
  125701. private bloomScale;
  125702. /**
  125703. * @hidden Internal
  125704. */
  125705. _effects: Array<PostProcess>;
  125706. /**
  125707. * @hidden Internal
  125708. */
  125709. _downscale: ExtractHighlightsPostProcess;
  125710. private _blurX;
  125711. private _blurY;
  125712. private _merge;
  125713. /**
  125714. * The luminance threshold to find bright areas of the image to bloom.
  125715. */
  125716. threshold: number;
  125717. /**
  125718. * The strength of the bloom.
  125719. */
  125720. weight: number;
  125721. /**
  125722. * Specifies the size of the bloom blur kernel, relative to the final output size
  125723. */
  125724. kernel: number;
  125725. /**
  125726. * Creates a new instance of @see BloomEffect
  125727. * @param scene The scene the effect belongs to.
  125728. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  125729. * @param bloomKernel The size of the kernel to be used when applying the blur.
  125730. * @param bloomWeight The the strength of bloom.
  125731. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  125732. * @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)
  125733. */
  125734. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  125735. /**
  125736. * Disposes each of the internal effects for a given camera.
  125737. * @param camera The camera to dispose the effect on.
  125738. */
  125739. disposeEffects(camera: Camera): void;
  125740. /**
  125741. * @hidden Internal
  125742. */
  125743. _updateEffects(): void;
  125744. /**
  125745. * Internal
  125746. * @returns if all the contained post processes are ready.
  125747. * @hidden
  125748. */
  125749. _isReady(): boolean;
  125750. }
  125751. }
  125752. declare module BABYLON {
  125753. /** @hidden */
  125754. export var chromaticAberrationPixelShader: {
  125755. name: string;
  125756. shader: string;
  125757. };
  125758. }
  125759. declare module BABYLON {
  125760. /**
  125761. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  125762. */
  125763. export class ChromaticAberrationPostProcess extends PostProcess {
  125764. /**
  125765. * The amount of seperation of rgb channels (default: 30)
  125766. */
  125767. aberrationAmount: number;
  125768. /**
  125769. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  125770. */
  125771. radialIntensity: number;
  125772. /**
  125773. * 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))
  125774. */
  125775. direction: Vector2;
  125776. /**
  125777. * 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))
  125778. */
  125779. centerPosition: Vector2;
  125780. /**
  125781. * Creates a new instance ChromaticAberrationPostProcess
  125782. * @param name The name of the effect.
  125783. * @param screenWidth The width of the screen to apply the effect on.
  125784. * @param screenHeight The height of the screen to apply the effect on.
  125785. * @param options The required width/height ratio to downsize to before computing the render pass.
  125786. * @param camera The camera to apply the render pass to.
  125787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125788. * @param engine The engine which the post process will be applied. (default: current engine)
  125789. * @param reusable If the post process can be reused on the same frame. (default: false)
  125790. * @param textureType Type of textures used when performing the post process. (default: 0)
  125791. * @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)
  125792. */
  125793. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125794. }
  125795. }
  125796. declare module BABYLON {
  125797. /** @hidden */
  125798. export var circleOfConfusionPixelShader: {
  125799. name: string;
  125800. shader: string;
  125801. };
  125802. }
  125803. declare module BABYLON {
  125804. /**
  125805. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  125806. */
  125807. export class CircleOfConfusionPostProcess extends PostProcess {
  125808. /**
  125809. * 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.
  125810. */
  125811. lensSize: number;
  125812. /**
  125813. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  125814. */
  125815. fStop: number;
  125816. /**
  125817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  125818. */
  125819. focusDistance: number;
  125820. /**
  125821. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  125822. */
  125823. focalLength: number;
  125824. private _depthTexture;
  125825. /**
  125826. * Creates a new instance CircleOfConfusionPostProcess
  125827. * @param name The name of the effect.
  125828. * @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.
  125829. * @param options The required width/height ratio to downsize to before computing the render pass.
  125830. * @param camera The camera to apply the render pass to.
  125831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125832. * @param engine The engine which the post process will be applied. (default: current engine)
  125833. * @param reusable If the post process can be reused on the same frame. (default: false)
  125834. * @param textureType Type of textures used when performing the post process. (default: 0)
  125835. * @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)
  125836. */
  125837. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  125838. /**
  125839. * 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.
  125840. */
  125841. depthTexture: RenderTargetTexture;
  125842. }
  125843. }
  125844. declare module BABYLON {
  125845. /** @hidden */
  125846. export var colorCorrectionPixelShader: {
  125847. name: string;
  125848. shader: string;
  125849. };
  125850. }
  125851. declare module BABYLON {
  125852. /**
  125853. *
  125854. * This post-process allows the modification of rendered colors by using
  125855. * a 'look-up table' (LUT). This effect is also called Color Grading.
  125856. *
  125857. * The object needs to be provided an url to a texture containing the color
  125858. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  125859. * Use an image editing software to tweak the LUT to match your needs.
  125860. *
  125861. * For an example of a color LUT, see here:
  125862. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  125863. * For explanations on color grading, see here:
  125864. * @see http://udn.epicgames.com/Three/ColorGrading.html
  125865. *
  125866. */
  125867. export class ColorCorrectionPostProcess extends PostProcess {
  125868. private _colorTableTexture;
  125869. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  125870. }
  125871. }
  125872. declare module BABYLON {
  125873. /** @hidden */
  125874. export var convolutionPixelShader: {
  125875. name: string;
  125876. shader: string;
  125877. };
  125878. }
  125879. declare module BABYLON {
  125880. /**
  125881. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  125882. * input texture to perform effects such as edge detection or sharpening
  125883. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  125884. */
  125885. export class ConvolutionPostProcess extends PostProcess {
  125886. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125887. kernel: number[];
  125888. /**
  125889. * Creates a new instance ConvolutionPostProcess
  125890. * @param name The name of the effect.
  125891. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  125892. * @param options The required width/height ratio to downsize to before computing the render pass.
  125893. * @param camera The camera to apply the render pass to.
  125894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125895. * @param engine The engine which the post process will be applied. (default: current engine)
  125896. * @param reusable If the post process can be reused on the same frame. (default: false)
  125897. * @param textureType Type of textures used when performing the post process. (default: 0)
  125898. */
  125899. constructor(name: string,
  125900. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  125901. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  125902. /**
  125903. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125904. */
  125905. static EdgeDetect0Kernel: number[];
  125906. /**
  125907. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125908. */
  125909. static EdgeDetect1Kernel: number[];
  125910. /**
  125911. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125912. */
  125913. static EdgeDetect2Kernel: number[];
  125914. /**
  125915. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125916. */
  125917. static SharpenKernel: number[];
  125918. /**
  125919. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125920. */
  125921. static EmbossKernel: number[];
  125922. /**
  125923. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  125924. */
  125925. static GaussianKernel: number[];
  125926. }
  125927. }
  125928. declare module BABYLON {
  125929. /**
  125930. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  125931. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  125932. * based on samples that have a large difference in distance than the center pixel.
  125933. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  125934. */
  125935. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  125936. direction: Vector2;
  125937. /**
  125938. * Creates a new instance CircleOfConfusionPostProcess
  125939. * @param name The name of the effect.
  125940. * @param scene The scene the effect belongs to.
  125941. * @param direction The direction the blur should be applied.
  125942. * @param kernel The size of the kernel used to blur.
  125943. * @param options The required width/height ratio to downsize to before computing the render pass.
  125944. * @param camera The camera to apply the render pass to.
  125945. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  125946. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  125947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  125948. * @param engine The engine which the post process will be applied. (default: current engine)
  125949. * @param reusable If the post process can be reused on the same frame. (default: false)
  125950. * @param textureType Type of textures used when performing the post process. (default: 0)
  125951. * @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)
  125952. */
  125953. 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);
  125954. }
  125955. }
  125956. declare module BABYLON {
  125957. /** @hidden */
  125958. export var depthOfFieldMergePixelShader: {
  125959. name: string;
  125960. shader: string;
  125961. };
  125962. }
  125963. declare module BABYLON {
  125964. /**
  125965. * Options to be set when merging outputs from the default pipeline.
  125966. */
  125967. export class DepthOfFieldMergePostProcessOptions {
  125968. /**
  125969. * The original image to merge on top of
  125970. */
  125971. originalFromInput: PostProcess;
  125972. /**
  125973. * Parameters to perform the merge of the depth of field effect
  125974. */
  125975. depthOfField?: {
  125976. circleOfConfusion: PostProcess;
  125977. blurSteps: Array<PostProcess>;
  125978. };
  125979. /**
  125980. * Parameters to perform the merge of bloom effect
  125981. */
  125982. bloom?: {
  125983. blurred: PostProcess;
  125984. weight: number;
  125985. };
  125986. }
  125987. /**
  125988. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  125989. */
  125990. export class DepthOfFieldMergePostProcess extends PostProcess {
  125991. private blurSteps;
  125992. /**
  125993. * Creates a new instance of DepthOfFieldMergePostProcess
  125994. * @param name The name of the effect.
  125995. * @param originalFromInput Post process which's input will be used for the merge.
  125996. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  125997. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  125998. * @param options The required width/height ratio to downsize to before computing the render pass.
  125999. * @param camera The camera to apply the render pass to.
  126000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126001. * @param engine The engine which the post process will be applied. (default: current engine)
  126002. * @param reusable If the post process can be reused on the same frame. (default: false)
  126003. * @param textureType Type of textures used when performing the post process. (default: 0)
  126004. * @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)
  126005. */
  126006. 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);
  126007. /**
  126008. * Updates the effect with the current post process compile time values and recompiles the shader.
  126009. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  126010. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  126011. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  126012. * @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
  126013. * @param onCompiled Called when the shader has been compiled.
  126014. * @param onError Called if there is an error when compiling a shader.
  126015. */
  126016. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  126017. }
  126018. }
  126019. declare module BABYLON {
  126020. /**
  126021. * Specifies the level of max blur that should be applied when using the depth of field effect
  126022. */
  126023. export enum DepthOfFieldEffectBlurLevel {
  126024. /**
  126025. * Subtle blur
  126026. */
  126027. Low = 0,
  126028. /**
  126029. * Medium blur
  126030. */
  126031. Medium = 1,
  126032. /**
  126033. * Large blur
  126034. */
  126035. High = 2
  126036. }
  126037. /**
  126038. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  126039. */
  126040. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  126041. private _circleOfConfusion;
  126042. /**
  126043. * @hidden Internal, blurs from high to low
  126044. */
  126045. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  126046. private _depthOfFieldBlurY;
  126047. private _dofMerge;
  126048. /**
  126049. * @hidden Internal post processes in depth of field effect
  126050. */
  126051. _effects: Array<PostProcess>;
  126052. /**
  126053. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  126054. */
  126055. focalLength: number;
  126056. /**
  126057. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  126058. */
  126059. fStop: number;
  126060. /**
  126061. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  126062. */
  126063. focusDistance: number;
  126064. /**
  126065. * 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.
  126066. */
  126067. lensSize: number;
  126068. /**
  126069. * Creates a new instance DepthOfFieldEffect
  126070. * @param scene The scene the effect belongs to.
  126071. * @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.
  126072. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  126073. * @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)
  126074. */
  126075. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  126076. /**
  126077. * Get the current class name of the current effet
  126078. * @returns "DepthOfFieldEffect"
  126079. */
  126080. getClassName(): string;
  126081. /**
  126082. * 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.
  126083. */
  126084. depthTexture: RenderTargetTexture;
  126085. /**
  126086. * Disposes each of the internal effects for a given camera.
  126087. * @param camera The camera to dispose the effect on.
  126088. */
  126089. disposeEffects(camera: Camera): void;
  126090. /**
  126091. * @hidden Internal
  126092. */
  126093. _updateEffects(): void;
  126094. /**
  126095. * Internal
  126096. * @returns if all the contained post processes are ready.
  126097. * @hidden
  126098. */
  126099. _isReady(): boolean;
  126100. }
  126101. }
  126102. declare module BABYLON {
  126103. /** @hidden */
  126104. export var displayPassPixelShader: {
  126105. name: string;
  126106. shader: string;
  126107. };
  126108. }
  126109. declare module BABYLON {
  126110. /**
  126111. * DisplayPassPostProcess which produces an output the same as it's input
  126112. */
  126113. export class DisplayPassPostProcess extends PostProcess {
  126114. /**
  126115. * Creates the DisplayPassPostProcess
  126116. * @param name The name of the effect.
  126117. * @param options The required width/height ratio to downsize to before computing the render pass.
  126118. * @param camera The camera to apply the render pass to.
  126119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126120. * @param engine The engine which the post process will be applied. (default: current engine)
  126121. * @param reusable If the post process can be reused on the same frame. (default: false)
  126122. */
  126123. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126124. }
  126125. }
  126126. declare module BABYLON {
  126127. /** @hidden */
  126128. export var filterPixelShader: {
  126129. name: string;
  126130. shader: string;
  126131. };
  126132. }
  126133. declare module BABYLON {
  126134. /**
  126135. * Applies a kernel filter to the image
  126136. */
  126137. export class FilterPostProcess extends PostProcess {
  126138. /** The matrix to be applied to the image */
  126139. kernelMatrix: Matrix;
  126140. /**
  126141. *
  126142. * @param name The name of the effect.
  126143. * @param kernelMatrix The matrix to be applied to the image
  126144. * @param options The required width/height ratio to downsize to before computing the render pass.
  126145. * @param camera The camera to apply the render pass to.
  126146. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126147. * @param engine The engine which the post process will be applied. (default: current engine)
  126148. * @param reusable If the post process can be reused on the same frame. (default: false)
  126149. */
  126150. constructor(name: string,
  126151. /** The matrix to be applied to the image */
  126152. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126153. }
  126154. }
  126155. declare module BABYLON {
  126156. /** @hidden */
  126157. export var fxaaPixelShader: {
  126158. name: string;
  126159. shader: string;
  126160. };
  126161. }
  126162. declare module BABYLON {
  126163. /** @hidden */
  126164. export var fxaaVertexShader: {
  126165. name: string;
  126166. shader: string;
  126167. };
  126168. }
  126169. declare module BABYLON {
  126170. /**
  126171. * Fxaa post process
  126172. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  126173. */
  126174. export class FxaaPostProcess extends PostProcess {
  126175. /** @hidden */
  126176. texelWidth: number;
  126177. /** @hidden */
  126178. texelHeight: number;
  126179. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126180. private _getDefines;
  126181. }
  126182. }
  126183. declare module BABYLON {
  126184. /** @hidden */
  126185. export var grainPixelShader: {
  126186. name: string;
  126187. shader: string;
  126188. };
  126189. }
  126190. declare module BABYLON {
  126191. /**
  126192. * The GrainPostProcess adds noise to the image at mid luminance levels
  126193. */
  126194. export class GrainPostProcess extends PostProcess {
  126195. /**
  126196. * The intensity of the grain added (default: 30)
  126197. */
  126198. intensity: number;
  126199. /**
  126200. * If the grain should be randomized on every frame
  126201. */
  126202. animated: boolean;
  126203. /**
  126204. * Creates a new instance of @see GrainPostProcess
  126205. * @param name The name of the effect.
  126206. * @param options The required width/height ratio to downsize to before computing the render pass.
  126207. * @param camera The camera to apply the render pass to.
  126208. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126209. * @param engine The engine which the post process will be applied. (default: current engine)
  126210. * @param reusable If the post process can be reused on the same frame. (default: false)
  126211. * @param textureType Type of textures used when performing the post process. (default: 0)
  126212. * @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)
  126213. */
  126214. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126215. }
  126216. }
  126217. declare module BABYLON {
  126218. /** @hidden */
  126219. export var highlightsPixelShader: {
  126220. name: string;
  126221. shader: string;
  126222. };
  126223. }
  126224. declare module BABYLON {
  126225. /**
  126226. * Extracts highlights from the image
  126227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126228. */
  126229. export class HighlightsPostProcess extends PostProcess {
  126230. /**
  126231. * Extracts highlights from the image
  126232. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  126233. * @param name The name of the effect.
  126234. * @param options The required width/height ratio to downsize to before computing the render pass.
  126235. * @param camera The camera to apply the render pass to.
  126236. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126237. * @param engine The engine which the post process will be applied. (default: current engine)
  126238. * @param reusable If the post process can be reused on the same frame. (default: false)
  126239. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  126240. */
  126241. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  126242. }
  126243. }
  126244. declare module BABYLON {
  126245. /** @hidden */
  126246. export var mrtFragmentDeclaration: {
  126247. name: string;
  126248. shader: string;
  126249. };
  126250. }
  126251. declare module BABYLON {
  126252. /** @hidden */
  126253. export var geometryPixelShader: {
  126254. name: string;
  126255. shader: string;
  126256. };
  126257. }
  126258. declare module BABYLON {
  126259. /** @hidden */
  126260. export var geometryVertexShader: {
  126261. name: string;
  126262. shader: string;
  126263. };
  126264. }
  126265. declare module BABYLON {
  126266. /** @hidden */
  126267. interface ISavedTransformationMatrix {
  126268. world: Matrix;
  126269. viewProjection: Matrix;
  126270. }
  126271. /**
  126272. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  126273. */
  126274. export class GeometryBufferRenderer {
  126275. /**
  126276. * Constant used to retrieve the position texture index in the G-Buffer textures array
  126277. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  126278. */
  126279. static readonly POSITION_TEXTURE_TYPE: number;
  126280. /**
  126281. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  126282. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  126283. */
  126284. static readonly VELOCITY_TEXTURE_TYPE: number;
  126285. /**
  126286. * Dictionary used to store the previous transformation matrices of each rendered mesh
  126287. * in order to compute objects velocities when enableVelocity is set to "true"
  126288. * @hidden
  126289. */
  126290. _previousTransformationMatrices: {
  126291. [index: number]: ISavedTransformationMatrix;
  126292. };
  126293. /**
  126294. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  126295. * in order to compute objects velocities when enableVelocity is set to "true"
  126296. * @hidden
  126297. */
  126298. _previousBonesTransformationMatrices: {
  126299. [index: number]: Float32Array;
  126300. };
  126301. /**
  126302. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  126303. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  126304. */
  126305. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  126306. private _scene;
  126307. private _multiRenderTarget;
  126308. private _ratio;
  126309. private _enablePosition;
  126310. private _enableVelocity;
  126311. private _positionIndex;
  126312. private _velocityIndex;
  126313. protected _effect: Effect;
  126314. protected _cachedDefines: string;
  126315. /**
  126316. * Set the render list (meshes to be rendered) used in the G buffer.
  126317. */
  126318. renderList: Mesh[];
  126319. /**
  126320. * Gets wether or not G buffer are supported by the running hardware.
  126321. * This requires draw buffer supports
  126322. */
  126323. readonly isSupported: boolean;
  126324. /**
  126325. * Returns the index of the given texture type in the G-Buffer textures array
  126326. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  126327. * @returns the index of the given texture type in the G-Buffer textures array
  126328. */
  126329. getTextureIndex(textureType: number): number;
  126330. /**
  126331. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  126332. */
  126333. /**
  126334. * Sets whether or not objects positions are enabled for the G buffer.
  126335. */
  126336. enablePosition: boolean;
  126337. /**
  126338. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  126339. */
  126340. /**
  126341. * Sets wether or not objects velocities are enabled for the G buffer.
  126342. */
  126343. enableVelocity: boolean;
  126344. /**
  126345. * Gets the scene associated with the buffer.
  126346. */
  126347. readonly scene: Scene;
  126348. /**
  126349. * Gets the ratio used by the buffer during its creation.
  126350. * How big is the buffer related to the main canvas.
  126351. */
  126352. readonly ratio: number;
  126353. /** @hidden */
  126354. static _SceneComponentInitialization: (scene: Scene) => void;
  126355. /**
  126356. * Creates a new G Buffer for the scene
  126357. * @param scene The scene the buffer belongs to
  126358. * @param ratio How big is the buffer related to the main canvas.
  126359. */
  126360. constructor(scene: Scene, ratio?: number);
  126361. /**
  126362. * Checks wether everything is ready to render a submesh to the G buffer.
  126363. * @param subMesh the submesh to check readiness for
  126364. * @param useInstances is the mesh drawn using instance or not
  126365. * @returns true if ready otherwise false
  126366. */
  126367. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  126368. /**
  126369. * Gets the current underlying G Buffer.
  126370. * @returns the buffer
  126371. */
  126372. getGBuffer(): MultiRenderTarget;
  126373. /**
  126374. * Gets the number of samples used to render the buffer (anti aliasing).
  126375. */
  126376. /**
  126377. * Sets the number of samples used to render the buffer (anti aliasing).
  126378. */
  126379. samples: number;
  126380. /**
  126381. * Disposes the renderer and frees up associated resources.
  126382. */
  126383. dispose(): void;
  126384. protected _createRenderTargets(): void;
  126385. private _copyBonesTransformationMatrices;
  126386. }
  126387. }
  126388. declare module BABYLON {
  126389. interface Scene {
  126390. /** @hidden (Backing field) */
  126391. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126392. /**
  126393. * Gets or Sets the current geometry buffer associated to the scene.
  126394. */
  126395. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  126396. /**
  126397. * Enables a GeometryBufferRender and associates it with the scene
  126398. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  126399. * @returns the GeometryBufferRenderer
  126400. */
  126401. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  126402. /**
  126403. * Disables the GeometryBufferRender associated with the scene
  126404. */
  126405. disableGeometryBufferRenderer(): void;
  126406. }
  126407. /**
  126408. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  126409. * in several rendering techniques.
  126410. */
  126411. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  126412. /**
  126413. * The component name helpful to identify the component in the list of scene components.
  126414. */
  126415. readonly name: string;
  126416. /**
  126417. * The scene the component belongs to.
  126418. */
  126419. scene: Scene;
  126420. /**
  126421. * Creates a new instance of the component for the given scene
  126422. * @param scene Defines the scene to register the component in
  126423. */
  126424. constructor(scene: Scene);
  126425. /**
  126426. * Registers the component in a given scene
  126427. */
  126428. register(): void;
  126429. /**
  126430. * Rebuilds the elements related to this component in case of
  126431. * context lost for instance.
  126432. */
  126433. rebuild(): void;
  126434. /**
  126435. * Disposes the component and the associated ressources
  126436. */
  126437. dispose(): void;
  126438. private _gatherRenderTargets;
  126439. }
  126440. }
  126441. declare module BABYLON {
  126442. /** @hidden */
  126443. export var motionBlurPixelShader: {
  126444. name: string;
  126445. shader: string;
  126446. };
  126447. }
  126448. declare module BABYLON {
  126449. /**
  126450. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  126451. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  126452. * As an example, all you have to do is to create the post-process:
  126453. * var mb = new BABYLON.MotionBlurPostProcess(
  126454. * 'mb', // The name of the effect.
  126455. * scene, // The scene containing the objects to blur according to their velocity.
  126456. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  126457. * camera // The camera to apply the render pass to.
  126458. * );
  126459. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  126460. */
  126461. export class MotionBlurPostProcess extends PostProcess {
  126462. /**
  126463. * Defines how much the image is blurred by the movement. Default value is equal to 1
  126464. */
  126465. motionStrength: number;
  126466. /**
  126467. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  126468. */
  126469. /**
  126470. * Sets the number of iterations to be used for motion blur quality
  126471. */
  126472. motionBlurSamples: number;
  126473. private _motionBlurSamples;
  126474. private _geometryBufferRenderer;
  126475. /**
  126476. * Creates a new instance MotionBlurPostProcess
  126477. * @param name The name of the effect.
  126478. * @param scene The scene containing the objects to blur according to their velocity.
  126479. * @param options The required width/height ratio to downsize to before computing the render pass.
  126480. * @param camera The camera to apply the render pass to.
  126481. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126482. * @param engine The engine which the post process will be applied. (default: current engine)
  126483. * @param reusable If the post process can be reused on the same frame. (default: false)
  126484. * @param textureType Type of textures used when performing the post process. (default: 0)
  126485. * @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)
  126486. */
  126487. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126488. /**
  126489. * Excludes the given skinned mesh from computing bones velocities.
  126490. * 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.
  126491. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  126492. */
  126493. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126494. /**
  126495. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  126496. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  126497. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  126498. */
  126499. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  126500. /**
  126501. * Disposes the post process.
  126502. * @param camera The camera to dispose the post process on.
  126503. */
  126504. dispose(camera?: Camera): void;
  126505. }
  126506. }
  126507. declare module BABYLON {
  126508. /** @hidden */
  126509. export var refractionPixelShader: {
  126510. name: string;
  126511. shader: string;
  126512. };
  126513. }
  126514. declare module BABYLON {
  126515. /**
  126516. * Post process which applies a refractin texture
  126517. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126518. */
  126519. export class RefractionPostProcess extends PostProcess {
  126520. /** the base color of the refraction (used to taint the rendering) */
  126521. color: Color3;
  126522. /** simulated refraction depth */
  126523. depth: number;
  126524. /** the coefficient of the base color (0 to remove base color tainting) */
  126525. colorLevel: number;
  126526. private _refTexture;
  126527. private _ownRefractionTexture;
  126528. /**
  126529. * Gets or sets the refraction texture
  126530. * Please note that you are responsible for disposing the texture if you set it manually
  126531. */
  126532. refractionTexture: Texture;
  126533. /**
  126534. * Initializes the RefractionPostProcess
  126535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  126536. * @param name The name of the effect.
  126537. * @param refractionTextureUrl Url of the refraction texture to use
  126538. * @param color the base color of the refraction (used to taint the rendering)
  126539. * @param depth simulated refraction depth
  126540. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  126541. * @param camera The camera to apply the render pass to.
  126542. * @param options The required width/height ratio to downsize to before computing the render pass.
  126543. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126544. * @param engine The engine which the post process will be applied. (default: current engine)
  126545. * @param reusable If the post process can be reused on the same frame. (default: false)
  126546. */
  126547. constructor(name: string, refractionTextureUrl: string,
  126548. /** the base color of the refraction (used to taint the rendering) */
  126549. color: Color3,
  126550. /** simulated refraction depth */
  126551. depth: number,
  126552. /** the coefficient of the base color (0 to remove base color tainting) */
  126553. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  126554. /**
  126555. * Disposes of the post process
  126556. * @param camera Camera to dispose post process on
  126557. */
  126558. dispose(camera: Camera): void;
  126559. }
  126560. }
  126561. declare module BABYLON {
  126562. /** @hidden */
  126563. export var sharpenPixelShader: {
  126564. name: string;
  126565. shader: string;
  126566. };
  126567. }
  126568. declare module BABYLON {
  126569. /**
  126570. * The SharpenPostProcess applies a sharpen kernel to every pixel
  126571. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  126572. */
  126573. export class SharpenPostProcess extends PostProcess {
  126574. /**
  126575. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  126576. */
  126577. colorAmount: number;
  126578. /**
  126579. * How much sharpness should be applied (default: 0.3)
  126580. */
  126581. edgeAmount: number;
  126582. /**
  126583. * Creates a new instance ConvolutionPostProcess
  126584. * @param name The name of the effect.
  126585. * @param options The required width/height ratio to downsize to before computing the render pass.
  126586. * @param camera The camera to apply the render pass to.
  126587. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126588. * @param engine The engine which the post process will be applied. (default: current engine)
  126589. * @param reusable If the post process can be reused on the same frame. (default: false)
  126590. * @param textureType Type of textures used when performing the post process. (default: 0)
  126591. * @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)
  126592. */
  126593. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126594. }
  126595. }
  126596. declare module BABYLON {
  126597. /**
  126598. * PostProcessRenderPipeline
  126599. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126600. */
  126601. export class PostProcessRenderPipeline {
  126602. private engine;
  126603. private _renderEffects;
  126604. private _renderEffectsForIsolatedPass;
  126605. /**
  126606. * List of inspectable custom properties (used by the Inspector)
  126607. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  126608. */
  126609. inspectableCustomProperties: IInspectable[];
  126610. /**
  126611. * @hidden
  126612. */
  126613. protected _cameras: Camera[];
  126614. /** @hidden */
  126615. _name: string;
  126616. /**
  126617. * Gets pipeline name
  126618. */
  126619. readonly name: string;
  126620. /**
  126621. * Initializes a PostProcessRenderPipeline
  126622. * @param engine engine to add the pipeline to
  126623. * @param name name of the pipeline
  126624. */
  126625. constructor(engine: Engine, name: string);
  126626. /**
  126627. * Gets the class name
  126628. * @returns "PostProcessRenderPipeline"
  126629. */
  126630. getClassName(): string;
  126631. /**
  126632. * If all the render effects in the pipeline are supported
  126633. */
  126634. readonly isSupported: boolean;
  126635. /**
  126636. * Adds an effect to the pipeline
  126637. * @param renderEffect the effect to add
  126638. */
  126639. addEffect(renderEffect: PostProcessRenderEffect): void;
  126640. /** @hidden */
  126641. _rebuild(): void;
  126642. /** @hidden */
  126643. _enableEffect(renderEffectName: string, cameras: Camera): void;
  126644. /** @hidden */
  126645. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  126646. /** @hidden */
  126647. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126648. /** @hidden */
  126649. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  126650. /** @hidden */
  126651. _attachCameras(cameras: Camera, unique: boolean): void;
  126652. /** @hidden */
  126653. _attachCameras(cameras: Camera[], unique: boolean): void;
  126654. /** @hidden */
  126655. _detachCameras(cameras: Camera): void;
  126656. /** @hidden */
  126657. _detachCameras(cameras: Nullable<Camera[]>): void;
  126658. /** @hidden */
  126659. _update(): void;
  126660. /** @hidden */
  126661. _reset(): void;
  126662. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  126663. /**
  126664. * Disposes of the pipeline
  126665. */
  126666. dispose(): void;
  126667. }
  126668. }
  126669. declare module BABYLON {
  126670. /**
  126671. * PostProcessRenderPipelineManager class
  126672. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126673. */
  126674. export class PostProcessRenderPipelineManager {
  126675. private _renderPipelines;
  126676. /**
  126677. * Initializes a PostProcessRenderPipelineManager
  126678. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126679. */
  126680. constructor();
  126681. /**
  126682. * Gets the list of supported render pipelines
  126683. */
  126684. readonly supportedPipelines: PostProcessRenderPipeline[];
  126685. /**
  126686. * Adds a pipeline to the manager
  126687. * @param renderPipeline The pipeline to add
  126688. */
  126689. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  126690. /**
  126691. * Attaches a camera to the pipeline
  126692. * @param renderPipelineName The name of the pipeline to attach to
  126693. * @param cameras the camera to attach
  126694. * @param unique if the camera can be attached multiple times to the pipeline
  126695. */
  126696. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  126697. /**
  126698. * Detaches a camera from the pipeline
  126699. * @param renderPipelineName The name of the pipeline to detach from
  126700. * @param cameras the camera to detach
  126701. */
  126702. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  126703. /**
  126704. * Enables an effect by name on a pipeline
  126705. * @param renderPipelineName the name of the pipeline to enable the effect in
  126706. * @param renderEffectName the name of the effect to enable
  126707. * @param cameras the cameras that the effect should be enabled on
  126708. */
  126709. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126710. /**
  126711. * Disables an effect by name on a pipeline
  126712. * @param renderPipelineName the name of the pipeline to disable the effect in
  126713. * @param renderEffectName the name of the effect to disable
  126714. * @param cameras the cameras that the effect should be disabled on
  126715. */
  126716. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  126717. /**
  126718. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  126719. */
  126720. update(): void;
  126721. /** @hidden */
  126722. _rebuild(): void;
  126723. /**
  126724. * Disposes of the manager and pipelines
  126725. */
  126726. dispose(): void;
  126727. }
  126728. }
  126729. declare module BABYLON {
  126730. interface Scene {
  126731. /** @hidden (Backing field) */
  126732. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126733. /**
  126734. * Gets the postprocess render pipeline manager
  126735. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  126736. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126737. */
  126738. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  126739. }
  126740. /**
  126741. * Defines the Render Pipeline scene component responsible to rendering pipelines
  126742. */
  126743. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  126744. /**
  126745. * The component name helpfull to identify the component in the list of scene components.
  126746. */
  126747. readonly name: string;
  126748. /**
  126749. * The scene the component belongs to.
  126750. */
  126751. scene: Scene;
  126752. /**
  126753. * Creates a new instance of the component for the given scene
  126754. * @param scene Defines the scene to register the component in
  126755. */
  126756. constructor(scene: Scene);
  126757. /**
  126758. * Registers the component in a given scene
  126759. */
  126760. register(): void;
  126761. /**
  126762. * Rebuilds the elements related to this component in case of
  126763. * context lost for instance.
  126764. */
  126765. rebuild(): void;
  126766. /**
  126767. * Disposes the component and the associated ressources
  126768. */
  126769. dispose(): void;
  126770. private _gatherRenderTargets;
  126771. }
  126772. }
  126773. declare module BABYLON {
  126774. /**
  126775. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  126776. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  126777. */
  126778. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  126779. private _scene;
  126780. private _camerasToBeAttached;
  126781. /**
  126782. * ID of the sharpen post process,
  126783. */
  126784. private readonly SharpenPostProcessId;
  126785. /**
  126786. * @ignore
  126787. * ID of the image processing post process;
  126788. */
  126789. readonly ImageProcessingPostProcessId: string;
  126790. /**
  126791. * @ignore
  126792. * ID of the Fast Approximate Anti-Aliasing post process;
  126793. */
  126794. readonly FxaaPostProcessId: string;
  126795. /**
  126796. * ID of the chromatic aberration post process,
  126797. */
  126798. private readonly ChromaticAberrationPostProcessId;
  126799. /**
  126800. * ID of the grain post process
  126801. */
  126802. private readonly GrainPostProcessId;
  126803. /**
  126804. * Sharpen post process which will apply a sharpen convolution to enhance edges
  126805. */
  126806. sharpen: SharpenPostProcess;
  126807. private _sharpenEffect;
  126808. private bloom;
  126809. /**
  126810. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  126811. */
  126812. depthOfField: DepthOfFieldEffect;
  126813. /**
  126814. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  126815. */
  126816. fxaa: FxaaPostProcess;
  126817. /**
  126818. * Image post processing pass used to perform operations such as tone mapping or color grading.
  126819. */
  126820. imageProcessing: ImageProcessingPostProcess;
  126821. /**
  126822. * Chromatic aberration post process which will shift rgb colors in the image
  126823. */
  126824. chromaticAberration: ChromaticAberrationPostProcess;
  126825. private _chromaticAberrationEffect;
  126826. /**
  126827. * Grain post process which add noise to the image
  126828. */
  126829. grain: GrainPostProcess;
  126830. private _grainEffect;
  126831. /**
  126832. * Glow post process which adds a glow to emissive areas of the image
  126833. */
  126834. private _glowLayer;
  126835. /**
  126836. * Animations which can be used to tweak settings over a period of time
  126837. */
  126838. animations: Animation[];
  126839. private _imageProcessingConfigurationObserver;
  126840. private _sharpenEnabled;
  126841. private _bloomEnabled;
  126842. private _depthOfFieldEnabled;
  126843. private _depthOfFieldBlurLevel;
  126844. private _fxaaEnabled;
  126845. private _imageProcessingEnabled;
  126846. private _defaultPipelineTextureType;
  126847. private _bloomScale;
  126848. private _chromaticAberrationEnabled;
  126849. private _grainEnabled;
  126850. private _buildAllowed;
  126851. /**
  126852. * Gets active scene
  126853. */
  126854. readonly scene: Scene;
  126855. /**
  126856. * Enable or disable the sharpen process from the pipeline
  126857. */
  126858. sharpenEnabled: boolean;
  126859. private _resizeObserver;
  126860. private _hardwareScaleLevel;
  126861. private _bloomKernel;
  126862. /**
  126863. * Specifies the size of the bloom blur kernel, relative to the final output size
  126864. */
  126865. bloomKernel: number;
  126866. /**
  126867. * Specifies the weight of the bloom in the final rendering
  126868. */
  126869. private _bloomWeight;
  126870. /**
  126871. * Specifies the luma threshold for the area that will be blurred by the bloom
  126872. */
  126873. private _bloomThreshold;
  126874. private _hdr;
  126875. /**
  126876. * The strength of the bloom.
  126877. */
  126878. bloomWeight: number;
  126879. /**
  126880. * The strength of the bloom.
  126881. */
  126882. bloomThreshold: number;
  126883. /**
  126884. * The scale of the bloom, lower value will provide better performance.
  126885. */
  126886. bloomScale: number;
  126887. /**
  126888. * Enable or disable the bloom from the pipeline
  126889. */
  126890. bloomEnabled: boolean;
  126891. private _rebuildBloom;
  126892. /**
  126893. * If the depth of field is enabled.
  126894. */
  126895. depthOfFieldEnabled: boolean;
  126896. /**
  126897. * Blur level of the depth of field effect. (Higher blur will effect performance)
  126898. */
  126899. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  126900. /**
  126901. * If the anti aliasing is enabled.
  126902. */
  126903. fxaaEnabled: boolean;
  126904. private _samples;
  126905. /**
  126906. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  126907. */
  126908. samples: number;
  126909. /**
  126910. * If image processing is enabled.
  126911. */
  126912. imageProcessingEnabled: boolean;
  126913. /**
  126914. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  126915. */
  126916. glowLayerEnabled: boolean;
  126917. /**
  126918. * Gets the glow layer (or null if not defined)
  126919. */
  126920. readonly glowLayer: Nullable<GlowLayer>;
  126921. /**
  126922. * Enable or disable the chromaticAberration process from the pipeline
  126923. */
  126924. chromaticAberrationEnabled: boolean;
  126925. /**
  126926. * Enable or disable the grain process from the pipeline
  126927. */
  126928. grainEnabled: boolean;
  126929. /**
  126930. * @constructor
  126931. * @param name - The rendering pipeline name (default: "")
  126932. * @param hdr - If high dynamic range textures should be used (default: true)
  126933. * @param scene - The scene linked to this pipeline (default: the last created scene)
  126934. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  126935. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  126936. */
  126937. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  126938. /**
  126939. * Get the class name
  126940. * @returns "DefaultRenderingPipeline"
  126941. */
  126942. getClassName(): string;
  126943. /**
  126944. * Force the compilation of the entire pipeline.
  126945. */
  126946. prepare(): void;
  126947. private _hasCleared;
  126948. private _prevPostProcess;
  126949. private _prevPrevPostProcess;
  126950. private _setAutoClearAndTextureSharing;
  126951. private _depthOfFieldSceneObserver;
  126952. private _buildPipeline;
  126953. private _disposePostProcesses;
  126954. /**
  126955. * Adds a camera to the pipeline
  126956. * @param camera the camera to be added
  126957. */
  126958. addCamera(camera: Camera): void;
  126959. /**
  126960. * Removes a camera from the pipeline
  126961. * @param camera the camera to remove
  126962. */
  126963. removeCamera(camera: Camera): void;
  126964. /**
  126965. * Dispose of the pipeline and stop all post processes
  126966. */
  126967. dispose(): void;
  126968. /**
  126969. * Serialize the rendering pipeline (Used when exporting)
  126970. * @returns the serialized object
  126971. */
  126972. serialize(): any;
  126973. /**
  126974. * Parse the serialized pipeline
  126975. * @param source Source pipeline.
  126976. * @param scene The scene to load the pipeline to.
  126977. * @param rootUrl The URL of the serialized pipeline.
  126978. * @returns An instantiated pipeline from the serialized object.
  126979. */
  126980. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  126981. }
  126982. }
  126983. declare module BABYLON {
  126984. /** @hidden */
  126985. export var lensHighlightsPixelShader: {
  126986. name: string;
  126987. shader: string;
  126988. };
  126989. }
  126990. declare module BABYLON {
  126991. /** @hidden */
  126992. export var depthOfFieldPixelShader: {
  126993. name: string;
  126994. shader: string;
  126995. };
  126996. }
  126997. declare module BABYLON {
  126998. /**
  126999. * BABYLON.JS Chromatic Aberration GLSL Shader
  127000. * Author: Olivier Guyot
  127001. * Separates very slightly R, G and B colors on the edges of the screen
  127002. * Inspired by Francois Tarlier & Martins Upitis
  127003. */
  127004. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  127005. /**
  127006. * @ignore
  127007. * The chromatic aberration PostProcess id in the pipeline
  127008. */
  127009. LensChromaticAberrationEffect: string;
  127010. /**
  127011. * @ignore
  127012. * The highlights enhancing PostProcess id in the pipeline
  127013. */
  127014. HighlightsEnhancingEffect: string;
  127015. /**
  127016. * @ignore
  127017. * The depth-of-field PostProcess id in the pipeline
  127018. */
  127019. LensDepthOfFieldEffect: string;
  127020. private _scene;
  127021. private _depthTexture;
  127022. private _grainTexture;
  127023. private _chromaticAberrationPostProcess;
  127024. private _highlightsPostProcess;
  127025. private _depthOfFieldPostProcess;
  127026. private _edgeBlur;
  127027. private _grainAmount;
  127028. private _chromaticAberration;
  127029. private _distortion;
  127030. private _highlightsGain;
  127031. private _highlightsThreshold;
  127032. private _dofDistance;
  127033. private _dofAperture;
  127034. private _dofDarken;
  127035. private _dofPentagon;
  127036. private _blurNoise;
  127037. /**
  127038. * @constructor
  127039. *
  127040. * Effect parameters are as follow:
  127041. * {
  127042. * chromatic_aberration: number; // from 0 to x (1 for realism)
  127043. * edge_blur: number; // from 0 to x (1 for realism)
  127044. * distortion: number; // from 0 to x (1 for realism)
  127045. * grain_amount: number; // from 0 to 1
  127046. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  127047. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  127048. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  127049. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  127050. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  127051. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  127052. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  127053. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  127054. * }
  127055. * Note: if an effect parameter is unset, effect is disabled
  127056. *
  127057. * @param name The rendering pipeline name
  127058. * @param parameters - An object containing all parameters (see above)
  127059. * @param scene The scene linked to this pipeline
  127060. * @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)
  127061. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127062. */
  127063. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  127064. /**
  127065. * Get the class name
  127066. * @returns "LensRenderingPipeline"
  127067. */
  127068. getClassName(): string;
  127069. /**
  127070. * Gets associated scene
  127071. */
  127072. readonly scene: Scene;
  127073. /**
  127074. * Gets or sets the edge blur
  127075. */
  127076. edgeBlur: number;
  127077. /**
  127078. * Gets or sets the grain amount
  127079. */
  127080. grainAmount: number;
  127081. /**
  127082. * Gets or sets the chromatic aberration amount
  127083. */
  127084. chromaticAberration: number;
  127085. /**
  127086. * Gets or sets the depth of field aperture
  127087. */
  127088. dofAperture: number;
  127089. /**
  127090. * Gets or sets the edge distortion
  127091. */
  127092. edgeDistortion: number;
  127093. /**
  127094. * Gets or sets the depth of field distortion
  127095. */
  127096. dofDistortion: number;
  127097. /**
  127098. * Gets or sets the darken out of focus amount
  127099. */
  127100. darkenOutOfFocus: number;
  127101. /**
  127102. * Gets or sets a boolean indicating if blur noise is enabled
  127103. */
  127104. blurNoise: boolean;
  127105. /**
  127106. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  127107. */
  127108. pentagonBokeh: boolean;
  127109. /**
  127110. * Gets or sets the highlight grain amount
  127111. */
  127112. highlightsGain: number;
  127113. /**
  127114. * Gets or sets the highlight threshold
  127115. */
  127116. highlightsThreshold: number;
  127117. /**
  127118. * Sets the amount of blur at the edges
  127119. * @param amount blur amount
  127120. */
  127121. setEdgeBlur(amount: number): void;
  127122. /**
  127123. * Sets edge blur to 0
  127124. */
  127125. disableEdgeBlur(): void;
  127126. /**
  127127. * Sets the amout of grain
  127128. * @param amount Amount of grain
  127129. */
  127130. setGrainAmount(amount: number): void;
  127131. /**
  127132. * Set grain amount to 0
  127133. */
  127134. disableGrain(): void;
  127135. /**
  127136. * Sets the chromatic aberration amount
  127137. * @param amount amount of chromatic aberration
  127138. */
  127139. setChromaticAberration(amount: number): void;
  127140. /**
  127141. * Sets chromatic aberration amount to 0
  127142. */
  127143. disableChromaticAberration(): void;
  127144. /**
  127145. * Sets the EdgeDistortion amount
  127146. * @param amount amount of EdgeDistortion
  127147. */
  127148. setEdgeDistortion(amount: number): void;
  127149. /**
  127150. * Sets edge distortion to 0
  127151. */
  127152. disableEdgeDistortion(): void;
  127153. /**
  127154. * Sets the FocusDistance amount
  127155. * @param amount amount of FocusDistance
  127156. */
  127157. setFocusDistance(amount: number): void;
  127158. /**
  127159. * Disables depth of field
  127160. */
  127161. disableDepthOfField(): void;
  127162. /**
  127163. * Sets the Aperture amount
  127164. * @param amount amount of Aperture
  127165. */
  127166. setAperture(amount: number): void;
  127167. /**
  127168. * Sets the DarkenOutOfFocus amount
  127169. * @param amount amount of DarkenOutOfFocus
  127170. */
  127171. setDarkenOutOfFocus(amount: number): void;
  127172. private _pentagonBokehIsEnabled;
  127173. /**
  127174. * Creates a pentagon bokeh effect
  127175. */
  127176. enablePentagonBokeh(): void;
  127177. /**
  127178. * Disables the pentagon bokeh effect
  127179. */
  127180. disablePentagonBokeh(): void;
  127181. /**
  127182. * Enables noise blur
  127183. */
  127184. enableNoiseBlur(): void;
  127185. /**
  127186. * Disables noise blur
  127187. */
  127188. disableNoiseBlur(): void;
  127189. /**
  127190. * Sets the HighlightsGain amount
  127191. * @param amount amount of HighlightsGain
  127192. */
  127193. setHighlightsGain(amount: number): void;
  127194. /**
  127195. * Sets the HighlightsThreshold amount
  127196. * @param amount amount of HighlightsThreshold
  127197. */
  127198. setHighlightsThreshold(amount: number): void;
  127199. /**
  127200. * Disables highlights
  127201. */
  127202. disableHighlights(): void;
  127203. /**
  127204. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  127205. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  127206. */
  127207. dispose(disableDepthRender?: boolean): void;
  127208. private _createChromaticAberrationPostProcess;
  127209. private _createHighlightsPostProcess;
  127210. private _createDepthOfFieldPostProcess;
  127211. private _createGrainTexture;
  127212. }
  127213. }
  127214. declare module BABYLON {
  127215. /** @hidden */
  127216. export var ssao2PixelShader: {
  127217. name: string;
  127218. shader: string;
  127219. };
  127220. }
  127221. declare module BABYLON {
  127222. /** @hidden */
  127223. export var ssaoCombinePixelShader: {
  127224. name: string;
  127225. shader: string;
  127226. };
  127227. }
  127228. declare module BABYLON {
  127229. /**
  127230. * Render pipeline to produce ssao effect
  127231. */
  127232. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  127233. /**
  127234. * @ignore
  127235. * The PassPostProcess id in the pipeline that contains the original scene color
  127236. */
  127237. SSAOOriginalSceneColorEffect: string;
  127238. /**
  127239. * @ignore
  127240. * The SSAO PostProcess id in the pipeline
  127241. */
  127242. SSAORenderEffect: string;
  127243. /**
  127244. * @ignore
  127245. * The horizontal blur PostProcess id in the pipeline
  127246. */
  127247. SSAOBlurHRenderEffect: string;
  127248. /**
  127249. * @ignore
  127250. * The vertical blur PostProcess id in the pipeline
  127251. */
  127252. SSAOBlurVRenderEffect: string;
  127253. /**
  127254. * @ignore
  127255. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127256. */
  127257. SSAOCombineRenderEffect: string;
  127258. /**
  127259. * The output strength of the SSAO post-process. Default value is 1.0.
  127260. */
  127261. totalStrength: number;
  127262. /**
  127263. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  127264. */
  127265. maxZ: number;
  127266. /**
  127267. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  127268. */
  127269. minZAspect: number;
  127270. private _samples;
  127271. /**
  127272. * Number of samples used for the SSAO calculations. Default value is 8
  127273. */
  127274. samples: number;
  127275. private _textureSamples;
  127276. /**
  127277. * Number of samples to use for antialiasing
  127278. */
  127279. textureSamples: number;
  127280. /**
  127281. * Ratio object used for SSAO ratio and blur ratio
  127282. */
  127283. private _ratio;
  127284. /**
  127285. * Dynamically generated sphere sampler.
  127286. */
  127287. private _sampleSphere;
  127288. /**
  127289. * Blur filter offsets
  127290. */
  127291. private _samplerOffsets;
  127292. private _expensiveBlur;
  127293. /**
  127294. * If bilateral blur should be used
  127295. */
  127296. expensiveBlur: boolean;
  127297. /**
  127298. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  127299. */
  127300. radius: number;
  127301. /**
  127302. * The base color of the SSAO post-process
  127303. * The final result is "base + ssao" between [0, 1]
  127304. */
  127305. base: number;
  127306. /**
  127307. * Support test.
  127308. */
  127309. static readonly IsSupported: boolean;
  127310. private _scene;
  127311. private _depthTexture;
  127312. private _normalTexture;
  127313. private _randomTexture;
  127314. private _originalColorPostProcess;
  127315. private _ssaoPostProcess;
  127316. private _blurHPostProcess;
  127317. private _blurVPostProcess;
  127318. private _ssaoCombinePostProcess;
  127319. private _firstUpdate;
  127320. /**
  127321. * Gets active scene
  127322. */
  127323. readonly scene: Scene;
  127324. /**
  127325. * @constructor
  127326. * @param name The rendering pipeline name
  127327. * @param scene The scene linked to this pipeline
  127328. * @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 }
  127329. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127330. */
  127331. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127332. /**
  127333. * Get the class name
  127334. * @returns "SSAO2RenderingPipeline"
  127335. */
  127336. getClassName(): string;
  127337. /**
  127338. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127339. */
  127340. dispose(disableGeometryBufferRenderer?: boolean): void;
  127341. private _createBlurPostProcess;
  127342. /** @hidden */
  127343. _rebuild(): void;
  127344. private _bits;
  127345. private _radicalInverse_VdC;
  127346. private _hammersley;
  127347. private _hemisphereSample_uniform;
  127348. private _generateHemisphere;
  127349. private _createSSAOPostProcess;
  127350. private _createSSAOCombinePostProcess;
  127351. private _createRandomTexture;
  127352. /**
  127353. * Serialize the rendering pipeline (Used when exporting)
  127354. * @returns the serialized object
  127355. */
  127356. serialize(): any;
  127357. /**
  127358. * Parse the serialized pipeline
  127359. * @param source Source pipeline.
  127360. * @param scene The scene to load the pipeline to.
  127361. * @param rootUrl The URL of the serialized pipeline.
  127362. * @returns An instantiated pipeline from the serialized object.
  127363. */
  127364. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  127365. }
  127366. }
  127367. declare module BABYLON {
  127368. /** @hidden */
  127369. export var ssaoPixelShader: {
  127370. name: string;
  127371. shader: string;
  127372. };
  127373. }
  127374. declare module BABYLON {
  127375. /**
  127376. * Render pipeline to produce ssao effect
  127377. */
  127378. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  127379. /**
  127380. * @ignore
  127381. * The PassPostProcess id in the pipeline that contains the original scene color
  127382. */
  127383. SSAOOriginalSceneColorEffect: string;
  127384. /**
  127385. * @ignore
  127386. * The SSAO PostProcess id in the pipeline
  127387. */
  127388. SSAORenderEffect: string;
  127389. /**
  127390. * @ignore
  127391. * The horizontal blur PostProcess id in the pipeline
  127392. */
  127393. SSAOBlurHRenderEffect: string;
  127394. /**
  127395. * @ignore
  127396. * The vertical blur PostProcess id in the pipeline
  127397. */
  127398. SSAOBlurVRenderEffect: string;
  127399. /**
  127400. * @ignore
  127401. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  127402. */
  127403. SSAOCombineRenderEffect: string;
  127404. /**
  127405. * The output strength of the SSAO post-process. Default value is 1.0.
  127406. */
  127407. totalStrength: number;
  127408. /**
  127409. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  127410. */
  127411. radius: number;
  127412. /**
  127413. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  127414. * Must not be equal to fallOff and superior to fallOff.
  127415. * Default value is 0.0075
  127416. */
  127417. area: number;
  127418. /**
  127419. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  127420. * Must not be equal to area and inferior to area.
  127421. * Default value is 0.000001
  127422. */
  127423. fallOff: number;
  127424. /**
  127425. * The base color of the SSAO post-process
  127426. * The final result is "base + ssao" between [0, 1]
  127427. */
  127428. base: number;
  127429. private _scene;
  127430. private _depthTexture;
  127431. private _randomTexture;
  127432. private _originalColorPostProcess;
  127433. private _ssaoPostProcess;
  127434. private _blurHPostProcess;
  127435. private _blurVPostProcess;
  127436. private _ssaoCombinePostProcess;
  127437. private _firstUpdate;
  127438. /**
  127439. * Gets active scene
  127440. */
  127441. readonly scene: Scene;
  127442. /**
  127443. * @constructor
  127444. * @param name - The rendering pipeline name
  127445. * @param scene - The scene linked to this pipeline
  127446. * @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 }
  127447. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  127448. */
  127449. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  127450. /**
  127451. * Get the class name
  127452. * @returns "SSAORenderingPipeline"
  127453. */
  127454. getClassName(): string;
  127455. /**
  127456. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  127457. */
  127458. dispose(disableDepthRender?: boolean): void;
  127459. private _createBlurPostProcess;
  127460. /** @hidden */
  127461. _rebuild(): void;
  127462. private _createSSAOPostProcess;
  127463. private _createSSAOCombinePostProcess;
  127464. private _createRandomTexture;
  127465. }
  127466. }
  127467. declare module BABYLON {
  127468. /** @hidden */
  127469. export var standardPixelShader: {
  127470. name: string;
  127471. shader: string;
  127472. };
  127473. }
  127474. declare module BABYLON {
  127475. /**
  127476. * Standard rendering pipeline
  127477. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127478. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  127479. */
  127480. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  127481. /**
  127482. * Public members
  127483. */
  127484. /**
  127485. * Post-process which contains the original scene color before the pipeline applies all the effects
  127486. */
  127487. originalPostProcess: Nullable<PostProcess>;
  127488. /**
  127489. * Post-process used to down scale an image x4
  127490. */
  127491. downSampleX4PostProcess: Nullable<PostProcess>;
  127492. /**
  127493. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  127494. */
  127495. brightPassPostProcess: Nullable<PostProcess>;
  127496. /**
  127497. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  127498. */
  127499. blurHPostProcesses: PostProcess[];
  127500. /**
  127501. * Post-process array storing all the vertical blur post-processes used by the pipeline
  127502. */
  127503. blurVPostProcesses: PostProcess[];
  127504. /**
  127505. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  127506. */
  127507. textureAdderPostProcess: Nullable<PostProcess>;
  127508. /**
  127509. * Post-process used to create volumetric lighting effect
  127510. */
  127511. volumetricLightPostProcess: Nullable<PostProcess>;
  127512. /**
  127513. * Post-process used to smooth the previous volumetric light post-process on the X axis
  127514. */
  127515. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  127516. /**
  127517. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  127518. */
  127519. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  127520. /**
  127521. * Post-process used to merge the volumetric light effect and the real scene color
  127522. */
  127523. volumetricLightMergePostProces: Nullable<PostProcess>;
  127524. /**
  127525. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  127526. */
  127527. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  127528. /**
  127529. * Base post-process used to calculate the average luminance of the final image for HDR
  127530. */
  127531. luminancePostProcess: Nullable<PostProcess>;
  127532. /**
  127533. * Post-processes used to create down sample post-processes in order to get
  127534. * the average luminance of the final image for HDR
  127535. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  127536. */
  127537. luminanceDownSamplePostProcesses: PostProcess[];
  127538. /**
  127539. * Post-process used to create a HDR effect (light adaptation)
  127540. */
  127541. hdrPostProcess: Nullable<PostProcess>;
  127542. /**
  127543. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  127544. */
  127545. textureAdderFinalPostProcess: Nullable<PostProcess>;
  127546. /**
  127547. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  127548. */
  127549. lensFlareFinalPostProcess: Nullable<PostProcess>;
  127550. /**
  127551. * Post-process used to merge the final HDR post-process and the real scene color
  127552. */
  127553. hdrFinalPostProcess: Nullable<PostProcess>;
  127554. /**
  127555. * Post-process used to create a lens flare effect
  127556. */
  127557. lensFlarePostProcess: Nullable<PostProcess>;
  127558. /**
  127559. * Post-process that merges the result of the lens flare post-process and the real scene color
  127560. */
  127561. lensFlareComposePostProcess: Nullable<PostProcess>;
  127562. /**
  127563. * Post-process used to create a motion blur effect
  127564. */
  127565. motionBlurPostProcess: Nullable<PostProcess>;
  127566. /**
  127567. * Post-process used to create a depth of field effect
  127568. */
  127569. depthOfFieldPostProcess: Nullable<PostProcess>;
  127570. /**
  127571. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  127572. */
  127573. fxaaPostProcess: Nullable<FxaaPostProcess>;
  127574. /**
  127575. * Represents the brightness threshold in order to configure the illuminated surfaces
  127576. */
  127577. brightThreshold: number;
  127578. /**
  127579. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  127580. */
  127581. blurWidth: number;
  127582. /**
  127583. * Sets if the blur for highlighted surfaces must be only horizontal
  127584. */
  127585. horizontalBlur: boolean;
  127586. /**
  127587. * Gets the overall exposure used by the pipeline
  127588. */
  127589. /**
  127590. * Sets the overall exposure used by the pipeline
  127591. */
  127592. exposure: number;
  127593. /**
  127594. * Texture used typically to simulate "dirty" on camera lens
  127595. */
  127596. lensTexture: Nullable<Texture>;
  127597. /**
  127598. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  127599. */
  127600. volumetricLightCoefficient: number;
  127601. /**
  127602. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  127603. */
  127604. volumetricLightPower: number;
  127605. /**
  127606. * Used the set the blur intensity to smooth the volumetric lights
  127607. */
  127608. volumetricLightBlurScale: number;
  127609. /**
  127610. * Light (spot or directional) used to generate the volumetric lights rays
  127611. * The source light must have a shadow generate so the pipeline can get its
  127612. * depth map
  127613. */
  127614. sourceLight: Nullable<SpotLight | DirectionalLight>;
  127615. /**
  127616. * For eye adaptation, represents the minimum luminance the eye can see
  127617. */
  127618. hdrMinimumLuminance: number;
  127619. /**
  127620. * For eye adaptation, represents the decrease luminance speed
  127621. */
  127622. hdrDecreaseRate: number;
  127623. /**
  127624. * For eye adaptation, represents the increase luminance speed
  127625. */
  127626. hdrIncreaseRate: number;
  127627. /**
  127628. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127629. */
  127630. /**
  127631. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  127632. */
  127633. hdrAutoExposure: boolean;
  127634. /**
  127635. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  127636. */
  127637. lensColorTexture: Nullable<Texture>;
  127638. /**
  127639. * The overall strengh for the lens flare effect
  127640. */
  127641. lensFlareStrength: number;
  127642. /**
  127643. * Dispersion coefficient for lens flare ghosts
  127644. */
  127645. lensFlareGhostDispersal: number;
  127646. /**
  127647. * Main lens flare halo width
  127648. */
  127649. lensFlareHaloWidth: number;
  127650. /**
  127651. * Based on the lens distortion effect, defines how much the lens flare result
  127652. * is distorted
  127653. */
  127654. lensFlareDistortionStrength: number;
  127655. /**
  127656. * Configures the blur intensity used for for lens flare (halo)
  127657. */
  127658. lensFlareBlurWidth: number;
  127659. /**
  127660. * Lens star texture must be used to simulate rays on the flares and is available
  127661. * in the documentation
  127662. */
  127663. lensStarTexture: Nullable<Texture>;
  127664. /**
  127665. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  127666. * flare effect by taking account of the dirt texture
  127667. */
  127668. lensFlareDirtTexture: Nullable<Texture>;
  127669. /**
  127670. * Represents the focal length for the depth of field effect
  127671. */
  127672. depthOfFieldDistance: number;
  127673. /**
  127674. * Represents the blur intensity for the blurred part of the depth of field effect
  127675. */
  127676. depthOfFieldBlurWidth: number;
  127677. /**
  127678. * Gets how much the image is blurred by the movement while using the motion blur post-process
  127679. */
  127680. /**
  127681. * Sets how much the image is blurred by the movement while using the motion blur post-process
  127682. */
  127683. motionStrength: number;
  127684. /**
  127685. * Gets wether or not the motion blur post-process is object based or screen based.
  127686. */
  127687. /**
  127688. * Sets wether or not the motion blur post-process should be object based or screen based
  127689. */
  127690. objectBasedMotionBlur: boolean;
  127691. /**
  127692. * List of animations for the pipeline (IAnimatable implementation)
  127693. */
  127694. animations: Animation[];
  127695. /**
  127696. * Private members
  127697. */
  127698. private _scene;
  127699. private _currentDepthOfFieldSource;
  127700. private _basePostProcess;
  127701. private _fixedExposure;
  127702. private _currentExposure;
  127703. private _hdrAutoExposure;
  127704. private _hdrCurrentLuminance;
  127705. private _motionStrength;
  127706. private _isObjectBasedMotionBlur;
  127707. private _floatTextureType;
  127708. private _camerasToBeAttached;
  127709. private _ratio;
  127710. private _bloomEnabled;
  127711. private _depthOfFieldEnabled;
  127712. private _vlsEnabled;
  127713. private _lensFlareEnabled;
  127714. private _hdrEnabled;
  127715. private _motionBlurEnabled;
  127716. private _fxaaEnabled;
  127717. private _motionBlurSamples;
  127718. private _volumetricLightStepsCount;
  127719. private _samples;
  127720. /**
  127721. * @ignore
  127722. * Specifies if the bloom pipeline is enabled
  127723. */
  127724. BloomEnabled: boolean;
  127725. /**
  127726. * @ignore
  127727. * Specifies if the depth of field pipeline is enabed
  127728. */
  127729. DepthOfFieldEnabled: boolean;
  127730. /**
  127731. * @ignore
  127732. * Specifies if the lens flare pipeline is enabed
  127733. */
  127734. LensFlareEnabled: boolean;
  127735. /**
  127736. * @ignore
  127737. * Specifies if the HDR pipeline is enabled
  127738. */
  127739. HDREnabled: boolean;
  127740. /**
  127741. * @ignore
  127742. * Specifies if the volumetric lights scattering effect is enabled
  127743. */
  127744. VLSEnabled: boolean;
  127745. /**
  127746. * @ignore
  127747. * Specifies if the motion blur effect is enabled
  127748. */
  127749. MotionBlurEnabled: boolean;
  127750. /**
  127751. * Specifies if anti-aliasing is enabled
  127752. */
  127753. fxaaEnabled: boolean;
  127754. /**
  127755. * Specifies the number of steps used to calculate the volumetric lights
  127756. * Typically in interval [50, 200]
  127757. */
  127758. volumetricLightStepsCount: number;
  127759. /**
  127760. * Specifies the number of samples used for the motion blur effect
  127761. * Typically in interval [16, 64]
  127762. */
  127763. motionBlurSamples: number;
  127764. /**
  127765. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  127766. */
  127767. samples: number;
  127768. /**
  127769. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  127770. * @constructor
  127771. * @param name The rendering pipeline name
  127772. * @param scene The scene linked to this pipeline
  127773. * @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)
  127774. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  127775. * @param cameras The array of cameras that the rendering pipeline will be attached to
  127776. */
  127777. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  127778. private _buildPipeline;
  127779. private _createDownSampleX4PostProcess;
  127780. private _createBrightPassPostProcess;
  127781. private _createBlurPostProcesses;
  127782. private _createTextureAdderPostProcess;
  127783. private _createVolumetricLightPostProcess;
  127784. private _createLuminancePostProcesses;
  127785. private _createHdrPostProcess;
  127786. private _createLensFlarePostProcess;
  127787. private _createDepthOfFieldPostProcess;
  127788. private _createMotionBlurPostProcess;
  127789. private _getDepthTexture;
  127790. private _disposePostProcesses;
  127791. /**
  127792. * Dispose of the pipeline and stop all post processes
  127793. */
  127794. dispose(): void;
  127795. /**
  127796. * Serialize the rendering pipeline (Used when exporting)
  127797. * @returns the serialized object
  127798. */
  127799. serialize(): any;
  127800. /**
  127801. * Parse the serialized pipeline
  127802. * @param source Source pipeline.
  127803. * @param scene The scene to load the pipeline to.
  127804. * @param rootUrl The URL of the serialized pipeline.
  127805. * @returns An instantiated pipeline from the serialized object.
  127806. */
  127807. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  127808. /**
  127809. * Luminance steps
  127810. */
  127811. static LuminanceSteps: number;
  127812. }
  127813. }
  127814. declare module BABYLON {
  127815. /** @hidden */
  127816. export var tonemapPixelShader: {
  127817. name: string;
  127818. shader: string;
  127819. };
  127820. }
  127821. declare module BABYLON {
  127822. /** Defines operator used for tonemapping */
  127823. export enum TonemappingOperator {
  127824. /** Hable */
  127825. Hable = 0,
  127826. /** Reinhard */
  127827. Reinhard = 1,
  127828. /** HejiDawson */
  127829. HejiDawson = 2,
  127830. /** Photographic */
  127831. Photographic = 3
  127832. }
  127833. /**
  127834. * Defines a post process to apply tone mapping
  127835. */
  127836. export class TonemapPostProcess extends PostProcess {
  127837. private _operator;
  127838. /** Defines the required exposure adjustement */
  127839. exposureAdjustment: number;
  127840. /**
  127841. * Creates a new TonemapPostProcess
  127842. * @param name defines the name of the postprocess
  127843. * @param _operator defines the operator to use
  127844. * @param exposureAdjustment defines the required exposure adjustement
  127845. * @param camera defines the camera to use (can be null)
  127846. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  127847. * @param engine defines the hosting engine (can be ignore if camera is set)
  127848. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  127849. */
  127850. constructor(name: string, _operator: TonemappingOperator,
  127851. /** Defines the required exposure adjustement */
  127852. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  127853. }
  127854. }
  127855. declare module BABYLON {
  127856. /** @hidden */
  127857. export var depthVertexShader: {
  127858. name: string;
  127859. shader: string;
  127860. };
  127861. }
  127862. declare module BABYLON {
  127863. /** @hidden */
  127864. export var volumetricLightScatteringPixelShader: {
  127865. name: string;
  127866. shader: string;
  127867. };
  127868. }
  127869. declare module BABYLON {
  127870. /** @hidden */
  127871. export var volumetricLightScatteringPassVertexShader: {
  127872. name: string;
  127873. shader: string;
  127874. };
  127875. }
  127876. declare module BABYLON {
  127877. /** @hidden */
  127878. export var volumetricLightScatteringPassPixelShader: {
  127879. name: string;
  127880. shader: string;
  127881. };
  127882. }
  127883. declare module BABYLON {
  127884. /**
  127885. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  127886. */
  127887. export class VolumetricLightScatteringPostProcess extends PostProcess {
  127888. private _volumetricLightScatteringPass;
  127889. private _volumetricLightScatteringRTT;
  127890. private _viewPort;
  127891. private _screenCoordinates;
  127892. private _cachedDefines;
  127893. /**
  127894. * If not undefined, the mesh position is computed from the attached node position
  127895. */
  127896. attachedNode: {
  127897. position: Vector3;
  127898. };
  127899. /**
  127900. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  127901. */
  127902. customMeshPosition: Vector3;
  127903. /**
  127904. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  127905. */
  127906. useCustomMeshPosition: boolean;
  127907. /**
  127908. * If the post-process should inverse the light scattering direction
  127909. */
  127910. invert: boolean;
  127911. /**
  127912. * The internal mesh used by the post-process
  127913. */
  127914. mesh: Mesh;
  127915. /**
  127916. * @hidden
  127917. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  127918. */
  127919. useDiffuseColor: boolean;
  127920. /**
  127921. * Array containing the excluded meshes not rendered in the internal pass
  127922. */
  127923. excludedMeshes: AbstractMesh[];
  127924. /**
  127925. * Controls the overall intensity of the post-process
  127926. */
  127927. exposure: number;
  127928. /**
  127929. * Dissipates each sample's contribution in range [0, 1]
  127930. */
  127931. decay: number;
  127932. /**
  127933. * Controls the overall intensity of each sample
  127934. */
  127935. weight: number;
  127936. /**
  127937. * Controls the density of each sample
  127938. */
  127939. density: number;
  127940. /**
  127941. * @constructor
  127942. * @param name The post-process name
  127943. * @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)
  127944. * @param camera The camera that the post-process will be attached to
  127945. * @param mesh The mesh used to create the light scattering
  127946. * @param samples The post-process quality, default 100
  127947. * @param samplingModeThe post-process filtering mode
  127948. * @param engine The babylon engine
  127949. * @param reusable If the post-process is reusable
  127950. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  127951. */
  127952. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  127953. /**
  127954. * Returns the string "VolumetricLightScatteringPostProcess"
  127955. * @returns "VolumetricLightScatteringPostProcess"
  127956. */
  127957. getClassName(): string;
  127958. private _isReady;
  127959. /**
  127960. * Sets the new light position for light scattering effect
  127961. * @param position The new custom light position
  127962. */
  127963. setCustomMeshPosition(position: Vector3): void;
  127964. /**
  127965. * Returns the light position for light scattering effect
  127966. * @return Vector3 The custom light position
  127967. */
  127968. getCustomMeshPosition(): Vector3;
  127969. /**
  127970. * Disposes the internal assets and detaches the post-process from the camera
  127971. */
  127972. dispose(camera: Camera): void;
  127973. /**
  127974. * Returns the render target texture used by the post-process
  127975. * @return the render target texture used by the post-process
  127976. */
  127977. getPass(): RenderTargetTexture;
  127978. private _meshExcluded;
  127979. private _createPass;
  127980. private _updateMeshScreenCoordinates;
  127981. /**
  127982. * Creates a default mesh for the Volumeric Light Scattering post-process
  127983. * @param name The mesh name
  127984. * @param scene The scene where to create the mesh
  127985. * @return the default mesh
  127986. */
  127987. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  127988. }
  127989. }
  127990. declare module BABYLON {
  127991. interface Scene {
  127992. /** @hidden (Backing field) */
  127993. _boundingBoxRenderer: BoundingBoxRenderer;
  127994. /** @hidden (Backing field) */
  127995. _forceShowBoundingBoxes: boolean;
  127996. /**
  127997. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  127998. */
  127999. forceShowBoundingBoxes: boolean;
  128000. /**
  128001. * Gets the bounding box renderer associated with the scene
  128002. * @returns a BoundingBoxRenderer
  128003. */
  128004. getBoundingBoxRenderer(): BoundingBoxRenderer;
  128005. }
  128006. interface AbstractMesh {
  128007. /** @hidden (Backing field) */
  128008. _showBoundingBox: boolean;
  128009. /**
  128010. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  128011. */
  128012. showBoundingBox: boolean;
  128013. }
  128014. /**
  128015. * Component responsible of rendering the bounding box of the meshes in a scene.
  128016. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  128017. */
  128018. export class BoundingBoxRenderer implements ISceneComponent {
  128019. /**
  128020. * The component name helpfull to identify the component in the list of scene components.
  128021. */
  128022. readonly name: string;
  128023. /**
  128024. * The scene the component belongs to.
  128025. */
  128026. scene: Scene;
  128027. /**
  128028. * Color of the bounding box lines placed in front of an object
  128029. */
  128030. frontColor: Color3;
  128031. /**
  128032. * Color of the bounding box lines placed behind an object
  128033. */
  128034. backColor: Color3;
  128035. /**
  128036. * Defines if the renderer should show the back lines or not
  128037. */
  128038. showBackLines: boolean;
  128039. /**
  128040. * @hidden
  128041. */
  128042. renderList: SmartArray<BoundingBox>;
  128043. private _colorShader;
  128044. private _vertexBuffers;
  128045. private _indexBuffer;
  128046. private _fillIndexBuffer;
  128047. private _fillIndexData;
  128048. /**
  128049. * Instantiates a new bounding box renderer in a scene.
  128050. * @param scene the scene the renderer renders in
  128051. */
  128052. constructor(scene: Scene);
  128053. /**
  128054. * Registers the component in a given scene
  128055. */
  128056. register(): void;
  128057. private _evaluateSubMesh;
  128058. private _activeMesh;
  128059. private _prepareRessources;
  128060. private _createIndexBuffer;
  128061. /**
  128062. * Rebuilds the elements related to this component in case of
  128063. * context lost for instance.
  128064. */
  128065. rebuild(): void;
  128066. /**
  128067. * @hidden
  128068. */
  128069. reset(): void;
  128070. /**
  128071. * Render the bounding boxes of a specific rendering group
  128072. * @param renderingGroupId defines the rendering group to render
  128073. */
  128074. render(renderingGroupId: number): void;
  128075. /**
  128076. * In case of occlusion queries, we can render the occlusion bounding box through this method
  128077. * @param mesh Define the mesh to render the occlusion bounding box for
  128078. */
  128079. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  128080. /**
  128081. * Dispose and release the resources attached to this renderer.
  128082. */
  128083. dispose(): void;
  128084. }
  128085. }
  128086. declare module BABYLON {
  128087. /** @hidden */
  128088. export var depthPixelShader: {
  128089. name: string;
  128090. shader: string;
  128091. };
  128092. }
  128093. declare module BABYLON {
  128094. /**
  128095. * This represents a depth renderer in Babylon.
  128096. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128097. */
  128098. export class DepthRenderer {
  128099. private _scene;
  128100. private _depthMap;
  128101. private _effect;
  128102. private readonly _storeNonLinearDepth;
  128103. private readonly _clearColor;
  128104. /** Get if the depth renderer is using packed depth or not */
  128105. readonly isPacked: boolean;
  128106. private _cachedDefines;
  128107. private _camera;
  128108. /**
  128109. * Specifiess that the depth renderer will only be used within
  128110. * the camera it is created for.
  128111. * This can help forcing its rendering during the camera processing.
  128112. */
  128113. useOnlyInActiveCamera: boolean;
  128114. /** @hidden */
  128115. static _SceneComponentInitialization: (scene: Scene) => void;
  128116. /**
  128117. * Instantiates a depth renderer
  128118. * @param scene The scene the renderer belongs to
  128119. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128120. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128121. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128122. */
  128123. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128124. /**
  128125. * Creates the depth rendering effect and checks if the effect is ready.
  128126. * @param subMesh The submesh to be used to render the depth map of
  128127. * @param useInstances If multiple world instances should be used
  128128. * @returns if the depth renderer is ready to render the depth map
  128129. */
  128130. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128131. /**
  128132. * Gets the texture which the depth map will be written to.
  128133. * @returns The depth map texture
  128134. */
  128135. getDepthMap(): RenderTargetTexture;
  128136. /**
  128137. * Disposes of the depth renderer.
  128138. */
  128139. dispose(): void;
  128140. }
  128141. }
  128142. declare module BABYLON {
  128143. interface Scene {
  128144. /** @hidden (Backing field) */
  128145. _depthRenderer: {
  128146. [id: string]: DepthRenderer;
  128147. };
  128148. /**
  128149. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  128150. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  128151. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128152. * @returns the created depth renderer
  128153. */
  128154. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  128155. /**
  128156. * Disables a depth renderer for a given camera
  128157. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  128158. */
  128159. disableDepthRenderer(camera?: Nullable<Camera>): void;
  128160. }
  128161. /**
  128162. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  128163. * in several rendering techniques.
  128164. */
  128165. export class DepthRendererSceneComponent implements ISceneComponent {
  128166. /**
  128167. * The component name helpfull to identify the component in the list of scene components.
  128168. */
  128169. readonly name: string;
  128170. /**
  128171. * The scene the component belongs to.
  128172. */
  128173. scene: Scene;
  128174. /**
  128175. * Creates a new instance of the component for the given scene
  128176. * @param scene Defines the scene to register the component in
  128177. */
  128178. constructor(scene: Scene);
  128179. /**
  128180. * Registers the component in a given scene
  128181. */
  128182. register(): void;
  128183. /**
  128184. * Rebuilds the elements related to this component in case of
  128185. * context lost for instance.
  128186. */
  128187. rebuild(): void;
  128188. /**
  128189. * Disposes the component and the associated ressources
  128190. */
  128191. dispose(): void;
  128192. private _gatherRenderTargets;
  128193. private _gatherActiveCameraRenderTargets;
  128194. }
  128195. }
  128196. declare module BABYLON {
  128197. /** @hidden */
  128198. export var outlinePixelShader: {
  128199. name: string;
  128200. shader: string;
  128201. };
  128202. }
  128203. declare module BABYLON {
  128204. /** @hidden */
  128205. export var outlineVertexShader: {
  128206. name: string;
  128207. shader: string;
  128208. };
  128209. }
  128210. declare module BABYLON {
  128211. interface Scene {
  128212. /** @hidden */
  128213. _outlineRenderer: OutlineRenderer;
  128214. /**
  128215. * Gets the outline renderer associated with the scene
  128216. * @returns a OutlineRenderer
  128217. */
  128218. getOutlineRenderer(): OutlineRenderer;
  128219. }
  128220. interface AbstractMesh {
  128221. /** @hidden (Backing field) */
  128222. _renderOutline: boolean;
  128223. /**
  128224. * Gets or sets a boolean indicating if the outline must be rendered as well
  128225. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  128226. */
  128227. renderOutline: boolean;
  128228. /** @hidden (Backing field) */
  128229. _renderOverlay: boolean;
  128230. /**
  128231. * Gets or sets a boolean indicating if the overlay must be rendered as well
  128232. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  128233. */
  128234. renderOverlay: boolean;
  128235. }
  128236. /**
  128237. * This class is responsible to draw bothe outline/overlay of meshes.
  128238. * It should not be used directly but through the available method on mesh.
  128239. */
  128240. export class OutlineRenderer implements ISceneComponent {
  128241. /**
  128242. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  128243. */
  128244. private static _StencilReference;
  128245. /**
  128246. * The name of the component. Each component must have a unique name.
  128247. */
  128248. name: string;
  128249. /**
  128250. * The scene the component belongs to.
  128251. */
  128252. scene: Scene;
  128253. /**
  128254. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  128255. */
  128256. zOffset: number;
  128257. private _engine;
  128258. private _effect;
  128259. private _cachedDefines;
  128260. private _savedDepthWrite;
  128261. /**
  128262. * Instantiates a new outline renderer. (There could be only one per scene).
  128263. * @param scene Defines the scene it belongs to
  128264. */
  128265. constructor(scene: Scene);
  128266. /**
  128267. * Register the component to one instance of a scene.
  128268. */
  128269. register(): void;
  128270. /**
  128271. * Rebuilds the elements related to this component in case of
  128272. * context lost for instance.
  128273. */
  128274. rebuild(): void;
  128275. /**
  128276. * Disposes the component and the associated ressources.
  128277. */
  128278. dispose(): void;
  128279. /**
  128280. * Renders the outline in the canvas.
  128281. * @param subMesh Defines the sumesh to render
  128282. * @param batch Defines the batch of meshes in case of instances
  128283. * @param useOverlay Defines if the rendering is for the overlay or the outline
  128284. */
  128285. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  128286. /**
  128287. * Returns whether or not the outline renderer is ready for a given submesh.
  128288. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  128289. * @param subMesh Defines the submesh to check readyness for
  128290. * @param useInstances Defines wheter wee are trying to render instances or not
  128291. * @returns true if ready otherwise false
  128292. */
  128293. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128294. private _beforeRenderingMesh;
  128295. private _afterRenderingMesh;
  128296. }
  128297. }
  128298. declare module BABYLON {
  128299. /**
  128300. * Class used to manage multiple sprites of different sizes on the same spritesheet
  128301. * @see http://doc.babylonjs.com/babylon101/sprites
  128302. */
  128303. export class SpritePackedManager extends SpriteManager {
  128304. /** defines the packed manager's name */
  128305. name: string;
  128306. /**
  128307. * Creates a new sprite manager from a packed sprite sheet
  128308. * @param name defines the manager's name
  128309. * @param imgUrl defines the sprite sheet url
  128310. * @param capacity defines the maximum allowed number of sprites
  128311. * @param scene defines the hosting scene
  128312. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  128313. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  128314. * @param samplingMode defines the smapling mode to use with spritesheet
  128315. * @param fromPacked set to true; do not alter
  128316. */
  128317. constructor(
  128318. /** defines the packed manager's name */
  128319. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  128320. }
  128321. }
  128322. declare module BABYLON {
  128323. /**
  128324. * Defines the list of states available for a task inside a AssetsManager
  128325. */
  128326. export enum AssetTaskState {
  128327. /**
  128328. * Initialization
  128329. */
  128330. INIT = 0,
  128331. /**
  128332. * Running
  128333. */
  128334. RUNNING = 1,
  128335. /**
  128336. * Done
  128337. */
  128338. DONE = 2,
  128339. /**
  128340. * Error
  128341. */
  128342. ERROR = 3
  128343. }
  128344. /**
  128345. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  128346. */
  128347. export abstract class AbstractAssetTask {
  128348. /**
  128349. * Task name
  128350. */ name: string;
  128351. /**
  128352. * Callback called when the task is successful
  128353. */
  128354. onSuccess: (task: any) => void;
  128355. /**
  128356. * Callback called when the task is not successful
  128357. */
  128358. onError: (task: any, message?: string, exception?: any) => void;
  128359. /**
  128360. * Creates a new AssetsManager
  128361. * @param name defines the name of the task
  128362. */
  128363. constructor(
  128364. /**
  128365. * Task name
  128366. */ name: string);
  128367. private _isCompleted;
  128368. private _taskState;
  128369. private _errorObject;
  128370. /**
  128371. * Get if the task is completed
  128372. */
  128373. readonly isCompleted: boolean;
  128374. /**
  128375. * Gets the current state of the task
  128376. */
  128377. readonly taskState: AssetTaskState;
  128378. /**
  128379. * Gets the current error object (if task is in error)
  128380. */
  128381. readonly errorObject: {
  128382. message?: string;
  128383. exception?: any;
  128384. };
  128385. /**
  128386. * Internal only
  128387. * @hidden
  128388. */
  128389. _setErrorObject(message?: string, exception?: any): void;
  128390. /**
  128391. * Execute the current task
  128392. * @param scene defines the scene where you want your assets to be loaded
  128393. * @param onSuccess is a callback called when the task is successfully executed
  128394. * @param onError is a callback called if an error occurs
  128395. */
  128396. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128397. /**
  128398. * Execute the current task
  128399. * @param scene defines the scene where you want your assets to be loaded
  128400. * @param onSuccess is a callback called when the task is successfully executed
  128401. * @param onError is a callback called if an error occurs
  128402. */
  128403. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128404. /**
  128405. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  128406. * This can be used with failed tasks that have the reason for failure fixed.
  128407. */
  128408. reset(): void;
  128409. private onErrorCallback;
  128410. private onDoneCallback;
  128411. }
  128412. /**
  128413. * Define the interface used by progress events raised during assets loading
  128414. */
  128415. export interface IAssetsProgressEvent {
  128416. /**
  128417. * Defines the number of remaining tasks to process
  128418. */
  128419. remainingCount: number;
  128420. /**
  128421. * Defines the total number of tasks
  128422. */
  128423. totalCount: number;
  128424. /**
  128425. * Defines the task that was just processed
  128426. */
  128427. task: AbstractAssetTask;
  128428. }
  128429. /**
  128430. * Class used to share progress information about assets loading
  128431. */
  128432. export class AssetsProgressEvent implements IAssetsProgressEvent {
  128433. /**
  128434. * Defines the number of remaining tasks to process
  128435. */
  128436. remainingCount: number;
  128437. /**
  128438. * Defines the total number of tasks
  128439. */
  128440. totalCount: number;
  128441. /**
  128442. * Defines the task that was just processed
  128443. */
  128444. task: AbstractAssetTask;
  128445. /**
  128446. * Creates a AssetsProgressEvent
  128447. * @param remainingCount defines the number of remaining tasks to process
  128448. * @param totalCount defines the total number of tasks
  128449. * @param task defines the task that was just processed
  128450. */
  128451. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  128452. }
  128453. /**
  128454. * Define a task used by AssetsManager to load meshes
  128455. */
  128456. export class MeshAssetTask extends AbstractAssetTask {
  128457. /**
  128458. * Defines the name of the task
  128459. */
  128460. name: string;
  128461. /**
  128462. * Defines the list of mesh's names you want to load
  128463. */
  128464. meshesNames: any;
  128465. /**
  128466. * Defines the root url to use as a base to load your meshes and associated resources
  128467. */
  128468. rootUrl: string;
  128469. /**
  128470. * Defines the filename of the scene to load from
  128471. */
  128472. sceneFilename: string;
  128473. /**
  128474. * Gets the list of loaded meshes
  128475. */
  128476. loadedMeshes: Array<AbstractMesh>;
  128477. /**
  128478. * Gets the list of loaded particle systems
  128479. */
  128480. loadedParticleSystems: Array<IParticleSystem>;
  128481. /**
  128482. * Gets the list of loaded skeletons
  128483. */
  128484. loadedSkeletons: Array<Skeleton>;
  128485. /**
  128486. * Gets the list of loaded animation groups
  128487. */
  128488. loadedAnimationGroups: Array<AnimationGroup>;
  128489. /**
  128490. * Callback called when the task is successful
  128491. */
  128492. onSuccess: (task: MeshAssetTask) => void;
  128493. /**
  128494. * Callback called when the task is successful
  128495. */
  128496. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  128497. /**
  128498. * Creates a new MeshAssetTask
  128499. * @param name defines the name of the task
  128500. * @param meshesNames defines the list of mesh's names you want to load
  128501. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  128502. * @param sceneFilename defines the filename of the scene to load from
  128503. */
  128504. constructor(
  128505. /**
  128506. * Defines the name of the task
  128507. */
  128508. name: string,
  128509. /**
  128510. * Defines the list of mesh's names you want to load
  128511. */
  128512. meshesNames: any,
  128513. /**
  128514. * Defines the root url to use as a base to load your meshes and associated resources
  128515. */
  128516. rootUrl: string,
  128517. /**
  128518. * Defines the filename of the scene to load from
  128519. */
  128520. sceneFilename: string);
  128521. /**
  128522. * Execute the current task
  128523. * @param scene defines the scene where you want your assets to be loaded
  128524. * @param onSuccess is a callback called when the task is successfully executed
  128525. * @param onError is a callback called if an error occurs
  128526. */
  128527. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128528. }
  128529. /**
  128530. * Define a task used by AssetsManager to load text content
  128531. */
  128532. export class TextFileAssetTask extends AbstractAssetTask {
  128533. /**
  128534. * Defines the name of the task
  128535. */
  128536. name: string;
  128537. /**
  128538. * Defines the location of the file to load
  128539. */
  128540. url: string;
  128541. /**
  128542. * Gets the loaded text string
  128543. */
  128544. text: string;
  128545. /**
  128546. * Callback called when the task is successful
  128547. */
  128548. onSuccess: (task: TextFileAssetTask) => void;
  128549. /**
  128550. * Callback called when the task is successful
  128551. */
  128552. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  128553. /**
  128554. * Creates a new TextFileAssetTask object
  128555. * @param name defines the name of the task
  128556. * @param url defines the location of the file to load
  128557. */
  128558. constructor(
  128559. /**
  128560. * Defines the name of the task
  128561. */
  128562. name: string,
  128563. /**
  128564. * Defines the location of the file to load
  128565. */
  128566. url: string);
  128567. /**
  128568. * Execute the current task
  128569. * @param scene defines the scene where you want your assets to be loaded
  128570. * @param onSuccess is a callback called when the task is successfully executed
  128571. * @param onError is a callback called if an error occurs
  128572. */
  128573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128574. }
  128575. /**
  128576. * Define a task used by AssetsManager to load binary data
  128577. */
  128578. export class BinaryFileAssetTask extends AbstractAssetTask {
  128579. /**
  128580. * Defines the name of the task
  128581. */
  128582. name: string;
  128583. /**
  128584. * Defines the location of the file to load
  128585. */
  128586. url: string;
  128587. /**
  128588. * Gets the lodaded data (as an array buffer)
  128589. */
  128590. data: ArrayBuffer;
  128591. /**
  128592. * Callback called when the task is successful
  128593. */
  128594. onSuccess: (task: BinaryFileAssetTask) => void;
  128595. /**
  128596. * Callback called when the task is successful
  128597. */
  128598. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  128599. /**
  128600. * Creates a new BinaryFileAssetTask object
  128601. * @param name defines the name of the new task
  128602. * @param url defines the location of the file to load
  128603. */
  128604. constructor(
  128605. /**
  128606. * Defines the name of the task
  128607. */
  128608. name: string,
  128609. /**
  128610. * Defines the location of the file to load
  128611. */
  128612. url: string);
  128613. /**
  128614. * Execute the current task
  128615. * @param scene defines the scene where you want your assets to be loaded
  128616. * @param onSuccess is a callback called when the task is successfully executed
  128617. * @param onError is a callback called if an error occurs
  128618. */
  128619. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128620. }
  128621. /**
  128622. * Define a task used by AssetsManager to load images
  128623. */
  128624. export class ImageAssetTask extends AbstractAssetTask {
  128625. /**
  128626. * Defines the name of the task
  128627. */
  128628. name: string;
  128629. /**
  128630. * Defines the location of the image to load
  128631. */
  128632. url: string;
  128633. /**
  128634. * Gets the loaded images
  128635. */
  128636. image: HTMLImageElement;
  128637. /**
  128638. * Callback called when the task is successful
  128639. */
  128640. onSuccess: (task: ImageAssetTask) => void;
  128641. /**
  128642. * Callback called when the task is successful
  128643. */
  128644. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  128645. /**
  128646. * Creates a new ImageAssetTask
  128647. * @param name defines the name of the task
  128648. * @param url defines the location of the image to load
  128649. */
  128650. constructor(
  128651. /**
  128652. * Defines the name of the task
  128653. */
  128654. name: string,
  128655. /**
  128656. * Defines the location of the image to load
  128657. */
  128658. url: string);
  128659. /**
  128660. * Execute the current task
  128661. * @param scene defines the scene where you want your assets to be loaded
  128662. * @param onSuccess is a callback called when the task is successfully executed
  128663. * @param onError is a callback called if an error occurs
  128664. */
  128665. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128666. }
  128667. /**
  128668. * Defines the interface used by texture loading tasks
  128669. */
  128670. export interface ITextureAssetTask<TEX extends BaseTexture> {
  128671. /**
  128672. * Gets the loaded texture
  128673. */
  128674. texture: TEX;
  128675. }
  128676. /**
  128677. * Define a task used by AssetsManager to load 2D textures
  128678. */
  128679. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  128680. /**
  128681. * Defines the name of the task
  128682. */
  128683. name: string;
  128684. /**
  128685. * Defines the location of the file to load
  128686. */
  128687. url: string;
  128688. /**
  128689. * Defines if mipmap should not be generated (default is false)
  128690. */
  128691. noMipmap?: boolean | undefined;
  128692. /**
  128693. * Defines if texture must be inverted on Y axis (default is false)
  128694. */
  128695. invertY?: boolean | undefined;
  128696. /**
  128697. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128698. */
  128699. samplingMode: number;
  128700. /**
  128701. * Gets the loaded texture
  128702. */
  128703. texture: Texture;
  128704. /**
  128705. * Callback called when the task is successful
  128706. */
  128707. onSuccess: (task: TextureAssetTask) => void;
  128708. /**
  128709. * Callback called when the task is successful
  128710. */
  128711. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  128712. /**
  128713. * Creates a new TextureAssetTask object
  128714. * @param name defines the name of the task
  128715. * @param url defines the location of the file to load
  128716. * @param noMipmap defines if mipmap should not be generated (default is false)
  128717. * @param invertY defines if texture must be inverted on Y axis (default is false)
  128718. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128719. */
  128720. constructor(
  128721. /**
  128722. * Defines the name of the task
  128723. */
  128724. name: string,
  128725. /**
  128726. * Defines the location of the file to load
  128727. */
  128728. url: string,
  128729. /**
  128730. * Defines if mipmap should not be generated (default is false)
  128731. */
  128732. noMipmap?: boolean | undefined,
  128733. /**
  128734. * Defines if texture must be inverted on Y axis (default is false)
  128735. */
  128736. invertY?: boolean | undefined,
  128737. /**
  128738. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  128739. */
  128740. samplingMode?: number);
  128741. /**
  128742. * Execute the current task
  128743. * @param scene defines the scene where you want your assets to be loaded
  128744. * @param onSuccess is a callback called when the task is successfully executed
  128745. * @param onError is a callback called if an error occurs
  128746. */
  128747. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128748. }
  128749. /**
  128750. * Define a task used by AssetsManager to load cube textures
  128751. */
  128752. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  128753. /**
  128754. * Defines the name of the task
  128755. */
  128756. name: string;
  128757. /**
  128758. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128759. */
  128760. url: string;
  128761. /**
  128762. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128763. */
  128764. extensions?: string[] | undefined;
  128765. /**
  128766. * Defines if mipmaps should not be generated (default is false)
  128767. */
  128768. noMipmap?: boolean | undefined;
  128769. /**
  128770. * Defines the explicit list of files (undefined by default)
  128771. */
  128772. files?: string[] | undefined;
  128773. /**
  128774. * Gets the loaded texture
  128775. */
  128776. texture: CubeTexture;
  128777. /**
  128778. * Callback called when the task is successful
  128779. */
  128780. onSuccess: (task: CubeTextureAssetTask) => void;
  128781. /**
  128782. * Callback called when the task is successful
  128783. */
  128784. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  128785. /**
  128786. * Creates a new CubeTextureAssetTask
  128787. * @param name defines the name of the task
  128788. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128789. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128790. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128791. * @param files defines the explicit list of files (undefined by default)
  128792. */
  128793. constructor(
  128794. /**
  128795. * Defines the name of the task
  128796. */
  128797. name: string,
  128798. /**
  128799. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  128800. */
  128801. url: string,
  128802. /**
  128803. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  128804. */
  128805. extensions?: string[] | undefined,
  128806. /**
  128807. * Defines if mipmaps should not be generated (default is false)
  128808. */
  128809. noMipmap?: boolean | undefined,
  128810. /**
  128811. * Defines the explicit list of files (undefined by default)
  128812. */
  128813. files?: string[] | undefined);
  128814. /**
  128815. * Execute the current task
  128816. * @param scene defines the scene where you want your assets to be loaded
  128817. * @param onSuccess is a callback called when the task is successfully executed
  128818. * @param onError is a callback called if an error occurs
  128819. */
  128820. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128821. }
  128822. /**
  128823. * Define a task used by AssetsManager to load HDR cube textures
  128824. */
  128825. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  128826. /**
  128827. * Defines the name of the task
  128828. */
  128829. name: string;
  128830. /**
  128831. * Defines the location of the file to load
  128832. */
  128833. url: string;
  128834. /**
  128835. * Defines the desired size (the more it increases the longer the generation will be)
  128836. */
  128837. size: number;
  128838. /**
  128839. * Defines if mipmaps should not be generated (default is false)
  128840. */
  128841. noMipmap: boolean;
  128842. /**
  128843. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128844. */
  128845. generateHarmonics: boolean;
  128846. /**
  128847. * 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)
  128848. */
  128849. gammaSpace: boolean;
  128850. /**
  128851. * Internal Use Only
  128852. */
  128853. reserved: boolean;
  128854. /**
  128855. * Gets the loaded texture
  128856. */
  128857. texture: HDRCubeTexture;
  128858. /**
  128859. * Callback called when the task is successful
  128860. */
  128861. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  128862. /**
  128863. * Callback called when the task is successful
  128864. */
  128865. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  128866. /**
  128867. * Creates a new HDRCubeTextureAssetTask object
  128868. * @param name defines the name of the task
  128869. * @param url defines the location of the file to load
  128870. * @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.
  128871. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128872. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128873. * @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)
  128874. * @param reserved Internal use only
  128875. */
  128876. constructor(
  128877. /**
  128878. * Defines the name of the task
  128879. */
  128880. name: string,
  128881. /**
  128882. * Defines the location of the file to load
  128883. */
  128884. url: string,
  128885. /**
  128886. * Defines the desired size (the more it increases the longer the generation will be)
  128887. */
  128888. size: number,
  128889. /**
  128890. * Defines if mipmaps should not be generated (default is false)
  128891. */
  128892. noMipmap?: boolean,
  128893. /**
  128894. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  128895. */
  128896. generateHarmonics?: boolean,
  128897. /**
  128898. * 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)
  128899. */
  128900. gammaSpace?: boolean,
  128901. /**
  128902. * Internal Use Only
  128903. */
  128904. reserved?: boolean);
  128905. /**
  128906. * Execute the current task
  128907. * @param scene defines the scene where you want your assets to be loaded
  128908. * @param onSuccess is a callback called when the task is successfully executed
  128909. * @param onError is a callback called if an error occurs
  128910. */
  128911. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128912. }
  128913. /**
  128914. * Define a task used by AssetsManager to load Equirectangular cube textures
  128915. */
  128916. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  128917. /**
  128918. * Defines the name of the task
  128919. */
  128920. name: string;
  128921. /**
  128922. * Defines the location of the file to load
  128923. */
  128924. url: string;
  128925. /**
  128926. * Defines the desired size (the more it increases the longer the generation will be)
  128927. */
  128928. size: number;
  128929. /**
  128930. * Defines if mipmaps should not be generated (default is false)
  128931. */
  128932. noMipmap: boolean;
  128933. /**
  128934. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128935. * but the standard material would require them in Gamma space) (default is true)
  128936. */
  128937. gammaSpace: boolean;
  128938. /**
  128939. * Gets the loaded texture
  128940. */
  128941. texture: EquiRectangularCubeTexture;
  128942. /**
  128943. * Callback called when the task is successful
  128944. */
  128945. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  128946. /**
  128947. * Callback called when the task is successful
  128948. */
  128949. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  128950. /**
  128951. * Creates a new EquiRectangularCubeTextureAssetTask object
  128952. * @param name defines the name of the task
  128953. * @param url defines the location of the file to load
  128954. * @param size defines the desired size (the more it increases the longer the generation will be)
  128955. * If the size is omitted this implies you are using a preprocessed cubemap.
  128956. * @param noMipmap defines if mipmaps should not be generated (default is false)
  128957. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  128958. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  128959. * (default is true)
  128960. */
  128961. constructor(
  128962. /**
  128963. * Defines the name of the task
  128964. */
  128965. name: string,
  128966. /**
  128967. * Defines the location of the file to load
  128968. */
  128969. url: string,
  128970. /**
  128971. * Defines the desired size (the more it increases the longer the generation will be)
  128972. */
  128973. size: number,
  128974. /**
  128975. * Defines if mipmaps should not be generated (default is false)
  128976. */
  128977. noMipmap?: boolean,
  128978. /**
  128979. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  128980. * but the standard material would require them in Gamma space) (default is true)
  128981. */
  128982. gammaSpace?: boolean);
  128983. /**
  128984. * Execute the current task
  128985. * @param scene defines the scene where you want your assets to be loaded
  128986. * @param onSuccess is a callback called when the task is successfully executed
  128987. * @param onError is a callback called if an error occurs
  128988. */
  128989. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  128990. }
  128991. /**
  128992. * This class can be used to easily import assets into a scene
  128993. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  128994. */
  128995. export class AssetsManager {
  128996. private _scene;
  128997. private _isLoading;
  128998. protected _tasks: AbstractAssetTask[];
  128999. protected _waitingTasksCount: number;
  129000. protected _totalTasksCount: number;
  129001. /**
  129002. * Callback called when all tasks are processed
  129003. */
  129004. onFinish: (tasks: AbstractAssetTask[]) => void;
  129005. /**
  129006. * Callback called when a task is successful
  129007. */
  129008. onTaskSuccess: (task: AbstractAssetTask) => void;
  129009. /**
  129010. * Callback called when a task had an error
  129011. */
  129012. onTaskError: (task: AbstractAssetTask) => void;
  129013. /**
  129014. * Callback called when a task is done (whatever the result is)
  129015. */
  129016. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  129017. /**
  129018. * Observable called when all tasks are processed
  129019. */
  129020. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  129021. /**
  129022. * Observable called when a task had an error
  129023. */
  129024. onTaskErrorObservable: Observable<AbstractAssetTask>;
  129025. /**
  129026. * Observable called when all tasks were executed
  129027. */
  129028. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  129029. /**
  129030. * Observable called when a task is done (whatever the result is)
  129031. */
  129032. onProgressObservable: Observable<IAssetsProgressEvent>;
  129033. /**
  129034. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  129035. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  129036. */
  129037. useDefaultLoadingScreen: boolean;
  129038. /**
  129039. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  129040. * when all assets have been downloaded.
  129041. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  129042. */
  129043. autoHideLoadingUI: boolean;
  129044. /**
  129045. * Creates a new AssetsManager
  129046. * @param scene defines the scene to work on
  129047. */
  129048. constructor(scene: Scene);
  129049. /**
  129050. * Add a MeshAssetTask to the list of active tasks
  129051. * @param taskName defines the name of the new task
  129052. * @param meshesNames defines the name of meshes to load
  129053. * @param rootUrl defines the root url to use to locate files
  129054. * @param sceneFilename defines the filename of the scene file
  129055. * @returns a new MeshAssetTask object
  129056. */
  129057. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  129058. /**
  129059. * Add a TextFileAssetTask to the list of active tasks
  129060. * @param taskName defines the name of the new task
  129061. * @param url defines the url of the file to load
  129062. * @returns a new TextFileAssetTask object
  129063. */
  129064. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  129065. /**
  129066. * Add a BinaryFileAssetTask to the list of active tasks
  129067. * @param taskName defines the name of the new task
  129068. * @param url defines the url of the file to load
  129069. * @returns a new BinaryFileAssetTask object
  129070. */
  129071. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  129072. /**
  129073. * Add a ImageAssetTask to the list of active tasks
  129074. * @param taskName defines the name of the new task
  129075. * @param url defines the url of the file to load
  129076. * @returns a new ImageAssetTask object
  129077. */
  129078. addImageTask(taskName: string, url: string): ImageAssetTask;
  129079. /**
  129080. * Add a TextureAssetTask to the list of active tasks
  129081. * @param taskName defines the name of the new task
  129082. * @param url defines the url of the file to load
  129083. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129084. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  129085. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  129086. * @returns a new TextureAssetTask object
  129087. */
  129088. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  129089. /**
  129090. * Add a CubeTextureAssetTask to the list of active tasks
  129091. * @param taskName defines the name of the new task
  129092. * @param url defines the url of the file to load
  129093. * @param extensions defines the extension to use to load the cube map (can be null)
  129094. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129095. * @param files defines the list of files to load (can be null)
  129096. * @returns a new CubeTextureAssetTask object
  129097. */
  129098. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  129099. /**
  129100. *
  129101. * Add a HDRCubeTextureAssetTask to the list of active tasks
  129102. * @param taskName defines the name of the new task
  129103. * @param url defines the url of the file to load
  129104. * @param size defines the size you want for the cubemap (can be null)
  129105. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129106. * @param generateHarmonics defines if you want to automatically generate (true by default)
  129107. * @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)
  129108. * @param reserved Internal use only
  129109. * @returns a new HDRCubeTextureAssetTask object
  129110. */
  129111. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  129112. /**
  129113. *
  129114. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  129115. * @param taskName defines the name of the new task
  129116. * @param url defines the url of the file to load
  129117. * @param size defines the size you want for the cubemap (can be null)
  129118. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  129119. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  129120. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  129121. * @returns a new EquiRectangularCubeTextureAssetTask object
  129122. */
  129123. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  129124. /**
  129125. * Remove a task from the assets manager.
  129126. * @param task the task to remove
  129127. */
  129128. removeTask(task: AbstractAssetTask): void;
  129129. private _decreaseWaitingTasksCount;
  129130. private _runTask;
  129131. /**
  129132. * Reset the AssetsManager and remove all tasks
  129133. * @return the current instance of the AssetsManager
  129134. */
  129135. reset(): AssetsManager;
  129136. /**
  129137. * Start the loading process
  129138. * @return the current instance of the AssetsManager
  129139. */
  129140. load(): AssetsManager;
  129141. /**
  129142. * Start the loading process as an async operation
  129143. * @return a promise returning the list of failed tasks
  129144. */
  129145. loadAsync(): Promise<void>;
  129146. }
  129147. }
  129148. declare module BABYLON {
  129149. /**
  129150. * Wrapper class for promise with external resolve and reject.
  129151. */
  129152. export class Deferred<T> {
  129153. /**
  129154. * The promise associated with this deferred object.
  129155. */
  129156. readonly promise: Promise<T>;
  129157. private _resolve;
  129158. private _reject;
  129159. /**
  129160. * The resolve method of the promise associated with this deferred object.
  129161. */
  129162. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  129163. /**
  129164. * The reject method of the promise associated with this deferred object.
  129165. */
  129166. readonly reject: (reason?: any) => void;
  129167. /**
  129168. * Constructor for this deferred object.
  129169. */
  129170. constructor();
  129171. }
  129172. }
  129173. declare module BABYLON {
  129174. /**
  129175. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  129176. */
  129177. export class MeshExploder {
  129178. private _centerMesh;
  129179. private _meshes;
  129180. private _meshesOrigins;
  129181. private _toCenterVectors;
  129182. private _scaledDirection;
  129183. private _newPosition;
  129184. private _centerPosition;
  129185. /**
  129186. * Explodes meshes from a center mesh.
  129187. * @param meshes The meshes to explode.
  129188. * @param centerMesh The mesh to be center of explosion.
  129189. */
  129190. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  129191. private _setCenterMesh;
  129192. /**
  129193. * Get class name
  129194. * @returns "MeshExploder"
  129195. */
  129196. getClassName(): string;
  129197. /**
  129198. * "Exploded meshes"
  129199. * @returns Array of meshes with the centerMesh at index 0.
  129200. */
  129201. getMeshes(): Array<Mesh>;
  129202. /**
  129203. * Explodes meshes giving a specific direction
  129204. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  129205. */
  129206. explode(direction?: number): void;
  129207. }
  129208. }
  129209. declare module BABYLON {
  129210. /**
  129211. * Class used to help managing file picking and drag'n'drop
  129212. */
  129213. export class FilesInput {
  129214. /**
  129215. * List of files ready to be loaded
  129216. */
  129217. static readonly FilesToLoad: {
  129218. [key: string]: File;
  129219. };
  129220. /**
  129221. * Callback called when a file is processed
  129222. */
  129223. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  129224. private _engine;
  129225. private _currentScene;
  129226. private _sceneLoadedCallback;
  129227. private _progressCallback;
  129228. private _additionalRenderLoopLogicCallback;
  129229. private _textureLoadingCallback;
  129230. private _startingProcessingFilesCallback;
  129231. private _onReloadCallback;
  129232. private _errorCallback;
  129233. private _elementToMonitor;
  129234. private _sceneFileToLoad;
  129235. private _filesToLoad;
  129236. /**
  129237. * Creates a new FilesInput
  129238. * @param engine defines the rendering engine
  129239. * @param scene defines the hosting scene
  129240. * @param sceneLoadedCallback callback called when scene is loaded
  129241. * @param progressCallback callback called to track progress
  129242. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  129243. * @param textureLoadingCallback callback called when a texture is loading
  129244. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  129245. * @param onReloadCallback callback called when a reload is requested
  129246. * @param errorCallback callback call if an error occurs
  129247. */
  129248. 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);
  129249. private _dragEnterHandler;
  129250. private _dragOverHandler;
  129251. private _dropHandler;
  129252. /**
  129253. * Calls this function to listen to drag'n'drop events on a specific DOM element
  129254. * @param elementToMonitor defines the DOM element to track
  129255. */
  129256. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  129257. /**
  129258. * Release all associated resources
  129259. */
  129260. dispose(): void;
  129261. private renderFunction;
  129262. private drag;
  129263. private drop;
  129264. private _traverseFolder;
  129265. private _processFiles;
  129266. /**
  129267. * Load files from a drop event
  129268. * @param event defines the drop event to use as source
  129269. */
  129270. loadFiles(event: any): void;
  129271. private _processReload;
  129272. /**
  129273. * Reload the current scene from the loaded files
  129274. */
  129275. reload(): void;
  129276. }
  129277. }
  129278. declare module BABYLON {
  129279. /**
  129280. * Defines the root class used to create scene optimization to use with SceneOptimizer
  129281. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129282. */
  129283. export class SceneOptimization {
  129284. /**
  129285. * Defines the priority of this optimization (0 by default which means first in the list)
  129286. */
  129287. priority: number;
  129288. /**
  129289. * Gets a string describing the action executed by the current optimization
  129290. * @returns description string
  129291. */
  129292. getDescription(): string;
  129293. /**
  129294. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129295. * @param scene defines the current scene where to apply this optimization
  129296. * @param optimizer defines the current optimizer
  129297. * @returns true if everything that can be done was applied
  129298. */
  129299. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129300. /**
  129301. * Creates the SceneOptimization object
  129302. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129303. * @param desc defines the description associated with the optimization
  129304. */
  129305. constructor(
  129306. /**
  129307. * Defines the priority of this optimization (0 by default which means first in the list)
  129308. */
  129309. priority?: number);
  129310. }
  129311. /**
  129312. * Defines an optimization used to reduce the size of render target textures
  129313. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129314. */
  129315. export class TextureOptimization extends SceneOptimization {
  129316. /**
  129317. * Defines the priority of this optimization (0 by default which means first in the list)
  129318. */
  129319. priority: number;
  129320. /**
  129321. * 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
  129322. */
  129323. maximumSize: number;
  129324. /**
  129325. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129326. */
  129327. step: number;
  129328. /**
  129329. * Gets a string describing the action executed by the current optimization
  129330. * @returns description string
  129331. */
  129332. getDescription(): string;
  129333. /**
  129334. * Creates the TextureOptimization object
  129335. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129336. * @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
  129337. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129338. */
  129339. constructor(
  129340. /**
  129341. * Defines the priority of this optimization (0 by default which means first in the list)
  129342. */
  129343. priority?: number,
  129344. /**
  129345. * 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
  129346. */
  129347. maximumSize?: number,
  129348. /**
  129349. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  129350. */
  129351. step?: number);
  129352. /**
  129353. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129354. * @param scene defines the current scene where to apply this optimization
  129355. * @param optimizer defines the current optimizer
  129356. * @returns true if everything that can be done was applied
  129357. */
  129358. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129359. }
  129360. /**
  129361. * Defines an optimization used to increase or decrease the rendering resolution
  129362. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129363. */
  129364. export class HardwareScalingOptimization extends SceneOptimization {
  129365. /**
  129366. * Defines the priority of this optimization (0 by default which means first in the list)
  129367. */
  129368. priority: number;
  129369. /**
  129370. * Defines the maximum scale to use (2 by default)
  129371. */
  129372. maximumScale: number;
  129373. /**
  129374. * Defines the step to use between two passes (0.5 by default)
  129375. */
  129376. step: number;
  129377. private _currentScale;
  129378. private _directionOffset;
  129379. /**
  129380. * Gets a string describing the action executed by the current optimization
  129381. * @return description string
  129382. */
  129383. getDescription(): string;
  129384. /**
  129385. * Creates the HardwareScalingOptimization object
  129386. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129387. * @param maximumScale defines the maximum scale to use (2 by default)
  129388. * @param step defines the step to use between two passes (0.5 by default)
  129389. */
  129390. constructor(
  129391. /**
  129392. * Defines the priority of this optimization (0 by default which means first in the list)
  129393. */
  129394. priority?: number,
  129395. /**
  129396. * Defines the maximum scale to use (2 by default)
  129397. */
  129398. maximumScale?: number,
  129399. /**
  129400. * Defines the step to use between two passes (0.5 by default)
  129401. */
  129402. step?: number);
  129403. /**
  129404. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129405. * @param scene defines the current scene where to apply this optimization
  129406. * @param optimizer defines the current optimizer
  129407. * @returns true if everything that can be done was applied
  129408. */
  129409. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129410. }
  129411. /**
  129412. * Defines an optimization used to remove shadows
  129413. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129414. */
  129415. export class ShadowsOptimization extends SceneOptimization {
  129416. /**
  129417. * Gets a string describing the action executed by the current optimization
  129418. * @return description string
  129419. */
  129420. getDescription(): string;
  129421. /**
  129422. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129423. * @param scene defines the current scene where to apply this optimization
  129424. * @param optimizer defines the current optimizer
  129425. * @returns true if everything that can be done was applied
  129426. */
  129427. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129428. }
  129429. /**
  129430. * Defines an optimization used to turn post-processes off
  129431. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129432. */
  129433. export class PostProcessesOptimization extends SceneOptimization {
  129434. /**
  129435. * Gets a string describing the action executed by the current optimization
  129436. * @return description string
  129437. */
  129438. getDescription(): string;
  129439. /**
  129440. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129441. * @param scene defines the current scene where to apply this optimization
  129442. * @param optimizer defines the current optimizer
  129443. * @returns true if everything that can be done was applied
  129444. */
  129445. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129446. }
  129447. /**
  129448. * Defines an optimization used to turn lens flares off
  129449. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129450. */
  129451. export class LensFlaresOptimization extends SceneOptimization {
  129452. /**
  129453. * Gets a string describing the action executed by the current optimization
  129454. * @return description string
  129455. */
  129456. getDescription(): string;
  129457. /**
  129458. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129459. * @param scene defines the current scene where to apply this optimization
  129460. * @param optimizer defines the current optimizer
  129461. * @returns true if everything that can be done was applied
  129462. */
  129463. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129464. }
  129465. /**
  129466. * Defines an optimization based on user defined callback.
  129467. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129468. */
  129469. export class CustomOptimization extends SceneOptimization {
  129470. /**
  129471. * Callback called to apply the custom optimization.
  129472. */
  129473. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  129474. /**
  129475. * Callback called to get custom description
  129476. */
  129477. onGetDescription: () => string;
  129478. /**
  129479. * Gets a string describing the action executed by the current optimization
  129480. * @returns description string
  129481. */
  129482. getDescription(): string;
  129483. /**
  129484. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129485. * @param scene defines the current scene where to apply this optimization
  129486. * @param optimizer defines the current optimizer
  129487. * @returns true if everything that can be done was applied
  129488. */
  129489. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129490. }
  129491. /**
  129492. * Defines an optimization used to turn particles off
  129493. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129494. */
  129495. export class ParticlesOptimization extends SceneOptimization {
  129496. /**
  129497. * Gets a string describing the action executed by the current optimization
  129498. * @return description string
  129499. */
  129500. getDescription(): string;
  129501. /**
  129502. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129503. * @param scene defines the current scene where to apply this optimization
  129504. * @param optimizer defines the current optimizer
  129505. * @returns true if everything that can be done was applied
  129506. */
  129507. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129508. }
  129509. /**
  129510. * Defines an optimization used to turn render targets off
  129511. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129512. */
  129513. export class RenderTargetsOptimization extends SceneOptimization {
  129514. /**
  129515. * Gets a string describing the action executed by the current optimization
  129516. * @return description string
  129517. */
  129518. getDescription(): string;
  129519. /**
  129520. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129521. * @param scene defines the current scene where to apply this optimization
  129522. * @param optimizer defines the current optimizer
  129523. * @returns true if everything that can be done was applied
  129524. */
  129525. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  129526. }
  129527. /**
  129528. * Defines an optimization used to merge meshes with compatible materials
  129529. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129530. */
  129531. export class MergeMeshesOptimization extends SceneOptimization {
  129532. private static _UpdateSelectionTree;
  129533. /**
  129534. * Gets or sets a boolean which defines if optimization octree has to be updated
  129535. */
  129536. /**
  129537. * Gets or sets a boolean which defines if optimization octree has to be updated
  129538. */
  129539. static UpdateSelectionTree: boolean;
  129540. /**
  129541. * Gets a string describing the action executed by the current optimization
  129542. * @return description string
  129543. */
  129544. getDescription(): string;
  129545. private _canBeMerged;
  129546. /**
  129547. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  129548. * @param scene defines the current scene where to apply this optimization
  129549. * @param optimizer defines the current optimizer
  129550. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  129551. * @returns true if everything that can be done was applied
  129552. */
  129553. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  129554. }
  129555. /**
  129556. * Defines a list of options used by SceneOptimizer
  129557. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129558. */
  129559. export class SceneOptimizerOptions {
  129560. /**
  129561. * Defines the target frame rate to reach (60 by default)
  129562. */
  129563. targetFrameRate: number;
  129564. /**
  129565. * Defines the interval between two checkes (2000ms by default)
  129566. */
  129567. trackerDuration: number;
  129568. /**
  129569. * Gets the list of optimizations to apply
  129570. */
  129571. optimizations: SceneOptimization[];
  129572. /**
  129573. * Creates a new list of options used by SceneOptimizer
  129574. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  129575. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  129576. */
  129577. constructor(
  129578. /**
  129579. * Defines the target frame rate to reach (60 by default)
  129580. */
  129581. targetFrameRate?: number,
  129582. /**
  129583. * Defines the interval between two checkes (2000ms by default)
  129584. */
  129585. trackerDuration?: number);
  129586. /**
  129587. * Add a new optimization
  129588. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  129589. * @returns the current SceneOptimizerOptions
  129590. */
  129591. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  129592. /**
  129593. * Add a new custom optimization
  129594. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  129595. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  129596. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  129597. * @returns the current SceneOptimizerOptions
  129598. */
  129599. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  129600. /**
  129601. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  129602. * @param targetFrameRate defines the target frame rate (60 by default)
  129603. * @returns a SceneOptimizerOptions object
  129604. */
  129605. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129606. /**
  129607. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  129608. * @param targetFrameRate defines the target frame rate (60 by default)
  129609. * @returns a SceneOptimizerOptions object
  129610. */
  129611. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129612. /**
  129613. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  129614. * @param targetFrameRate defines the target frame rate (60 by default)
  129615. * @returns a SceneOptimizerOptions object
  129616. */
  129617. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  129618. }
  129619. /**
  129620. * Class used to run optimizations in order to reach a target frame rate
  129621. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  129622. */
  129623. export class SceneOptimizer implements IDisposable {
  129624. private _isRunning;
  129625. private _options;
  129626. private _scene;
  129627. private _currentPriorityLevel;
  129628. private _targetFrameRate;
  129629. private _trackerDuration;
  129630. private _currentFrameRate;
  129631. private _sceneDisposeObserver;
  129632. private _improvementMode;
  129633. /**
  129634. * Defines an observable called when the optimizer reaches the target frame rate
  129635. */
  129636. onSuccessObservable: Observable<SceneOptimizer>;
  129637. /**
  129638. * Defines an observable called when the optimizer enables an optimization
  129639. */
  129640. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  129641. /**
  129642. * Defines an observable called when the optimizer is not able to reach the target frame rate
  129643. */
  129644. onFailureObservable: Observable<SceneOptimizer>;
  129645. /**
  129646. * Gets a boolean indicating if the optimizer is in improvement mode
  129647. */
  129648. readonly isInImprovementMode: boolean;
  129649. /**
  129650. * Gets the current priority level (0 at start)
  129651. */
  129652. readonly currentPriorityLevel: number;
  129653. /**
  129654. * Gets the current frame rate checked by the SceneOptimizer
  129655. */
  129656. readonly currentFrameRate: number;
  129657. /**
  129658. * Gets or sets the current target frame rate (60 by default)
  129659. */
  129660. /**
  129661. * Gets or sets the current target frame rate (60 by default)
  129662. */
  129663. targetFrameRate: number;
  129664. /**
  129665. * Gets or sets the current interval between two checks (every 2000ms by default)
  129666. */
  129667. /**
  129668. * Gets or sets the current interval between two checks (every 2000ms by default)
  129669. */
  129670. trackerDuration: number;
  129671. /**
  129672. * Gets the list of active optimizations
  129673. */
  129674. readonly optimizations: SceneOptimization[];
  129675. /**
  129676. * Creates a new SceneOptimizer
  129677. * @param scene defines the scene to work on
  129678. * @param options defines the options to use with the SceneOptimizer
  129679. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  129680. * @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)
  129681. */
  129682. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  129683. /**
  129684. * Stops the current optimizer
  129685. */
  129686. stop(): void;
  129687. /**
  129688. * Reset the optimizer to initial step (current priority level = 0)
  129689. */
  129690. reset(): void;
  129691. /**
  129692. * Start the optimizer. By default it will try to reach a specific framerate
  129693. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  129694. */
  129695. start(): void;
  129696. private _checkCurrentState;
  129697. /**
  129698. * Release all resources
  129699. */
  129700. dispose(): void;
  129701. /**
  129702. * Helper function to create a SceneOptimizer with one single line of code
  129703. * @param scene defines the scene to work on
  129704. * @param options defines the options to use with the SceneOptimizer
  129705. * @param onSuccess defines a callback to call on success
  129706. * @param onFailure defines a callback to call on failure
  129707. * @returns the new SceneOptimizer object
  129708. */
  129709. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  129710. }
  129711. }
  129712. declare module BABYLON {
  129713. /**
  129714. * Class used to serialize a scene into a string
  129715. */
  129716. export class SceneSerializer {
  129717. /**
  129718. * Clear cache used by a previous serialization
  129719. */
  129720. static ClearCache(): void;
  129721. /**
  129722. * Serialize a scene into a JSON compatible object
  129723. * @param scene defines the scene to serialize
  129724. * @returns a JSON compatible object
  129725. */
  129726. static Serialize(scene: Scene): any;
  129727. /**
  129728. * Serialize a mesh into a JSON compatible object
  129729. * @param toSerialize defines the mesh to serialize
  129730. * @param withParents defines if parents must be serialized as well
  129731. * @param withChildren defines if children must be serialized as well
  129732. * @returns a JSON compatible object
  129733. */
  129734. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  129735. }
  129736. }
  129737. declare module BABYLON {
  129738. /**
  129739. * Class used to host texture specific utilities
  129740. */
  129741. export class TextureTools {
  129742. /**
  129743. * Uses the GPU to create a copy texture rescaled at a given size
  129744. * @param texture Texture to copy from
  129745. * @param width defines the desired width
  129746. * @param height defines the desired height
  129747. * @param useBilinearMode defines if bilinear mode has to be used
  129748. * @return the generated texture
  129749. */
  129750. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  129751. }
  129752. }
  129753. declare module BABYLON {
  129754. /**
  129755. * This represents the different options available for the video capture.
  129756. */
  129757. export interface VideoRecorderOptions {
  129758. /** Defines the mime type of the video. */
  129759. mimeType: string;
  129760. /** Defines the FPS the video should be recorded at. */
  129761. fps: number;
  129762. /** Defines the chunk size for the recording data. */
  129763. recordChunckSize: number;
  129764. /** The audio tracks to attach to the recording. */
  129765. audioTracks?: MediaStreamTrack[];
  129766. }
  129767. /**
  129768. * This can help with recording videos from BabylonJS.
  129769. * This is based on the available WebRTC functionalities of the browser.
  129770. *
  129771. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  129772. */
  129773. export class VideoRecorder {
  129774. private static readonly _defaultOptions;
  129775. /**
  129776. * Returns whether or not the VideoRecorder is available in your browser.
  129777. * @param engine Defines the Babylon Engine.
  129778. * @returns true if supported otherwise false.
  129779. */
  129780. static IsSupported(engine: Engine): boolean;
  129781. private readonly _options;
  129782. private _canvas;
  129783. private _mediaRecorder;
  129784. private _recordedChunks;
  129785. private _fileName;
  129786. private _resolve;
  129787. private _reject;
  129788. /**
  129789. * True when a recording is already in progress.
  129790. */
  129791. readonly isRecording: boolean;
  129792. /**
  129793. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  129794. * @param engine Defines the BabylonJS Engine you wish to record.
  129795. * @param options Defines options that can be used to customize the capture.
  129796. */
  129797. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  129798. /**
  129799. * Stops the current recording before the default capture timeout passed in the startRecording function.
  129800. */
  129801. stopRecording(): void;
  129802. /**
  129803. * Starts recording the canvas for a max duration specified in parameters.
  129804. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  129805. * If null no automatic download will start and you can rely on the promise to get the data back.
  129806. * @param maxDuration Defines the maximum recording time in seconds.
  129807. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  129808. * @return A promise callback at the end of the recording with the video data in Blob.
  129809. */
  129810. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  129811. /**
  129812. * Releases internal resources used during the recording.
  129813. */
  129814. dispose(): void;
  129815. private _handleDataAvailable;
  129816. private _handleError;
  129817. private _handleStop;
  129818. }
  129819. }
  129820. declare module BABYLON {
  129821. /**
  129822. * Class containing a set of static utilities functions for screenshots
  129823. */
  129824. export class ScreenshotTools {
  129825. /**
  129826. * Captures a screenshot of the current rendering
  129827. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129828. * @param engine defines the rendering engine
  129829. * @param camera defines the source camera
  129830. * @param size This parameter can be set to a single number or to an object with the
  129831. * following (optional) properties: precision, width, height. If a single number is passed,
  129832. * it will be used for both width and height. If an object is passed, the screenshot size
  129833. * will be derived from the parameters. The precision property is a multiplier allowing
  129834. * rendering at a higher or lower resolution
  129835. * @param successCallback defines the callback receives a single parameter which contains the
  129836. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129837. * src parameter of an <img> to display it
  129838. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129839. * Check your browser for supported MIME types
  129840. */
  129841. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  129842. /**
  129843. * Captures a screenshot of the current rendering
  129844. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129845. * @param engine defines the rendering engine
  129846. * @param camera defines the source camera
  129847. * @param size This parameter can be set to a single number or to an object with the
  129848. * following (optional) properties: precision, width, height. If a single number is passed,
  129849. * it will be used for both width and height. If an object is passed, the screenshot size
  129850. * will be derived from the parameters. The precision property is a multiplier allowing
  129851. * rendering at a higher or lower resolution
  129852. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  129853. * Check your browser for supported MIME types
  129854. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129855. * to the src parameter of an <img> to display it
  129856. */
  129857. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  129858. /**
  129859. * Generates an image screenshot from the specified camera.
  129860. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129861. * @param engine The engine to use for rendering
  129862. * @param camera The camera to use for rendering
  129863. * @param size This parameter can be set to a single number or to an object with the
  129864. * following (optional) properties: precision, width, height. If a single number is passed,
  129865. * it will be used for both width and height. If an object is passed, the screenshot size
  129866. * will be derived from the parameters. The precision property is a multiplier allowing
  129867. * rendering at a higher or lower resolution
  129868. * @param successCallback The callback receives a single parameter which contains the
  129869. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  129870. * src parameter of an <img> to display it
  129871. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129872. * Check your browser for supported MIME types
  129873. * @param samples Texture samples (default: 1)
  129874. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129875. * @param fileName A name for for the downloaded file.
  129876. */
  129877. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  129878. /**
  129879. * Generates an image screenshot from the specified camera.
  129880. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  129881. * @param engine The engine to use for rendering
  129882. * @param camera The camera to use for rendering
  129883. * @param size This parameter can be set to a single number or to an object with the
  129884. * following (optional) properties: precision, width, height. If a single number is passed,
  129885. * it will be used for both width and height. If an object is passed, the screenshot size
  129886. * will be derived from the parameters. The precision property is a multiplier allowing
  129887. * rendering at a higher or lower resolution
  129888. * @param mimeType The MIME type of the screenshot image (default: image/png).
  129889. * Check your browser for supported MIME types
  129890. * @param samples Texture samples (default: 1)
  129891. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  129892. * @param fileName A name for for the downloaded file.
  129893. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  129894. * to the src parameter of an <img> to display it
  129895. */
  129896. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  129897. /**
  129898. * Gets height and width for screenshot size
  129899. * @private
  129900. */
  129901. private static _getScreenshotSize;
  129902. }
  129903. }
  129904. declare module BABYLON {
  129905. /**
  129906. * A cursor which tracks a point on a path
  129907. */
  129908. export class PathCursor {
  129909. private path;
  129910. /**
  129911. * Stores path cursor callbacks for when an onchange event is triggered
  129912. */
  129913. private _onchange;
  129914. /**
  129915. * The value of the path cursor
  129916. */
  129917. value: number;
  129918. /**
  129919. * The animation array of the path cursor
  129920. */
  129921. animations: Animation[];
  129922. /**
  129923. * Initializes the path cursor
  129924. * @param path The path to track
  129925. */
  129926. constructor(path: Path2);
  129927. /**
  129928. * Gets the cursor point on the path
  129929. * @returns A point on the path cursor at the cursor location
  129930. */
  129931. getPoint(): Vector3;
  129932. /**
  129933. * Moves the cursor ahead by the step amount
  129934. * @param step The amount to move the cursor forward
  129935. * @returns This path cursor
  129936. */
  129937. moveAhead(step?: number): PathCursor;
  129938. /**
  129939. * Moves the cursor behind by the step amount
  129940. * @param step The amount to move the cursor back
  129941. * @returns This path cursor
  129942. */
  129943. moveBack(step?: number): PathCursor;
  129944. /**
  129945. * Moves the cursor by the step amount
  129946. * If the step amount is greater than one, an exception is thrown
  129947. * @param step The amount to move the cursor
  129948. * @returns This path cursor
  129949. */
  129950. move(step: number): PathCursor;
  129951. /**
  129952. * Ensures that the value is limited between zero and one
  129953. * @returns This path cursor
  129954. */
  129955. private ensureLimits;
  129956. /**
  129957. * Runs onchange callbacks on change (used by the animation engine)
  129958. * @returns This path cursor
  129959. */
  129960. private raiseOnChange;
  129961. /**
  129962. * Executes a function on change
  129963. * @param f A path cursor onchange callback
  129964. * @returns This path cursor
  129965. */
  129966. onchange(f: (cursor: PathCursor) => void): PathCursor;
  129967. }
  129968. }
  129969. declare module BABYLON {
  129970. /** @hidden */
  129971. export var blurPixelShader: {
  129972. name: string;
  129973. shader: string;
  129974. };
  129975. }
  129976. declare module BABYLON {
  129977. /** @hidden */
  129978. export var pointCloudVertexDeclaration: {
  129979. name: string;
  129980. shader: string;
  129981. };
  129982. }
  129983. // Mixins
  129984. interface Window {
  129985. mozIndexedDB: IDBFactory;
  129986. webkitIndexedDB: IDBFactory;
  129987. msIndexedDB: IDBFactory;
  129988. webkitURL: typeof URL;
  129989. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  129990. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  129991. WebGLRenderingContext: WebGLRenderingContext;
  129992. MSGesture: MSGesture;
  129993. CANNON: any;
  129994. AudioContext: AudioContext;
  129995. webkitAudioContext: AudioContext;
  129996. PointerEvent: any;
  129997. Math: Math;
  129998. Uint8Array: Uint8ArrayConstructor;
  129999. Float32Array: Float32ArrayConstructor;
  130000. mozURL: typeof URL;
  130001. msURL: typeof URL;
  130002. VRFrameData: any; // WebVR, from specs 1.1
  130003. DracoDecoderModule: any;
  130004. setImmediate(handler: (...args: any[]) => void): number;
  130005. }
  130006. interface HTMLCanvasElement {
  130007. requestPointerLock(): void;
  130008. msRequestPointerLock?(): void;
  130009. mozRequestPointerLock?(): void;
  130010. webkitRequestPointerLock?(): void;
  130011. /** Track wether a record is in progress */
  130012. isRecording: boolean;
  130013. /** Capture Stream method defined by some browsers */
  130014. captureStream(fps?: number): MediaStream;
  130015. }
  130016. interface CanvasRenderingContext2D {
  130017. msImageSmoothingEnabled: boolean;
  130018. }
  130019. interface MouseEvent {
  130020. mozMovementX: number;
  130021. mozMovementY: number;
  130022. webkitMovementX: number;
  130023. webkitMovementY: number;
  130024. msMovementX: number;
  130025. msMovementY: number;
  130026. }
  130027. interface Navigator {
  130028. mozGetVRDevices: (any: any) => any;
  130029. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130030. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130031. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  130032. webkitGetGamepads(): Gamepad[];
  130033. msGetGamepads(): Gamepad[];
  130034. webkitGamepads(): Gamepad[];
  130035. }
  130036. interface HTMLVideoElement {
  130037. mozSrcObject: any;
  130038. }
  130039. interface Math {
  130040. fround(x: number): number;
  130041. imul(a: number, b: number): number;
  130042. }
  130043. interface WebGLRenderingContext {
  130044. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  130045. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  130046. vertexAttribDivisor(index: number, divisor: number): void;
  130047. createVertexArray(): any;
  130048. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  130049. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  130050. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  130051. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  130052. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  130053. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  130054. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  130055. // Queries
  130056. createQuery(): WebGLQuery;
  130057. deleteQuery(query: WebGLQuery): void;
  130058. beginQuery(target: number, query: WebGLQuery): void;
  130059. endQuery(target: number): void;
  130060. getQueryParameter(query: WebGLQuery, pname: number): any;
  130061. getQuery(target: number, pname: number): any;
  130062. MAX_SAMPLES: number;
  130063. RGBA8: number;
  130064. READ_FRAMEBUFFER: number;
  130065. DRAW_FRAMEBUFFER: number;
  130066. UNIFORM_BUFFER: number;
  130067. HALF_FLOAT_OES: number;
  130068. RGBA16F: number;
  130069. RGBA32F: number;
  130070. R32F: number;
  130071. RG32F: number;
  130072. RGB32F: number;
  130073. R16F: number;
  130074. RG16F: number;
  130075. RGB16F: number;
  130076. RED: number;
  130077. RG: number;
  130078. R8: number;
  130079. RG8: number;
  130080. UNSIGNED_INT_24_8: number;
  130081. DEPTH24_STENCIL8: number;
  130082. MIN: number;
  130083. MAX: number;
  130084. /* Multiple Render Targets */
  130085. drawBuffers(buffers: number[]): void;
  130086. readBuffer(src: number): void;
  130087. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  130088. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  130089. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  130090. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  130091. // Occlusion Query
  130092. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  130093. ANY_SAMPLES_PASSED: number;
  130094. QUERY_RESULT_AVAILABLE: number;
  130095. QUERY_RESULT: number;
  130096. }
  130097. interface WebGLProgram {
  130098. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  130099. }
  130100. interface EXT_disjoint_timer_query {
  130101. QUERY_COUNTER_BITS_EXT: number;
  130102. TIME_ELAPSED_EXT: number;
  130103. TIMESTAMP_EXT: number;
  130104. GPU_DISJOINT_EXT: number;
  130105. QUERY_RESULT_EXT: number;
  130106. QUERY_RESULT_AVAILABLE_EXT: number;
  130107. queryCounterEXT(query: WebGLQuery, target: number): void;
  130108. createQueryEXT(): WebGLQuery;
  130109. beginQueryEXT(target: number, query: WebGLQuery): void;
  130110. endQueryEXT(target: number): void;
  130111. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  130112. deleteQueryEXT(query: WebGLQuery): void;
  130113. }
  130114. interface WebGLUniformLocation {
  130115. _currentState: any;
  130116. }
  130117. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  130118. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  130119. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  130120. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130121. interface WebGLRenderingContext {
  130122. readonly RASTERIZER_DISCARD: number;
  130123. readonly DEPTH_COMPONENT24: number;
  130124. readonly TEXTURE_3D: number;
  130125. readonly TEXTURE_2D_ARRAY: number;
  130126. readonly TEXTURE_COMPARE_FUNC: number;
  130127. readonly TEXTURE_COMPARE_MODE: number;
  130128. readonly COMPARE_REF_TO_TEXTURE: number;
  130129. readonly TEXTURE_WRAP_R: number;
  130130. readonly HALF_FLOAT: number;
  130131. readonly RGB8: number;
  130132. readonly RED_INTEGER: number;
  130133. readonly RG_INTEGER: number;
  130134. readonly RGB_INTEGER: number;
  130135. readonly RGBA_INTEGER: number;
  130136. readonly R8_SNORM: number;
  130137. readonly RG8_SNORM: number;
  130138. readonly RGB8_SNORM: number;
  130139. readonly RGBA8_SNORM: number;
  130140. readonly R8I: number;
  130141. readonly RG8I: number;
  130142. readonly RGB8I: number;
  130143. readonly RGBA8I: number;
  130144. readonly R8UI: number;
  130145. readonly RG8UI: number;
  130146. readonly RGB8UI: number;
  130147. readonly RGBA8UI: number;
  130148. readonly R16I: number;
  130149. readonly RG16I: number;
  130150. readonly RGB16I: number;
  130151. readonly RGBA16I: number;
  130152. readonly R16UI: number;
  130153. readonly RG16UI: number;
  130154. readonly RGB16UI: number;
  130155. readonly RGBA16UI: number;
  130156. readonly R32I: number;
  130157. readonly RG32I: number;
  130158. readonly RGB32I: number;
  130159. readonly RGBA32I: number;
  130160. readonly R32UI: number;
  130161. readonly RG32UI: number;
  130162. readonly RGB32UI: number;
  130163. readonly RGBA32UI: number;
  130164. readonly RGB10_A2UI: number;
  130165. readonly R11F_G11F_B10F: number;
  130166. readonly RGB9_E5: number;
  130167. readonly RGB10_A2: number;
  130168. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  130169. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  130170. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  130171. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  130172. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  130173. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  130174. 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;
  130175. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  130176. readonly TRANSFORM_FEEDBACK: number;
  130177. readonly INTERLEAVED_ATTRIBS: number;
  130178. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  130179. createTransformFeedback(): WebGLTransformFeedback;
  130180. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  130181. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  130182. beginTransformFeedback(primitiveMode: number): void;
  130183. endTransformFeedback(): void;
  130184. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  130185. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130186. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130187. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  130188. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  130189. }
  130190. interface ImageBitmap {
  130191. readonly width: number;
  130192. readonly height: number;
  130193. close(): void;
  130194. }
  130195. interface WebGLQuery extends WebGLObject {
  130196. }
  130197. declare var WebGLQuery: {
  130198. prototype: WebGLQuery;
  130199. new(): WebGLQuery;
  130200. };
  130201. interface WebGLSampler extends WebGLObject {
  130202. }
  130203. declare var WebGLSampler: {
  130204. prototype: WebGLSampler;
  130205. new(): WebGLSampler;
  130206. };
  130207. interface WebGLSync extends WebGLObject {
  130208. }
  130209. declare var WebGLSync: {
  130210. prototype: WebGLSync;
  130211. new(): WebGLSync;
  130212. };
  130213. interface WebGLTransformFeedback extends WebGLObject {
  130214. }
  130215. declare var WebGLTransformFeedback: {
  130216. prototype: WebGLTransformFeedback;
  130217. new(): WebGLTransformFeedback;
  130218. };
  130219. interface WebGLVertexArrayObject extends WebGLObject {
  130220. }
  130221. declare var WebGLVertexArrayObject: {
  130222. prototype: WebGLVertexArrayObject;
  130223. new(): WebGLVertexArrayObject;
  130224. };
  130225. // Type definitions for WebVR API
  130226. // Project: https://w3c.github.io/webvr/
  130227. // Definitions by: six a <https://github.com/lostfictions>
  130228. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  130229. interface VRDisplay extends EventTarget {
  130230. /**
  130231. * Dictionary of capabilities describing the VRDisplay.
  130232. */
  130233. readonly capabilities: VRDisplayCapabilities;
  130234. /**
  130235. * z-depth defining the far plane of the eye view frustum
  130236. * enables mapping of values in the render target depth
  130237. * attachment to scene coordinates. Initially set to 10000.0.
  130238. */
  130239. depthFar: number;
  130240. /**
  130241. * z-depth defining the near plane of the eye view frustum
  130242. * enables mapping of values in the render target depth
  130243. * attachment to scene coordinates. Initially set to 0.01.
  130244. */
  130245. depthNear: number;
  130246. /**
  130247. * An identifier for this distinct VRDisplay. Used as an
  130248. * association point in the Gamepad API.
  130249. */
  130250. readonly displayId: number;
  130251. /**
  130252. * A display name, a user-readable name identifying it.
  130253. */
  130254. readonly displayName: string;
  130255. readonly isConnected: boolean;
  130256. readonly isPresenting: boolean;
  130257. /**
  130258. * If this VRDisplay supports room-scale experiences, the optional
  130259. * stage attribute contains details on the room-scale parameters.
  130260. */
  130261. readonly stageParameters: VRStageParameters | null;
  130262. /**
  130263. * Passing the value returned by `requestAnimationFrame` to
  130264. * `cancelAnimationFrame` will unregister the callback.
  130265. * @param handle Define the hanle of the request to cancel
  130266. */
  130267. cancelAnimationFrame(handle: number): void;
  130268. /**
  130269. * Stops presenting to the VRDisplay.
  130270. * @returns a promise to know when it stopped
  130271. */
  130272. exitPresent(): Promise<void>;
  130273. /**
  130274. * Return the current VREyeParameters for the given eye.
  130275. * @param whichEye Define the eye we want the parameter for
  130276. * @returns the eye parameters
  130277. */
  130278. getEyeParameters(whichEye: string): VREyeParameters;
  130279. /**
  130280. * Populates the passed VRFrameData with the information required to render
  130281. * the current frame.
  130282. * @param frameData Define the data structure to populate
  130283. * @returns true if ok otherwise false
  130284. */
  130285. getFrameData(frameData: VRFrameData): boolean;
  130286. /**
  130287. * Get the layers currently being presented.
  130288. * @returns the list of VR layers
  130289. */
  130290. getLayers(): VRLayer[];
  130291. /**
  130292. * Return a VRPose containing the future predicted pose of the VRDisplay
  130293. * when the current frame will be presented. The value returned will not
  130294. * change until JavaScript has returned control to the browser.
  130295. *
  130296. * The VRPose will contain the position, orientation, velocity,
  130297. * and acceleration of each of these properties.
  130298. * @returns the pose object
  130299. */
  130300. getPose(): VRPose;
  130301. /**
  130302. * Return the current instantaneous pose of the VRDisplay, with no
  130303. * prediction applied.
  130304. * @returns the current instantaneous pose
  130305. */
  130306. getImmediatePose(): VRPose;
  130307. /**
  130308. * The callback passed to `requestAnimationFrame` will be called
  130309. * any time a new frame should be rendered. When the VRDisplay is
  130310. * presenting the callback will be called at the native refresh
  130311. * rate of the HMD. When not presenting this function acts
  130312. * identically to how window.requestAnimationFrame acts. Content should
  130313. * make no assumptions of frame rate or vsync behavior as the HMD runs
  130314. * asynchronously from other displays and at differing refresh rates.
  130315. * @param callback Define the eaction to run next frame
  130316. * @returns the request handle it
  130317. */
  130318. requestAnimationFrame(callback: FrameRequestCallback): number;
  130319. /**
  130320. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  130321. * Repeat calls while already presenting will update the VRLayers being displayed.
  130322. * @param layers Define the list of layer to present
  130323. * @returns a promise to know when the request has been fulfilled
  130324. */
  130325. requestPresent(layers: VRLayer[]): Promise<void>;
  130326. /**
  130327. * Reset the pose for this display, treating its current position and
  130328. * orientation as the "origin/zero" values. VRPose.position,
  130329. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  130330. * updated when calling resetPose(). This should be called in only
  130331. * sitting-space experiences.
  130332. */
  130333. resetPose(): void;
  130334. /**
  130335. * The VRLayer provided to the VRDisplay will be captured and presented
  130336. * in the HMD. Calling this function has the same effect on the source
  130337. * canvas as any other operation that uses its source image, and canvases
  130338. * created without preserveDrawingBuffer set to true will be cleared.
  130339. * @param pose Define the pose to submit
  130340. */
  130341. submitFrame(pose?: VRPose): void;
  130342. }
  130343. declare var VRDisplay: {
  130344. prototype: VRDisplay;
  130345. new(): VRDisplay;
  130346. };
  130347. interface VRLayer {
  130348. leftBounds?: number[] | Float32Array | null;
  130349. rightBounds?: number[] | Float32Array | null;
  130350. source?: HTMLCanvasElement | null;
  130351. }
  130352. interface VRDisplayCapabilities {
  130353. readonly canPresent: boolean;
  130354. readonly hasExternalDisplay: boolean;
  130355. readonly hasOrientation: boolean;
  130356. readonly hasPosition: boolean;
  130357. readonly maxLayers: number;
  130358. }
  130359. interface VREyeParameters {
  130360. /** @deprecated */
  130361. readonly fieldOfView: VRFieldOfView;
  130362. readonly offset: Float32Array;
  130363. readonly renderHeight: number;
  130364. readonly renderWidth: number;
  130365. }
  130366. interface VRFieldOfView {
  130367. readonly downDegrees: number;
  130368. readonly leftDegrees: number;
  130369. readonly rightDegrees: number;
  130370. readonly upDegrees: number;
  130371. }
  130372. interface VRFrameData {
  130373. readonly leftProjectionMatrix: Float32Array;
  130374. readonly leftViewMatrix: Float32Array;
  130375. readonly pose: VRPose;
  130376. readonly rightProjectionMatrix: Float32Array;
  130377. readonly rightViewMatrix: Float32Array;
  130378. readonly timestamp: number;
  130379. }
  130380. interface VRPose {
  130381. readonly angularAcceleration: Float32Array | null;
  130382. readonly angularVelocity: Float32Array | null;
  130383. readonly linearAcceleration: Float32Array | null;
  130384. readonly linearVelocity: Float32Array | null;
  130385. readonly orientation: Float32Array | null;
  130386. readonly position: Float32Array | null;
  130387. readonly timestamp: number;
  130388. }
  130389. interface VRStageParameters {
  130390. sittingToStandingTransform?: Float32Array;
  130391. sizeX?: number;
  130392. sizeY?: number;
  130393. }
  130394. interface Navigator {
  130395. getVRDisplays(): Promise<VRDisplay[]>;
  130396. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  130397. }
  130398. interface Window {
  130399. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  130400. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  130401. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  130402. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130403. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  130404. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  130405. }
  130406. interface Gamepad {
  130407. readonly displayId: number;
  130408. }
  130409. type XRSessionMode =
  130410. | "inline"
  130411. | "immersive-vr"
  130412. | "immersive-ar";
  130413. type XRReferenceSpaceType =
  130414. | "viewer"
  130415. | "local"
  130416. | "local-floor"
  130417. | "bounded-floor"
  130418. | "unbounded";
  130419. type XREnvironmentBlendMode =
  130420. | "opaque"
  130421. | "additive"
  130422. | "alpha-blend";
  130423. type XRVisibilityState =
  130424. | "visible"
  130425. | "visible-blurred"
  130426. | "hidden";
  130427. type XRHandedness =
  130428. | "none"
  130429. | "left"
  130430. | "right";
  130431. type XRTargetRayMode =
  130432. | "gaze"
  130433. | "tracked-pointer"
  130434. | "screen";
  130435. type XREye =
  130436. | "none"
  130437. | "left"
  130438. | "right";
  130439. interface XRSpace extends EventTarget {
  130440. }
  130441. interface XRRenderState {
  130442. depthNear?: number;
  130443. depthFar?: number;
  130444. inlineVerticalFieldOfView?: number;
  130445. baseLayer?: XRWebGLLayer;
  130446. }
  130447. interface XRInputSource {
  130448. handedness: XRHandedness;
  130449. targetRayMode: XRTargetRayMode;
  130450. targetRaySpace: XRSpace;
  130451. gripSpace: XRSpace | undefined;
  130452. gamepad: Gamepad | undefined;
  130453. profiles: Array<string>;
  130454. }
  130455. interface XRSession {
  130456. addEventListener: Function;
  130457. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  130458. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  130459. requestAnimationFrame: Function;
  130460. end(): Promise<void>;
  130461. renderState: XRRenderState;
  130462. inputSources: Array<XRInputSource>;
  130463. }
  130464. interface XRReferenceSpace extends XRSpace {
  130465. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  130466. onreset: any;
  130467. }
  130468. interface XRFrame {
  130469. session: XRSession;
  130470. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  130471. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  130472. }
  130473. interface XRViewerPose extends XRPose {
  130474. views: Array<XRView>;
  130475. }
  130476. interface XRPose {
  130477. transform: XRRigidTransform;
  130478. emulatedPosition: boolean;
  130479. }
  130480. declare var XRWebGLLayer: {
  130481. prototype: XRWebGLLayer;
  130482. new(session: XRSession, context: WebGLRenderingContext | undefined): XRWebGLLayer;
  130483. };
  130484. interface XRWebGLLayer {
  130485. framebuffer: WebGLFramebuffer;
  130486. framebufferWidth: number;
  130487. framebufferHeight: number;
  130488. getViewport: Function;
  130489. }
  130490. interface XRRigidTransform {
  130491. position: DOMPointReadOnly;
  130492. orientation: DOMPointReadOnly;
  130493. matrix: Float32Array;
  130494. inverse: XRRigidTransform;
  130495. }
  130496. interface XRView {
  130497. eye: XREye;
  130498. projectionMatrix: Float32Array;
  130499. transform: XRRigidTransform;
  130500. }
  130501. interface XRInputSourceChangeEvent {
  130502. session: XRSession;
  130503. removed: Array<XRInputSource>;
  130504. added: Array<XRInputSource>;
  130505. }